diff options
author | hunt <hunt> | 2005-03-29 18:07:58 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-03-29 18:07:58 +0000 |
commit | e32551b18f4560056d2d482f5e1505b1b98fa82a (patch) | |
tree | 4e9e07a9b46a4fd5dea27732571cbb04c0ef5dee /runtime/io.c | |
parent | 13b35bb112459702e7371ecc89d7deb789818a86 (diff) | |
download | systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.tar.gz systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.tar.xz systemtap-steved-e32551b18f4560056d2d482f5e1505b1b98fa82a.zip |
*** empty log message ***
Diffstat (limited to 'runtime/io.c')
-rw-r--r-- | runtime/io.c | 121 |
1 files changed, 32 insertions, 89 deletions
diff --git a/runtime/io.c b/runtime/io.c index 16343bef..0612f563 100644 --- a/runtime/io.c +++ b/runtime/io.c @@ -1,17 +1,26 @@ +#ifndef _IO_C_ +#define _IO_C_ + /* -*- linux-c -*- */ /** @file io.c * @brief I/O functions */ +/** @addtogroup io I/O + * I/O functions + * @{ + */ -/** Logs data. +/** Logs Data. * This function is compatible with printk. In fact it currently * sends all output to vprintk, after sending "STP: ". This allows - * us to easily detect SystemTap output in the log file. + * us to easily detect SystemTap output in the log file. * * @param fmt A variable number of args. - * @bug Lines are limited in length by printk buffer. - * @todo Needs replaced with something much faster that does not - * use the system log. + * @bug Lines are limited in length by printk buffer. If there is + * no newline in the format string, then other syslog output could + * get appended to the SystemTap line. + * @todo Either deprecate or redefine this as a way to log debug or + * status messages, separate from the normal program output. */ void dlog (const char *fmt, ...) { @@ -22,102 +31,36 @@ void dlog (const char *fmt, ...) va_end(args); } - -/** Lookup symbol. - * This simply calls the kernel function kallsyms_lookup(). - * That function is not exported, so this workaround is required. - * See the kernel source, kernel/kallsyms.c for more information. - */ -static const char * (*_stp_kallsyms_lookup)(unsigned long addr, - unsigned long *symbolsize, - unsigned long *offset, - char **modname, char *namebuf)=(void *)KALLSYMS_LOOKUP; - - -#define STP_BUF_LEN 8191 - -/** Static buffer for printing */ -static char _stp_pbuf[STP_BUF_LEN+1]; -static int _stp_pbuf_len = STP_BUF_LEN; - -/** Print into the print buffer. - * Like printf, except output goes into _stp_pbuf, - * which will contain the null-terminated output. - * Safe because overflowing _stp_pbuf is not allowed. - * Size is limited by length of print buffer. +/** Prints to the trace buffer. + * This function uses the same formatting as printk. It currently + * writes to the system log. * * @param fmt A variable number of args. - * @note Formatting output should never be done within - * a probe. Use at module exit time. - * @sa _stp_print_buf_init + * @todo Needs replaced with something much faster that does not + * use the system log. */ -void _stp_print_buf (const char *fmt, ...) +void _stp_print (const char *fmt, ...) { - int num; va_list args; - char *buf = _stp_pbuf + STP_BUF_LEN - _stp_pbuf_len; va_start(args, fmt); - num = vscnprintf(buf, _stp_pbuf_len, fmt, args); + vprintk(fmt, args); va_end(args); - if (num > 0) - _stp_pbuf_len -= num; } -/** Clear the print buffer. - * Output from _stp_print_buf() will accumulate in the buffer - * until this is called. - */ - -void _stp_print_buf_init (void) -{ - _stp_pbuf_len = STP_BUF_LEN; - _stp_pbuf[0] = 0; -} - -/** Print addresses symbolically into the print buffer. - * @param fmt A variable number of args. - * @param address The address to lookup. - * @note Formatting output should never be done within - * a probe. Use at module exit time. +/** Prints to the trace buffer. + * This function will write a string to the trace buffer. It currently + * writes to the system log. + * + * @param str String. + * @todo Needs replaced with something much faster that does not + * use the system log. */ -void _stp_print_symbol(const char *fmt, unsigned long address) +void _stp_print_str (char *str) { - char *modname; - const char *name; - unsigned long offset, size; - char namebuf[KSYM_NAME_LEN+1]; - - name = _stp_kallsyms_lookup(address, &size, &offset, &modname, namebuf); - - if (!name) - _stp_print_buf("0x%lx", address); - else { - if (modname) - _stp_print_buf("%s+%#lx/%#lx [%s]", name, offset, - size, modname); - else - _stp_print_buf("%s+%#lx/%#lx", name, offset, size); - } + printk ("%s", str); } -/** Get the current return address. - * Call from kprobes (not jprobes). - * @param regs The pt_regs saved by the kprobe. - * @return The return address saved in esp or rsp. - * @note i386 and x86_64 only. - */ - -unsigned long cur_ret_addr (struct pt_regs *regs) -{ -#ifdef __x86_64__ - unsigned long *ra = (unsigned long *)regs->rsp; -#else - unsigned long *ra = (unsigned long *)regs->esp; -#endif - if (ra) - return *ra; - else - return 0; -} +/** @} */ +#endif /* _IO_C_ */ |