mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 04:01:36 +01:00
give up on trac2line full porting, just call sh script for now
This commit is contained in:
85
trace2line
85
trace2line
@@ -1,5 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
'''
|
||||
TODO port this to Python fully. I started it, but then it was hanging on some
|
||||
IO blocking annoyance in the pipeline, and I don't have the time to deal with
|
||||
it, so I'm just going to forward the common options to the old shell script for
|
||||
now...
|
||||
'''
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@@ -11,43 +18,45 @@ parser = common.get_argparse(argparse_args={
|
||||
'description': 'Convert an execution trace containing PC values into the Linux kernel linex executed'
|
||||
})
|
||||
args = common.setup(parser)
|
||||
if args.gem5:
|
||||
def get_pc(line):
|
||||
# pc_re =
|
||||
# stdin = sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file")
|
||||
pass
|
||||
else:
|
||||
def get_pc(line):
|
||||
return line.split('=')[-1]
|
||||
with \
|
||||
subprocess.Popen(
|
||||
[
|
||||
common.get_toolchain_tool('addr2line'),
|
||||
'-e',
|
||||
common.vmlinux,
|
||||
'-f',
|
||||
'-p',
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stdin=subprocess.PIPE,
|
||||
) as proc, \
|
||||
open(common.trace_txt_file, 'r') as infile, \
|
||||
open(os.path.join(common.run_dir, 'trace-lines.txt'), 'w') as outfile \
|
||||
:
|
||||
i = 0;
|
||||
__import__('ipdb').set_trace()
|
||||
for in_line in infile:
|
||||
print(i)
|
||||
proc.stdin.write(get_pc(in_line).encode())
|
||||
proc.stdin.flush()
|
||||
stdout = proc.stdout.read()
|
||||
outfile.write(stdout.decode())
|
||||
i+=1
|
||||
sys.exit(subprocess.Popen([
|
||||
os.path.join(common.root_dir, 'trace2line.sh'),
|
||||
'true' if args.gem5 else 'false',
|
||||
common.trace_txt_file,
|
||||
common.get_toolchain_tool('addr2line'),
|
||||
common.vmlinux,
|
||||
common.run_dir,
|
||||
]).wait())
|
||||
|
||||
# sed -E "s|at ${common.linux_build_dir}/(\./\|)||"
|
||||
# uniq -c
|
||||
# This was the full conversion attempt.
|
||||
|
||||
|
||||
|
||||
|
||||
# sys.exit()
|
||||
# if args.gem5:
|
||||
# def get_pc(line):
|
||||
# # TODO
|
||||
# # stdin = sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file")
|
||||
# pass
|
||||
# else:
|
||||
# def get_pc(line):
|
||||
# return line.split('=')[-1]
|
||||
# with \
|
||||
# subprocess.Popen(
|
||||
# [
|
||||
# common.get_toolchain_tool('addr2line'),
|
||||
# '-e',
|
||||
# common.vmlinux,
|
||||
# '-f',
|
||||
# '-p',
|
||||
# ],
|
||||
# stdout=subprocess.PIPE,
|
||||
# stdin=subprocess.PIPE,
|
||||
# ) as proc, \
|
||||
# open(common.trace_txt_file, 'r') as infile, \
|
||||
# open(os.path.join(common.run_dir, 'trace-lines.txt'), 'w') as outfile \
|
||||
# :
|
||||
# for in_line in infile:
|
||||
# proc.stdin.write(get_pc(in_line).encode())
|
||||
# proc.stdin.flush()
|
||||
# stdout = proc.stdout.read()
|
||||
# outfile.write(stdout.decode())
|
||||
# # TODO
|
||||
# # sed -E "s|at ${common.linux_build_dir}/(\./\|)||"
|
||||
# # uniq -c
|
||||
|
||||
Reference in New Issue
Block a user