【发布时间】:2014-04-18 19:43:09
【问题描述】:
设置断点时出现这种奇怪的行为:
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
这恰好是 6 行,其中没有一条是我想要的实际行,即。 base58.h 的第 144 行。什么可能导致此问题,我该如何确定问题并解决它?
我有 GNU Make 3.81。如果这有什么不同,我正在使用 -j8 。 gcc 是 Debian 4.8.2-16。
我尝试在其他文件中设置断点,它们似乎可以工作,包括其他头文件。我也尝试过清理makefile ...没有运气。我尝试清除 ccache... 也没有运气。
【问题讨论】:
-
很可能您在编译代码中的多个位置设置了断点,因为包含在多个源文件中。
-
如果您试图在模板中设置断点,GDB 将不得不在模板实例化的每个位置创建断点。它必须为内联函数做类似的事情。
-
内联函数在其他文件中不是问题,因为我已经尝试过了。我还尝试在方法中设置断点,但失败了。因此,即使此示例中的断点位于内联函数中,这也不是问题。这也不是模板。
-
如果是要包含在多个源文件中,那为什么其他头文件可以工作?
-
这取决于函数是否真的被内联了。也许编译器决定不从其他头文件内联函数。你可以通过检查 DWARF 来确定。
标签: gcc gdb breakpoints debug-symbols gcc4