/usr/share/systemtap/tapset/context-symbols.stp is in systemtap-common 1.7-1+deb7u1.
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | // context-symbols tapset
// Copyright (C) 2005-2008, 2011 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>
/**
* sfunction print_stack - Print out kernel stack from string
* @stk: String with list of hexadecimal addresses
*
* Description: This function performs a symbolic lookup of the addresses
* in the given string,
* which is assumed to be the result of a prior call to
* backtrace().
*
* Print one line per address, including the address, the
* name of the function containing the address, and an estimate of
* its position within that function. Return nothing.
*/
function print_stack(stk:string) %{ /* pragma:symbols */
char *ptr = THIS->stk;
char *tok = strsep(&ptr, " ");
while (tok && *tok) {
_stp_print_addr (simple_strtol(tok, NULL, 16),
_STP_SYM_FULL, NULL);
tok = strsep(&ptr, " ");
}
%}
/**
* sfunction sprint_stack - Return stack for kernel addresses from string (EXPERIMENTAL)
* @stk: String with list of hexadecimal (kernel) addresses
*
* Perform a symbolic lookup of the addresses in the given string,
* which is assumed to be the result of a prior call to backtrace().
*
* Returns a simple backtrace from the given hex string. 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_stack.
*/
function sprint_stack:string(stk:string) %{ /* pure */ /* pragma:symbols */
char *ptr = THIS->stk;
char *tok = strsep(&ptr, " ");
char *str = THIS->__retvalue;
size_t len = MAXSTRINGLEN - 1;
while (tok && *tok && len > 0) {
int s = _stp_snprint_addr(str, len,
simple_strtol(tok, NULL, 16),
_STP_SYM_SIMPLE, NULL);
len -= s;
str += s;
tok = strsep(&ptr, " ");
}
str--;
if (len > 0)
str[0] = '\0';
else
THIS->__retvalue[MAXSTRINGLEN - 1] = '\0';
%}
/**
* sfunction probefunc - Return the probe point's function name, if known
*
* Description: This function returns the name of the function being probed.
* It will do this based on the probe point string as returned by pp().
* Please note: this function is deprecated, please use symname() and/or
* usymname(). This function might return a function name based on the
* current address if the probe point context couldn't be parsed.
*/
function probefunc:string () %{ /* pure */ /* pragma:symbols */
char *ptr, *start;
THIS->__retvalue[0] = '\0';
start = strstr(CONTEXT->probe_point, "function(\"");
ptr = start + 10;
if (!start) {
start = strstr(CONTEXT->probe_point, "inline(\"");
ptr = start + 8;
}
if (start) {
int len = MAXSTRINGLEN;
char *dst = THIS->__retvalue;
while (*ptr != '@' && *ptr != '"' && --len > 0 && *ptr)
*dst++ = *ptr++;
*dst = 0;
} else {
struct pt_regs *regs;
int user_mode;
user_mode = c->probe_flags & _STP_PROBE_STATE_USER_MODE;
regs = user_mode ? CONTEXT->uregs : CONTEXT->kregs;
if (regs) {
_stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN,
REG_IP(regs), _STP_SYM_SYMBOL,
(user_mode ? current : NULL));
}
}
%}
/**
* sfunction probemod - Return the probe point's kernel module name
*
* Description: This function returns the name of the kernel module
* containing the probe point, if known.
*/
function probemod:string () %{ /* pure */
char *ptr, *start;
start = strstr(CONTEXT->probe_point, "module(\"");
ptr = start + 8;
if (start) {
int len = MAXSTRINGLEN;
char *dst = THIS->__retvalue;
while (*ptr != '"' && --len && *ptr)
*dst++ = *ptr++;
*dst = 0;
} else if (CONTEXT->kregs
&& ! (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)) {
struct _stp_module *m;
m = _stp_kmod_sec_lookup (REG_IP(CONTEXT->kregs), NULL);
if (m && m->name)
strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN);
else
strlcpy (THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
} else
strlcpy (THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
%}
/**
* sfunction modname - Return the kernel module name loaded at the address
* @addr: The address to map to a kernel module name
*
* Description: Returns the module name associated with the given
* address if known. If not known it will return the string "<unknown>".
* If the address was not in a kernel module, but in the kernel itself,
* then the string "kernel" will be returned.
*/
function modname:string (addr: long) %{ /* pure */
struct _stp_module *m;
#ifdef STAPCONF_MODULE_TEXT_ADDRESS
struct module *ko;
#endif
m = _stp_kmod_sec_lookup (THIS->addr, NULL);
if (m && m->name)
{
strlcpy (THIS->__retvalue, m->name, MAXSTRINGLEN);
return;
}
#ifdef STAPCONF_MODULE_TEXT_ADDRESS
preempt_disable();
ko = __module_text_address (THIS->addr);
if (ko && ko->name)
{
strlcpy (THIS->__retvalue, ko->name, MAXSTRINGLEN);
preempt_enable_no_resched();
return;
}
preempt_enable_no_resched();
#endif
strlcpy (THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
%}
/**
* sfunction symname - Return the kernel symbol associated with the given address
* @addr: The address to translate
*
* Description: Returns the (function) symbol name associated with the
* given address if known. If not known it will return the hex string
* representation of addr.
*/
function symname:string (addr: long) %{ /* pure */ /* pragma:symbols */
_stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
_STP_SYM_SYMBOL, NULL);
%}
/**
* sfunction symdata - Return the kernel symbol and module offset for the address
* @addr: The address to translate
*
* Description: Returns the (function) symbol name associated with the
* given address if known, the offset from the start and size of the
* symbol, plus module name (between brackets). If symbol is unknown,
* but module is known, the offset inside the module, plus the size of
* the module is added. If any element is not known it will be
* omitted and if the symbol name is unknown it will return the hex
* string for the given address.
*/
function symdata:string (addr: long) %{ /* pure */ /* pragma:symbols */
_stp_snprint_addr(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
_STP_SYM_DATA, NULL);
%}
|