| 1 |
.\" t |
| 2 |
.TH ERROR::DWARF 7stap |
| 3 |
.SH NAME |
| 4 |
error::dwarf \- dwarf debuginfo quality problems |
| 5 |
|
| 6 |
.SH DESCRIPTION |
| 7 |
|
| 8 |
Systemtap sometimes relies on ELF/DWARF debuginfo for programs being |
| 9 |
instrumented to locate places to probe, or context variables to |
| 10 |
read/write, just like a symbolic debugger does. Even though |
| 11 |
examination of the program's source code may show variables or lines |
| 12 |
where probes may be desired, the compiler must preserve information |
| 13 |
about them for systemtap (or a debugger such as gdb) to get pinpoint |
| 14 |
access to the desired information. If a script requires such data, |
| 15 |
but the compiler did not preserve enough of it, pass-2 errors may |
| 16 |
result. |
| 17 |
.PP |
| 18 |
Common conditions that trigger these problems include: |
| 19 |
|
| 20 |
.TP |
| 21 |
debuginfo missing or mismatching |
| 22 |
Sometimes debuginfo is installed, but does not match the binaries being |
| 23 |
probed. See the \fIwarning::debuginfo\fP man page for more help for |
| 24 |
locating correct debuginfo. |
| 25 |
|
| 26 |
.TP |
| 27 |
compiler version |
| 28 |
Prior to GCC version 4.5, debuginfo quality was fairly limited. |
| 29 |
Often developers were advised to build their programs with |
| 30 |
.IR "-O0 -g" |
| 31 |
flags to disable optimization. GCC version 4.5 introduced |
| 32 |
a facility called "variable-tracking assignments" that allows it |
| 33 |
to generate high-quality debuginfo under full |
| 34 |
.IR "-O2 -g" |
| 35 |
optimization. It is not perfect, but much better than before. |
| 36 |
Note that, due to another gcc bug (PR51358) |
| 37 |
.IR "-O0 -g" |
| 38 |
can actually sometimes make debuginfo quality worse than for |
| 39 |
.IR "-O2 -g" . |
| 40 |
|
| 41 |
Another related problem involves debuginfo quality for the |
| 42 |
prologue area of a function (PR15123), wherein a program |
| 43 |
compiled with CFLAGS=-mfentry (especially the kernel, for ftrace) |
| 44 |
may lack accurate debuginfo for the entry instructions for gcc |
| 45 |
prior to version 4.8. If able, arrange to compile your programs |
| 46 |
with |
| 47 |
.IR "-grecord-gcc-switches" |
| 48 |
CFLAGS, and/or try rerunning systemtap with |
| 49 |
.nh |
| 50 |
.IR $PR15123_ASSUME_MFENTRY=1 . |
| 51 |
.hy |
| 52 |
|
| 53 |
.TP |
| 54 |
linux kbuild damaging debuginfo quality |
| 55 |
An upstream kernel commit #2062afb4f804a put |
| 56 |
\%-fno-var-tracking-assignments into KCFLAGS, dramatically reducing |
| 57 |
debuginfo quality, which can cause debuginfo failures. The simplest |
| 58 |
fix is to \fBerase, excise, nay, eradicate\fP this line from the top |
| 59 |
level linux Makefile: |
| 60 |
|
| 61 |
.SAMPLE |
| 62 |
KBUILD_CFLAGS += [...] -fno-var-tracking-assignments [...] |
| 63 |
.ESAMPLE |
| 64 |
|
| 65 |
.TP |
| 66 |
function inlining |
| 67 |
Even modern gcc sometimes has problems with parameters for inlined functions. |
| 68 |
It may be necessary to change the script to probe at a slightly different place. |
| 69 |
Try a |
| 70 |
.IR .statement() " probe, instead of a " .function() " probe," |
| 71 |
somewhere a few source lines into the body of the inlined function. Or try |
| 72 |
putting a probe at the call site of the inlined function. Or use the |
| 73 |
.nh |
| 74 |
.IR "if @defined($var) { ... }" |
| 75 |
.hy |
| 76 |
script language construct to test for the resolvability of the context |
| 77 |
variable before using it. |
| 78 |
|
| 79 |
.TP |
| 80 |
instruction reordering |
| 81 |
Heavily optimized code often smears the instructions from |
| 82 |
multiple source statements together. This can leave systemtap with no place |
| 83 |
to choose to place a probe, especially a statement probe specified by line |
| 84 |
number. Systemtap may advise to try a nearby line number, but these may |
| 85 |
not work well either. Consider placing a probe by a statement wildcard |
| 86 |
or line number range. |
| 87 |
|
| 88 |
.TP |
| 89 |
elfutils configuration |
| 90 |
It is possible that the DWARF debuginfo being sought is available, but not in |
| 91 |
a format acceptable to the copy of elfutils used by systemtap. For example, |
| 92 |
your copy of gcc might produce compressed debuginfo (\f2.zdebug_*\f1 ELF |
| 93 |
sections or \f2.xz\f1 files) while your copy of elfutils might lack |
| 94 |
appropriate decompression capabilities. Unfortunately, there is no easy |
| 95 |
way to tell if this is the problem. If you're building your own copy |
| 96 |
of elfutils, ensure all decompression library headers/libraries are |
| 97 |
available at build time. |
| 98 |
|
| 99 |
.TP |
| 100 |
debuginfo configuration |
| 101 |
Some tools may generate debuginfo that is unsupported by systemtap, such |
| 102 |
as the linux kernel CONFIG_DEBUG_INFO_SPLIT (\f2.dwo\f1 files) option. |
| 103 |
Stick with plain ELF/DWARF (optinally split, Fedora-style), if possible. |
| 104 |
|
| 105 |
|
| 106 |
.SH ALTERNATIVES |
| 107 |
|
| 108 |
In order to reduce reliance on ELF/DWARF debuginfo, consider the use of |
| 109 |
statically compiled-in instrumentation, such as kernel tracepoints, or |
| 110 |
.IR <sys/sdt.h> |
| 111 |
userspace markers. Such instrumentation hook sites are relatively low |
| 112 |
cost (just one NOP instruction for sdt.h), and nearly guarantee the |
| 113 |
availability of parameter data and a reliable probe site, |
| 114 |
all without reliance on debuginfo. |
| 115 |
|
| 116 |
.SH SEE ALSO |
| 117 |
.nh |
| 118 |
.nf |
| 119 |
.IR stap (1), |
| 120 |
.IR http://dwarfstd.org/ , |
| 121 |
.IR http://sourceware.org/systemtap/wiki/TipContextVariables , |
| 122 |
.IR http://gcc.gnu.org/wiki/Var_Tracking_Assignments , |
| 123 |
.IR warning::debuginfo (7stap), |
| 124 |
.IR warning::buildid (7stap), |
| 125 |
.IR error::reporting (7stap) |