diff options
| author | Jack Humbert <jack.humb@gmail.com> | 2016-11-07 10:55:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-07 10:55:05 -0500 |
| commit | a9e0fd410ce7c8b975ba72cd7900c3f6edc0d108 (patch) | |
| tree | 6ad9fae08c3ca15d0b56507afa2b788fc625571e /quantum/variable_trace.h | |
| parent | 309d93184e7c9fab561a8678a4d287ef9ec970fd (diff) | |
| parent | 0ba3e523a7c124e4ce54dfd043dc32e72ad3233b (diff) | |
| download | qmk_firmware-a9e0fd410ce7c8b975ba72cd7900c3f6edc0d108.tar.gz qmk_firmware-a9e0fd410ce7c8b975ba72cd7900c3f6edc0d108.zip | |
Merge pull request #867 from fredizzimo/variable_trace
Variable trace
Diffstat (limited to 'quantum/variable_trace.h')
| -rw-r--r-- | quantum/variable_trace.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/quantum/variable_trace.h b/quantum/variable_trace.h new file mode 100644 index 000000000..46bd82786 --- /dev/null +++ b/quantum/variable_trace.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #ifndef VARIABLE_TRACE_H | ||
| 2 | #define VARIABLE_TRACE_H | ||
| 3 | |||
| 4 | // For more information about the variable tracing see the readme. | ||
| 5 | |||
| 6 | #include "print.h" | ||
| 7 | |||
| 8 | #ifdef NUM_TRACED_VARIABLES | ||
| 9 | |||
| 10 | // Start tracing a variable at the memory address addr | ||
| 11 | // The name can be anything and is used only for reporting | ||
| 12 | // The size should usually be the same size as the variable you are interested in | ||
| 13 | #define ADD_TRACED_VARIABLE(name, addr, size) \ | ||
| 14 | add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__) | ||
| 15 | |||
| 16 | // Stop tracing the variable with the given name | ||
| 17 | #define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__) | ||
| 18 | |||
| 19 | // Call to get messages when the variable has been changed | ||
| 20 | #define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__) | ||
| 21 | |||
| 22 | #else | ||
| 23 | |||
| 24 | #define ADD_TRACED_VARIABLE(name, addr, size) | ||
| 25 | #define REMOVE_TRACED_VARIABLE(name) | ||
| 26 | #define VERIFY_TRACED_VARIABLES() | ||
| 27 | |||
| 28 | #endif | ||
| 29 | |||
| 30 | // Don't call directly, use the macros instead | ||
| 31 | void add_traced_variable(const char* name, void* addr, unsigned size, const char* func, int line); | ||
| 32 | void remove_traced_variable(const char* name, const char* func, int line); | ||
| 33 | void verify_traced_variables(const char* func, int line); | ||
| 34 | #endif | ||
