I caught an exception! Yay! Now what?
#1 Marketplace Seller - Reputation: 8951
Posted 16 October 2012 - 03:55 PM
Example: basic_string::_S_construct null not valid
Okay, so a string is be accidentally initialized with NULL somewhere (after googling that poorly worded message).
...
...
...?
Where was the exception thrown from? C++ doesn't have any way to give a strack-trace of the throw? Does C++11 add anything of use here?
I'm using MinGW on Windows 7 32bit. Some options, like Mr Edd's dbg library, only seem to support stacktraces if you are the one throwing the exception. But in this case, std::string is throwing it.
Note: Normally I try to catch the exceptions as close to the source as possible, if I know an exception is likely to be thrown in a certain area. However, in this case, it's being caught by my lowest "just catch everything" at the entry of my program.
Also note: I'm sure I can manually locate the cause of the exception within 15 minutes - that's not the issue. I am wondering if there is a better solution, for all future cases. than to manually locating it.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal
#3 Moderators - Reputation: 6649
Posted 16 October 2012 - 04:27 PM
#4 Members - Reputation: 2771
Posted 16 October 2012 - 06:41 PM
(gdb) catch throwI'm not sure this really helps you, but Visual C++ allows you to set it to break on the line throwing any exception deriving from std::exception (as well as as lots of windows-specific exceptions).
Maybe gdb has something similar?
Yeah, sounds stupid. Works.
Professional Free Software Developer
#5 Marketplace Seller - Reputation: 8951
Posted 18 October 2012 - 09:56 AM
For others using QtCreator, here's how you use it:
Right-click where your breakpoints are, and select 'Add breakpoint'
Then you get a nice few options:
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal






