如何为GCC 8.1.0添加调试符号?

如何为GCC 8.1.0添加调试符号?,gcc,gdb,dwarf,gcc8,Gcc,Gdb,Dwarf,Gcc8,我已经将使用的GCC版本从4.2.1更新为8.1.0。(这是我唯一改变的事) 问题是,在我完成之后,调试符号就消失了 我只使用“-g”选项运行GDB 对于gcc v8.1.0,运行gdb时没有调试符号: (gdb) br test Breakpoint 1 at 0xa5fa053 (gdb) bt 0 0x09fa2303 in test_func() 1 0x097cecc7 in test_func_2 () 2 0x097cf314 in test_func_3 () (gdb)

我已经将使用的GCC版本从4.2.1更新为8.1.0。(这是我唯一改变的事)

问题是,在我完成之后,调试符号就消失了

我只使用“-g”选项运行GDB

对于gcc v8.1.0,运行gdb时没有调试符号:

(gdb) br test
Breakpoint 1 at 0xa5fa053
(gdb) bt
0  0x09fa2303 in test_func()
1  0x097cecc7 in test_func_2 ()
2  0x097cf314 in test_func_3 ()
(gdb) br test_func
Breakpoint 1 at 0xaa2fc7a: file /projects/gabriela/test/test.c, line 3
(gdb) r
Breakpoint 1, test_func(unit=0, flags=0, test1=0xffff95e0, test2=0xffff9b9c) at /projects/gabriela/test/test.c, line 3
(gdb) bt
0  test_func (unit=0, flags=0, test1=0xffff95e0, test2=0xffff9b9c) at /projects/gabriela/test/test.c, line 3
1  0x099ad349 in test_func_2 (unit=0, flags=0, test1=0x0, test2=0x0) at /projects/gabriela/test/test.c:10
2  0x099ada04 in test_func_3 (unit=0, flags=0, test1=0x0) at /projects/gabriela/test/test.c:20
与v4.2.1类似:

(gdb) br test
Breakpoint 1 at 0xa5fa053
(gdb) bt
0  0x09fa2303 in test_func()
1  0x097cecc7 in test_func_2 ()
2  0x097cf314 in test_func_3 ()
(gdb) br test_func
Breakpoint 1 at 0xaa2fc7a: file /projects/gabriela/test/test.c, line 3
(gdb) r
Breakpoint 1, test_func(unit=0, flags=0, test1=0xffff95e0, test2=0xffff9b9c) at /projects/gabriela/test/test.c, line 3
(gdb) bt
0  test_func (unit=0, flags=0, test1=0xffff95e0, test2=0xffff9b9c) at /projects/gabriela/test/test.c, line 3
1  0x099ad349 in test_func_2 (unit=0, flags=0, test1=0x0, test2=0x0) at /projects/gabriela/test/test.c:10
2  0x099ada04 in test_func_3 (unit=0, flags=0, test1=0x0) at /projects/gabriela/test/test.c:20

如何使gcc8.1.0的dbg符号类似于gcc4.2.1

在4.2.1和8.1.0版本之间,gcc中有很多变化。GCC4.8中发生的一个变化是默认情况下它开始发出DWARF4调试信息。以前是矮人。很可能您的gdb无法理解DWARF4格式。您可以做的一件事是尝试使用
-gdwarf-2
gcc选项发出DWARF2。见:

DWARF4现在是生成DWARF调试信息时的默认值。 在使用DWARF调试信息的平台上使用-g时, GCC现在将默认为-gdwarf-4-fno调试类型部分。GDB 7.5, Valgrind 3.8.0和elfutils 0.154用户支持的调试信息 默认情况下为4。在GCC4.8之前,使用的默认版本是DWARF2。 要使GCC4.8生成较旧的DWARF版本,请将-g与 -gdwarf-2或-gdwarf-3


gcc在4.2.1和8.1.0版本之间有很多变化。GCC4.8中发生的一个变化是默认情况下它开始发出DWARF4调试信息。以前是矮人。很可能您的gdb无法理解DWARF4格式。您可以做的一件事是尝试使用
-gdwarf-2
gcc选项发出DWARF2。见:

DWARF4现在是生成DWARF调试信息时的默认值。 在使用DWARF调试信息的平台上使用-g时, GCC现在将默认为-gdwarf-4-fno调试类型部分。GDB 7.5, Valgrind 3.8.0和elfutils 0.154用户支持的调试信息 默认情况下为4。在GCC4.8之前,使用的默认版本是DWARF2。 要使GCC4.8生成较旧的DWARF版本,请将-g与 -gdwarf-2或-gdwarf-3