events_h.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. trace/generated-events.h
  5. """
  6. __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
  7. __copyright__ = "Copyright 2012-2014, 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. def generate(events, backend):
  13. out('/* This file is autogenerated by tracetool, do not edit. */',
  14. '',
  15. '#ifndef TRACE__GENERATED_EVENTS_H',
  16. '#define TRACE__GENERATED_EVENTS_H',
  17. '',
  18. '#include <stdbool.h>',
  19. '')
  20. # event identifiers
  21. out('typedef enum {')
  22. for e in events:
  23. out(' TRACE_%s,' % e.name.upper())
  24. out(' TRACE_EVENT_COUNT',
  25. '} TraceEventID;')
  26. # static state
  27. for e in events:
  28. if 'disable' in e.properties:
  29. enabled = 0
  30. else:
  31. enabled = 1
  32. out('#define TRACE_%s_ENABLED %d' % (e.name.upper(), enabled))
  33. out('#include "trace/event-internal.h"',
  34. '',
  35. '#endif /* TRACE__GENERATED_EVENTS_H */')