Debian Codegraph @

runtime/dyninst/stapdyn.h

raw
1 /* stapdyn interface header
2 * Copyright (C) 2012-2019 Red Hat Inc.
3 *
4 * This file is part of systemtap, and is free software. You can
5 * redistribute it and/or modify it under the terms of the GNU General
6 * Public License (GPL); either version 2, or (at your option) any
7 * later version.
8 */
9
10 #ifndef _STAPDYN_H_
11 #define _STAPDYN_H_
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #include <stdint.h>
18 #include <asm/ptrace.h>
19
20 #if defined(__aarch64__)
21
22 /* <asm/ptrace.h> defines user_pt_regs not pt_regs so clone this from kernel's
23 * arch/arm64/include/asm/ptrace.h */
24 /*
25 * This struct defines the way the registers are stored on the stack during an
26 * exception. Note that sizeof(struct pt_regs) has to be a multiple of 16 (for
27 * stack alignment). struct user_pt_regs must form a prefix of struct pt_regs.
28 */
29
30 struct pt_regs {
31 union {
32 struct user_pt_regs user_regs;
33 struct {
34 unsigned long long regs[31];
35 unsigned long long sp;
36 unsigned long long pc;
37 unsigned long long pstate;
38 };
39 };
40 unsigned long long orig_x0;
41 #ifdef __AARCH64EB__
42 unsigned int unused2;
43 signed int syscallno;
44 #else
45 signed int syscallno;
46 unsigned int unused2;
47 #endif
48
49 unsigned long long orig_addr_limit;
50 unsigned long long unused; // maintain 16 byte alignment
51 unsigned long long stackframe[2];
52 };
53 #endif
54
55 /* These are declarations of all interfaces that stapdyn may call in the
56 * module, either directly or via dyninst in the mutatee. To maintain
57 * compatibility as much as possible, function signatures should not be
58 * changed between releases, only deprecated/renamed as necessary.
59 *
60 * NB: These are organized by the systemtap release in which each was first
61 * added, so we can keep some idea of the ABI progression.
62 */
63
64
65 /* With -fvisibility=hidden, we have to expose these manually.
66 * Using "protected" keeps internal references always internal. */
67 #pragma GCC visibility push(protected)
68
69
70 /**** STAP 2.0 : ****/
71
72 extern int stp_dyninst_session_init(void);
73 extern void stp_dyninst_session_exit(void);
74
75 extern uint64_t stp_dyninst_target_count(void);
76 extern const char* stp_dyninst_target_path(uint64_t index);
77
78 extern uint64_t stp_dyninst_probe_count(void);
79 extern uint64_t stp_dyninst_probe_target(uint64_t index);
80 extern uint64_t stp_dyninst_probe_offset(uint64_t index);
81 extern uint64_t stp_dyninst_probe_semaphore(uint64_t index);
82
83 extern int enter_dyninst_uprobe(uint64_t index, struct pt_regs *regs);
84
85 /* This is somewhat of a hack until we can figure out how to build a pt_regs
86 * struct directly with stapdyn. The varargs are all unsigned long, giving
87 * first the original PC, then DWARF-ordered registers. */
88 extern int enter_dyninst_uprobe_regs(uint64_t index, unsigned long nregs, ...);
89 extern int enter_dyninst_uprobe_partial_regs(uint64_t index, unsigned long nregs, ...);
90
91
92 /**** STAP 2.1 : ****/
93
94 /* uprobes-like flags */
95 #define STAPDYN_PROBE_FLAG_RETURN 0x1
96
97 /* utrace-like flags */
98 #define STAPDYN_PROBE_FLAG_PROC_BEGIN 0x100
99 #define STAPDYN_PROBE_FLAG_PROC_END 0x200
100 #define STAPDYN_PROBE_FLAG_THREAD_BEGIN 0x400
101 #define STAPDYN_PROBE_FLAG_THREAD_END 0x800
102
103 extern uint64_t stp_dyninst_probe_flags(uint64_t index);
104
105 extern int enter_dyninst_utrace_probe(uint64_t index, struct pt_regs *regs);
106
107 extern const char* stp_dyninst_shm_init(void);
108 extern int stp_dyninst_shm_connect(const char* name);
109
110
111 /**** STAP 2.2 : ****/
112
113 /* The following function is dynamically generated by systemtap, and
114 * used by stapdyn to modify global variables at module startup only
115 * (that is, *before* running stp_dyninst_session_init()). If the
116 * name starts with '@', the name is assumed to be an internal value. */
117 extern int stp_global_setter(const char *name, const char *value);
118
119
120 /**** STAP 2.3 : ****/
121
122 /* Just returns an exit code, for indicating errors in the script.
123 * This should be called after stp_dyninst_session_exit (which really
124 * should have returned int itself, but now it's a legacy API). */
125 int stp_dyninst_exit_status(void);
126
127
128 /**** STAP 2.x : ****/
129
130
131 /* STAPDYN_PROBE_ALL_FLAGS was first added for 2.1, but is placed here so
132 * it can continue to be updated with new flags too. */
133 #define STAPDYN_PROBE_ALL_FLAGS (uint64_t)(STAPDYN_PROBE_FLAG_RETURN \
134 | STAPDYN_PROBE_FLAG_PROC_BEGIN | STAPDYN_PROBE_FLAG_PROC_END \
135 | STAPDYN_PROBE_FLAG_THREAD_BEGIN | STAPDYN_PROBE_FLAG_THREAD_END)
136
137
138 #pragma GCC visibility pop
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* _STAPDYN_H_ */