Debug Levels - nomius/dmemory GitHub Wiki
dmemory allows you to set more debug information if needed in three different levels. Those are information, warnings and errors.
The function dmemory_init() allows you to set additional debug information with it's parameter.
| Int | Additional debug description |
|---|---|
| -1 | dmemory works as normal dynamic memory functions without any additions |
| 0 | No aditional debug added (only reports will be generated) |
| 1 | Only error will be issued (in case malloc/calloc/realloc returns NULL) |
| 2 | Warnings, in dmemory, warnings are referred as a double free or a free to a wrong address space |
| 4 | Library information like, no report or exceptions filename given, also, errors related to additional library features are shown as information |
For example we set debug information to full in the initialization call:
$ cat example.c
#include <stdlib.h>
#include <dmemory.h>
int main(int argc, char *argv[])
{
dmemory_init(4);
free((void *)0xFFFF);
if (dmemory_end())
return 1;
return 0;
}
$Now, if we run our program we'll see more information in the standard error:
$ ./example
WARNING: [example.c:8] You can not free this variable, as it was never reserved
INFO: [LIBRARY:0] DMEMORY_EXCEPTIONS not defined, no exceptions will be used
$ cat report.txt
(F) [example.c] [8] (address: 0x000000010007)
$