Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

io.c File Reference

I/O functions. More...

Go to the source code of this file.

Defines

#define STP_BUF_LEN   8191

Functions

void dlog (const char *fmt,...)
 Logs data.
void _stp_print_buf (const char *fmt,...)
 Print into the print buffer.
void _stp_print_buf_init (void)
 Clear the print buffer.
void _stp_print_symbol (const char *fmt, unsigned long address)
 Print addresses symbolically into the print buffer.
unsigned long cur_ret_addr (struct pt_regs *regs)
 Get the current return address.

Variables

static const char *(* _stp_kallsyms_lookup )(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) = (void *)KALLSYMS_LOOKUP
 Lookup symbol.
static char _stp_pbuf [8191+1]
 Static buffer for printing.
static int _stp_pbuf_len = 8191


Detailed Description

I/O functions.

Definition in file io.c.


Function Documentation

void _stp_print_buf const char *  fmt,
  ...
 

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.

Parameters:
fmt A variable number of args.
Note:
Formatting output should never be done within a probe. Use at module exit time.
See also:
_stp_print_buf_init

Definition at line 55 of file io.c.

References _stp_pbuf.

Referenced by _stp_print_symbol().

void _stp_print_buf_init void   ) 
 

Clear the print buffer.

Output from _stp_print_buf() will accumulate in the buffer until this is called.

Definition at line 72 of file io.c.

References _stp_pbuf.

void _stp_print_symbol const char *  fmt,
unsigned long  address
 

Print addresses symbolically into the print buffer.

Parameters:
fmt A variable number of args.
address The address to lookup.
Note:
Formatting output should never be done within a probe. Use at module exit time.

Definition at line 85 of file io.c.

References _stp_kallsyms_lookup, and _stp_print_buf().

unsigned long cur_ret_addr struct pt_regs *  regs  ) 
 

Get the current return address.

Call from kprobes (not jprobes).

Parameters:
regs The pt_regs saved by the kprobe.
Returns:
The return address saved in esp or rsp.
Note:
i386 and x86_64 only.

Definition at line 112 of file io.c.

void dlog const char *  fmt,
  ...
 

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.

Parameters:
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.

Definition at line 16 of file io.c.

Referenced by _stp_list_clear(), _stp_register_jprobes(), _stp_register_kprobes(), _stp_unregister_jprobes(), and _stp_unregister_kprobes().


Variable Documentation

const char*(* _stp_kallsyms_lookup)(unsigned long addr, unsigned long *symbolsize, unsigned long *offset, char **modname, char *namebuf) = (void *)KALLSYMS_LOOKUP [static]
 

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.

Definition at line 31 of file io.c.

Referenced by _stp_print_symbol().


Generated on Tue Mar 22 10:27:36 2005 for SystemTap.