2
0

stderr.py 947 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 <stdio.h>',
  15. '#include "trace/control.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. ' fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s);',
  23. ' }',
  24. event_id="TRACE_" + event.name.upper(),
  25. name=event.name,
  26. fmt=event.fmt.rstrip("\n"),
  27. argnames=argnames)