/usr/share/systemtap/tapset/dyninst/context.stp is in systemtap-common 2.9-2ubuntu2.
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 | // context tapset
// Copyright (C) 2012 Red Hat, Inc.
//
// 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.
// NB: functionally equivalent to linux/context.stp
%{
#include <sched.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
%}
function execname:string ()
%{
/* Need a 16-byte buffer, which will be 0-terminated only if shorter.
* Use 17 bytes to make sure we always have termination. */
char arg2[17] = {0};
if (prctl(PR_GET_NAME, (unsigned long)arg2, 0, 0, 0) == 0)
strlcpy (STAP_RETVALUE, arg2, MAXSTRINGLEN);
%}
function pid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getpid();
%}
function tid:long ()
%{ /* pure */ /* unprivileged */
/* NB: no glibc wrapper available */
STAP_RETVALUE = syscall(SYS_gettid);
%}
function ppid:long()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getppid();
%}
function pgrp:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getpgrp();
%}
function sid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getsid(0);
%}
// TODO function pexecname:string ()
function gid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getgid();
%}
function egid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getegid();
%}
function uid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = getuid();
%}
function euid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = geteuid();
%}
// TODO function is_myproc:long ()
// NB: dyninst by nature is myproc-only, *except if you're root*
function cpu:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = _stp_sched_getcpu();
%}
function registers_valid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = (CONTEXT->uregs != NULL);
%}
function user_mode:long ()
{
return 1;
}
function is_return:long ()
%{ /* pure */ /* unprivileged */
if (CONTEXT->probe_type == stp_probe_type_uretprobe)
STAP_RETVALUE = 1;
else
STAP_RETVALUE = 0;
%}
function target:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = stp_session_attributes()->target;
%}
function module_name:string ()
%{ /* pure */ /* unprivileged */
strlcpy(STAP_RETVALUE, stp_session_attributes()->module_name, MAXSTRINGLEN);
%}
function stp_pid:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = stp_session_attributes()->stp_pid;
%}
// TODO function remote_id:long ()
// TODO function remote_uri:string ()
// TODO function stack_size:long ()
// TODO function stack_used:long ()
// TODO function stack_unused:long ()
function addr:long ()
{
return uaddr()
}
function uaddr:long ()
%{ /* pure */ /* unprivileged */
STAP_RETVALUE = (intptr_t)(CONTEXT->uregs ? REG_IP(CONTEXT->uregs) : 0);
%}
// TODO function cmdline_args:string(n:long, m:long, delim:string)
// TODO function cmdline_arg:string(n:long)
// TODO function cmdline_str:string()
|