summaryrefslogtreecommitdiffstats
path: root/tapset/ucontext-symbols.stp
blob: dbfa684f5e3c3ff6064fafe99887381911ef3c3b (plain)
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
// User context symbols tapset
// Copyright (C) 2009 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.

// <tapsetdescription>
// User context symbol functions provide additional information about
// addresses from an application. These functions can provide
// information about the user space map (library) that the event occurred or
// the function symbol of an address.
// </tapsetdescription>

%{
#ifndef STP_NEED_SYMBOL_DATA
#define STP_NEED_SYMBOL_DATA 1
#endif
#ifndef STP_NEED_VMA_TRACKER
#define STP_NEED_VMA_TRACKER 1
#endif
%}

/**
 * sfunction usymname - Return the symbol of an address in the current task. EXPERIMENTAL!
 * @addr: The address to translate.
 *
 * Description: Returns the (function) symbol name associated with the
 * given address if known. If not known it will return the hex string
 * representation of addr.
 */
function usymname:string (addr: long) %{ /* pure */ /* unprivileged */
         assert_is_myproc();
	 _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
			     current, 0);
%}

/**
 * sfunction usymdata - Return the symbol and module offset of an address. EXPERIMENTAL!
 * @addr: The address to translate.
 *
 * Description: Returns the (function) symbol name associated with the
 * given address in the current task if known, plus the module name
 * (between brackets) and the offset inside the module (shared library),
 * plus the size of the symbol function. If any element is not known it
 * will be omitted and if the symbol name is unknown it will return the
 * hex string for the given address.
 */
function usymdata:string (addr: long) %{ /* pure */ /* unprivileged */
         assert_is_myproc();
	 _stp_symbol_snprint(THIS->__retvalue, MAXSTRINGLEN, THIS->addr,
			     current, 1);
%}

/**
 * sfunction print_ustack - Print out stack for the current task from string. EXPERIMENTAL!
 * @stk: String with list of hexadecimal addresses for the current task.
 *
 *  Perform a symbolic lookup of the addresses in the given string,
 *  which is assumed to be the result of a prior call to 
 *  ubacktrace() for the current task.
 * 
 *  Print one line per address, including the address, the
 *  name  of the function containing the address, and an estimate of
 *  its position within that function.  Return nothing.
 */
function print_ustack(stk:string) %{ /* unprivileged */
        char *ptr = THIS->stk;
        char *tok = strsep(&ptr, " ");
        assert_is_myproc();
        while (tok && *tok) {
                _stp_print_char(' ');
                _stp_usymbol_print (simple_strtol(tok, NULL, 16), current);
                _stp_print_char('\n');
                tok = strsep(&ptr, " ");
        }
%}