RAVE
pyrave_debug.h File Reference

Useful macros and functions when debugging python rave objects. More...

#include <stdio.h>
#include "rave_debug.h"

Go to the source code of this file.

Classes

struct  PyRaveObjectDebugging
 Debugger struct to be used in rave python modules. More...
 

Macros

#define PYRAVE_DEBUG_MODULE(oname)
 Setup of the debugged python module.
 
#define PYRAVE_DEBUG_OBJECT_CREATED    _pyravedebug.created++
 Call this each time a object has been successfully been created.
 
#define PYRAVE_DEBUG_OBJECT_DESTROYED    _pyravedebug.destroyed++
 Call this each time a object has been successfully been destroyed.
 
#define PYRAVE_DEBUG_INITIALIZE
 Call this function in the module_init function,.
 

Detailed Description

Useful macros and functions when debugging python rave objects.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-12-14

Macro Definition Documentation

◆ PYRAVE_DEBUG_INITIALIZE

#define PYRAVE_DEBUG_INITIALIZE
Value:
if (atexit(_pyravedebug_statistics) != 0) { \
fprintf(stderr, "Failed to setup debug statistics for module %s\n", _pyravedebug.name); \
}

Call this function in the module_init function,.

◆ PYRAVE_DEBUG_MODULE

#define PYRAVE_DEBUG_MODULE ( oname)
Value:
static PyRaveObjectDebugging _pyravedebug = { \
0, 0, oname }; \
\
static void _pyravedebug_statistics(void) { \
if ((_pyravedebug.created - _pyravedebug.destroyed) != 0) { \
fprintf(stderr, "\n------------------------------------------\n"); \
fprintf(stderr, "CRITICAL ( Python module: %s ) \n", _pyravedebug.name); \
fprintf(stderr, "Created objects: %ld\n", _pyravedebug.created); \
fprintf(stderr, "Destroyed objects: %ld\n", _pyravedebug.destroyed); \
fprintf(stderr, "Objects lost: %ld\n", (_pyravedebug.created - _pyravedebug.destroyed)); \
fprintf(stderr, "\n"); \
} \
}
Debugger struct to be used in rave python modules.
Definition pyrave_debug.h:33
long destroyed
counts how many times an object has been destroyed
Definition pyrave_debug.h:35
long created
counts how many times an object has been created
Definition pyrave_debug.h:34
const char * name
the name for this object
Definition pyrave_debug.h:36

Setup of the debugged python module.

Use this macro just below the include section. E.g.

* #include "pyrave_debug.h"
* PYRAVE_DEBUG_MODULE("mymodule");
* 

◆ PYRAVE_DEBUG_OBJECT_CREATED

#define PYRAVE_DEBUG_OBJECT_CREATED    _pyravedebug.created++

Call this each time a object has been successfully been created.

◆ PYRAVE_DEBUG_OBJECT_DESTROYED

#define PYRAVE_DEBUG_OBJECT_DESTROYED    _pyravedebug.destroyed++

Call this each time a object has been successfully been destroyed.