diff options
Diffstat (limited to 'runtime/docs/html/io_8c-source.html')
-rw-r--r-- | runtime/docs/html/io_8c-source.html | 206 |
1 files changed, 123 insertions, 83 deletions
diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index 246f36d8..c241bba1 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -5,89 +5,129 @@ </head><body> <!-- Generated by Doxygen 1.4.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> -<h1>io.c</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/** Logs data.</span> -00002 <span class="comment"> * This function is compatible with printk. In fact it currently</span> -00003 <span class="comment"> * sends all output to vprintk, after sending "STP: ". This allows</span> -00004 <span class="comment"> * us to easily detect SystemTap output in the log file.</span> -00005 <span class="comment"> *</span> -00006 <span class="comment"> * @param fmt A variable number of args.</span> -00007 <span class="comment"> * @bug Lines are limited in length by printk buffer.</span> -00008 <span class="comment"> * @todo Needs replaced with something much faster that does not</span> -00009 <span class="comment"> * use the system log.</span> -00010 <span class="comment"> */</span> -00011 <span class="keywordtype">void</span> dlog (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...) -00012 { -00013 va_list args; -00014 printk(<span class="stringliteral">"STP: "</span>); -00015 va_start(args, fmt); -00016 vprintk(fmt, args); -00017 va_end(args); -00018 } -00019 -00020 -00021 <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, -00022 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *symbolsize, -00023 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *offset, -00024 <span class="keywordtype">char</span> **modname, <span class="keywordtype">char</span> *namebuf)=(<span class="keywordtype">void</span> *)KALLSYMS_LOOKUP; -00025 -00026 -00027 <span class="preprocessor">#define STP_BUF_LEN 8191</span> -00028 <span class="preprocessor"></span> -00029 <span class="comment">/* FIXME. These need to be per-cpu */</span> -00030 <span class="keyword">static</span> <span class="keywordtype">char</span> _stp_pbuf[STP_BUF_LEN+1]; -00031 <span class="keyword">static</span> <span class="keywordtype">int</span> _stp_pbuf_len = STP_BUF_LEN; -00032 -00033 <span class="keywordtype">void</span> _stp_print_buf (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...) -00034 { -00035 <span class="keywordtype">int</span> num; -00036 va_list args; -00037 <span class="keywordtype">char</span> *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len; -00038 va_start(args, fmt); -00039 num = vscnprintf(buf, _stp_pbuf_len, fmt, args); -00040 va_end(args); -00041 <span class="keywordflow">if</span> (num > 0) -00042 _stp_pbuf_len -= num; -00043 } -00044 -00045 <span class="keywordtype">void</span> _stp_print_buf_init (<span class="keywordtype">void</span>) -00046 { -00047 _stp_pbuf_len = STP_BUF_LEN; -00048 _stp_pbuf[0] = 0; -00049 } -00050 -00051 <span class="keywordtype">void</span> _stp_print_symbol(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address) -00052 { -00053 <span class="keywordtype">char</span> *modname; -00054 <span class="keyword">const</span> <span class="keywordtype">char</span> *name; -00055 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> offset, size; -00056 <span class="keywordtype">char</span> namebuf[KSYM_NAME_LEN+1]; -00057 -00058 name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf); -00059 -00060 <span class="keywordflow">if</span> (!name) -00061 _stp_print_buf("0x%lx", address); -00062 else { -00063 <span class="keywordflow">if</span> (modname) -00064 _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset, -00065 size, modname); -00066 else -00067 _stp_print_buf("%s+%#lx/%#lx", name, offset, size); -00068 } -00069 } -00070 -00071 -00072 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> cur_ret_addr (struct pt_regs *regs) +<h1>io.c</h1><a href="io_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* -*- linux-c -*- */</span><span class="comment"></span> +00002 <span class="comment">/** @file io.c</span> +00003 <span class="comment"> * @brief I/O functions</span> +00004 <span class="comment"> */</span> +00005 <span class="comment"></span> +00006 <span class="comment">/** Logs data.</span> +00007 <span class="comment"> * This function is compatible with printk. In fact it currently</span> +00008 <span class="comment"> * sends all output to vprintk, after sending "STP: ". This allows</span> +00009 <span class="comment"> * us to easily detect SystemTap output in the log file.</span> +00010 <span class="comment"> *</span> +00011 <span class="comment"> * @param fmt A variable number of args.</span> +00012 <span class="comment"> * @bug Lines are limited in length by printk buffer.</span> +00013 <span class="comment"> * @todo Needs replaced with something much faster that does not</span> +00014 <span class="comment"> * use the system log.</span> +00015 <span class="comment"> */</span> +<a name="l00016"></a><a class="code" href="io_8c.html#a4">00016</a> <span class="keywordtype">void</span> <a class="code" href="io_8c.html#a4">dlog</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...) +00017 { +00018 va_list args; +00019 printk(<span class="stringliteral">"STP: "</span>); +00020 va_start(args, fmt); +00021 vprintk(fmt, args); +00022 va_end(args); +00023 } +00024 +00025 <span class="comment"></span> +00026 <span class="comment">/** Lookup symbol.</span> +00027 <span class="comment"> * This simply calls the kernel function kallsyms_lookup().</span> +00028 <span class="comment"> * That function is not exported, so this workaround is required.</span> +00029 <span class="comment"> * See the kernel source, kernel/kallsyms.c for more information.</span> +00030 <span class="comment"> */</span> +<a name="l00031"></a><a class="code" href="io_8c.html#a1">00031</a> <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, +00032 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *symbolsize, +00033 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *offset, +00034 <span class="keywordtype">char</span> **modname, <span class="keywordtype">char</span> *namebuf)=(<span class="keywordtype">void</span> *)KALLSYMS_LOOKUP; +00035 +00036 +00037 <span class="preprocessor">#define STP_BUF_LEN 8191</span> +00038 <span class="preprocessor"></span><span class="comment"></span> +00039 <span class="comment">/** Static buffer for printing */</span> +<a name="l00040"></a><a class="code" href="io_8c.html#a2">00040</a> <span class="keyword">static</span> <span class="keywordtype">char</span> <a class="code" href="io_8c.html#a2">_stp_pbuf</a>[STP_BUF_LEN+1]; +00041 <span class="keyword">static</span> <span class="keywordtype">int</span> _stp_pbuf_len = STP_BUF_LEN; +00042 <span class="comment"></span> +00043 <span class="comment">/** Print into the print buffer.</span> +00044 <span class="comment"> * Like printf, except output goes into _stp_pbuf,</span> +00045 <span class="comment"> * which will contain the null-terminated output.</span> +00046 <span class="comment"> * Safe because overflowing _stp_pbuf is not allowed.</span> +00047 <span class="comment"> * Size is limited by length of print buffer.</span> +00048 <span class="comment"> *</span> +00049 <span class="comment"> * @param fmt A variable number of args.</span> +00050 <span class="comment"> * @note Formatting output should never be done within</span> +00051 <span class="comment"> * a probe. Use at module exit time.</span> +00052 <span class="comment"> * @sa _stp_print_buf_init</span> +00053 <span class="comment"> */</span> +00054 +<a name="l00055"></a><a class="code" href="io_8c.html#a5">00055</a> <span class="keywordtype">void</span> <a class="code" href="io_8c.html#a5">_stp_print_buf</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...) +00056 { +00057 <span class="keywordtype">int</span> num; +00058 va_list args; +00059 <span class="keywordtype">char</span> *buf = <a class="code" href="io_8c.html#a2">_stp_pbuf</a> + STP_BUF_LEN - _stp_pbuf_len; +00060 va_start(args, fmt); +00061 num = vscnprintf(buf, _stp_pbuf_len, fmt, args); +00062 va_end(args); +00063 <span class="keywordflow">if</span> (num > 0) +00064 _stp_pbuf_len -= num; +00065 } +00066 <span class="comment"></span> +00067 <span class="comment">/** Clear the print buffer.</span> +00068 <span class="comment"> * Output from _stp_print_buf() will accumulate in the buffer</span> +00069 <span class="comment"> * until this is called.</span> +00070 <span class="comment"> */</span> +00071 +<a name="l00072"></a><a class="code" href="io_8c.html#a6">00072</a> <span class="keywordtype">void</span> <a class="code" href="io_8c.html#a6">_stp_print_buf_init</a> (<span class="keywordtype">void</span>) 00073 { -00074 <span class="preprocessor">#ifdef __x86_64__</span> -00075 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *ra = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *)regs->rsp; -00076 <span class="preprocessor">#else</span> -00077 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *ra = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *)regs->esp; -00078 <span class="preprocessor">#endif</span> -00079 <span class="preprocessor"></span> <span class="keywordflow">if</span> (ra) -00080 return *ra; -00081 else -00082 return 0; -00083 } +00074 _stp_pbuf_len = STP_BUF_LEN; +00075 <a class="code" href="io_8c.html#a2">_stp_pbuf</a>[0] = 0; +00076 } +00077 <span class="comment"></span> +00078 <span class="comment">/** Print addresses symbolically into the print buffer.</span> +00079 <span class="comment"> * @param fmt A variable number of args.</span> +00080 <span class="comment"> * @param address The address to lookup.</span> +00081 <span class="comment"> * @note Formatting output should never be done within</span> +00082 <span class="comment"> * a probe. Use at module exit time.</span> +00083 <span class="comment"> */</span> +00084 +<a name="l00085"></a><a class="code" href="io_8c.html#a7">00085</a> <span class="keywordtype">void</span> <a class="code" href="io_8c.html#a7">_stp_print_symbol</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> address) +00086 { +00087 <span class="keywordtype">char</span> *modname; +00088 <span class="keyword">const</span> <span class="keywordtype">char</span> *name; +00089 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> offset, size; +00090 <span class="keywordtype">char</span> namebuf[KSYM_NAME_LEN+1]; +00091 +00092 name = <a class="code" href="io_8c.html#a1">_stp_kallsyms_lookup</a>(address, &size, &offset, &modname, namebuf); +00093 +00094 <span class="keywordflow">if</span> (!name) +00095 <a class="code" href="io_8c.html#a5">_stp_print_buf</a>(<span class="stringliteral">"0x%lx"</span>, address); +00096 <span class="keywordflow">else</span> { +00097 <span class="keywordflow">if</span> (modname) +00098 <a class="code" href="io_8c.html#a5">_stp_print_buf</a>(<span class="stringliteral">"%s+%#lx/%#lx [%s]"</span>, name, offset, +00099 size, modname); +00100 <span class="keywordflow">else</span> +00101 <a class="code" href="io_8c.html#a5">_stp_print_buf</a>(<span class="stringliteral">"%s+%#lx/%#lx"</span>, name, offset, size); +00102 } +00103 } +00104 <span class="comment"></span> +00105 <span class="comment">/** Get the current return address.</span> +00106 <span class="comment"> * Call from kprobes (not jprobes).</span> +00107 <span class="comment"> * @param regs The pt_regs saved by the kprobe.</span> +00108 <span class="comment"> * @return The return address saved in esp or rsp.</span> +00109 <span class="comment"> * @note i386 and x86_64 only.</span> +00110 <span class="comment"> */</span> +00111 +<a name="l00112"></a><a class="code" href="io_8c.html#a8">00112</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="io_8c.html#a8">cur_ret_addr</a> (<span class="keyword">struct</span> pt_regs *regs) +00113 { +00114 <span class="preprocessor">#ifdef __x86_64__</span> +00115 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *ra = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *)regs->rsp; +00116 <span class="preprocessor">#else</span> +00117 <span class="preprocessor"></span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *ra = (<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *)regs->esp; +00118 <span class="preprocessor">#endif</span> +00119 <span class="preprocessor"></span> <span class="keywordflow">if</span> (ra) +00120 <span class="keywordflow">return</span> *ra; +00121 <span class="keywordflow">else</span> +00122 <span class="keywordflow">return</span> 0; +00123 } </pre></div><hr size="1"><address style="align: right;"><small> -Generated on Tue Mar 22 00:32:02 2005 for SystemTap.</small></body> +Generated on Tue Mar 22 10:27:36 2005 for SystemTap.</small></body> </html> |