Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > e2ec330d3ecf5110b4aa890342e53d96 > files > 771

systemtap-client-2.1-2.fc17.i686.rpm

<?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>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 name="generator" content="publican 2.8" /><meta name="package" content="Systemtap-SystemTap_Beginners_Guide-2.1-en-US-2.1-2" /><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="http://www.fedoraproject.org"><img src="Common_Content/images/image_left.png" alt="Product Site" /></a><a class="right" href="http://docs.fedoraproject.org"><img src="Common_Content/images/image_right.png" alt="Documentation Site" /></a></p><ul class="docnav"><li class="previous"><a accesskey="p" href="utargetvariable.html"><strong>Prev</strong></a></li><li class="next"><a accesskey="n" href="useful-systemtap-scripts.html"><strong>Next</strong></a></li></ul><div class="section" id="ustack"><div class="titlepage"><div><div keep-together.within-column="always"><h2 class="title" id="ustack">4.3. User-Space Stack Backtraces</h2></div></div></div><a id="idm2390184" class="indexterm"></a><div class="para">
			The probe point (<code class="command">pp</code>) function indicates which particular event triggered the 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. You will need to use the <code class="command">-d <em class="replaceable"><code>executable</code></em></code> for the application executable and <code class="command">-ldd</code> for shared libraries to ensure that the needed debug information is used to produce the user-space stack backtraces.
		</div><div class="para">
			If you want to see how the function <code class="command">xmalloc</code> function is being called by the command <code class="command">ls</code>, you could use the user-space backtrack functions to provide that information. With the debuginfo for the <code class="command">ls</code> command installed the following SystemTap command will provide a backtrace each time the <code class="command">xmalloc</code> function is called:
		</div><pre class="screen">stap -d /bin/ls --ldd \
-e 'probe process("ls").function("xmalloc") {print_usyms(ubacktrace())}' \
-c "ls /"</pre><div class="para">
			When the SystemTap script runs will have 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 look at the <code class="command">ucontext-symbols.stp</code> and <code class="command">ucontext-unwind.stp</code> tapsets. The descriptions of the functions in those tapsets can also be found 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>