UCL Common Library Reference |
---|
#include <debug.h> #define UNUSED (x) #define debug_msgvoid debug_dump (void *lp, longlen );void debug_set_core_dir (constchar *argv0);
These functions relate to outputing diagnostic messages and information.
Use of these functions requires DEBUG to be defined at compilation
time. On Unix systems, the configure script has
a command-line option --enable-debug
. On Win32 a
debug configuration exists.
#define UNUSED(x) (x=x)
Available for use to prevent compiler warnings when a function argument is not used. Sometimes this is unavoidable because function has to conform to an interface.
x : | unused function argument that generates compiler warning. |
#define debug_msg _dprintf("[pid/%d +%d %s] ", getpid(), __LINE__, __FILE__), _dprintf
When DEBUG is defined this will write a formatted message to the
platform defined error stream. The format of the message has the same
semantics as standard C library call
. The error
message displayed is prepended by the process id, the file and the
line number, where printf()
debug_msg()
was called.
On Unix the message is rendered on the standard error stream. On
Win32 a debug message is created using the Win32 API function
.
OutputDebugString()
void debug_dump (void *lp, longlen );
Writes a dump of a memory region to stdout. The dump contains a hexadecimal and an ascii representation of the memory region.
lp : | pointer to memory region. |
Param2 : |
|
void debug_set_core_dir (constchar *argv0);
Creates a directory with the application name and makes it the current working directory.
This function exists because some unix variants use the name 'core' for core dump files. When an application uses multiple processes, this can be problematic if the failure of one process leads to the failure of another because the dependent process 'core' file will overwrite the core of the failing process.
argv0 : | the application path (usually argv[0] in |
<<< RTP | Memory >>> |