mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 03:31:36 +01:00
failed attempt at trace2line
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
while getopts "h${common_getopts_flags}" OPT; do
|
||||
case "$OPT" in
|
||||
h)
|
||||
echo "https://github.com/cirosantilli/linux-kernel-module-cheat#getvar" 2>&1
|
||||
echo "https://github.com/cirosantilli/linux-kernel-module-cheat#bisection" 2>&1
|
||||
exit
|
||||
;;
|
||||
?)
|
||||
|
||||
75
trace2line
75
trace2line
@@ -1,22 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
||||
while getopts "${common_getopts_flags}" OPT; do
|
||||
case "$OPT" in
|
||||
?)
|
||||
common_getopts_case "$OPT"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
common_setup
|
||||
kernel_dir="${common_build_dir}/linux-custom"
|
||||
(
|
||||
if "$common_gem5"; then
|
||||
sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file"
|
||||
else
|
||||
sed -r 's/.*pc=//' "$common_trace_txt_file"
|
||||
fi
|
||||
) | \
|
||||
xargs "${common_host_dir}/bin/${common_arch}-linux-addr2line" -e "${common_vmlinux}" -fp | \
|
||||
sed -E "s|at ${kernel_dir}/(\./\|)||" | \
|
||||
uniq -c \
|
||||
> "${common_run_dir}/trace-lines.txt"
|
||||
#!/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()
|
||||
|
||||
Reference in New Issue
Block a user