diff options
author | hunt <hunt> | 2006-10-12 18:46:38 +0000 |
---|---|---|
committer | hunt <hunt> | 2006-10-12 18:46:38 +0000 |
commit | d2a11534a5193a1f4eae4cc4184165113ab2869d (patch) | |
tree | ff8d4fc866fefe95ab611b06b643c795b64c3652 | |
parent | fcff848ec9185300024200b1d8323607f4434377 (diff) | |
download | systemtap-steved-d2a11534a5193a1f4eae4cc4184165113ab2869d.tar.gz systemtap-steved-d2a11534a5193a1f4eae4cc4184165113ab2869d.tar.xz systemtap-steved-d2a11534a5193a1f4eae4cc4184165113ab2869d.zip |
2006-10-12 Martin Hunt <hunt@redhat.com>
* context.stp (print_backtrace): Pass in new
kretprobe instance arg.
(backtrace): Ditto.
(is_return): Rewrite.
(stack_size): New.
(stack_used): New.
(stack_unused): New.
(called_addr): New.
(caller): New.
-rw-r--r-- | tapset/ChangeLog | 11 | ||||
-rw-r--r-- | tapset/context.stp | 49 |
2 files changed, 53 insertions, 7 deletions
diff --git a/tapset/ChangeLog b/tapset/ChangeLog index e6f3f024..fa7b6262 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,14 @@ +2006-10-12 Martin Hunt <hunt@redhat.com> + * context.stp (print_backtrace): Pass in new + kretprobe instance arg. + (backtrace): Ditto. + (is_return): Rewrite. + (stack_size): New. + (stack_used): New. + (stack_unused): New. + (called_addr): New. + (caller): New. + 2006-10-12 Li Guanglei <guanglei@cn.ibm.com> * ioscheduler.stp: bugfix to avoid refer to NULL pointer diff --git a/tapset/context.stp b/tapset/context.stp index ab71193a..449e135d 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -15,7 +15,7 @@ function print_regs () %{ function print_backtrace () %{ if (CONTEXT->regs) { - _stp_stack_print(CONTEXT->regs); + _stp_stack_print(CONTEXT->regs, CONTEXT->pi); } %} @@ -24,7 +24,7 @@ function backtrace:string () %{ /* pure */ /* 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); + _stp_stack_sprint (str, CONTEXT->regs, 0, CONTEXT->pi); strlcpy (THIS->__retvalue, _stp_string_ptr(str), MAXSTRINGLEN); } else strlcpy (THIS->__retvalue, "", MAXSTRINGLEN); @@ -136,11 +136,10 @@ function probemod:string () %{ /* pure */ %} function is_return:long () %{ /* pure */ - char *ptr = strrchr(CONTEXT->probe_point, '.'); - if (ptr) { - if (strcmp(ptr+1,"return") == 0) - THIS->__retvalue = 1; - } + if (CONTEXT->pi) + THIS->__retvalue = 1; + else + THIS->__retvalue = 0; %} function target:long () %{ /* pure */ @@ -150,3 +149,39 @@ function target:long () %{ /* pure */ function stp_pid:long () %{ /* pure */ THIS->__retvalue = _stp_pid; %} + +# return the size of the stack +function stack_size:long () %{ /* pure */ + THIS->__retvalue = THREAD_SIZE; +%} + +# return how many bytes are currently used in the stack +function stack_used:long () %{ /* pure */ + char a; + THIS->__retvalue = THREAD_SIZE - ((long)&a & (THREAD_SIZE-1)); +%} + +# return how many bytes are currently unused in the stack +function stack_unused:long () %{ /* pure */ + char a; + THIS->__retvalue = (long)&a & (THREAD_SIZE-1); +%} + +# Return the address of the calling function. Works only for +# return probes at this time. +function caller_addr () %{ /* pure */ + if (CONTEXT->pi) + THIS->__retvalue = (int64_t)(long)_stp_ret_addr_r(CONTEXT->pi); + else + THIS->__retvalue = 0; +%} + +# Return the address and name of the calling function. Works +# only for return probes at this time. +function caller:string() %{ /* pure */ + if (CONTEXT->pi) + _stp_symbol_sprint_basic( THIS->__retvalue, MAXSTRINGLEN, + (unsigned long)_stp_ret_addr_r(CONTEXT->pi)); + else + strlcpy(THIS->__retvalue,"unknown",MAXSTRINGLEN); +%} |