ust_events_h.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # -*- coding: utf-8 -*-
  2. """
  3. trace/generated-ust-provider.h
  4. """
  5. __author__ = "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
  6. __copyright__ = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
  7. __license__ = "GPL version 2 or (at your option) any later version"
  8. __maintainer__ = "Stefan Hajnoczi"
  9. __email__ = "stefanha@redhat.com"
  10. from tracetool import out
  11. def generate(events, backend, group):
  12. events = [e for e in events
  13. if "disabled" not in e.properties]
  14. if group == "all":
  15. include = "trace-ust-all.h"
  16. else:
  17. include = "trace-ust.h"
  18. out('/* This file is autogenerated by tracetool, do not edit. */',
  19. '',
  20. '#undef TRACEPOINT_PROVIDER',
  21. '#define TRACEPOINT_PROVIDER qemu',
  22. '',
  23. '#undef TRACEPOINT_INCLUDE_FILE',
  24. '#define TRACEPOINT_INCLUDE_FILE ./%s' % include,
  25. '',
  26. '#if !defined (TRACE_%s_GENERATED_UST_H) || \\' % group.upper(),
  27. ' defined(TRACEPOINT_HEADER_MULTI_READ)',
  28. '#define TRACE_%s_GENERATED_UST_H' % group.upper(),
  29. '',
  30. '#include <lttng/tracepoint.h>',
  31. '',
  32. '/*',
  33. ' * LTTng ust 2.0 does not allow you to use TP_ARGS(void) for tracepoints',
  34. ' * requiring no arguments. We define these macros introduced in more recent'
  35. ' * versions of LTTng ust as a workaround',
  36. ' */',
  37. '#ifndef _TP_EXPROTO1',
  38. '#define _TP_EXPROTO1(a) void',
  39. '#endif',
  40. '#ifndef _TP_EXDATA_PROTO1',
  41. '#define _TP_EXDATA_PROTO1(a) void *__tp_data',
  42. '#endif',
  43. '#ifndef _TP_EXDATA_VAR1',
  44. '#define _TP_EXDATA_VAR1(a) __tp_data',
  45. '#endif',
  46. '#ifndef _TP_EXVAR1',
  47. '#define _TP_EXVAR1(a)',
  48. '#endif',
  49. '')
  50. for e in events:
  51. if len(e.args) > 0:
  52. out('TRACEPOINT_EVENT(',
  53. ' qemu,',
  54. ' %(name)s,',
  55. ' TP_ARGS(%(args)s),',
  56. ' TP_FIELDS(',
  57. name=e.name,
  58. args=", ".join(", ".join(i) for i in e.args))
  59. types = e.args.types()
  60. names = e.args.names()
  61. fmts = e.formats()
  62. for t,n,f in zip(types, names, fmts):
  63. if ('char *' in t) or ('char*' in t):
  64. out(' ctf_string(' + n + ', ' + n + ')')
  65. elif ("%p" in f) or ("x" in f) or ("PRIx" in f):
  66. out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
  67. elif ("ptr" in t) or ("*" in t):
  68. out(' ctf_integer_hex('+ t + ', ' + n + ', ' + n + ')')
  69. elif ('int' in t) or ('long' in t) or ('unsigned' in t) \
  70. or ('size_t' in t) or ('bool' in t):
  71. out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
  72. elif ('double' in t) or ('float' in t):
  73. out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
  74. elif ('void *' in t) or ('void*' in t):
  75. out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
  76. out(' )',
  77. ')',
  78. '')
  79. else:
  80. out('TRACEPOINT_EVENT(',
  81. ' qemu,',
  82. ' %(name)s,',
  83. ' TP_ARGS(void),',
  84. ' TP_FIELDS()',
  85. ')',
  86. '',
  87. name=e.name)
  88. out('#endif /* TRACE_%s_GENERATED_UST_H */' % group.upper(),
  89. '',
  90. '/* This part must be outside ifdef protection */',
  91. '#include <lttng/tracepoint-event.h>')