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.

trace.c 549B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "trace.h"
  2. #ifdef L2_ENABLE_TRACE
  3. #include <stdio.h>
  4. int l2_trace_depth = 0;
  5. void l2_trace_push(const char *name) {
  6. for (int i = 0; i < l2_trace_depth; ++i) {
  7. fprintf(stderr, " ");
  8. }
  9. fprintf(stderr, "%s {\n", name);
  10. l2_trace_depth += 1;
  11. }
  12. void l2_trace_pop() {
  13. l2_trace_depth -= 1;
  14. for (int i = 0; i < l2_trace_depth; ++i) {
  15. fprintf(stderr, " ");
  16. }
  17. fprintf(stderr, "}\n");
  18. }
  19. void l2_trace(const char *name) {
  20. fprintf(stderr, "TRACE %s\n", name);
  21. }
  22. void l2_trace_cleanup(void *unused) {
  23. l2_trace_pop();
  24. }
  25. #endif