This file is indexed.

/usr/share/systemtap/tapset/errno.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
// errno tapset
// Copyright (C) 2006 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.

%{
#define N(a) [a]=#a

static const char * const errlist[] = {
/* from asm-generic/errno-base.h */
[1] = "EPERM",
[2] = "ENOENT",
[3] = "ESRCH",
[4] = "EINTR",
[5] = "EIO",
[6] = "ENXIO",
[7] = "E2BIG",
[8] = "ENOEXEC",
[9] = "EBADF",
[10]= "ECHILD",
[11]= "EAGAIN",
[12]= "ENOMEM",
[13]= "EACCES",
[14]= "EFAULT",
[15]= "ENOTBLK",
[16]= "EBUSY",
[17]= "EEXIST",
[18]= "EXDEV",
[19]= "ENODEV",
[20]= "ENOTDIR",
[21]= "EISDIR",
[22]= "EINVAL",
[23]= "ENFILE",
[24]= "EMFILE",
[25]= "ENOTTY",
[26]= "ETXTBSY",
[27]= "EFBIG",
[28]= "ENOSPC",
[29]= "ESPIPE",
[30]= "EROFS",
[31]= "EMLINK",
[32]= "EPIPE",
[33]= "EDOM",
[34]= "ERANGE",
/* end of errno-base.h */
/* The rest of this is arch-dependent */
#ifdef EDEADLK
	N(EDEADLK),
#endif
#ifdef ENAMETOOLONG
	N(ENAMETOOLONG),
#endif
#ifdef ENOLCK
	N(ENOLCK),
#endif
#ifdef ENOSYS
	N(ENOSYS),
#endif
#ifdef ENOTEMPTY
	N(ENOTEMPTY),
#endif
#ifdef ELOOP
	N(ELOOP),
#endif
#ifdef ENOMSG
	N(ENOMSG),
#endif
#ifdef EIDRM
	N(EIDRM),
#endif
#ifdef ECHRNG
	N(ECHRNG),
#endif
#ifdef EL2NSYNC
	N(EL2NSYNC),
#endif
#ifdef EL3HLT
	N(EL3HLT),
#endif
#ifdef EL3RST
	N(EL3RST),
#endif
#ifdef ELNRNG
	N(ELNRNG),
#endif
#ifdef EUNATCH
	N(EUNATCH),
#endif
#ifdef ENOCSI
	N(ENOCSI),
#endif
#ifdef EL2HLT
	N(EL2HLT),
#endif
#ifdef EBADE
	N(EBADE),
#endif
#ifdef EBADR
	N(EBADR),
#endif
#ifdef EXFULL
	N(EXFULL),
#endif
#ifdef ENOANO
	N(ENOANO),
#endif
#ifdef EBADRQC
	N(EBADRQC),
#endif
#ifdef EBADSLT
	N(EBADSLT),
#endif
#ifdef EBFONT
	N(EBFONT),
#endif
#ifdef ENOSTR
	N(ENOSTR),
#endif
#ifdef ENODATA
	N(ENODATA),
#endif
#ifdef ETIME
	N(ETIME),
#endif
#ifdef ENOSR
	N(ENOSR),
#endif
#ifdef ENONET
	N(ENONET),
#endif
#ifdef ENOPKG
	N(ENOPKG),
#endif
#ifdef EREMOTE
	N(EREMOTE),
#endif
#ifdef ENOLINK
	N(ENOLINK),
#endif
#ifdef EADV
	N(EADV),
#endif
#ifdef ESRMNT
	N(ESRMNT),
#endif
#ifdef ECOMM
	N(ECOMM),
#endif
#ifdef EPROTO
	N(EPROTO),
#endif
#ifdef EMULTIHOP
	N(EMULTIHOP),
#endif
#ifdef EDOTDOT
	N(EDOTDOT),
#endif
#ifdef EBADMSG
	N(EBADMSG),
#endif
#ifdef EOVERFLOW
	N(EOVERFLOW),
#endif
#ifdef ENOTUNIQ
	N(ENOTUNIQ),
#endif
#ifdef EBADFD
	N(EBADFD),
#endif
#ifdef EREMCHG
	N(EREMCHG),
#endif
#ifdef ELIBACC
	N(ELIBACC),
#endif
#ifdef ELIBBAD
	N(ELIBBAD),
#endif
#ifdef ELIBSCN
	N(ELIBSCN),
#endif
#ifdef ELIBMAX
	N(ELIBMAX),
#endif
#ifdef ELIBEXEC
	N(ELIBEXEC),
#endif
#ifdef EILSEQ
	N(EILSEQ),
#endif
#ifdef ERESTART
	N(ERESTART),
#endif
#ifdef ESTRPIPE
	N(ESTRPIPE),
#endif
#ifdef EUSERS
	N(EUSERS),
#endif
#ifdef ENOTSOCK
	N(ENOTSOCK),
#endif
#ifdef EDESTADDRREQ
	N(EDESTADDRREQ),
#endif
#ifdef EMSGSIZE
	N(EMSGSIZE),
#endif
#ifdef EPROTOTYPE
	N(EPROTOTYPE),
#endif
#ifdef ENOPROTOOPT
	N(ENOPROTOOPT),
#endif
#ifdef EPROTONOSUPPORT
	N(EPROTONOSUPPORT),
#endif
#ifdef ESOCKTNOSUPPORT
	N(ESOCKTNOSUPPORT),
#endif
#ifdef EOPNOTSUPP
	N(EOPNOTSUPP),
#endif
#ifdef EPFNOSUPPORT
	N(EPFNOSUPPORT),
#endif
#ifdef EAFNOSUPPORT
	N(EAFNOSUPPORT),
#endif
#ifdef EADDRINUSE
	N(EADDRINUSE),
#endif
#ifdef EADDRNOTAVAIL
	N(EADDRNOTAVAIL),
#endif
#ifdef ENETDOWN
	N(ENETDOWN),
#endif
#ifdef ENETUNREACH
	N(ENETUNREACH),
#endif
#ifdef ENETRESET
	N(ENETRESET),
#endif
#ifdef ECONNABORTED
	N(ECONNABORTED),
#endif
#ifdef ECONNRESET
	N(ECONNRESET),
#endif
#ifdef ENOBUFS
	N(ENOBUFS),
#endif
#ifdef EISCONN
	N(EISCONN),
#endif
#ifdef ENOTCONN
	N(ENOTCONN),
#endif
#ifdef ESHUTDOWN
	N(ESHUTDOWN),
#endif
#ifdef ETOOMANYREFS
	N(ETOOMANYREFS),
#endif
#ifdef ETIMEDOUT
	N(ETIMEDOUT),
#endif
#ifdef ECONNREFUSED
	N(ECONNREFUSED),
#endif
#ifdef EHOSTDOWN
	N(EHOSTDOWN),
#endif
#ifdef EHOSTUNREACH
	N(EHOSTUNREACH),
#endif
#ifdef EALREADY
	N(EALREADY),
#endif
#ifdef EINPROGRESS
	N(EINPROGRESS),
#endif
#ifdef ESTALE
	N(ESTALE),
#endif
#ifdef EUCLEAN
	N(EUCLEAN),
#endif
#ifdef ENOTNAM
	N(ENOTNAM),
#endif
#ifdef ENAVAIL
	N(ENAVAIL),
#endif
#ifdef EISNAM
	N(EISNAM),
#endif
#ifdef EREMOTEIO
	N(EREMOTEIO),
#endif
#ifdef EDQUOT
	N(EDQUOT),
#endif
#ifdef ENOMEDIUM
	N(ENOMEDIUM),
#endif
#ifdef EMEDIUMTYPE
	N(EMEDIUMTYPE),
#endif
#ifdef ECANCELED
	N(ECANCELED),
#endif
#ifdef ENOKEY
	N(ENOKEY),
#endif
#ifdef EKEYEXPIRED
	N(EKEYEXPIRED),
#endif
#ifdef EKEYREVOKED
	N(EKEYREVOKED),
#endif
#ifdef EKEYREJECTED
	N(EKEYREJECTED),
#endif
#ifdef EOWNERDEAD
	N(EOWNERDEAD),
#endif
#ifdef ENOTRECOVERABLE
	N(ENOTRECOVERABLE),
#endif
#if defined (EDEADLOCK) && EDEADLOCK != EDEADLK
	N(EDEADLOCK),
#endif
#ifdef E
	N(EADV),
#endif
};
#undef N
static const int Maxerrno = sizeof(errlist)/sizeof(char *);
%}

/**
 * sfunction errno_str - Symbolic string associated with error code
 *
 * @err: The error number received
 *
 * Description: This function returns the symbolic string associated
 * with the giver error code, such as ENOENT for the number 2, or
 * E#3333 for an out-of-range value such as 3333.
 */
function errno_str:string (err:long) %{ /* pure */
	long e = THIS->err;
	e = (e > 0 ? e : -e);
	if (e > 0 && e < Maxerrno && errlist[e])
		strlcpy (THIS->__retvalue, errlist[e], MAXSTRINGLEN);
%}

function errno_p:long (err:long) %{ /* pure */
	long e = THIS->err;
	e = (e > 0 ? e : -e);
	if (e > 0 && e < Maxerrno && errlist[e])
		THIS->__retvalue = e;	
	else
		THIS->__retvalue = 0;
%}

%{
static long _stp_returnval(struct pt_regs *regs) {
	if (regs) {
#if defined  (STAPCONF_X86_UNIREGS)  && (defined (__x86_64__) || defined (__i386__))
		return regs->ax;
#elif defined (__i386__)
		return regs->eax;
#elif defined (__x86_64__)
		// TODO: Handle -m32 apps.
		return regs->rax;
#elif defined (__powerpc__)
		return regs->gpr[3];
#elif defined (__ia64__)
		return regs->r8;
#elif defined (__sparc64__)
		return regs->u_regs[UREG_RETPC];
#elif defined (__s390x__)
		return regs->gprs[2];
#elif defined (__arm__)
		return regs->ARM_r0;
#else
		_stp_error("returnval() not defined for this architecture");
		return 0;
#endif
	} else {
		_stp_error("returnval() not defined in this context");
		return 0;
	}
}
%}

/**
 * sfunction returnval - Possible return value of probed function
 *
 * Description: Return the value of the register in which function values
 * are typically returned. Can be used in probes where $return isn't
 * available. This is only a guess of the actual return value and can be
 * totally wrong. Normally only used in dwarfless probes.
 */
function returnval:long () %{ /* pure */
	struct pt_regs *regs;
	regs = ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
		? CONTEXT->uregs : CONTEXT->kregs);
	THIS->__retvalue = _stp_returnval(regs);
%}

/**
 * sfunction returnstr - Formats the return value as a string
 *
 * @format: Variable to determine return type base value
 * 
 * Description: This function is used by the nd_syscall tapset, and 
 * returns a string. Set format equal to 1 for a decimal, 
 * 2 for hex, 3 for octal.
 *
 * Note that this function should only be used in dwarfless probes
 * (i.e. 'kprobe.function("foo")').  Other probes should use
 * return_str().
 */
function returnstr:string (format:long) %{ /* pure */
	struct pt_regs *regs;
	regs = ((CONTEXT->probe_flags & _STP_PROBE_STATE_USER_MODE)
		? CONTEXT->uregs : CONTEXT->kregs);
	if (regs) {
		long ret = _stp_returnval(regs);
		if (ret < 0 && ret > -Maxerrno && errlist[-ret])
			snprintf (THIS->__retvalue, MAXSTRINGLEN, "%ld (%s)", ret, errlist[-ret]);
		else if (THIS->format == 2)
			snprintf (THIS->__retvalue, MAXSTRINGLEN, "0x%lx", ret);
		else if (THIS->format == 3)
			snprintf (THIS->__retvalue, MAXSTRINGLEN, "%#lo", ret);
		else 	
			snprintf (THIS->__retvalue, MAXSTRINGLEN, "%ld", ret);
	} else {
no_ret:
		strlcpy(THIS->__retvalue, "N/A", MAXSTRINGLEN);
	}
%}

/** 
 * sfunction return_str - Formats the return value as a string
 *
 * @format: Variable to determine return type base value
 * @ret: Return value (typically $return)
 * 
 * Description: This function is used by the syscall tapset, and 
 * returns a string. Set format equal to 1 for a decimal, 
 * 2 for hex, 3 for octal.
 *
 * Note that this function is preferred over returnstr().
 */
function return_str:string(format:long, ret:long)
{
	if (ret < 0 && errno_p(ret))
		return sprintf("%d (%s)", ret, errno_str(ret))

	if (format == 2)
		return sprintf("0x%x", ret)
	else if (format == 3)
		return sprintf("%#o", ret)
	else	
		return sprintf("%d", ret)
}