2
0

ust.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. LTTng User Space Tracing backend.
  5. """
  6. __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
  7. __copyright__ = "Copyright 2012, Lluís Vilanova <vilanova@ac.upc.edu>"
  8. __license__ = "GPL version 2 or (at your option) any later version"
  9. __maintainer__ = "Stefan Hajnoczi"
  10. __email__ = "stefanha@linux.vnet.ibm.com"
  11. from tracetool import out
  12. PUBLIC = True
  13. def c(events):
  14. pass
  15. def h(events):
  16. out('#include <lttng/tracepoint.h>',
  17. '#include "trace/generated-ust-provider.h"',
  18. '')
  19. for e in events:
  20. argnames = ", ".join(e.args.names())
  21. if len(e.args) > 0:
  22. argnames = ", " + argnames
  23. out('static inline void trace_%(name)s(%(args)s)',
  24. '{',
  25. ' tracepoint(qemu, %(name)s%(tp_args)s);',
  26. '}',
  27. '',
  28. name = e.name,
  29. args = e.args,
  30. tp_args = argnames,
  31. )
  32. def ust_events_c(events):
  33. pass
  34. def ust_events_h(events):
  35. for e in events:
  36. if len(e.args) > 0:
  37. out('TRACEPOINT_EVENT(',
  38. ' qemu,',
  39. ' %(name)s,',
  40. ' TP_ARGS(%(args)s),',
  41. ' TP_FIELDS(',
  42. name = e.name,
  43. args = ", ".join(", ".join(i) for i in e.args),
  44. )
  45. for t,n in e.args:
  46. if ('int' in t) or ('long' in t) or ('unsigned' in t) or ('size_t' in t):
  47. out(' ctf_integer(' + t + ', ' + n + ', ' + n + ')')
  48. elif ('double' in t) or ('float' in t):
  49. out(' ctf_float(' + t + ', ' + n + ', ' + n + ')')
  50. elif ('char *' in t) or ('char*' in t):
  51. out(' ctf_string(' + n + ', ' + n + ')')
  52. elif ('void *' in t) or ('void*' in t):
  53. out(' ctf_integer_hex(unsigned long, ' + n + ', ' + n + ')')
  54. out(' )',
  55. ')',
  56. '')
  57. else:
  58. out('TRACEPOINT_EVENT(',
  59. ' qemu,',
  60. ' %(name)s,',
  61. ' TP_ARGS(void),',
  62. ' TP_FIELDS()',
  63. ')',
  64. '',
  65. name = e.name,
  66. )