summaryrefslogtreecommitdiffstats
path: root/runtime/docs/html/sym_8c-source.html
blob: 8e7f21b8914c28ed4b69630c6b25f7636aa59343 (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
74
75
76
77
78
79
<!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="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</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 "<a class="code" href="string_8c.html">string.c</a>"</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="comment"></span>
00023 <span class="comment">/** Write addresses symbolically into a String</span>
00024 <span class="comment"> * @param str String</span>
00025 <span class="comment"> * @param address The address to lookup.</span>
00026 <span class="comment"> * @note Symbolic lookups should not normally be done within</span>
00027 <span class="comment"> * a probe because it is too time-consuming. Use at module exit time.</span>
00028 <span class="comment"> */</span>
00029 
<a name="l00030"></a><a class="code" href="group__sym.html#ga1">00030</a> String <a class="code" href="group__sym.html#ga1">_stp_symbol_sprint</a> (String str, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address)
00031 { 
00032         <span class="keywordtype">char</span> *modname;
00033         <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
00034         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> offset, size;
00035         <span class="keywordtype">char</span> namebuf[KSYM_NAME_LEN+1];
00036 
00037         name = _stp_kallsyms_lookup(address, &amp;size, &amp;offset, &amp;modname, namebuf);
00038 
00039         <a class="code" href="group__string.html#ga3">_stp_sprintf</a> (str, <span class="stringliteral">"0x%lx : "</span>, address);
00040         <span class="keywordflow">if</span> (modname)
00041                 <a class="code" href="group__string.html#ga3">_stp_sprintf</a> (str, <span class="stringliteral">"%s+%#lx/%#lx [%s]"</span>, name, offset, size, modname);
00042         <span class="keywordflow">else</span>
00043                 <a class="code" href="group__string.html#ga3">_stp_sprintf</a> (str, <span class="stringliteral">"%s+%#lx/%#lx"</span>, name, offset, size);
00044         <span class="keywordflow">return</span> str;
00045 }
00046 
00047 <span class="comment"></span>
00048 <span class="comment">/** Print addresses symbolically to the print buffer.</span>
00049 <span class="comment"> * @param address The address to lookup.</span>
00050 <span class="comment"> * @note Symbolic lookups should not normally be done within</span>
00051 <span class="comment"> * a probe because it is too time-consuming. Use at module exit time.</span>
00052 <span class="comment"> */</span>
00053 
<a name="l00054"></a><a class="code" href="group__sym.html#ga2">00054</a> <span class="keywordtype">void</span> <a class="code" href="group__sym.html#ga2">_stp_symbol_print</a> (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address)
00055 {
00056         <span class="keywordtype">char</span> *modname;
00057         <span class="keyword">const</span> <span class="keywordtype">char</span> *name;
00058         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> offset, size;
00059         <span class="keywordtype">char</span> namebuf[KSYM_NAME_LEN+1];
00060 
00061         name = _stp_kallsyms_lookup(address, &amp;size, &amp;offset, &amp;modname, namebuf);
00062 
00063         <a class="code" href="group__print.html#ga3">_stp_printf</a> (<span class="stringliteral">"0x%lx : "</span>, address);
00064         <span class="keywordflow">if</span> (modname)
00065                 <a class="code" href="group__print.html#ga3">_stp_printf</a> (<span class="stringliteral">"%s+%#lx/%#lx [%s]"</span>, name, offset, size, modname);
00066         <span class="keywordflow">else</span>
00067                 <a class="code" href="group__print.html#ga3">_stp_printf</a> (<span class="stringliteral">"%s+%#lx/%#lx"</span>, name, offset, size);
00068 }
00069 <span class="comment"></span>
00070 <span class="comment">/** @} */</span>
00071 <span class="preprocessor">#endif </span><span class="comment">/* _SYM_C_ */</span>
</pre></div></body></html>