// context-unwind tapset // Copyright (C) 2005-2008 Red Hat Inc. // Copyright (C) 2006 Intel Corporation. // // This file is part of systemtap, and is free software. You can // redistribute it and/or modify it under the terms of the GNU General // Public License (GPL); either version 2, or (at your option) any // later version. %{ #ifndef STP_NEED_UNWIND_DATA #define STP_NEED_UNWIND_DATA 1 #endif #ifndef STP_NEED_SYMBOL_DATA #define STP_NEED_SYMBOL_DATA 1 #endif %} /** * sfunction print_backtrace - Print stack back trace * * Equivalent to print_stack(backtrace()), * except that deeper stack nesting may be supported. Return nothing. */ function print_backtrace () %{ if (! CONTEXT->regs) WARN_ON (! CONTEXT->regs); else _stp_stack_print(CONTEXT->regs, 1, CONTEXT->pi, MAXTRACE); %} /** * sfunction backtrace - Hex backtrace of current stack * * Return a string of hex addresses that are a backtrace of the * stack. It may be truncated due to maximum string length. */ function backtrace:string () %{ /* pure */ if (! CONTEXT->regs) WARN_ON (! CONTEXT->regs); else _stp_stack_snprint (THIS->__retvalue, MAXSTRINGLEN, CONTEXT->regs, 0, CONTEXT->pi, MAXTRACE); %} /** * sfunction caller - Return name and address of calling function * * 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_snprint( THIS->__retvalue, MAXSTRINGLEN, (unsigned long)_stp_ret_addr_r(CONTEXT->pi)); else strlcpy(THIS->__retvalue,"unknown",MAXSTRINGLEN); %} /** * sfunction caller_addr - Return caller address * * Return the address of the calling function. * Works only for return probes at this time. */ function caller_addr:long () %{ /* pure */ if (CONTEXT->pi) THIS->__retvalue = (int64_t)(long)_stp_ret_addr_r(CONTEXT->pi); else THIS->__retvalue = 0; %}