trace_export.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * trace_export.c - export basic ftrace utilities to user space
  3. *
  4. * Copyright (C) 2009 Steven Rostedt <srostedt@redhat.com>
  5. */
  6. #include <linux/stringify.h>
  7. #include <linux/kallsyms.h>
  8. #include <linux/seq_file.h>
  9. #include <linux/debugfs.h>
  10. #include <linux/uaccess.h>
  11. #include <linux/ftrace.h>
  12. #include <linux/module.h>
  13. #include <linux/init.h>
  14. #include <linux/fs.h>
  15. #include "trace_output.h"
  16. #include "trace_format.h"
  17. #undef TRACE_FIELD_ZERO_CHAR
  18. #define TRACE_FIELD_ZERO_CHAR(item) \
  19. ret = trace_seq_printf(s, "\tfield: char " #item ";\t" \
  20. "offset:%lu;\tsize:0;\n", \
  21. offsetof(typeof(field), item)); \
  22. if (!ret) \
  23. return 0;
  24. #undef TPRAWFMT
  25. #define TPRAWFMT(args...) args
  26. #undef TRACE_EVENT_FORMAT
  27. #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
  28. static int \
  29. ftrace_format_##call(struct trace_seq *s) \
  30. { \
  31. struct args field; \
  32. int ret; \
  33. \
  34. tstruct; \
  35. \
  36. trace_seq_printf(s, "\nprint fmt: \"%s\"\n", tpfmt); \
  37. \
  38. return ret; \
  39. }
  40. #include "trace_event_types.h"
  41. #undef TRACE_ZERO_CHAR
  42. #define TRACE_ZERO_CHAR(arg)
  43. #undef TRACE_FIELD
  44. #define TRACE_FIELD(type, item, assign)\
  45. entry->item = assign;
  46. #undef TRACE_FIELD
  47. #define TRACE_FIELD(type, item, assign)\
  48. entry->item = assign;
  49. #undef TPCMD
  50. #define TPCMD(cmd...) cmd
  51. #undef TRACE_ENTRY
  52. #define TRACE_ENTRY entry
  53. #undef TRACE_FIELD_SPECIAL
  54. #define TRACE_FIELD_SPECIAL(type_item, item, cmd) \
  55. cmd;
  56. #undef TRACE_EVENT_FORMAT
  57. #define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \
  58. \
  59. static struct ftrace_event_call __used \
  60. __attribute__((__aligned__(4))) \
  61. __attribute__((section("_ftrace_events"))) event_##call = { \
  62. .name = #call, \
  63. .id = proto, \
  64. .system = __stringify(TRACE_SYSTEM), \
  65. .show_format = ftrace_format_##call, \
  66. }
  67. #include "trace_event_types.h"