User forums > Using Code::Blocks
Boost assertions closes the debugger
ThundThund:
Hi together!
I've searched for this topic in the forum but I have found nothing related.
I'm using Boost libraries to test my projects in CB, but I've found that when I use BOOST_ASSERT macro, the application closes and the developer has no information about what happened.
Why doesn't CB stop at the line the assertion fails?
Is it the normal behaviour?
Should I configure something?
Must I execute assertions in another way?
Thanks in advance to all of you.
oBFusCATed:
Have you tried the debugger branch?
What is your OS/C::B version/GCC/boost/GDB?
Simple code to reproduce the problem?
Does normal assert(false) works?
zabzonk:
> Why doesn't CB stop at the line the assertion fails?
Why should it? The assertion mechanism knows nothing about the debugger, and the debugger knows nothing about the assertion mechanism.
oBFusCATed:
Because the assertion mechanism most of the times causes the application to crash, at least the assert(false) macro, does so.
If the app crashes the debugger should catch it and the user should be able to inspect the reason for the crash.
zabzonk:
If you want to write your own code to process the the BOOST_ASSERT, this is how to do it:
#include <iostream>
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
using namespace std;
namespace boost
{
void assertion_failed(char const * expr, char const * function, char const * file, long line) {
cout << "BOOST assertion failed\n";
}
}
int main()
{
BOOST_ASSERT( 1 == 0 );
cout << "Hello world!" << endl;
return 0;
}
Replace:
cout << "BOOST assertion failed\n";
with whatever you need to do to enter the debugger, though your stack frame will probably be off.
See also http://www.boost.org/doc/libs/1_36_0/libs/utility/assert.html. But at the end of the day, assertions are not great debugging tools.
Navigation
[0] Message Index
[#] Next page
Go to full version