log.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Stderr built-in backend.
  5. """
  6. __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
  7. __copyright__ = "Copyright 2012-2017, 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 generate_h_begin(events, group):
  14. out('#include "qemu/log.h"',
  15. '')
  16. def generate_h(event, group):
  17. argnames = ", ".join(event.args.names())
  18. if len(event.args) > 0:
  19. argnames = ", " + argnames
  20. if "vcpu" in event.properties:
  21. # already checked on the generic format code
  22. cond = "true"
  23. else:
  24. cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
  25. out(' if (%(cond)s) {',
  26. ' struct timeval _now;',
  27. ' gettimeofday(&_now, NULL);',
  28. ' qemu_log_mask(LOG_TRACE,',
  29. ' "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
  30. ' getpid(),',
  31. ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
  32. ' %(argnames)s);',
  33. ' }',
  34. cond=cond,
  35. name=event.name,
  36. fmt=event.fmt.rstrip("\n"),
  37. argnames=argnames)
  38. def generate_h_backend_dstate(event, group):
  39. out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
  40. event_id="TRACE_" + event.name.upper())