User forums > Using Code::Blocks
constructor breakpoint issue
tiwag:
--- Quote from: thomas on July 18, 2006, 07:28:47 pm ---
--- Quote ---works too to get into the debugger
but i can't understand why this happens
--- End quote ---
That's easy. It is because the debugger catches all exceptions. :)
--- End quote ---
Dear Thomas ! :lol: :lol: :lol:
that the debugger catches my forced exception is clear (at least for me) :lol: :lol: :lol:
what i don't understand is, that the breakpoint works with the Dummy() method called from the constructor
but obviously no set breakpoint within the constructor. :( :( :(
Game_Ender:
Does CB have this problem on linux? I am running:
--- Code: ---GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:01:44 GMT 2006)
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5341)
--- End code ---
And at least in Xcode I can break in constructors so it is possible.
thomas:
--- Quote from: tiwag on July 18, 2006, 07:37:03 pm ---Dear Thomas ! :lol: :lol: :lol:
that the debugger catches my forced exception is clear (at least for me) :lol: :lol: :lol:
what i don't understand is, that the breakpoint works with the Dummy() method called from the constructor
--- End quote ---
That's easy, too. :)
The compiler generates several versions of the constructor to be able to implement virtual base classes (this happens regardless of whether or not you use virtual functions).
Although the linker sees these different constructors mangled differently, they have the same "real" name (even though they are physically different object code).
Thus, setting a breakpoint is russian roulette. You may be lucky to hit just the right one (the one that's actually called), or you may not be.
If you call a dummy function from the constructor and you set the BP into the dummy, then no matter which constructor is called, you still hit the dummy in any case (as there is only one).
Pecan:
--- Quote from: Game_Ender on July 18, 2006, 07:40:40 pm ---Does CB have this problem on linux? I am running:
--- Code: ---GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:01:44 GMT 2006)
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5341)
--- End code ---
And at least in Xcode I can break in constructors so it is possible.
--- End quote ---
Yes. Apple has heavily modified the compiler and the debugger.
I've gotten clipped a number of times trying methods on Linux and windows CB that worked on MAC but not on "normal" gcc/gdb. Then thinking... duh... I'm not on the Mac now.
marfig:
--- Quote from: thomas on July 18, 2006, 08:00:09 pm ---If you call a dummy function from the constructor and you set the BP into the dummy, then no matter which constructor is called, you still hit the dummy in any case (as there is only one).
--- End quote ---
I still prefer to set the break at the object initialization and then send rbreak ClassName::ClassName to the debugger :)
Arguably, it's more work since this has to be done everytime I start a debug session. But the good thing is that any BP set inside the constructor will start working :D
Navigation
[0] Message Index
[*] Previous page
Go to full version