summaryrefslogtreecommitdiffstats
path: root/runtime/docs/html/sym_8c-source.html
blob: 2e8ffc8a26d25c0508875cab5048d298bb29d87e (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>SystemTap: sym.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<h1>sym.c</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef _SYM_C_ </span><span class="comment">/* -*- linux-c -*- */</span>
00002 <span class="preprocessor">#define _SYM_C_</span>
00003 <span class="preprocessor"></span>
00004 <span class="preprocessor">#include "scbuf.c"</span>
00005 <span class="comment"></span>
00006 <span class="comment">/** @file sym.c</span>
00007 <span class="comment"> * @addtogroup sym Symbolic Functions</span>
00008 <span class="comment"> * Symbolic Lookup Functions</span>
00009 <span class="comment"> * @{</span>
00010 <span class="comment"> */</span>
00011 <span class="comment"></span>
00012 <span class="comment">/** Lookup symbol.</span>
00013 <span class="comment"> * This simply calls the kernel function kallsyms_lookup().</span>
00014 <span class="comment"> * That function is not exported, so this workaround is required.</span>
00015 <span class="comment"> * See the kernel source, kernel/kallsyms.c for more information.</span>
00016 <span class="comment"> */</span>
00017 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * (*_stp_kallsyms_lookup)(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> addr,
00018                             <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *symbolsize,
00019                             <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *offset,
00020                             <span class="keywordtype">char</span> **modname, <span class="keywordtype">char</span> *namebuf)=(<span class="keywordtype">void</span> *)KALLSYMS_LOOKUP;
00021 
00022 <span class="keyword">static</span> <span class="keywordtype">void</span> __stp_symbol_print (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address, <span class="keywordtype">void</span> (*prtfunc)(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...))
00023 {
00024         <span class="keywordtype">char</span> *modname;
00025         <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
00026         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> offset, size;
00027         <span class="keywordtype">char</span> namebuf[KSYM_NAME_LEN+1];
00028 
00029         name = _stp_kallsyms_lookup(address, &amp;size, &amp;offset, &amp;modname, namebuf);
00030 
00031         (*prtfunc)(<span class="stringliteral">"0x%lx : "</span>, address);
00032         <span class="keywordflow">if</span> (modname)
00033                 (*prtfunc)(<span class="stringliteral">"%s+%#lx/%#lx [%s]"</span>, name, offset, size, modname);
00034         <span class="keywordflow">else</span>
00035                 (*prtfunc)(<span class="stringliteral">"%s+%#lx/%#lx"</span>, name, offset, size);
00036 }
00037 <span class="comment"></span>
00038 <span class="comment">/** Print addresses symbolically into a string</span>
00039 <span class="comment"> * @param address The address to lookup.</span>
00040 <span class="comment"> * @note Symbolic lookups should not be done within</span>
00041 <span class="comment"> * a probe because it is too time-consuming. Use at module exit time.</span>
00042 <span class="comment"> * @note Uses scbuf.</span>
00043 <span class="comment"> */</span>
00044 
<a name="l00045"></a><a class="code" href="group__sym.html#ga2">00045</a> <span class="keywordtype">char</span> * <a class="code" href="group__sym.html#ga2">_stp_symbol_sprint</a> (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address)
00046 { 
00047         <span class="keywordtype">char</span> *ptr = _stp_scbuf_cur();
00048         __stp_symbol_print (address, <a class="code" href="group__scbuf.html#ga2">_stp_sprint</a>);
00049         <span class="keywordflow">return</span> ptr;
00050 }
00051 
00052 <span class="comment"></span>
00053 <span class="comment">/** Print addresses symbolically to the trace buffer.</span>
00054 <span class="comment"> * @param address The address to lookup.</span>
00055 <span class="comment"> * @note Symbolic lookups should not be done within</span>
00056 <span class="comment"> * a probe because it is too time-consuming. Use at module exit time.</span>
00057 <span class="comment"> */</span>
00058 
<a name="l00059"></a><a class="code" href="group__sym.html#ga3">00059</a> <span class="keywordtype">void</span> <a class="code" href="group__sym.html#ga3">_stp_symbol_print</a> (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address)
00060 {
00061         __stp_symbol_print (address, <a class="code" href="group__io.html#ga1">_stp_print</a>);
00062 }
00063 <span class="comment"></span>
00064 <span class="comment">/** @} */</span>
00065 <span class="preprocessor">#endif </span><span class="comment">/* _SYM_C_ */</span>
</pre></div></body></html>