spinn_common 7.2.2
Support code for SpiNNaker applications.
|
SpiNNaker debug header file. More...
#include "spin-print.h"
Go to the source code of this file.
Macros | |
#define | abort(n) do { exit(n); } while (0) |
This macro is intended to mimic the behaviour of 'C's exit system call. | |
#define | LOG_ERROR 10 |
The log level for errors. | |
#define | LOG_WARNING 20 |
The log level for warnings. | |
#define | LOG_INFO 30 |
The log level for information. | |
#define | LOG_DEBUG 40 |
The log level for debugging. | |
#define | LOG_LEVEL LOG_DEBUG |
The logging level. | |
#define | check(condition, message, ...) |
This macro prints out a check message to the log file. | |
#define | sentinel(message, ...) |
This macro prints out a sentinel message to the log file and aborts. | |
#define | assert(assertion) |
This macro performs an assertion check on a condition and aborts if the condition is not met. | |
#define | assert_info(assertion, message, ...) |
This macro performs an assertion check on a condition and aborts if the condition is not met. | |
#define | check_memory(a) check((a), "Out of memory") |
This macro tests whether a pointer returned by malloc is null. | |
#define | check_itcm(a) |
This macro tests whether a pointer's address lies in itcm. | |
#define | check_dtcm(a) |
This macro tests whether a pointer's address lies in dtcm. | |
#define | check_sysram(a) |
This macro tests whether a pointer's address lies in sysram. | |
#define | check_sdram(a) |
This macro tests whether a pointer's address lies in sdram. | |
Functions | |
static unsigned int | __addr__ (void *ptr) |
This function returns the unsigned integer associated with a pointer address. | |
SpiNNaker debug header file.
A header file that can be used to incorporate and control debug information. It is switched ON by default; to switch OFF, the code is compiled with
-DPRODUCTION_CODE
or
-DNDEBUG
By default it is used for SpiNNaker ARM code; it can also be used in host-side C, by compiling with -DDEBUG_ON_HOST
To use, you must ‘hash-include’ debug.h:
Assertions:
assert(0.0 < c && c < 1.0); // assertion checking
Checking:
check(1==1, "1 !=1 !!!!!!"); // assertion with message xp = malloc(n); check_memory(xp); // checks malloc is non-null
Sentinels:
switch(n) { ... default: sentinel("switch: out of range"); // used for control flow checks .... }
SpiNNaker memory checking:
If we are running on SpiNNaker hardware, we have the following additional checks available:
check_itcm(addr); check_dtcm(addr); check_sysram(addr); check_sdram(addr);
Controlling the volume of logging information:
-DNO_DEBUG_INFO Switches OFF the [INFO] information -D'DEBUG_LOG(n)=(n>10)' Switches OFF [ERROR]s with number less than or equal 10 -D'DEBUG_WARN(n)=(n>5)' Switches OFF [WARNING]s with number less than or equal 5
By default all information is printed.
There is no way to switch off [ASSERT]s except by using either of the compilation flags: -DPRODUCTION_CODE
or -DNDEBUG
#define abort | ( | n | ) | do { exit(n); } while (0) |
This macro is intended to mimic the behaviour of 'C's exit system call.
[in] | n | Value to pass to exit() |
#define check | ( | condition, | |
message, | |||
... | |||
) |
This macro prints out a check message to the log file.
[in] | condition | The condition being tested. |
[in] | message | The message to be printed if the condition is false |
#define sentinel | ( | message, | |
... | |||
) |
This macro prints out a sentinel message to the log file and aborts.
[in] | message | The message to be printed if execution reaches this point |
#define assert | ( | assertion | ) |
This macro performs an assertion check on a condition and aborts if the condition is not met.
[in] | assertion | The condition being tested. |
#define assert_info | ( | assertion, | |
message, | |||
... | |||
) |
This macro performs an assertion check on a condition and aborts if the condition is not met.
[in] | assertion | The condition being tested. |
[in] | message | The message to be printed if the condition is false |
#define check_memory | ( | a | ) | check((a), "Out of memory") |
This macro tests whether a pointer returned by malloc is null.
[in] | a | The address returned by malloc. |
#define check_itcm | ( | a | ) |
This macro tests whether a pointer's address lies in itcm.
[in] | a | The pointer. |
#define check_dtcm | ( | a | ) |
#define check_sysram | ( | a | ) |
#define check_sdram | ( | a | ) |
|
inlinestatic |
This function returns the unsigned integer associated with a pointer address.
[in] | ptr | The pointer whose address is required. |