This file is indexed.

/usr/share/systemtap/tapset/context.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
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
// context tapset
// Copyright (C) 2005-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_regs - Print a register dump
 * 
 * Description: This function prints a register dump. Does nothing if no registers are available for the probe point.
 */
function print_regs ()
%{
	if ((c->probe_flags & _STP_PROBE_STATE_USER_MODE) && CONTEXT->uregs) {
		_stp_print_regs (CONTEXT->uregs);
	} else if (CONTEXT->kregs) {
		_stp_print_regs (CONTEXT->kregs);
	}
%}

/**
 * sfunction execname - Returns the execname of a target process (or group of processes)
 * 
 * Description: Returns the execname of a target process (or group of processes).
 */
function execname:string ()
%{ /* pure */ /* unprivileged */
	strlcpy (THIS->__retvalue, current->comm, MAXSTRINGLEN);
%}

/**
 * sfunction pid - Returns the ID of a target process
 * 
 * Description: This function returns the ID of a target process.
 */
function pid:long ()
%{ /* pure */ /* unprivileged */
	THIS->__retvalue = current->tgid;
%}

/**
 * sfunction tid - Returns the thread ID of a target process
 * 
 * Description: This function returns the thread ID of the target process.
 */
function tid:long ()
%{ /* pure */ /* unprivileged */
	THIS->__retvalue = current->pid;
%}

/**
 * sfunction ppid - Returns the process ID of a target process's parent process
 *
 * Description: This function return the process ID of the target proccess's parent process.
 */
function ppid:long()
%{ /* pure */ /* unprivileged */
#if defined(STAPCONF_REAL_PARENT)
	THIS->__retvalue = current->real_parent->tgid;
#else
	THIS->__retvalue = current->parent->tgid;
#endif
%}

/**
 * sfunction pgrp - Returns the process group ID of the current process
 *
 * Description: This function returns the process group ID of the
 * current process.
 */
function pgrp:long ()
%{ /* pure */ /* unprivileged */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
	struct signal_struct *ss = kread( &(current->signal) );
	THIS->__retvalue = kread ( &(ss->pgrp) );
	CATCH_DEREF_FAULT();
#else
	THIS->__retvalue = task_pgrp_nr_ns(current, &init_pid_ns);
#endif
%}

/**
 * sfunction sid - Returns the session ID of the current process
 *
 * Description: The session ID of a process is the process group ID
 * of the session leader. Session ID is stored in the signal_struct
 *  since Kernel 2.6.0.
 */
function sid:long ()
%{ /* pure */ /* unprivileged */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
	struct signal_struct *ss = kread( &(current->signal) );
	THIS->__retvalue = kread ( &(ss->session) );
	CATCH_DEREF_FAULT();
#else
	THIS->__retvalue = task_session_nr_ns(current, &init_pid_ns);
#endif
%}

/**
 * sfunction pexecname - Returns the execname of a target process's parent process
 * 
 * Description: This function returns the execname of a target
 * process's parent procces.
 */
function pexecname:string ()
%{ /* pure */ /* unprivileged */
#if defined(STAPCONF_REAL_PARENT)
	strlcpy (THIS->__retvalue, current->real_parent->comm, MAXSTRINGLEN);
#else
	strlcpy (THIS->__retvalue, current->parent->comm, MAXSTRINGLEN);
#endif
%}

/**
 * sfunction gid - Returns the group ID of a target process
 * 
 * Description: This function returns the group ID of a target process.
 */
function gid:long ()
%{ /* pure */ /* unprivileged */
#ifdef STAPCONF_TASK_UID
	THIS->__retvalue = current->gid;
#else
	THIS->__retvalue = current_gid();
#endif
%}

/**
 * sfunction egid - Returns the effective gid of a target process
 * 
 * Description: This function returns the effective gid of a target process
 */
function egid:long ()
%{ /* pure */ /* unprivileged */
#ifdef STAPCONF_TASK_UID
	THIS->__retvalue = current->egid;
#else
	THIS->__retvalue = current_egid();
#endif
%}

/**
 * sfunction uid - Returns the user ID of a target process
 * 
 * Description: This function returns the user ID of the target process.
 */
function uid:long ()
%{ /* pure */ /* unprivileged */
#ifdef STAPCONF_TASK_UID
	THIS->__retvalue = current->uid;
#else
	THIS->__retvalue = current_uid();
#endif
%}

/**
 * sfunction euid - Return the effective uid of a target process
 *
 * Description: Returns the effective user ID of the target process.
 */
function euid:long ()
%{ /* pure */ /* unprivileged */
#ifdef STAPCONF_TASK_UID
	THIS->__retvalue = current->euid;
#else
	THIS->__retvalue = current_euid();
#endif
%}


/**
 * sfunction is_myproc - Determines if the current probe point has occurred in the user's own process
 *
 * Description: This function returns 1 if the current probe
 * point has occurred in the user's own process.
 */
function is_myproc:long ()
%{ /* pure */ /* unprivileged */
        THIS->__retvalue = is_myproc();
%}


%( systemtap_v <= "1.4" %?
/**
 * sfunction cpuid - Returns the current cpu number
 * 
 * Description: This function returns the current cpu number.
 * Deprecated in SystemTap 1.4 and removed in SystemTap 1.5.
 */
function cpuid:long ()
%{ /* pure */
	THIS->__retvalue = smp_processor_id();
%}
%)

/**
 * sfunction cpu - Returns the current cpu number
 *
 * Description: This function returns the current cpu number.
 */
function cpu:long ()
%{ /* pure */ /* unprivileged */
	THIS->__retvalue = smp_processor_id();
%}

/**
 * sfunction pp - Returns the active probe point
 *
 * Description: This function returns the fully-resolved probe point
 * associated with a currently running probe handler, including alias
 * and wild-card expansion effects. Context: The current probe point.
 */
function pp:string ()
%{ /* pure */ /* unprivileged */
	strlcpy (THIS->__retvalue, CONTEXT->probe_point, MAXSTRINGLEN);
%}

/**
 * sfunction registers_valid - Determines validity of register() and u_register() in current context
 *
 * Description: This function returns 1 if register() and u_register()
 * can be used in the current context, or 0 otherwise.
 * For example, registers_valid() returns 0
 * when called from a begin or end probe.
 */
function registers_valid:long ()
%{ /* pure */ /* unprivileged */
	THIS->__retvalue = ((c->probe_flags & _STP_PROBE_STATE_USER_MODE)
			    ? (CONTEXT->uregs != NULL)
			    : (CONTEXT->kregs != NULL));
%}

/**
 * sfunction user_mode - Determines if probe point occurs in user-mode
 *
 * Return 1 if the probe point occurred in user-mode.
 */
function user_mode:long ()
%{ /* pure */ /* unprivileged */
  THIS->__retvalue = (CONTEXT->probe_flags
		      & _STP_PROBE_STATE_USER_MODE) ? 1 : 0;
%}

/**
 * sfunction is_return - Whether the current probe context is a return probe
 * 
 * Description: Returns 1 if the current probe context is a return probe,
 * returns 0 otherwise.
 */
function is_return:long ()
%{ /* pure */
	if (CONTEXT->probe_type == _STP_PROBE_HANDLER_KRETPROBE
	    || CONTEXT->probe_type == _STP_PROBE_HANDLER_URETPROBE)
		THIS->__retvalue = 1;
	else
		THIS->__retvalue = 0;
%}

/**
 * sfunction target - Return the process ID of the target process
 * 
 * Description: This function returns the process ID of the target
 * process.  This is useful in conjunction with the -x PID or
 * -c CMD command-line options to stap. An example of its use is
 * to create scripts that filter on a specific process.
 *
 * -x <pid>
 * target() returns the pid specified by -x
 *
 * -c <command>
 * target() returns the pid for the executed command specified by -c
 */
function target:long ()
%{ /* pure */ /* unprivileged */
        THIS->__retvalue = _stp_target;
%}

/**
 * sfunction module_name - The module name of the current script
 * 
 * Description: This function returns the name of the stap module.
 * Either generated randomly (stap_[0-9a-f]+_[0-9a-f]+)
 * or set by stap -m <module_name>.
 */
function module_name:string ()
%{ /* pure */ /* unprivileged */
	strlcpy(THIS->__retvalue, THIS_MODULE->name, MAXSTRINGLEN);
%}

/**
 * sfunction stp_pid - The process id of the stapio process
 *
 * Description: This function returns the process id of the 
 * stapio process that launched this script. There could be
 * other SystemTap scripts and stapio processes running on
 * the system.
 */
function stp_pid:long ()
%{ /* pure */
        THIS->__retvalue = _stp_pid;
%}


/**
 * sfunction remote_id - The index of this instance in a remote execution.
 *
 * Description: This function returns a number 0..N, which is the unique 
 * index of this particular script execution from a swarm of
 * "stap --remote A --remote B ..." runs, and is the same number
 * "stap --remote-prefix" would print.  The function returns -1 if the
 * script was not launched with "stap --remote", or if the remote 
 * staprun/stapsh are older than version 1.7.
 */
function remote_id:long () {
         return %{ /* pure */ /* unprivileged */ _stp_remote_id %}
}


/**
 * sfunction remote_uri - The name of this instance in a remote execution.
 *
 * Description: This function returns the remote host used to invoke
 * this particular script execution from a swarm of "stap --remote" runs.
 * It may not be unique among the swarm.
 * The function returns an empty string if the script was not launched with
 * "stap --remote".
 */
function remote_uri:string () {
         return %{ /* string */ /* pure */ /* unprivileged */ _stp_remote_uri %}
}


/**
 * sfunction stack_size - Return the size of the kernel stack
 * 
 * Description: This function returns the size of the kernel stack.
 */
function stack_size:long ()
%{ /* pure */
        THIS->__retvalue = THREAD_SIZE;
%}

/**
 * sfunction stack_used - Returns the amount of kernel stack used
 *
 * Description: This function determines how many bytes are
 * currently used in the kernel stack.
 */
function stack_used:long ()
%{ /* pure */
	char a;
        THIS->__retvalue = THREAD_SIZE - ((long)&a & (THREAD_SIZE-1));
%}

/**
 * sfunction stack_unused - Returns the amount of kernel stack currently available
 *
 * Description: This function determines how many bytes are
 * currently available in the kernel stack.
 */
function stack_unused:long ()
%{ /* pure */
	char a;
        THIS->__retvalue = (long)&a & (THREAD_SIZE-1);
%}

/**
 * sfunction addr - Address of the current probe point.
 *
 * Description: Returns the instruction pointer from the current probe's
 * register state.  Not all probe types have registers though, in which case
 * zero is returned.  The returned address is suitable for use with functions
 * like symname() and symdata().
 */
function addr:long ()
%{ /* pure */
  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE) {
    THIS->__retvalue = (intptr_t)(CONTEXT->uregs ? REG_IP(CONTEXT->uregs) : 0);
  } else {
    THIS->__retvalue = (intptr_t)(CONTEXT->kregs ? REG_IP(CONTEXT->kregs) : 0);
  }
%}

/**
 * sfunction uaddr - User space address of current running task (EXPERIMENTAL)
 *
 * Description: Returns the address in userspace that the current
 * task was at when the probe occurred. When the current running task
 * isn't a user space thread, or the address cannot be found, zero
 * is returned. Can be used to see where the current task is combined
 * with usymname() or usymdata(). Often the task will be in the VDSO
 * where it entered the kernel.
 */
function uaddr:long ()
%{ /* pure */ /* myproc-unprivileged */
  struct pt_regs *uregs;

  if (CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
    uregs = CONTEXT->uregs;
  else
    uregs = _stp_current_pt_regs();

  if (uregs)
    THIS->__retvalue = (int64_t) REG_IP(uregs);
  else
    THIS->__retvalue = 0;
%}


/**
 * sfunction probe_type - The low level probe handler type of the current probe.
 *
 * Description: Returns a short string describing the low level probe handler
 * type for the current probe point. This is for informational purposes only.
 * Depending on the low level probe handler different context functions can
 * or cannot provide information about the current event (for example some
 * probe handlers only trigger in user space and have no associated kernel
 * context). High-level probes might map to the same or different low-level
 * probes (depending on systemtap version and/or kernel used).
 */
function probe_type:string()
%{ /* pure */ /* unprivileged */
  switch (CONTEXT->probe_type)
  {
    case _STP_PROBE_HANDLER_BEEN:
      strlcpy (THIS->__retvalue, "begin_end", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_ITRACE:
      strlcpy (THIS->__retvalue, "itrace", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_MARKER:
      strlcpy (THIS->__retvalue, "kernel_marker", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_PERF:
      strlcpy (THIS->__retvalue, "perf_event", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_PROCFS:
      strlcpy (THIS->__retvalue, "procfs", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_TIMER:
      strlcpy (THIS->__retvalue, "timer", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_HRTIMER:
      strlcpy (THIS->__retvalue, "hrtimer", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_PROFILE_TIMER:
      strlcpy (THIS->__retvalue, "profile_timer", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_UTRACE:
      strlcpy (THIS->__retvalue, "utrace", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_UTRACE_SYSCALL:
      strlcpy (THIS->__retvalue, "utrace_syscall", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_KPROBE:
      strlcpy (THIS->__retvalue, "kprobe", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_KRETPROBE:
      strlcpy (THIS->__retvalue, "kretprobe", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_UPROBE:
      strlcpy (THIS->__retvalue, "uprobe", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_URETPROBE:
      strlcpy (THIS->__retvalue, "uretprobe", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_HWBKPT:
      strlcpy (THIS->__retvalue, "hardware_data_breakpoint", MAXSTRINGLEN);
      break;
    case _STP_PROBE_HANDLER_TRACEPOINT:
      strlcpy (THIS->__retvalue, "kernel_tracepoint", MAXSTRINGLEN);
      break;
    default:
      /* This should never happen. */
      snprintf(CONTEXT->error_buffer, sizeof(CONTEXT->error_buffer),
               "Unknown probe-type state %d", CONTEXT->probe_type);
      CONTEXT->last_error = CONTEXT->error_buffer;
      break;
  }
%}

/**
 * sfunction cmdline_args - Fetch command line arguments from current process
 * @n: First argument to get (zero is the command itself)
 * @m: Last argument to get (or minus one for all arguments after n)
 * @delim: String to use to delimit arguments when more than one.
 *
 * Description: Returns arguments from the current process starting
 * with argument number n, up to argument m. If there are less than n
 * arguments, or the arguments cannot be retrieved from the current
 * process, the empty string is returned. If m is smaller than n then
 * all arguments starting from argument n are returned. Argument zero
 * is traditionally the command itself.
 */
function cmdline_args:string(n:long, m:long, delim:string)
{
  args = "";
  mm = @cast(task_current(), "task_struct", "kernel<linux/sched.h>")->mm;
  if (mm)
    {
      arg_start = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_start;
      arg_end = @cast(mm, "mm_struct", "kernel<linux/sched.h>")->arg_end;
      if (arg_start != 0 && arg_end != 0)
        {
          nr = 0;
          len = arg_end - arg_start;
          arg = user_string2(arg_start, "");
          while (len > 0)
            {
              if (nr == n)
                args = arg;
              else if (nr > n)
                {
                  if (arg == "")
                    args .= delim . "\"\""
                  else
                    args .= delim . arg;
                }

              arg_len = strlen(arg);
              arg_start += arg_len + 1;
              len -= arg_len + 1;
              if (len > 0 && nr != m)
                arg = user_string2(arg_start, "");
              else
                arg = "";
              nr++;
            }
        }
    }
  return args;
}

/**
 * sfunction cmdline_arg - Fetch a command line argument
 * @n: Argument to get (zero is the command itself)
 *
 * Description: Returns argument the requested argument from the
 * current process or the empty string when there are not that many
 * arguments or there is a problem retrieving the argument. Argument
 * zero is traditionally the command itself.
 */
function cmdline_arg:string(n:long)
{
  return cmdline_args(n, n, "");
}

/**
 * sfunction cmdline_str - Fetch all command line arguments from current process
 *
 * Description: Returns all arguments from the current process
 * delimited by spaces. Returns the empty string when the arguments
 * cannot be retrieved.
 */
function cmdline_str:string()
{
  return cmdline_args(0, -1, " ");
}