diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | stapfuncs.5.in | 54 | ||||
-rw-r--r-- | tapset/context.stp | 5 | ||||
-rw-r--r-- | tapset/logging.stp | 8 | ||||
-rwxr-xr-x | testsuite/buildok/context_test.stp | 47 |
5 files changed, 113 insertions, 8 deletions
@@ -1,3 +1,10 @@ +2005-09-04 Martin Hunt <hunt@redhat.com> + + * testsuite/buildok/context_test.stp: New test. + * tapset/logging.stp (log): Call _stp_printf(). + * stapfuncs.5.in: Add contextinfo funcs. + * tapset/context.stp: Minor cleanup. + 2005-09-03 Frank Ch. Eigler <fche@elastic.org> PR 1187 prime diff --git a/stapfuncs.5.in b/stapfuncs.5.in index e4eedb94..212e5193 100644 --- a/stapfuncs.5.in +++ b/stapfuncs.5.in @@ -31,6 +31,10 @@ Log the given string to the kernel's printk buffer, at KERN_INFO severity. Append an implicit end-of-line. .TP +print:unknown (msg:string) +Print the given string to the common trace buffer. + +.TP log:unknown (msg:string) Log the given string to the common trace buffer. Append an implicit end-of-line. @@ -90,8 +94,56 @@ Return the number of milliseconds since the UNIX epoch. gettimeofday_s:long () Return the number of seconds since the UNIX epoch. -.\" .SS CONTEXTINFO +.SS CONTEXTINFO + +.TP +execname:string () +Returns the name of the current process. +.TP +pexecname:string() +Returns the name of the parent process. + +.TP +pid:long () +Returns the current pid. + +.TP +ppid:long () +Returns the current pid. + +.TP +uid:long () +Returns the uid of the current process. + +.TP +euid:long () +Returns the effective uid of the current process. + +.TP +gid:long () +Returns the gid of the current process. + +.TP +egid:long () +Returns the effective gid of the current process. + +.TP +print_regs:unknown () +Prints a register dump. + +.TP +print_backtrace:unknown () +Prints a symbolic backtrace. Use with care. May be timeconsuming. + +.TP +backtrace:string () +Returns a string of hex addresses that are a backtrace of the stack. +May be truncated due to maximum string length. + +.TP +print_stack(bt:string) +Does a symbolic lookup of the addresses in bt and prints one per line. .SH FILES .nh diff --git a/tapset/context.stp b/tapset/context.stp index 6d600190..4d801956 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -12,7 +12,8 @@ function print_backtrace () %{ function backtrace:string () %{ if (CONTEXT->regs) { - /* XXX: is String really necessary for this? */ + /* XXX: this won't be necessary when runtime and translator */ + /* agree on what a string is. */ String str = _stp_string_init (0); _stp_stack_sprint (str, CONTEXT->regs, 0); strlcpy (THIS->__retvalue, _stp_string_ptr(str), MAXSTRINGLEN); @@ -80,8 +81,6 @@ function euid:long () %{ function print_stack(stk:string) %{ char *ptr = THIS->stk; char *tok = strsep(&ptr, " "); - /* XXX: is this header really necessary & accurate? */ - _stp_printf ("trace for %d (%s)\n", current->pid, current->comm); while (tok && *tok) { _stp_print_cstr(" "); _stp_symbol_print (simple_strtol(tok, NULL, 16)); diff --git a/tapset/logging.stp b/tapset/logging.stp index eff7b555..e276aa3f 100644 --- a/tapset/logging.stp +++ b/tapset/logging.stp @@ -4,10 +4,10 @@ function print (msg:string) %{ _stp_print (THIS->msg); %} -// almost the same as print -function log (msg) { - print (msg . "\n") -} +// like print but with a newline +function log (msg:string) %{ + _stp_printf ("%s\n", THIS->msg); +%} function printk (msg:string) %{ printk (KERN_INFO "%s\n", THIS->msg); diff --git a/testsuite/buildok/context_test.stp b/testsuite/buildok/context_test.stp new file mode 100755 index 00000000..9059c04c --- /dev/null +++ b/testsuite/buildok/context_test.stp @@ -0,0 +1,47 @@ +#! stap -p4 + +probe kernel.function("uptime_read_proc") { + print("NOW IN UPTIME\n") + print_regs() + print_backtrace() + bt = backtrace() + print("the stack is " . bt) + print("\n\n") + print_stack(bt) + print("\n\n") + log("name is " . execname()) + log("pid is " . string(pid())) + log("parentname is " . pexecname()) + log("ppid is " . string(ppid())) + log("uid is " . string(uid())) + log("euid is " . string(euid())) + log("gid is " . string(gid())) + log("egid is " . string(egid())) +} + +probe kernel.function("uptime_read_proc").return { + print("DONE WITH UPTIME\n") + print_regs() + print_backtrace() + bt = backtrace() + print("the stack is " . bt) + print("\n\n") + print_stack(bt) + print("\n\n") + log("name is " . execname()) + log("pid is " . string(pid())) + log("parentname is " . pexecname()) + log("ppid is " . string(ppid())) + log("uid is " . string(uid())) + log("euid is " . string(euid())) + log("gid is " . string(gid())) + log("egid is " . string(egid())) +} + +probe begin { + print ("BEGIN\n") +} + +probe end { + print ("END\n") +} |