mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 20:14:27 +01:00
failed attempt at trace2line
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
while getopts "h${common_getopts_flags}" OPT; do
|
while getopts "h${common_getopts_flags}" OPT; do
|
||||||
case "$OPT" in
|
case "$OPT" in
|
||||||
h)
|
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
|
exit
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
|
|||||||
75
trace2line
75
trace2line
@@ -1,22 +1,53 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env python3
|
||||||
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
|
|
||||||
while getopts "${common_getopts_flags}" OPT; do
|
import os
|
||||||
case "$OPT" in
|
import re
|
||||||
?)
|
import subprocess
|
||||||
common_getopts_case "$OPT"
|
import sys
|
||||||
;;
|
|
||||||
esac
|
import common
|
||||||
done
|
|
||||||
common_setup
|
parser = common.get_argparse(argparse_args={
|
||||||
kernel_dir="${common_build_dir}/linux-custom"
|
'description': 'Convert an execution trace containing PC values into the Linux kernel linex executed'
|
||||||
(
|
})
|
||||||
if "$common_gem5"; then
|
args = common.setup(parser)
|
||||||
sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file"
|
if args.gem5:
|
||||||
else
|
def get_pc(line):
|
||||||
sed -r 's/.*pc=//' "$common_trace_txt_file"
|
# pc_re =
|
||||||
fi
|
# stdin = sed -r 's/^.* (0x[^. ]*)[. ].*/\1/' "$common_trace_txt_file")
|
||||||
) | \
|
pass
|
||||||
xargs "${common_host_dir}/bin/${common_arch}-linux-addr2line" -e "${common_vmlinux}" -fp | \
|
else:
|
||||||
sed -E "s|at ${kernel_dir}/(\./\|)||" | \
|
def get_pc(line):
|
||||||
uniq -c \
|
return line.split('=')[-1]
|
||||||
> "${common_run_dir}/trace-lines.txt"
|
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