January 05, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to dan | int 3 gives a continuable exception, so if your debugger is up to it (as I would expect it would) then continuing should be a no-brainer. If it's not, though, I'm not much of an expert any deeper than what we've touched on, so you'll be on your own. ;/ "dan" <dan_member@pathlink.com> wrote in message news:btbn6d$2bll$1@digitaldaemon.com... > >Sure. ENSURE is as good as anything else. :) > > Better than "assert", which, in English, means to "proclaim" or "emphatically > say"; NOT to "verify" or "ensure" or "test" as it does. ;-) > > By the way, if you haven't gone to sleep yet, is there a way I can continue > debugging after an int 3? I want to be able to single step or continue running > after an ENSURE clause fails, if I want to. Right now the debugger stops, and > all I can do is re-start execution... > > dan > > |
January 05, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | >int 3 gives a continuable exception, so if your debugger is up to it (as I would expect it would) then continuing should be a no-brainer. If it's not, though, I'm not much of an expert any deeper than what we've touched on, so you'll be on your own. ;/
You've been IMMENSLY helpful. My previous implementation of ENSURE() had a class with a static function that had to be in a CPP file, plus a fancy macro, and an overloaded global comma operator. Your int 3 tip got all that down to 5 lines, for me.
As for continuing, maybe Walter knows what's going on. But for now I can use this as it is, I don't mind re-starting the debugging session, for now.
And, by the way, thanks Walter; deleting the prj file worked. (Actually, I deleted all the files there.) Now I back them up twice a day.
|
January 06, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to dan | Forgive my ignorance but why the do and while? What's wrong if just
# define verify(x) if( !((x)) ) asm int 3;
or
# define verify(x) { if( !((x)) ) asm int 3; }
> //file: verify.hpp
> #ifndef VERIFY_HPP
> #define VERIFY_HPP
>
> #ifdef _DEBUG
> # define verify(x) do{ if( !((x)) ) asm int 3; }while(0)
> #else
> # define verify(x) (void)(0)
> #endif
>
> /*
> // Usage example:
> #include "verify.hpp"
> #include <stdio.h>
> char first_char( char const * s )
> {
> verify( s && ::strlen(s) );
> return s[0];
> }
> // Cheers!
> // dan
> */
>
> #endif
>
>
|
January 06, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean | "Sean" <seanchen@telus.net> wrote:
> Forgive my ignorance but why the do and while? What's wrong if just
> # define verify(x) if( !((x)) ) asm int 3;
> or
> # define verify(x) { if( !((x)) ) asm int 3; }
I'll ignore "your ignorance" :)
What would the compiler say about:
if (foo)
verify (x);
else verify (y);
The ';' would cause a parse error in both cases. And in the 1st case, the 'else' wouldn't be for the outer 'if', but the one in the macro.
--gv
|
January 06, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gisle Vanem | I see, thanks. "Gisle Vanem" <giva@users.sourceforge.net> ???? news:btdi7k$2759$1@digitaldaemon.com... > "Sean" <seanchen@telus.net> wrote: > > > Forgive my ignorance but why the do and while? What's wrong if just > > # define verify(x) if( !((x)) ) asm int 3; > > or > > # define verify(x) { if( !((x)) ) asm int 3; } > > I'll ignore "your ignorance" :) > What would the compiler say about: > if (foo) > verify (x); > else verify (y); > > The ';' would cause a parse error in both cases. And in the 1st case, the 'else' wouldn't be for the outer 'if', but the one in the macro. > > --gv |
January 07, 2004 Re: DebugBreak()... Forget assert(); verify() instead | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean | For if cases I usually use following form: #define check(x) if (x) do_something; else Than you are forced to write ; after check, i.e. check(a>b); But you have no problems with else and other stuff. Nic Tiger. "Sean" <seanchen@telus.net> wrote in message news:btdp5g$2h08$1@digitaldaemon.com... > I see, thanks. > > "Gisle Vanem" <giva@users.sourceforge.net> ???? news:btdi7k$2759$1@digitaldaemon.com... > > "Sean" <seanchen@telus.net> wrote: > > > > > Forgive my ignorance but why the do and while? What's wrong if just > > > # define verify(x) if( !((x)) ) asm int 3; > > > or > > > # define verify(x) { if( !((x)) ) asm int 3; } > > > > I'll ignore "your ignorance" :) > > What would the compiler say about: > > if (foo) > > verify (x); > > else verify (y); > > > > The ';' would cause a parse error in both cases. And in the 1st case, the > > 'else' wouldn't be for the outer 'if', but the one in the macro. > > > > --gv > > |
Copyright © 1999-2021 by the D Language Foundation