2
0

log.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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-2016, 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):
  14. out('#include "trace/control.h"',
  15. '#include "qemu/log.h"',
  16. '')
  17. def generate_h(event):
  18. argnames = ", ".join(event.args.names())
  19. if len(event.args) > 0:
  20. argnames = ", " + argnames
  21. if "vcpu" in event.properties:
  22. # already checked on the generic format code
  23. cond = "true"
  24. else:
  25. cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
  26. out(' if (%(cond)s) {',
  27. ' struct timeval _now;',
  28. ' gettimeofday(&_now, NULL);',
  29. ' qemu_log_mask(LOG_TRACE, "%%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)