ust_events_h.py 3.6 KB

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