mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-01-09 19:03:43 +01:00
MiniDebugInfo test: tests/run-coredump-unwind-mdi
Test that creates MiniDebugInfo-containing binary and then checks if it can recover the procedure names from its coredump. Signed-off-by: Martin Milata <mmilata@redhat.com>
This commit is contained in:
parent
7d5a197021
commit
4ab9e5dd10
4 changed files with 53 additions and 3 deletions
|
@ -2,7 +2,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||||
|
|
||||||
EXTRA_DIST = run-ia64-test-dyn1 run-ptrace-mapper run-ptrace-misc \
|
EXTRA_DIST = run-ia64-test-dyn1 run-ptrace-mapper run-ptrace-misc \
|
||||||
run-check-namespace run-coredump-unwind \
|
run-check-namespace run-coredump-unwind \
|
||||||
check-namespace.sh.in Gtest-nomalloc.c Gtest-nocalloc.c
|
run-coredump-unwind-mdi check-namespace.sh.in \
|
||||||
|
Gtest-nomalloc.c Gtest-nocalloc.c
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = Makefile.in
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
@ -60,6 +61,10 @@ endif
|
||||||
if OS_LINUX
|
if OS_LINUX
|
||||||
check_SCRIPTS_cdep += run-coredump-unwind
|
check_SCRIPTS_cdep += run-coredump-unwind
|
||||||
noinst_PROGRAMS_cdep += test-coredump-unwind
|
noinst_PROGRAMS_cdep += test-coredump-unwind
|
||||||
|
|
||||||
|
if HAVE_LZMA
|
||||||
|
check_SCRIPTS_cdep += run-coredump-unwind-mdi
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
perf: perf-startup Gperf-simple Lperf-simple Lperf-trace
|
perf: perf-startup Gperf-simple Lperf-simple Lperf-trace
|
||||||
|
|
|
@ -1,14 +1,51 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# this function is slight modification of the one used in RPM
|
||||||
|
# found at https://bugzilla.redhat.com/show_bug.cgi?id=834073
|
||||||
|
# written by Alexander Larsson <alexl@redhat.com>
|
||||||
|
add_minidebug()
|
||||||
|
{
|
||||||
|
debuginfo="$1" ## we don't have separate debuginfo file
|
||||||
|
binary="$1"
|
||||||
|
|
||||||
|
dynsyms=`mktemp`
|
||||||
|
funcsyms=`mktemp`
|
||||||
|
keep_symbols=`mktemp`
|
||||||
|
mini_debuginfo=`mktemp`
|
||||||
|
|
||||||
|
# Extract the dynamic symbols from the main binary, there is no need to also have these
|
||||||
|
# in the normal symbol table
|
||||||
|
nm -D "$binary" --format=posix --defined-only | awk '{ print $1 }' | sort > "$dynsyms"
|
||||||
|
# Extract all the text (i.e. function) symbols from the debuginfo
|
||||||
|
nm "$debuginfo" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > "$funcsyms"
|
||||||
|
# Keep all the function symbols not already in the dynamic symbol table
|
||||||
|
comm -13 "$dynsyms" "$funcsyms" > "$keep_symbols"
|
||||||
|
# Copy the full debuginfo, keeping only a minumal set of symbols and removing some unnecessary sections
|
||||||
|
objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols="$keep_symbols" "$debuginfo" "$mini_debuginfo" &> /dev/null
|
||||||
|
#Inject the compressed data into the .gnu_debugdata section of the original binary
|
||||||
|
xz "$mini_debuginfo"
|
||||||
|
mini_debuginfo="${mini_debuginfo}.xz"
|
||||||
|
objcopy --add-section .gnu_debugdata="$mini_debuginfo" "$binary"
|
||||||
|
rm -f "$dynsyms" "$funcsyms" "$keep_symbols" "$mini_debuginfo"
|
||||||
|
|
||||||
|
strip "$binary" ## throw away the symbol table
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TESTDIR=`pwd`
|
TESTDIR=`pwd`
|
||||||
TEMPDIR=`mktemp --tmpdir -d libunwind-test-XXXXXXXXXX`
|
TEMPDIR=`mktemp --tmpdir -d libunwind-test-XXXXXXXXXX`
|
||||||
trap "rm -r -- $TEMPDIR" EXIT
|
trap "rm -r -- $TEMPDIR" EXIT
|
||||||
|
|
||||||
|
cp crasher $TEMPDIR/crasher
|
||||||
|
if [ "$1" = "-minidebuginfo" ]; then
|
||||||
|
add_minidebug $TEMPDIR/crasher
|
||||||
|
fi
|
||||||
|
|
||||||
# create core dump
|
# create core dump
|
||||||
(
|
(
|
||||||
cd $TEMPDIR
|
cd $TEMPDIR
|
||||||
ulimit -c 10000
|
ulimit -c 10000
|
||||||
$TESTDIR/crasher $TEMPDIR/backing_files
|
./crasher backing_files
|
||||||
) 2>/dev/null
|
) 2>/dev/null
|
||||||
COREFILE=$TEMPDIR/core*
|
COREFILE=$TEMPDIR/core*
|
||||||
|
|
||||||
|
|
8
tests/run-coredump-unwind-mdi
Executable file
8
tests/run-coredump-unwind-mdi
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This test intends to test the unw_get_proc_name function on binaries without
|
||||||
|
# the symbol table but with so called MiniDebuginfo available. In particular,
|
||||||
|
# it is tested using the coredump accessors. For more info about MiniDebugInfo
|
||||||
|
# see e.g. http://fedoraproject.org/wiki/Features/MiniDebugInfo
|
||||||
|
|
||||||
|
./run-coredump-unwind -minidebuginfo
|
|
@ -269,7 +269,7 @@ main(int argc, char **argv)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#define TEST_FRAMES 4
|
#define TEST_FRAMES 4
|
||||||
#define TEST_NAME_LEN 16
|
#define TEST_NAME_LEN 32
|
||||||
int testcase = 0;
|
int testcase = 0;
|
||||||
int test_cur = 0;
|
int test_cur = 0;
|
||||||
long test_start_ips[TEST_FRAMES];
|
long test_start_ips[TEST_FRAMES];
|
||||||
|
|
Loading…
Reference in a new issue