stderr.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include "trace.h"
  2. #include "trace/control.h"
  3. void trace_print_events(FILE *stream, fprintf_function stream_printf)
  4. {
  5. unsigned int i;
  6. for (i = 0; i < NR_TRACE_EVENTS; i++) {
  7. stream_printf(stream, "%s [Event ID %u] : state %u\n",
  8. trace_list[i].tp_name, i, trace_list[i].state);
  9. }
  10. }
  11. bool trace_event_set_state(const char *name, bool state)
  12. {
  13. unsigned int i;
  14. unsigned int len;
  15. bool wildcard = false;
  16. bool matched = false;
  17. len = strlen(name);
  18. if (len > 0 && name[len - 1] == '*') {
  19. wildcard = true;
  20. len -= 1;
  21. }
  22. for (i = 0; i < NR_TRACE_EVENTS; i++) {
  23. if (wildcard) {
  24. if (!strncmp(trace_list[i].tp_name, name, len)) {
  25. trace_list[i].state = state;
  26. matched = true;
  27. }
  28. continue;
  29. }
  30. if (!strcmp(trace_list[i].tp_name, name)) {
  31. trace_list[i].state = state;
  32. return true;
  33. }
  34. }
  35. return matched;
  36. }
  37. bool trace_backend_init(const char *events, const char *file)
  38. {
  39. if (file) {
  40. fprintf(stderr, "error: -trace file=...: "
  41. "option not supported by the selected tracing backend\n");
  42. return false;
  43. }
  44. trace_backend_init_events(events);
  45. return true;
  46. }