wrongusername
wrongusername

Reputation: 18918

Using gdb to debug C++

So I am trying to follow this tutorial to debug my code. I tell gdb to run an executable, and it does, and the program crashes, giving this:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
0x00007fff907b06e5 in std::string::_Rep::_M_dispose ()

But I don't see any of the handy at main.cc:28 stuff that the tutorial talks about.

So I continue on anyways and try backtrace, which gives me this:

(gdb) backtrace
#0  0x00007fff907b06e5 in std::string::_Rep::_M_dispose ()
#1  0x00007fff907b12ba in std::string::assign ()
#2  0x00000001000029e4 in Map::insert ()
#3  0x0000000100001ac5 in main ()

Still no handy line numbers? What should I be doing?

(If it matters, I am using Mac OS 10.7 and installed the default set of C++ tools with XCode)

Upvotes: 0

Views: 607

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 994659

You need to turn on additional debug information in your build. In gcc, you want the -g compiler switch.

Upvotes: 2

Related Questions