Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: Question about relative and absolute paths to files in backtraces

I have question about gdb or gcc (but not firefox).

I see only absolute paths in gdb when i debugging firefox. Example:

5  0x01bb0c52 in nsAppShell::ProcessNextNativeEvent 
    (this=0xb7232ba0, mayWait=1)
    at 
    /media/25b7639d-9a70-42ca-aaa7-28f4d1f417fd/firefox-dev/mozilla-central/widget/src/gtk2/nsAppShell.cpp:144

It's uncomfortable for reading such backtraces. If i try to compile and debug tiny test program i see such backtrace (with relative paths to files):

0  main () at prog.c:5

How can i see only relative paths in backtraces when debugging firefox?

P.S. gcc 4.4.1; gdb 7.0.

like image 578
uintptr_t Avatar asked Jun 24 '11 20:06

uintptr_t


1 Answers

GDB will show absolute or relative path depending on how the program was compiled. Consider:

$ cd /tmp
$ cat t.c
int main() { return 0; }
$ gcc -g t.c && gdb -q -ex start -ex quit ./a.out
Reading symbols from /tmp/a.out...done.
Temporary breakpoint 1 at 0x4004c8: file t.c, line 1.

Temporary breakpoint 1, main () at t.c:1
1   int main() { return 0; }

Now the same, but compile source via absolute path:

$ gcc -g /tmp/t.c && gdb -q -ex start -ex quit ./a.out
Reading symbols from /tmp/a.out...done.
Temporary breakpoint 1 at 0x4004c8: file /tmp/t.c, line 1.

Temporary breakpoint 1, main () at /tmp/t.c:1
1   int main() { return 0; }

And again, this time with relative path that includes directory prefix:

$ cd /
$ gcc -g tmp/t.c -o tmp/a.out && gdb -q -ex start -ex quit tmp/a.out
Reading symbols from /tmp/a.out...done.
Temporary breakpoint 1 at 0x4004c8: file tmp/t.c, line 1.

Temporary breakpoint 1, main () at tmp/t.c:1
1   int main() { return 0; }

So, you can get gdb to show relative path if you change the way firefox is built. That may prove to be a very non-trivial proposition.

like image 186
Employed Russian Avatar answered Nov 20 '22 16:11

Employed Russian