Commit | Line | Data |
---|---|---|
23839b8c | 1 | /* Copyright 2016 Fred Sundvik |
2 | * | |
3 | * This program is free software: you can redistribute it and/or modify | |
4 | * it under the terms of the GNU General Public License as published by | |
5 | * the Free Software Foundation, either version 2 of the License, or | |
6 | * (at your option) any later version. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
16 | ||
a377017c FS |
17 | #ifndef VARIABLE_TRACE_H |
18 | #define VARIABLE_TRACE_H | |
19 | ||
0ba3e523 FS |
20 | // For more information about the variable tracing see the readme. |
21 | ||
a377017c FS |
22 | #include "print.h" |
23 | ||
24 | #ifdef NUM_TRACED_VARIABLES | |
25 | ||
0ba3e523 FS |
26 | // Start tracing a variable at the memory address addr |
27 | // The name can be anything and is used only for reporting | |
28 | // The size should usually be the same size as the variable you are interested in | |
b624f32f | 29 | # define ADD_TRACED_VARIABLE(name, addr, size) add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__) |
0ba3e523 FS |
30 | |
31 | // Stop tracing the variable with the given name | |
b624f32f | 32 | # define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__) |
0ba3e523 FS |
33 | |
34 | // Call to get messages when the variable has been changed | |
b624f32f | 35 | # define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__) |
a377017c FS |
36 | |
37 | #else | |
38 | ||
b624f32f | 39 | # define ADD_TRACED_VARIABLE(name, addr, size) |
40 | # define REMOVE_TRACED_VARIABLE(name) | |
41 | # define VERIFY_TRACED_VARIABLES() | |
a377017c FS |
42 | |
43 | #endif | |
44 | ||
45 | // Don't call directly, use the macros instead | |
46 | void add_traced_variable(const char* name, void* addr, unsigned size, const char* func, int line); | |
47 | void remove_traced_variable(const char* name, const char* func, int line); | |
48 | void verify_traced_variables(const char* func, int line); | |
49 | #endif |