[kvm-unit-tests PATCH v2 5/8] pretty_print_stacks: addr2line may need a cross prefix

Andrew Jones
2016-04-19T16:19:45Z

configure | 2 ++
scripts/pretty_print_stacks.py | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index ba6c55b3bc5b3..ca0ef83b942e5 100755
--- a/configure
+++ b/configure
@@ -7,6 +7,7 @@ ld=ld
objcopy=objcopy
objdump=objdump
ar=ar
+addr2line=addr2line
arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'`
host=$arch
cross_prefix=
@@ -154,6 +155,7 @@ LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
OBJDUMP=$cross_prefix$objdump
AR=$cross_prefix$ar
+ADDR2LINE=$cross_prefix$addr2line
API=$api
TEST_DIR=$testdir
FIRMWARE=$firmware
diff --git a/scripts/pretty_print_stacks.py b/scripts/pretty_print_stacks.py
index bd30a7376a6d8..11042a7953e11 100755
--- a/scripts/pretty_print_stacks.py
+++ b/scripts/pretty_print_stacks.py
@@ -5,6 +5,8 @@ import subprocess
import sys
import traceback

+config = {}
+
# Subvert output buffering.
def puts(string):
sys.stdout.write(string)
@@ -25,7 +27,7 @@ def pretty_print_stack(binary, line):
# Output like this:
# 0x004002be: start64 at path/to/kvm-unit-tests/x86/cstart64.S:208
# (inlined by) test_ept_violation at path/to/kvm-unit-tests/x86/vmx_tests.c:1719 (discriminator 1)
- cmd = ['addr2line', '-e', binary, '-i', '-f', '--pretty', '--address']
+ cmd = [config.get('ADDR2LINE', 'addr2line'), '-e', binary, '-i', '-f', '--pretty', '--address']
cmd.extend(addrs)

p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
@@ -60,6 +62,11 @@ def main():

binary = sys.argv[1].replace(".flat", ".elf")

+ with open("config.mak") as config_file:
+ for line in config_file:
+ name, val = line.partition("=")[::2]
+ config[name.strip()] = val.strip()
+
try:
while True:
# Subvert input buffering.
--
2.4.11