mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 11:41:35 +01:00
54 lines
1.2 KiB
Python
Executable File
54 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
|
|
import common
|
|
|
|
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
|
|
|
|
# sed -E "s|at ${common.linux_build_dir}/(\./\|)||"
|
|
# uniq -c
|
|
|
|
|
|
|
|
|
|
# sys.exit()
|