This file is indexed.

/usr/share/systemtap/tapset/linux/context-symbols.stp is in systemtap-common 2.6-0.2.

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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// context-symbols tapset
// Copyright (C) 2005-2012 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>

function __stack_raw (n:long) %{ /* pragma:unwind */ /* pure */
         /* basic sanity check for bounds: */
         if (unlikely(STAP_ARG_n < 0 || STAP_ARG_n >= MAXBACKTRACE))
                  STAP_RETVALUE = 0;
         else
                  STAP_RETVALUE = _stp_stack_kernel_get (CONTEXT, (unsigned)STAP_ARG_n);
%}

/**
 *  sfunction stack - Return address at given depth of kernel stack backtrace
 *  @n: number of levels to descend in the stack.
 *
 *  Description: Performs a simple (kernel) backtrace, and returns the
 *  element at the specified position. The results of the backtrace itself
 *  are cached, so that the backtrace computation is performed at most once
 *  no matter how many times stack() is called, or in what order.
 */
function stack:long (n:long) {
         __r = __stack_raw(n);
         if (__r != 0) return __r

         /* fallback: parse backtrace() to go deeper in the stack */
         __b = backtrace (); __orig_n = __n;
         __sym = tokenize (__b, " ");
         if (__sym == "") @__context_unwind_error(__orig_n);
         while (__n > 0) {
               __sym = tokenize ("", " ");
               if (__sym == "") @__context_unwind_error(__orig_n);
               __n--;
         }
         return strtol(__sym, 16)
}

/**
 *  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.
 *
 * NOTE: it is recommended to use print_syms() instead of this function.
 */
function print_stack(stk:string) { print_syms(stk) }

/**
 * sfunction sprint_stack - Return stack for kernel addresses from string
 * @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.
 *
 * NOTE: it is recommended to use sprint_syms() instead of this function.
 */
function sprint_stack:string(stk:string) { return sprint_syms(stk) }

/**
 * sfunction probefunc - Return the probe point's function name, if known
 *
 * Description: This function returns the name of the function being probed
 * based on the current address, as computed by symname(addr()) or
 * usymname(uaddr()) depending on probe context (whether the probe is
 * a user probe or a kernel probe).
 *
 * Please note: this function's behaviour differs between SystemTap 2.0
 * and earlier versions. Prior to 2.0, probefunc() obtained the function
 * name from the probe point string as returned by pp(), and used the
 * current address as a fallback.
 *
 * Consider using ppfunc() instead.
 */
function probefunc:string () %( systemtap_v < "2.0" %?
%{ /* pure */ /* pragma:symbols */
	char *ptr, *start;

	STAP_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 = STAP_RETVALUE;
		while (*ptr != '@' && *ptr != '"' && --len > 0 && *ptr)
			*dst++ = *ptr++;
		*dst = 0;

	} else {
		struct pt_regs *regs;
		int user_mode;
		user_mode = c->user_mode_p;
		regs = user_mode ? CONTEXT->uregs : CONTEXT->kregs;
		if (regs) {
			_stp_snprint_addr(STAP_RETVALUE, MAXSTRINGLEN,
					  REG_IP(regs), _STP_SYM_SYMBOL,
					  (user_mode ? current : NULL));
		}
	}
%}
%:
{
	%( systemtap_privilege != "stapusr" %?
	   return user_mode() ? usymname(uaddr()) : symname(addr())
	%:
	   return user_mode() ? usymname(uaddr())
	   	  	      : error("kernel probefunc() query from unprivileged script") /* XXX should be impossible */
        %)
}
%)

/**
 * 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 = STAP_RETVALUE;
		while (*ptr != '"' && --len && *ptr)
			*dst++ = *ptr++;
		*dst = 0;
	} else if (CONTEXT->kregs && ! CONTEXT->user_mode_p) {
		struct _stp_module *m;
		m = _stp_kmod_sec_lookup (REG_IP(CONTEXT->kregs), NULL);
		if (m && m->name)
			strlcpy (STAP_RETVALUE, m->name, MAXSTRINGLEN);
		else
#if STAP_COMPAT_VERSION <= STAP_VERSION(2,2)
			strlcpy (STAP_RETVALUE, "<unknown>", MAXSTRINGLEN);
#else
			CONTEXT->last_error = "Cannot determine kernel module name";
#endif
	} else
#if STAP_COMPAT_VERSION <= STAP_VERSION(2,2)
		strlcpy (STAP_RETVALUE, "<unknown>", MAXSTRINGLEN);
#else
		CONTEXT->last_error = "Cannot determine kernel module name";
#endif
%}

/**
 * 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 raise an error. 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 (STAP_ARG_addr, NULL);
	if (m && m->name)
	  {
	    strlcpy (STAP_RETVALUE, m->name, MAXSTRINGLEN);
	    return;
	  }

#ifdef STAPCONF_MODULE_TEXT_ADDRESS
	preempt_disable();
	ko = __module_text_address (STAP_ARG_addr);
	if (ko && ko->name)
	  {
	    strlcpy (STAP_RETVALUE, ko->name, MAXSTRINGLEN);
	    preempt_enable_no_resched();
	    return;
	  }
	preempt_enable_no_resched();
#endif
#if STAP_COMPAT_VERSION <= STAP_VERSION(2,2)
	strlcpy (STAP_RETVALUE, "<unknown>", MAXSTRINGLEN);
#else
	CONTEXT->last_error = "Cannot determine kernel module name";
#endif
%}

/**
 * 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(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_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(STAP_RETVALUE, MAXSTRINGLEN, STAP_ARG_addr,
			  _STP_SYM_DATA, NULL);
%}

/**
 * sfunction print_syms - Print out kernel stack from string
 * @callers: String with list of hexadecimal (kernel) addresses
 *
 *  Description: This function performs a symbolic lookup of the addresses
 *  in the given string,
 *  which are assumed to be the result of prior calls to stack(),
 *  callers(), and similar functions.
 * 
 *  Prints one line per address, including the address, the
 *  name of the function containing the address, and an estimate of
 *  its position within that function, as obtained by symdata().
 *  Returns nothing.
 */
function print_syms (callers:string) {
         __sym = tokenize (callers, " ");
         while (__sym != "") {
               printf (" %s : %s\n", __sym, symdata (strtol(__sym,16)));
               __sym = tokenize ("", " ");
         }
}

/**
 * sfunction sprint_syms - Return stack for kernel addresses from string
 *
 * @callers: String with list of hexadecimal (kernel) addresses
 *
 * Perform a symbolic lookup of the addresses in the given string,
 * which are assumed to be the result of a prior calls to stack(),
 * callers(), and similar functions.
 *
 * 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), as obtained from
 * symdata(). 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_syms().
 */
function sprint_syms (callers:string) {
         __sym = tokenize (callers, " ");
         __foo = ""; __l = 0
         while (__sym != "") {
               // cleanly handle overflow instead of printing partial line:
               __line = sprintf (" %s : %s\n", __sym, symdata (strtol(__sym,16)));
               __l += strlen(__line)
               if (__l > @MAXSTRINGLEN) break
               __foo .= __line
               __sym = tokenize ("", " ")
         }
         return __foo
}