summaryrefslogtreecommitdiffstats
path: root/tapset/ucontext-unwind.stp
blob: b9a9fbb534a5ebec898c16471ca1a18ed3a92700 (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
// User context unwind 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.

%{
#ifndef STP_NEED_UNWIND_DATA
#define STP_NEED_UNWIND_DATA 1
#endif
#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 print_ubacktrace - Print stack back trace for current task. EXPERIMENTAL!
 *
 *  Equivalent to print_ustack(ubacktrace()), 
 *  except that deeper stack nesting may be supported.  Return nothing.
 */
function print_ubacktrace () %{ /* unprivileged */
        assert_is_myproc();
	if (CONTEXT->regs) {
		_stp_stack_print(CONTEXT->regs, 1, CONTEXT->pi, MAXTRACE,
				 current, CONTEXT->ri);
	} else {
		_stp_printf("Systemtap probe: %s\n", CONTEXT->probe_point);
	}
%}

/**
 * sfunction print_ubacktrace_brief- Print stack back trace for current task. EXPERIMENTAL!
 *
 *  Equivalent to print_ubacktrace(), but output for each symbol is
 *  shorter (just name and offset), and the function address is
 *  printed if it can't be mapped to a name.
 */
function print_ubacktrace_brief () %{ /* unprivileged */
        assert_is_myproc();
	if (CONTEXT->regs) {
		_stp_stack_print(CONTEXT->regs, SYM_VERBOSE_BRIEF, CONTEXT->pi,
				 MAXTRACE, current, CONTEXT->ri);
	} else {
		_stp_printf("Systemtap probe: %s\n", CONTEXT->probe_point);
	}
%}

/**
 * sfunction ubacktrace - Hex backtrace of current task stack. EXPERIMENTAL!
 *
 *  Return a string of hex addresses that are a backtrace of the 
 *  stack of the current task.  Output may be truncated as per maximum
 *  string length. Returns empty string when current probe point cannot
 *  determine user backtrace.
 */
function ubacktrace:string () %{ /* pure */ /* unprivileged */
        assert_is_myproc();
	if (CONTEXT->regs)
		_stp_stack_snprint (THIS->__retvalue, MAXSTRINGLEN,
				    CONTEXT->regs, 0, CONTEXT->pi, MAXTRACE,
				    current, CONTEXT->ri);
	else 
		strlcpy (THIS->__retvalue, "", MAXSTRINGLEN);
%}