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
|
// context tapset
// Copyright (C) 2005, 2006, 2007 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.
/**
* sfunction print_regs - Print a register dump.
*/
function print_regs () %{
if (CONTEXT->regs) {
_stp_print_regs (CONTEXT->regs);
}
%}
/**
* sfunction execname - Execname of current processes
*
* Return the name of the current process.
*/
function execname:string () %{ /* pure */
strlcpy (THIS->__retvalue, current->comm, MAXSTRINGLEN);
%}
/**
* sfunction pid - Process ID of current process
*
*
* Return the id of the current process.
*/
function pid:long () %{ /* pure */
THIS->__retvalue = current->tgid;
%}
/**
* sfunction tid - Thread ID of current process
*
* Return the id of the current thread.
*/
function tid:long () %{ /* pure */
THIS->__retvalue = current->pid;
%}
/**
* sfunction ppid - Parent Process ID of current process
*
* Return the id of the parent process.
*/
function ppid:long () %{ /* pure */
#if defined(STAPCONF_REAL_PARENT)
THIS->__retvalue = current->real_parent->tgid;
#else
THIS->__retvalue = current->parent->tgid;
#endif
%}
/**
* sfunction pexecname - Execname of the parent process.
*
* Return the name of the parent process.
*/
function pexecname:string () %{ /* pure */
#if defined(STAPCONF_REAL_PARENT)
strlcpy (THIS->__retvalue, current->real_parent->comm, MAXSTRINGLEN);
#else
strlcpy (THIS->__retvalue, current->parent->comm, MAXSTRINGLEN);
#endif
%}
/**
* sfunction gid - Group ID of current process
*
* Return the gid of the current process.
*/
function gid:long () %{ /* pure */
THIS->__retvalue = current->gid;
%}
/**
* sfunction egid - Effective gid of the current process.
*
* Return the effective gid of the current process.
*/
function egid:long () %{ /* pure */
THIS->__retvalue = current->egid;
%}
/**
* sfunction uid -User ID of the current process.
*
* Return the uid of the current process.
*/
function uid:long () %{ /* pure */
THIS->__retvalue = current->uid;
%}
/**
* sfunction euid - Effective User ID of the current process.
*
* Return the effective uid of the current process.
*/
function euid:long () %{ /* pure */
THIS->__retvalue = current->euid;
%}
// cpuid() is not documented
function cpuid:long () %{ /* pure */
THIS->__retvalue = smp_processor_id();
%}
/**
* sfunction cpu - The current cpu number.
*
* Return the current cpu number.
*/
function cpu:long () %{ /* pure */
THIS->__retvalue = smp_processor_id();
%}
/**
* sfunction pp - Current probe point
*
* Return the probe point associated with the currently running
* probe handler, including alias and wildcard expansion effects.
*/
function pp:string () %{ /* pure */
strlcpy (THIS->__retvalue, CONTEXT->probe_point, MAXSTRINGLEN);
%}
/**
* sfunction registers_valid - Register information valid
*
* Return 1 if register() and u_register() can be used
* in the current context, or 0 otherwise.
* For example, <command>registers_valid()</command> returns 0
* when called from a begin or end probe.
*/
function registers_valid:long () %{ /* pure */
THIS->__retvalue = (CONTEXT->regs != NULL);
%}
/**
* sfunction user_mode - User Mode
*
* Return 1 if the probe point occurred in user-mode.
*/
function user_mode:long () %{ /* pure */ /* currently a user-mode address? */
if (CONTEXT->regs) {
#if defined(__i386__) || defined(__x86_64__)
THIS->__retvalue = (uint64_t) user_mode_vm (CONTEXT->regs);
#else
THIS->__retvalue = (uint64_t) user_mode (CONTEXT->regs);
#endif
} else {
THIS->__retvalue = 0;
}
%}
/**
* sfunction is_return - Is return probe
*
* Return 1 if the probe point is a return probe.
* <emphasis>Deprecated.</emphasis>
*/
function is_return:long () %{ /* pure */
if (CONTEXT->pi)
THIS->__retvalue = 1;
else
THIS->__retvalue = 0;
%}
/**
* sfunction target - Target pid
*
* Return the pid of the target process.
*/
function target:long () %{ /* pure */
THIS->__retvalue = _stp_target;
%}
///<formalpara id="module_name">
/// <title>module_name:string()</title>
/// <indexterm><primary>module_name</primary></indexterm>
/// <para>
/// <remark>FIXME: need description.</remark>
/// </para>
///</formalpara>
function module_name:string () %{ /* pure */
strlcpy(THIS->__retvalue, THIS_MODULE->name, MAXSTRINGLEN);
%}
///<formalpara id="stp_pid">
/// <title>stp_pid:long()</title>
/// <indexterm><primary>stp_pid</primary></indexterm>
/// <para>
/// <remark>FIXME: need description.</remark>
/// </para>
///</formalpara>
function stp_pid:long () %{ /* pure */
THIS->__retvalue = _stp_pid;
%}
/**
* sfunction stack_size - Size of kernel stack
*
* Return the size of the kernel stack.
*/
function stack_size:long () %{ /* pure */
THIS->__retvalue = THREAD_SIZE;
%}
/**
* sfunction stack_used - Current amount of kernel stack used
*
* Return 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 - Amount of kernel stack currently available
*
* Return how many bytes are currently available in the kernel stack.
*/
function stack_unused:long () %{ /* pure */
char a;
THIS->__retvalue = (long)&a & (THREAD_SIZE-1);
%}
|