Matthew Mitchell
Matthew Mitchell

Reputation: 5393

GDB sets multiple breakpoints when I am unambiguously setting a breakpoint for a line number. Bad debug symbols?

I get this strange behaviour when setting a breakpoint:

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

That happens to be 6 lines, none of which is the actual line I want, ie. line 144 of base58.h. What could cause this and how can I determine the problem and fix it?

I have GNU Make 3.81. I'm using -j8 if that makes any difference. gcc is Debian 4.8.2-16.

I tried setting breakpoints in other files and they appear to work, including other header files. I also tried cleaning the makefile... No luck. I tried clearing ccache... No luck either.

Upvotes: 2

Views: 1163

Answers (1)

Matthew Mitchell
Matthew Mitchell

Reputation: 5393

It's silly of me now that I think of it, but when I looked again the makefile included -02 in the compiler flags. Obviously if you use optimisation your debug symbols become useless, so never use optimisation for debug builds.

Upvotes: 2

Related Questions