uin*_*r_t 7 gcc gdb path backtrace
我有关于gdb或gcc的问题(但不是firefox).
我在调试firefox时只看到gdb中的绝对路径.例:
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
Run Code Online (Sandbox Code Playgroud)
阅读这样的回溯是不舒服的.如果我尝试编译和调试微小的测试程序,我会看到这样的回溯(与文件的相对路径):
0 main () at prog.c:5
Run Code Online (Sandbox Code Playgroud)
在调试firefox时,我怎么能看到回溯中的相对路径?
PS gcc 4.4.1; gdb 7.0.
GDB 将根据程序的编译方式显示绝对或相对路径。考虑:
$ 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; }
Run Code Online (Sandbox Code Playgroud)
现在相同,但通过绝对路径编译源:
$ 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; }
Run Code Online (Sandbox Code Playgroud)
再次,这次使用包含目录前缀的相对路径:
$ 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; }
Run Code Online (Sandbox Code Playgroud)
因此,如果您更改 Firefox 的构建方式,您可以让 gdb 显示相对路径。这可能被证明是一个非常重要的命题。