How to find encapsulating function name from line number?
I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file
and here are the contents of the file foo.file
Based on the above log file, I want to get function names def and ghi returned. I have googled but can't find good pointers or starting points to solve this.
Moderator's Comments:
Please use CODE tags, not QUOTE tags, when displaying sample input, sample output, and code segments.
Last edited by Don Cragun; 03-18-2019 at 01:45 PM..
I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file
and here are the contents of the file foo.file
Based on the above log file, I want to get function names def and ghi returned. I have googled but can't find good pointers or starting points to solve this.
Moderator's Comments:
Please use CODE tags, not QUOTE tags, when displaying sample input, sample output, and code segments.
As you know, it always helps us help you if you tell us what operating system you're using, what shell you're using, and anything you have done to try to solve this problem on your own.
A better description of the constraints on the code function definition lines and the endfunction lines would also be required to be able to reliably identify function boundaries.
After converting your QUOTE tags to CODE tags, we can see that the function and endfunction keywords in the language you're using have varying amounts of leading whitespace.
What characters are allowed in function names?
Can there be anything on a function definition line other than leading whitespace, the function keyword, a single space character, the name of the function and a pair of parentheses
Can there be anything on the end function line other than leading whitespace and the endfunction keyword?
What is the name of your log file?
Why is there so much variation in the leading whitespace in your log file? (Most log files don't waste space with a lot of leading whitespace characters, nor to they have varying amounts of leading whitespace characters.) What is the specification for the format of the log file you will be processing?
Do the source files for the language you are trying to parse here really have the filename extension .file?
The characters that are allowed in the function name are alphanumeric characters including underscore _.
There can be one more than one space between keyword function and function name as well as between function name and (
Assume No leading white space. I put it by mistake. There is no leading white space on the line with endfunction keyword
Log file name is error.log
The filename do have extension which is .v (for verilog) and .sv( for systemverilog) but there could be more extensions as well.
Is that an interpreted language, or a compiled one? For the latter, the compiler should generate a symbol table or equivalent, for debugging purposes amongst other things. For the former, wouldn't a simple numbered listing suffice?
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
I have a data file (which has five columns) from which im finding column count of all the records and writing into separate file say "colcnt.txt". And I find one (or more) records have less column counts (i.e split records). I need to know which record(s) have that split scenario. Is there any way... (4 Replies)
Hi Forum.
I was trying to search the following scenario on the forum but was not able to.
Let's say that I have a very large file that has some bad data in it (for ex: 0.0015 in the 12th column) and I would like to find the line number and remove that particular line.
What's the easiest... (3 Replies)
I have a two files containing numbers like below. First one contains one number on each line, the other is a table of numbers, each separated by a space. There are the same number of lines in each file.
I want to take each number in the row of the table and find the difference from the... (12 Replies)
Hi,
I am new to AIX and I am developing a small tool for our product which helps debug memory leaks etc.
Q1)Is there a way in which i can get a function trace back as to the call (lets say malloc() )has been made in which file--> in which function.
I tried using the
#pragma options (... (0 Replies)
Hi all,
I want to display line number for matching string in a file. can anyone please help me.
I used
grep -n "ABC" file
so it displays
6 ABC.
But i only want to have line number,i don't want that it should prefix matching context with line number.
Actually my original... (10 Replies)
Hi,
I need to write a script which will have a text string as a input and the output should find out the number in the text string and add one to it.
Eg:
Input => asfdosainovih1234lnsiohn
Output => 1235
All the numbers in the text will be together and only one time in the line.
... (2 Replies)
Hi,
I need to find the number of tab delimiters in the first line of a file.So using
word=`head -1 files.txt`
I have extracted the first line of file into a variable word.It has 20 tab delimted columns.So can anyone help me in finding the number of delimiters?
I am using csh and I am a... (5 Replies)