log.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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-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. 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. out(' if (trace_event_get_state(%(event_id)s)) {',
  22. ' struct timeval _now;',
  23. ' gettimeofday(&_now, NULL);',
  24. ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
  25. ' getpid(),',
  26. ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
  27. ' %(argnames)s);',
  28. ' }',
  29. event_id="TRACE_" + event.name.upper(),
  30. name=event.name,
  31. fmt=event.fmt.rstrip("\n"),
  32. argnames=argnames)