/usr/share/systemtap/tapset/linux/ucontext.stp is in systemtap-common 3.1-3ubuntu0.1.
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 | // User context tapset
// Copyright (C) 2010-2011 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.
/**
* sfunction umodname - Returns the (short) name of the user module.
* @addr: User-space address
*
* Returns the short name of the user space module for the current task that
* that the given address is part of. Reports an error when the address
* isn't in a (mapped in) module, or the module cannot be found for some reason.
*/
function umodname:string (addr:long) %{
/* pure */ /* myproc-unprivileged */ /* pragma:vma */
const char *name = NULL;
_stp_umod_lookup(STAP_ARG_addr, current, &name, NULL, NULL);
if (!name) {
name = "<unknown>";
#if STAP_COMPAT_VERSION >= STAP_VERSION(2,3) // PR15044
CONTEXT->last_error = "module cannot be found";
#endif
}
strlcpy (STAP_RETVALUE, name, MAXSTRINGLEN);
%}
/**
* sfunction ucallers - Return first n elements of user stack backtrace
*
* @n: number of levels to descend in the stack (not counting the top
* level). If n is -1, print the entire stack.
*
* Description: This function returns a string of the first n hex
* addresses from the backtrace of the user stack. Output may be
* truncated as per maximum string length (MAXSTRINGLEN).
*
* Note: To get (full) backtraces for user space applications and shared
* shared libraries not mentioned in the current script run stap with
* -d /path/to/exe-or-so and/or add --ldd to load all needed unwind data.
*/
function ucallers:string (n:long) {
__str = ""; __l = 0
for (__i = 0; __i <= n || n == -1; __i++) {
__foo = __i > 0 ? " " : ""
try {
__foo .= sprintf("0x%x", ustack(__i))
} catch { /* assume we've hit the end of the stack */
if (n == -1) break
@__context_unwind_error(n)
}
// ensure string cuts off cleanly at MAXSTRINGLEN:
__l += strlen(__foo); if (__l > @MAXSTRINGLEN) break
__str .= __foo
}
return __str
}
|