私は-ggdbたちが使用していた別のデバッグオプションよりも、私のために、より良い仕事を少なくとも1つの例があります。
[email protected]:~> cat > main.c
#include <stdio.h>
int main(int argc, char **argv)
{
printf("Args :%d\n", argc);
for (;argc > 0;)
printf("%s\n", argv[--argc]);
return 0;
}
[email protected]:~> gcc -gstabs+ main.c -o main
[email protected]:~> file main
main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically linked (uses shared libs), not stripped
[email protected]:~> /usr/bin/gdb ./main
GNU gdb 6.6.50.20070726-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-suse-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) break main
Breakpoint 1 at 0x400577: file main.c, line 5.
(gdb) run
Starting program: /home/amitkar/main
Breakpoint 1, main (argc=Cannot access memory at address 0x8000df37d57c
) at main.c:5
5 printf("Args :%d\n", argc);
(gdb) print argc
Cannot access memory at address 0x8000df37d57c
(gdb)
注:これは、x86-64のボックスにのみ発生し、-ggdbしてコンパイルするとき消えます。しかし、デバッガの新しいバージョンでも-gstabs +