]> sourceware.org Git - systemtap.git/commitdiff
Testcase and documentation for minidebuginfo
authorLukas Berk <lberk@redhat.com>
Fri, 23 Aug 2013 15:31:48 +0000 (11:31 -0400)
committerLukas Berk <lberk@redhat.com>
Fri, 23 Aug 2013 15:31:48 +0000 (11:31 -0400)
man/warning::debuginfo.7stap - explain basics of minidebuginfo, note
       that it requires elfutils 0.156 and add
       a pointer to the fedora feature page
testsuite/systemtap.base/ files:
create-minidebuginfo.sh - script to create minidebuginfo
minidebug.c - simple c program with multiple function calls
minidebuginfo.exp  - compile minidebug.c and generate minidebuginfo,
  test that the functions are still listed with
  probefunc()
minidebuginfo.stp - script to probe process.function("*") and list
  probefunc()'s

man/warning::debuginfo.7stap
testsuite/systemtap.base/create-minidebug.sh [new file with mode: 0755]
testsuite/systemtap.base/minidebug.c [new file with mode: 0644]
testsuite/systemtap.base/minidebuginfo.exp [new file with mode: 0644]
testsuite/systemtap.base/minidebuginfo.stp [new file with mode: 0644]

index 2b588873738e862c349a7a43921c517d6e0f869a..148e0f8299ab0e906e0a64c82c2c5d7863a6ff55 100644 (file)
@@ -1,5 +1,5 @@
 .\" t
-.TH WARNING::DEBUGINFO 7stap 
+.TH WARNING::DEBUGINFO 7stap
 .SH NAME
 warning::debuginfo \- systemtap missing-debuginfo warnings
 
@@ -7,7 +7,7 @@ warning::debuginfo \- systemtap missing-debuginfo warnings
 For many symbolic probing operations, systemtap needs DWARF debuginfo for
 the relevant binaries.  This often includes resolving function/statement
 probes, or $context variables in related handlers.  DWARF debuginfo may
-be found in the original binaries built during compilation, or may have 
+be found in the original binaries built during compilation, or may have
 been split into separate files.  The
 .IR SYSTEMTAP_DEBUGINFO_PATH
 environment variable affects where systemtap looks for these files.
@@ -20,8 +20,8 @@ not have debuginfo-equipped binaries at all, you may need to rebuild it.
 kernel debuginfo
 For scripts that target the kernel, systemtap may search for the
 .IR vmlinux
-file created during its original build.  This is distinct from the 
-boot-loader's compressed/stripped 
+file created during its original build.  This is distinct from the
+boot-loader's compressed/stripped
 .IR vmlinuz
 file, and much larger.  If you have a hand-built kernel, make sure
 it was built with the
@@ -31,10 +31,18 @@ option.
 .TP
 process debuginfo
 For scripts that target user-space, systemtap may search for debuginfo.
-If you have hand-built binaries, use 
+If you have hand-built binaries, use
 .IR "CFLAGS=-g -O2"
 to compile them.
 
+.TP
+minidebuginfo
+On some systems, binaries may be compiled with a subset of debuginfo
+useful for function tracing and backtraces.  This 'Minidebuginfo' is
+a xz compressed section labeled .gnu_debugdata.  Support for
+minidebuginfo relies on elfutils
+version 0.156.
+
 .TP
 unnecessary debuginfo
 In some cases, a script may be altered to avoid requiring debuginfo.
@@ -45,12 +53,12 @@ probes could try instead
 (for non-DWARF syscall): these work similarly, and use more intricate
 (fragile) tapset functions to extract system call arguments.  Another
 option is use of compiled-in instrumentation such as kernel tracepoints
-or user-space 
+or user-space
 .IR <sys/sdt.h>
 markers in libraries or executables, which do not require debuginfo.
 If debuginfo was required for resolving a complicated
 .IR $var->foo->bar
-expression, it may be possible to use 
+expression, it may be possible to use
 .IR @cast(var,"foo","foo.h")->foo->bar
 to synthesize debuginfo for that type from a header file.
 
@@ -63,9 +71,9 @@ with the
 flag.
 The
 .IR stap-prep
-script included with systemtap may be able to download the 
+script included with systemtap may be able to download the
 appropriate kernel debuginfo.  Another possibility is to install and
-use a 
+use a
 .IR stap\-server
 remote-compilation instance on a machine on your network, where
 debuginfo and compilation resources can be centralized.  Try the
@@ -77,5 +85,6 @@ option, in case such a server is already running.
 .IR stappaths (7),
 .IR stap-server (8),
 .IR strip (1),
-.IR error::reporting (7stap)
-.IR error::contextvars (7stap)
+.IR error::reporting (7stap),
+.IR error::contextvars (7stap),
+.IR http://fedoraproject.org/wiki/Features/MiniDebugInfo
diff --git a/testsuite/systemtap.base/create-minidebug.sh b/testsuite/systemtap.base/create-minidebug.sh
new file mode 100755 (executable)
index 0000000..de0571c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/bash
+
+# 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 binary --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 minimal set of symbols and
+# removing some unnecessary sections.
+objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=keep_symbols binary mini_debuginfo
+
+# Inject the compressed data into the .gnu_debugdata section of the
+# original binary.
+xz mini_debuginfo
+objcopy --add-section .gnu_debugdata=mini_debuginfo.xz binary
diff --git a/testsuite/systemtap.base/minidebug.c b/testsuite/systemtap.base/minidebug.c
new file mode 100644 (file)
index 0000000..b60bad6
--- /dev/null
@@ -0,0 +1,3 @@
+void foo() {}
+void bar() {foo();}
+int main() {bar(); return 0;}
diff --git a/testsuite/systemtap.base/minidebuginfo.exp b/testsuite/systemtap.base/minidebuginfo.exp
new file mode 100644 (file)
index 0000000..c93919f
--- /dev/null
@@ -0,0 +1,23 @@
+set test "minidebuginfo"
+
+if {![installtest_p]} { untested $test; return }
+
+catch { exec gcc -o binary -g $srcdir/$subdir/minidebug.c } err
+
+if {$err == ""} then { pass "$test compile" } else { fail "$test compile $err" }
+
+catch { exec $srcdir/$subdir/create-minidebug.sh } err
+if {$err == ""} then { pass "$test create minidebug" } else { fail "$test create-minidebug.sh $err" }
+spawn stap $srcdir/$subdir/minidebuginfo.stp -c "./binary"
+set ok 0
+expect {
+    -timeout 30
+    -re {[^\r\n]*main\r\n} { incr ok; exp_continue }
+    -re {[^\r\n]*bar\r\n} { incr ok; exp_continue }
+    -re {[^\r\n]*foo\r\n} { incr ok; exp_continue }
+    eof { }
+    timeout { fail "$test (timeout)" }
+}
+catch { close }; wait
+if {$ok == 3} then { pass "$test ($ok)" } else { fail "$test ($ok)" }
+catch { exec rm binary mini_debuginfo.xz dynsyms funcsyms keep_symbols } err
diff --git a/testsuite/systemtap.base/minidebuginfo.stp b/testsuite/systemtap.base/minidebuginfo.stp
new file mode 100644 (file)
index 0000000..eea7bad
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env stap
+
+probe process("binary").function("*") {log(probefunc())}
\ No newline at end of file
This page took 0.036404 seconds and 5 git commands to generate.