You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.2 KiB

  1. #ifndef VARIABLE_TRACE_H
  2. #define VARIABLE_TRACE_H
  3. // For more information about the variable tracing see the readme.
  4. #include "print.h"
  5. #ifdef NUM_TRACED_VARIABLES
  6. // Start tracing a variable at the memory address addr
  7. // The name can be anything and is used only for reporting
  8. // The size should usually be the same size as the variable you are interested in
  9. #define ADD_TRACED_VARIABLE(name, addr, size) \
  10. add_traced_variable(PSTR(name), (void*)addr, size, PSTR(__FILE__), __LINE__)
  11. // Stop tracing the variable with the given name
  12. #define REMOVE_TRACED_VARIABLE(name) remove_traced_variable(PSTR(name), PSTR(__FILE__), __LINE__)
  13. // Call to get messages when the variable has been changed
  14. #define VERIFY_TRACED_VARIABLES() verify_traced_variables(PSTR(__FILE__), __LINE__)
  15. #else
  16. #define ADD_TRACED_VARIABLE(name, addr, size)
  17. #define REMOVE_TRACED_VARIABLE(name)
  18. #define VERIFY_TRACED_VARIABLES()
  19. #endif
  20. // Don't call directly, use the macros instead
  21. void add_traced_variable(const char* name, void* addr, unsigned size, const char* func, int line);
  22. void remove_traced_variable(const char* name, const char* func, int line);
  23. void verify_traced_variables(const char* func, int line);
  24. #endif