Gcc 当我明确地为行号设置断点时,GDB会设置多个断点。错误的调试符号?

Gcc 当我明确地为行号设置断点时,GDB会设置多个断点。错误的调试符号?,gcc,gdb,breakpoints,debug-symbols,gcc4,Gcc,Gdb,Breakpoints,Debug Symbols,Gcc4,设置断点时,我会出现这种奇怪的行为: GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1) ... Blah blah legal stuff Reading symbols from /home/matt/Programming/Latium/latium/src/test_latium...done. (gdb) break base58.h:144 Breakpoint 1 at 0x43597f: base58.h:144. (6 locations) (gdb) i

设置断点时,我会出现这种奇怪的行为:

GNU gdb (GDB) 7.6.2 (Debian 7.6.2-1)
... Blah blah legal stuff
Reading symbols from /home/matt/Programming/Latium/latium/src/test_latium...done.
(gdb) break base58.h:144
Breakpoint 1 at 0x43597f: base58.h:144. (6 locations)
(gdb) info breakpoints
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   <MULTIPLE>         
1.1                         y     0x000000000043597f in CBase58Data::SetString(char const*) at base58.h:144
1.2                         y     0x0000000000452fcf in CBitcoinAddress::CBitcoinAddress(char const*) at /home/matt/Programming/Latium/latium/src/base58.h:144
1.3                         y     0x000000000045324f in CBitcoinSecret::SetString(char const*) at /home/matt/Programming/Latium/latium/src/base58.h:144
1.4                         y     0x00000000004db613 in DecodeAddress(std::string, CService&) at base58.h:144
1.5                         y     0x0000000000573d1a in CBitcoinAddress::CBitcoinAddress(std::string const&) at base58.h:144
1.6                         y     0x00000000005bea68 in ReadKeyValue(CWallet*, CDataStream&, CDataStream&, int&, std::vector<uint256, std::allocator<uint256> >&, bool&, bool&, std::string&, std::string&) at base58.h:144
GNU gdb(gdb)7.6.2(Debian 7.6.2-1)
... 诸如此类的法律问题
从/home/matt/Programming/Latium/Latium/src/test_Latium…读取符号完成。
(gdb)破垒58.h:144
断点1位于0x43597f:base58。h:144。(6个地点)
(gdb)信息断点
Num Type Disp Enb地址什么
1断点保持y
1.1 y 0x000000000043597f,位于base58的CBase58Data::SetString(char const*)。h:144
1.2 y 0x0000000000452fcf位于/home/matt/Programming/Latium/Latium/src/base58.h:144的CBitcoinAddress::CBitcoinAddress(char const*)中
1.3在/home/matt/Programming/Latium/Latium/src/base58.h中,在CBitcoinSecret::SetString(char const*)中使用0x000000000045324f
1.4 y 0x00000000004db613在base58的解码地址(标准::字符串,CService&)中。h:144
1.5 y 0x0000000000573d1a位于基58处的CBitcoinAddress::CBitcoinAddress(std::string const&)中。h:144
1.6 y 0x00000000005bea68在base58的ReadKeyValue(CWallet*、CDATA流和、CDATA流和、int和、std::vector和、bool和、bool和、std::string和std::string和)中。h:144
这正好是6行,没有一行是我想要的实际行,即base58.h的144行。是什么原因导致此问题?我如何确定问题并解决它

我的GNU是3.81。如果有什么不同的话,我用的是-j8。gcc是Debian 4.8.2-16


我尝试在其他文件中设置断点,它们似乎可以工作,包括其他头文件。我还尝试了清理makefile。。。不走运。我试着清理卡切。。。也不走运。

现在想到它,我真傻,但当我再次查看编译器标志中包含的makefile-02时。显然,如果使用优化,调试符号将变得毫无用处,因此永远不要对调试生成使用优化。

可能由于包含在多个源文件中而在编译代码的多个位置中断了某些内容。如果尝试在模板中设置断点,GDB必须在模板实例化的每个位置创建断点。它必须对内联函数执行类似的操作。内联函数在其他文件中不是问题,因为我已经尝试过了。我还尝试在方法中设置断点,但失败了。因此,即使本例中的断点位于内联函数中,这也不是问题所在。这也不是一个模板。如果是为了包含在多个源文件中,那么为什么其他头文件可以工作?这取决于函数是否已内联。也许编译器决定不内联来自另一个头的函数。你可以通过检查侏儒来确定答案。我强烈反对。这些天我调试的所有东西都经过了充分优化(由于代码的性质)。您只需调试它作为程序集级别,并考虑调试符号提示中的行号,可能会导致特定的汇编指令。它没有用处,但变得更加困难。