This implements the debugger based invariant checking code. The first two macros are the normal user interface; the remainder are used for configuring the behaviour on failure, etc. Note that these macros have no effect unless you run your program under the debugger and read in the commands generated by the `nana' command.
The checking using DI can be enabled and disabled by using the DI_LEVEL and DI_DEFAULT_GUARD macros. See the definitions below for these macros for further details.
Note that exprn should have no side-effects(6) since disabling the checking shouldn't change your programs behaviour.
I(!(e))
and
exists as piece of syntactic sugar which is helpful for complicated
boolean expressions.
0
DI
, DN
, etc.
1
2
DI_LEVEL
defaults to 1
.
DI_DEFAULT_GUARD
is used to selectively enable or disable
checking at compile or run time.
DI_DEFAULT_GUARD
defaults to TRUE
, i.e. always enabled.
A user would typically define DI_DEFAULT_GUARD
to be global or local
variable which is used to turn checking on or off at run--time. For
example:
#define DI_DEFAULT_GUARD (i_guard) extern int i_guard;
DI_DEFAULT_HANDLER
and defaults to
nothing, it is just some text and is intended to pass failure codes
(e.g. IEH303
) or requests (e.g. HW_DEAD
) information off
to the handler.
DI_DEFAULT_PARAMS
defaults to nothing.
When an error is detected the DI_DEFAULT_HANDLER
will be called to
handle the error. The arguments are:
exprn
"I(i>=0)"
.
file
__FILE__
.
line
__LINE__
.
param
DI_DEFAULT_PARAMS
. This can be used to pass failure codes or other
information from the checking code to the handler.
DI
, etc. It defaults to
asm("nop")
and can be redefined by the user.
All of these macros are used to individually override the default values defined above. Normally these macros would be used in a system wide header file to define macros appropriate for the application.
$
and can be used be
used for saving the state of program or for counting events. The
`DS' macro executes e under the same rules as DI
.
The `DSG' macro executes e only if the the expression
g is true.
Note that `DS' and `DSG' can also be used for modifying C variables and calling functions.
Go to the first, previous, next, last section, table of contents.