markers.py 926 B

123456789101112131415161718192021222324252627282930
  1. # Monitor SimMarker() calls made by the application.
  2. import sim
  3. class Marker:
  4. def setup(self, args):
  5. args = (args or '').split(':')
  6. self.write_terminal = 'verbose' in args
  7. self.write_markers = 'markers' in args
  8. self.write_stats = 'stats' in args
  9. def hook_magic_marker(self, thread, core, a, b, s):
  10. if self.write_terminal:
  11. print '[SCRIPT] Magic marker from thread %d: a = %d,' % (thread, a),
  12. if s:
  13. print 'str = %s' % s
  14. else:
  15. print 'b = %d' % b
  16. if self.write_markers:
  17. sim.stats.marker(thread, core, a, b, s)
  18. # Pass in 'stats' as option to write out statistics at each magic marker
  19. # $ run-sniper -s markers:stats
  20. # This will allow for e.g. partial CPI stacks of specific code regions:
  21. # $ tools/cpistack.py --partial=marker-1-4:marker-2-4
  22. if self.write_stats:
  23. sim.stats.write('marker-%d-%d' % (a, b))
  24. sim.util.register(Marker())