/usr/share/systemtap/tapset/context-unwind.stp is in systemtap-common 1.6-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | // context-unwind tapset
// Copyright (C) 2005-2010 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.
// <tapsetdescription>
// Context functions provide additional information about where an event occurred. These functions can
//provide information such as a backtrace to where the event occurred and the current register values for the
//processor.
// </tapsetdescription>
%{
#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
*
* Description: This function isEquivalent to print_stack(backtrace()),
* except that deeper stack nesting may be supported.
* The function does not return a value.
*/
function print_backtrace () %{
if (CONTEXT->regs && ! (CONTEXT->regflags & _STP_REGS_USER_FLAG)) {
_stp_stack_print(CONTEXT->regs, _STP_SYM_FULL,
CONTEXT->pi, MAXTRACE, NULL,
&CONTEXT->uwcontext, NULL, 0);
} else {
_stp_printf("Systemtap probe: %s\n", CONTEXT->probe_point);
}
%}
/**
* sfunction sprint_backtrace - Return stack back trace as string (EXPERIMENTAL)
*
* Returns a simple (kernel) backtrace. One line per address.
* Includes the symbol name (or hex address if symbol
* couldn't be resolved) and module name (if found). Includes the
* offset from the start of the function if found, otherwise the
* offset will be added to the module (if found, between
* brackets). Returns the backtrace as string (each line terminated by
* a newline character). Note that the returned stack will be
* truncated to MAXSTRINGLEN, to print fuller and richer stacks use
* print_backtrace(). Equivalent to sprint_stack(backtrace()),
* but more efficient (no need to translate between hex strings and
* final backtrace string).
*/
function sprint_backtrace:string () %{ /* pure */
if (CONTEXT->regs && ! (CONTEXT->regflags & _STP_REGS_USER_FLAG))
_stp_stack_sprint (THIS->__retvalue, MAXSTRINGLEN,
_STP_SYM_SIMPLE, CONTEXT->regs,
CONTEXT->pi, MAXTRACE, NULL,
&CONTEXT->uwcontext, NULL, 0);
else
strlcpy (THIS->__retvalue, "", MAXSTRINGLEN);
%}
/**
* sfunction backtrace - Hex backtrace of current stack
*
* Description: This function returns a string of hex addresses
* that are a backtrace of the stack. Output may be truncated as
* as per maximum string length (MAXSTRINGLEN).
*/
function backtrace:string () %{ /* pure */
if (CONTEXT->regs && ! (CONTEXT->regflags & _STP_REGS_USER_FLAG))
_stp_stack_sprint (THIS->__retvalue, MAXSTRINGLEN,
_STP_SYM_NONE, CONTEXT->regs,
CONTEXT->pi, MAXTRACE, NULL,
&CONTEXT->uwcontext, NULL, 0);
else
strlcpy (THIS->__retvalue, "", MAXSTRINGLEN);
%}
%( systemtap_v <= "1.6" %?
/**
* sfunction task_backtrace - Hex backtrace of an arbitrary task
* @task: pointer to task_struct
*
* Description: This function returns a string of hex addresses
* that are a backtrace of the stack of a particular task
* Output may be truncated as per maximum string length.
* Deprecated in SystemTap 1.6.
*/
function task_backtrace:string (task:long) %{ /* pure */
_stp_stack_snprint_tsk(THIS->__retvalue, MAXSTRINGLEN,
(struct task_struct *)(unsigned long)THIS->task,
_STP_SYM_NONE, MAXTRACE);
%}
%)
/**
* sfunction caller - Return name and address of calling function
*
* Description: This function returns the address and name of the
* calling function. This is equivalent to calling:
* sprintf("%s 0x%x", symname(caller_addr(), caller_addr()))
* Works only for return probes at this time.
*/
function caller:string() {
return sprintf("%s 0x%x", symname(caller_addr()), caller_addr());
}
/**
* sfunction caller_addr - Return caller address
*
* Description: This function returns 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;
%}
|