Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mr BiCEPS

GDB and constructors

This topic is 5419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been trying several times to set a breakpoint in a constructor with GDB, but it has not worked, even though I have upgraded to the latest version. A google groups search landed me this little piece of information:
quote:
When gcc 3.x compiles a C++ constructor or C++ destructor, it generates 2 or 3 different versions of the object code. These versions have unique mangled names (they have to, in order for linking to work), but they have identical source code names, which leads to a great deal of confusion. Specifically, if you set a breakpoint in a constructor or a destructor, gdb will put a breakpoint in one of the versions, but your program may execute the other version. This makes it impossible to set breakpoints reliably in constructors or destructors. gcc 3.x generates these multiple object code functions in order to implement virtual base classes. gcc 2.x generated just one object code function with a hidden parameter, but gcc 3.x conforms to a multi-vendor ABI for C++ which requires multiple object code functions.
Are there any workarounds for this?

Share this post


Link to post
Share on other sites
Advertisement
Take this with a grain of salt since I haven''t used gdb since man first tamed lightning and set it to work compiling C programs, but did you try putting a call to a dummy function in the constructor and then setting a breakpoint inside the dummy function?

Share this post


Link to post
Share on other sites
Well the thought did occur to me, but it''s not really what I want. I''m not asking this because of a specific problem I have, but because I could have used a breakpoint in constructors many times lately and it''s annoying to have to insert lots of cout statements instead because the debugger doesn''t work.

Oh well, I hope they fix it in the next version!

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!