Hi,
I'm trying to automate some debugging tasks. In certain cases, I print the value of $ra
[this is a MIPS machine] and parts of the stack as hex addresses. During debugging, I use addr2line
to convert them into file:line
pairs.
I'd like to automate this procedure.
The problem is that addr2line returns a filename that equivelent to the value of __FILE__
at compilation time; i.e., the name of the file as passed to the compiler. This is usually foo.c
, sometimes src/foo.c
. As my project has several hundred directories in total, this may not be enough to uniquely identify the file (there may be 1/foo.c
, 2/foo.c
, etc). Even if it was deterministic, it seems rather inefficient to start running find in my screen for each argument [I suppose I could build a hash table and save them, but I'd like to keep this as a straightforward bash script]
GDB seems to get the right file. If I look at the actual source file with debugging symbols, I can also see that right after the filename there appears to be the full path to the __FILE__
[i.e., if __FILE__
is src/foo.c
, and it's really in /home/me/projects/something/comp1/src/foo.c
, I will see /home/me/projects/something/comp1
in the file. How can I get this progmatically?
Thanks.