mkernel 0.0.2
Micro-kernel framework, everything as a module
assert.h File Reference

Debugging macros. More...

#include <stdlib.h>
Include dependency graph for assert.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ASSERT(condition)
 Assertion check macro. More...
 
#define DBG_TRACE    _trace(__FILE__,__LINE__, __DATE__, __TIME__, __func__)
 Checkpoint on stderr. More...
 
#define DBG_MSG(msg)    _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,msg)
 Checkpoint on stderr with a static message. More...
 
#define DBG_ITRACE(inst)
 Instruction checkpint. More...
 
#define DBG_PRINTF(p_Format, ...)    _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__, p_Format, __VA_ARGS__)
 Log a timestamped debugging message on stderr. More...
 

Functions

void _trace (const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function)
 Print a debug trace (checkpoint) More...
 
void _trace_msg (const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Message)
 Print a debug trace (checkpoint) with a static message. More...
 
void _trace_dynmsg (const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Format,...)
 Print a debug trace (checkpoint) with a formatted message. More...
 

Detailed Description

Debugging macros.

Date
11/05/1997
Author
François Cerbelle (Fanfan), franc.nosp@m.ois@.nosp@m.cerbe.nosp@m.lle..nosp@m.net

Originally inspired by "L'art du code", Steve Maguire, Microsoft Press

Definition in file assert.h.

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   condition)
Value:
if (!(condition)) { \
_trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,"Assertion failed (%s)" , #condition); \
abort(); \
}

Assertion check macro.

Parameters
[in]conditionto check

If NDEBUG is set, does nothing. If NDEBUG is not defined, checks that the condition is true, otherwise stop the process

Definition at line 103 of file assert.h.

◆ DBG_ITRACE

#define DBG_ITRACE (   inst)
Value:
_trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,#inst), \
inst
void _trace_msg(const char *p_File, const unsigned int p_Line, const char *p_CompilDate, const char *p_CompilTime, const char *p_Function, const char *p_Message)
Print a debug trace (checkpoint) with a static message.
Definition: assert.c:87

Instruction checkpint.

Writes a checkpoint trace with timestamp, filename, function name and line number when executing an instruction.

Definition at line 142 of file assert.h.

◆ DBG_MSG

#define DBG_MSG (   msg)     _trace_msg(__FILE__,__LINE__, __DATE__, __TIME__, __func__,msg)

Checkpoint on stderr with a static message.

Writes a timestamped checkpoint with filename, function and line number on stderr.

Definition at line 130 of file assert.h.

◆ DBG_PRINTF

#define DBG_PRINTF (   p_Format,
  ... 
)     _trace_dynmsg(__FILE__,__LINE__, __DATE__, __TIME__, __func__, p_Format, __VA_ARGS__)

Log a timestamped debugging message on stderr.

Writes a timestamped message on stderr with the filename, function name, line number.

Definition at line 155 of file assert.h.

◆ DBG_TRACE

#define DBG_TRACE    _trace(__FILE__,__LINE__, __DATE__, __TIME__, __func__)

Checkpoint on stderr.

Writes a timestamped checkpoint with filename, function and line number on stderr.

Definition at line 118 of file assert.h.

Function Documentation

◆ _trace()

void _trace ( const char *  p_File,
const unsigned int  p_Line,
const char *  p_CompilDate,
const char *  p_CompilTime,
const char *  p_Function 
)

Print a debug trace (checkpoint)

Parameters
[in]p_FileSource file
[in]p_LineSource line in the source file
[in]p_CompilDateCompilation date
[in]p_CompilTimeCompilation time
[in]p_FunctionFunction name in the source file

Outputs on stderr a timestamp, with the filename, the sourceline, the compilation date and time, the function name.

Definition at line 75 of file assert.c.

◆ _trace_dynmsg()

void _trace_dynmsg ( const char *  p_File,
const unsigned int  p_Line,
const char *  p_CompilDate,
const char *  p_CompilTime,
const char *  p_Function,
const char *  p_Format,
  ... 
)

Print a debug trace (checkpoint) with a formatted message.

Parameters
[in]p_FileSource file
[in]p_LineSource line in the source file
[in]p_CompilDateCompilation date
[in]p_CompilTimeCompilation time
[in]p_FunctionFunction name in the source file
[in]p_Formatformat string
[in]...Formatted string parameters

Outputs on stderr a timestamp, with the filename, the sourceline, the compilation date and time, the function name and a formatted message.

Todo:
Replace with a portable snprintf function

Definition at line 101 of file assert.c.

◆ _trace_msg()

void _trace_msg ( const char *  p_File,
const unsigned int  p_Line,
const char *  p_CompilDate,
const char *  p_CompilTime,
const char *  p_Function,
const char *  p_Message 
)

Print a debug trace (checkpoint) with a static message.

Parameters
[in]p_FileSource file
[in]p_LineSource line in the source file
[in]p_CompilDateCompilation date
[in]p_CompilTimeCompilation time
[in]p_FunctionFunction name in the source file
[in]p_MessageStatic message

Outputs on stderr a timestamp, with the filename, the sourceline, the compilation date and time, the function name and a static message.

Definition at line 87 of file assert.c.