trace2line 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python3
  2. '''
  3. TODO port this to Python fully. I started it, but then it was hanging on some
  4. IO blocking annoyance in the pipeline, and I don't have the time to deal with
  5. it, so I'm just going to forward the common options to the old shell script for
  6. now...
  7. '''
  8. import os
  9. import re
  10. import subprocess
  11. import sys
  12. import common
  13. parser = common.get_argparse(argparse_args={
  14. 'description': 'Convert an execution trace containing PC values into the Linux kernel linex executed'
  15. })
  16. args = common.setup(parser)
  17. sys.exit(subprocess.Popen([
  18. os.path.join(common.root_dir, 'trace2line.sh'),
  19. 'true' if args.gem5 else 'false',
  20. common.trace_txt_file,
  21. common.get_toolchain_tool('addr2line'),
  22. common.vmlinux,
  23. common.run_dir,
  24. ]).wait())
  25. # This was the full conversion attempt.
  26. # if args.gem5:
  27. # def get_pc(line):
  28. # # TODO
  29. # # stdin = sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file")
  30. # pass
  31. # else:
  32. # def get_pc(line):
  33. # return line.split('=')[-1]
  34. # with \
  35. # subprocess.Popen(
  36. # [
  37. # common.get_toolchain_tool('addr2line'),
  38. # '-e',
  39. # common.vmlinux,
  40. # '-f',
  41. # '-p',
  42. # ],
  43. # stdout=subprocess.PIPE,
  44. # stdin=subprocess.PIPE,
  45. # ) as proc, \
  46. # open(common.trace_txt_file, 'r') as infile, \
  47. # open(os.path.join(common.run_dir, 'trace-lines.txt'), 'w') as outfile \
  48. # :
  49. # for in_line in infile:
  50. # proc.stdin.write(get_pc(in_line).encode())
  51. # proc.stdin.flush()
  52. # stdout = proc.stdout.read()
  53. # outfile.write(stdout.decode())
  54. # # TODO
  55. # # sed -E "s|at ${common.linux_build_dir}/(\./\|)||"
  56. # # uniq -c