Files
linux-kernel-module-cheat/trace-boot
Ciro Santilli f5065183a8 tracing: create trace2line
This lead to a re-factoring of count boot instructions, since trace2line
relies on the same tracing mechanism.

Also, now that we have common factored, I've decided to put the traces on
the out dir, to concentrate all outputs in a single place, and allow
easy switching between archs.
2018-03-28 14:12:03 +01:00

24 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -eu
. common
arch=x86_64
while getopts a: OPT; do
case "$OPT" in
a)
arch="$OPTARG"
;;
esac
done
set_common_vars "$arch" false
time ./run -a "$arch" -e 'init=/poweroff.out' -- -trace exec_tb,file="${lkmc_out_dir}/trace.bin"
time ./qemu/scripts/simpletrace.py "${out_dir}/build/host-qemu-custom/trace-events-all" "${lkmc_out_dir}/trace.bin" >"${lkmc_out_dir}/trace.txt"
# Instruction count.
# We could put this on a separate script, but it just adds more arch boilerplate to a new script.
# So let's just leave it here for now since it did not add a significant processing time.
echo "instruction count all: $(wc -l "${lkmc_out_dir}/trace.txt" | cut -d' ' -f1)"
entry_addr=$("${out_dir}"/host/bin/*-buildroot-*-readelf -h "${out_dir}/build/linux-custom/vmlinux" | grep 'Entry point address' | sed -E 's/.*: *//')
echo "entry address: ${entry_addr}"
sed "/${entry_addr}/q" "${lkmc_out_dir}/trace.txt" >"${lkmc_out_dir}/trace-boot.txt"
echo "instruction count firmware: $(wc -l "${lkmc_out_dir}/trace-boot.txt" | cut -d' ' -f1)"