Boost logo

Boost :

From: Dan W. (danw_at_[hidden])
Date: 2004-01-05 20:39:47

Darren Cook wrote:
> Unfortunately there is no debug_on_assert() function :-). This should do
> it (if included after smart_assert_ext.hpp).
> namespace boost {
> namespace smart_assert {
> void debug_on_assert( const assert_context &) {
> break_into_debugger();
> }
> }
> }
> I've not tested it, but now I think about it the debugger will not break
> on the line of the assert but in the above debug_on_assert() function.
> So not quite what you want.

Right. Looks very neat though, with this simple walkthrough. Any
chance of stripping it to bare-bones, or doing a "portable asm int 3"?
Tell you what I'd like to do: An assert() or ENSURE() that,

A) Stops at the line of the assertion
B) Allows debugging from that point
C) *SUPER* light-weight; maybe a handful of assembly instructions overhead.

The reason for the last requirement is that "I have a dream", where
programming and debugging in C++ becomes like doing it in Eiffel, where
you traditionally,

1) Design a few class interfaces, like in C++, functions and members.
2) *Write the invariants code.*
3) *Stuff the functions with preconditions and postconditions*
4) Compile (phase 1) just to debug contract correctness.
5) Define the functions
6) Compile the functions
7) Test/Debug

And where in step 3 you try to be absolutely thorough about requirements
and assurances for each function. So, say, on average, you might have 3
or 4 lines of preconditions, and say, 2 lines of posconditions, for each
function. So, I don't see this happening with a standard assert, where
you might have a whole page of assembly code overhead. So, it should be
the simplest assert that could possibly stop the debugger at the line.
And if it does stop at the line, __FILE__ and __LINE__, as far as I can
think would serve no purpose, but there may be something I'm missing in
this respect; I'm not sure. In a program with 1,000,000 lines of code,
there might be an extra 1,000,000 lines of code in debug mode from all
those preconditions and postconditions; so, should be *fly-weight*.
Any advice on how I could go about it?


Boost list run by bdawes at, gregod at, cpdaniel at, john at