blob: 583940d9b720aa34716ab2aca4047e3341f843e5 (
plain) (
blame)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">4.3. User-Space Stack Backtraces</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="publican v4.1.3" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="SystemTap-SystemTap_Beginners_Guide-2.7-en-US-2.0-1" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="userspace-probing.html" title="Chapter 4. User-space Probing" /><link rel="prev" href="utargetvariable.html" title="4.2. Accessing User-Space Target Variables" /><link rel="next" href="useful-systemtap-scripts.html" title="Chapter 5. Useful SystemTap Scripts" /></head><body><p id="title"><a class="left" href="https://fedorahosted.org/publican"><img alt="Product Site" src="Common_Content/images//image_left.png" /></a><a class="right" href="https://fedorahosted.org/publican"><img alt="Documentation Site" src="Common_Content/images//image_right.png" /></a></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="utargetvariable.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="useful-systemtap-scripts.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h2 class="title"><a id="ustack"> </a>4.3. User-Space Stack Backtraces</h2></div></div></div><a id="idm47748228688992" class="indexterm"></a><div class="para"> The probe point (<code class="function">pp</code>) function indicates which particular event triggered the SystemTap event handler. A probe on the entry into a function would list the function name. However, in many cases the same probe point event may be triggered by many different modules in the program; this is particularly true for functions in shared libraries. A SystemTap backtrace of the user-space stack can provide additional context on how the probe point event is triggered. </div><div class="para"> The user-space stack backtrace generation is complicated by the compiler producing code optimized to eliminate stack frame pointers. However, the compiler also includes information in the debug information section to allow debugging tools to produce stack backtraces. SystemTap user-space stack backtrace mechanism makes use of that debug information to walk the stack to generate stack traces for 32-bit and 64-bit x86 processors; other processor architectures do not yet support the use of debug information to unwind the user-space stack. To ensure that the needed debug information is used to produce the user-space stack backtraces, use the <code class="option">-d <em class="replaceable">executable</em></code> option for executables and <code class="option">-ldd</code> for shared libraries. </div><div class="para"> For example, you can use the user-space backtrack functions to see how the <code class="function">xmalloc</code> function is being called by the <code class="command">ls</code> command. With the debuginfo for the <code class="command">ls</code> command installed, the following SystemTap command provides a backtrace each time the <code class="function">xmalloc</code> function is called: </div><pre class="screen"><code class="command">stap -d /bin/ls --ldd \</code> <code class="command">-e 'probe process("ls").function("xmalloc") {print_usyms(ubacktrace())}' \</code> <code class="command">-c "ls /"</code></pre><div class="para"> When executed, this command produces output similar to the following: </div><pre class="screen"> bin dev lib media net proc sbin sys var boot etc lib64 misc op_session profilerc selinux tmp cgroup home lost+found mnt opt root srv usr 0x4116c0 : xmalloc+0x0/0x20 [/bin/ls] 0x4116fc : xmemdup+0x1c/0x40 [/bin/ls] 0x40e68b : clone_quoting_options+0x3b/0x50 [/bin/ls] 0x4087e4 : main+0x3b4/0x1900 [/bin/ls] 0x3fa441ec5d : __libc_start_main+0xfd/0x1d0 [/lib64/libc-2.12.so] 0x402799 : _start+0x29/0x2c [/bin/ls] 0x4116c0 : xmalloc+0x0/0x20 [/bin/ls] 0x4116fc : xmemdup+0x1c/0x40 [/bin/ls] 0x40e68b : clone_quoting_options+0x3b/0x50 [/bin/ls] 0x40884a : main+0x41a/0x1900 [/bin/ls] 0x3fa441ec5d : __libc_start_main+0xfd/0x1d0 [/lib64/libc-2.12.so] ... </pre><div class="para"> For more details on the functions available for user-space stack backtraces, refer to <code class="filename">ucontext-symbols.stp</code> and <code class="filename">ucontext-unwind.stp</code> tapsets. You can also find the description of the functions in the aforementioned tapsets in the <em class="citetitle">SystemTap Tapset Reference Manual</em>. </div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="utargetvariable.html"><strong>Prev</strong>4.2. Accessing User-Space Target Variables</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="useful-systemtap-scripts.html"><strong>Next</strong>Chapter 5. Useful SystemTap Scripts</a></li></ul></body></html>
|