GDBserver

tracepoint.h
Go to the documentation of this file.
1 /* Tracepoint code for remote server for GDB.
2 Copyright (C) 1993-2018 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef TRACEPOINT_H
20 #define TRACEPOINT_H
21
22 /* Size for a small buffer to report problems from the in-process
23 agent back to GDBserver. */
24 #define IPA_BUFSIZ 100
25
26 void initialize_tracepoint (void);
27
28 #if defined(__GNUC__)
29 # define ATTR_USED __attribute__((used))
30 # define ATTR_NOINLINE __attribute__((noinline))
31 #else
32 # define ATTR_USED
33 # define ATTR_NOINLINE
34 #endif
35
36 /* How to make symbol public/exported. */
37
38 #if defined _WIN32 || defined __CYGWIN__
39 # define EXPORTED_SYMBOL __declspec (dllexport)
40 #else
41 # if __GNUC__ >= 4
42 # define EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
43 # else
44 # define EXPORTED_SYMBOL
45 # endif
46 #endif
47
48 /* Use these to make sure the functions and variables the IPA needs to
49 export (symbols GDBserver needs to query GDB about) are visible and
50 have C linkage.
51
52 Tag exported functions with IP_AGENT_EXPORT_FUNC, tag the
53 definitions of exported variables with IP_AGENT_EXPORT_VAR, and
54 variable declarations with IP_AGENT_EXPORT_VAR_DECL. Variables
55 must also be exported with C linkage. As we can't both use extern
56 "C" and initialize a variable in the same statement, variables that
57 don't have a separate declaration must use
58 EXTERN_C_PUSH/EXTERN_C_POP around their definition. */
59
60 #ifdef IN_PROCESS_AGENT
61 # define IP_AGENT_EXPORT_FUNC EXTERN_C EXPORTED_SYMBOL ATTR_NOINLINE ATTR_USED
62 # define IP_AGENT_EXPORT_VAR EXPORTED_SYMBOL ATTR_USED
63 # define IP_AGENT_EXPORT_VAR_DECL EXTERN_C EXPORTED_SYMBOL
64 #else
65 # define IP_AGENT_EXPORT_FUNC
66 # define IP_AGENT_EXPORT_VAR
67 # define IP_AGENT_EXPORT_VAR_DECL extern
68 #endif
69
70 IP_AGENT_EXPORT_VAR_DECL int tracing;
71
72 extern int disconnected_tracing;
73
74 void tracepoint_look_up_symbols (void);
75
76 void stop_tracing (void);
77
78 int handle_tracepoint_general_set (char *own_buf);
79 int handle_tracepoint_query (char *own_buf);
80
81 int tracepoint_finished_step (struct thread_info *tinfo, CORE_ADDR stop_pc);
82 int tracepoint_was_hit (struct thread_info *tinfo, CORE_ADDR stop_pc);
83
84 void release_while_stepping_state_list (struct thread_info *tinfo);
85
86 extern int current_traceframe;
87
88 int in_readonly_region (CORE_ADDR addr, ULONGEST length);
89 int traceframe_read_mem (int tfnum, CORE_ADDR addr,
90 unsigned char *buf, ULONGEST length,
91 ULONGEST *nbytes);
92 int fetch_traceframe_registers (int tfnum,
93 struct regcache *regcache,
94 int regnum);
95
96 int traceframe_read_sdata (int tfnum, ULONGEST offset,
97 unsigned char *buf, ULONGEST length,
98 ULONGEST *nbytes);
99
100 int traceframe_read_info (int tfnum, struct buffer *buffer);
101
102 /* If a thread is determined to be collecting a fast tracepoint, this
103 structure holds the collect status. */
104
105 struct fast_tpoint_collect_status
106 {
107 /* The tracepoint that is presently being collected. */
108 int tpoint_num;
109 CORE_ADDR tpoint_addr;
110
111 /* The address range in the jump pad of where the original
112 instruction the tracepoint jump was inserted was relocated
113 to. */
114 CORE_ADDR adjusted_insn_addr;
115 CORE_ADDR adjusted_insn_addr_end;
116 };
117
118 /* The possible states a thread can be in, related to the collection of fast
119 tracepoint. */
120
121 enum class fast_tpoint_collect_result
122 {
123 /* Not collecting a fast tracepoint. */
124 not_collecting,
125
126 /* In the jump pad, but before the relocated instruction. */
127 before_insn,
128
129 /* In the jump pad, but at (or after) the relocated instruction. */
130 at_insn,
131 };
132
133 fast_tpoint_collect_result fast_tracepoint_collecting
134 (CORE_ADDR thread_area, CORE_ADDR stop_pc,
135 struct fast_tpoint_collect_status *status);
136
137 void force_unlock_trace_buffer (void);
138
139 int handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc);
140
141 #ifdef IN_PROCESS_AGENT
142 void initialize_low_tracepoint (void);
143 const struct target_desc *get_ipa_tdesc (int idx);
144 void supply_fast_tracepoint_registers (struct regcache *regcache,
145 const unsigned char *regs);
146 void supply_static_tracepoint_registers (struct regcache *regcache,
147 const unsigned char *regs,
148 CORE_ADDR pc);
149 void set_trampoline_buffer_space (CORE_ADDR begin, CORE_ADDR end,
150 char *errmsg);
151 void *alloc_jump_pad_buffer (size_t size);
152 #ifndef HAVE_GETAUXVAL
153 unsigned long getauxval (unsigned long type);
154 #endif
155 #else
156 void stop_tracing (void);
157
158 int claim_trampoline_space (ULONGEST used, CORE_ADDR *trampoline);
159 int have_fast_tracepoint_trampoline_buffer (char *msgbuf);
160 void gdb_agent_about_to_close (int pid);
161 #endif
162
163 struct traceframe;
164 struct eval_agent_expr_context;
165
166 /* Do memory copies for bytecodes. */
167 /* Do the recording of memory blocks for actions and bytecodes. */
168
169 int agent_mem_read (struct eval_agent_expr_context *ctx,
170 unsigned char *to, CORE_ADDR from,
171 ULONGEST len);
172
173 LONGEST agent_get_trace_state_variable_value (int num);
174 void agent_set_trace_state_variable_value (int num, LONGEST val);
175
176 /* Record the value of a trace state variable. */
177
178 int agent_tsv_read (struct eval_agent_expr_context *ctx, int n);
179 int agent_mem_read_string (struct eval_agent_expr_context *ctx,
180 unsigned char *to,
181 CORE_ADDR from,
182 ULONGEST len);
183
184 /* The prototype the get_raw_reg function in the IPA. Each arch's
185 bytecode compiler emits calls to this function. */
186 ULONGEST get_raw_reg (const unsigned char *raw_regs, int regnum);
187
188 /* Returns the address of the get_raw_reg function in the IPA. */
189 CORE_ADDR get_raw_reg_func_addr (void);
190 /* Returns the address of the get_trace_state_variable_value
191 function in the IPA. */
192 CORE_ADDR get_get_tsv_func_addr (void);
193 /* Returns the address of the set_trace_state_variable_value
194 function in the IPA. */
195 CORE_ADDR get_set_tsv_func_addr (void);
196
197 #endif /* TRACEPOINT_H */
fast_tpoint_collect_status::tpoint_addr
CORE_ADDR tpoint_addr
Definition: tracepoint.h:109
fast_tpoint_collect_status
Definition: tracepoint.h:105
stop_tracing
void stop_tracing(void)
Definition: tracepoint.c:3413
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
tracepoint_finished_step
int tracepoint_finished_step(struct thread_info *tinfo, CORE_ADDR stop_pc)
Definition: tracepoint.c:4367
fast_tpoint_collect_result::not_collecting
handle_tracepoint_bkpts
int handle_tracepoint_bkpts(struct thread_info *tinfo, CORE_ADDR stop_pc)
Definition: tracepoint.c:4472
handle_tracepoint_query
int handle_tracepoint_query(char *own_buf)
Definition: tracepoint.c:4234
disconnected_tracing
int disconnected_tracing
Definition: tracepoint.c:1251
fast_tpoint_collect_status::adjusted_insn_addr_end
CORE_ADDR adjusted_insn_addr_end
Definition: tracepoint.h:115
in_readonly_region
int in_readonly_region(CORE_ADDR addr, ULONGEST length)
Definition: tracepoint.c:2903
eval_agent_expr_context
Definition: ax.h:74
traceframe
Definition: tracepoint.c:953
regnum
regnum
Definition: linux-xtensa-low.c:34
regcache
Definition: regcache.h:31
tracepoint_look_up_symbols
void tracepoint_look_up_symbols(void)
Definition: tracepoint.c:314
traceframe_read_info
int traceframe_read_info(int tfnum, struct buffer *buffer)
Definition: tracepoint.c:5462
thread_info
Definition: gdbthread.h:30
agent_get_trace_state_variable_value
LONGEST agent_get_trace_state_variable_value(int num)
Definition: tracepoint.c:2140
fast_tpoint_collect_result
fast_tpoint_collect_result
Definition: tracepoint.h:121
offset
int offset
Definition: tracepoint.c:181
alloc_jump_pad_buffer
void * alloc_jump_pad_buffer(size_t size)
Definition: linux-aarch64-ipa.c:165
force_unlock_trace_buffer
void force_unlock_trace_buffer(void)
Definition: tracepoint.c:5555
handle_tracepoint_general_set
int handle_tracepoint_general_set(char *own_buf)
Definition: tracepoint.c:4157
fast_tpoint_collect_status::tpoint_num
int tpoint_num
Definition: tracepoint.h:108
tracepoint_was_hit
int tracepoint_was_hit(struct thread_info *tinfo, CORE_ADDR stop_pc)
Definition: tracepoint.c:4554
get_raw_reg
ULONGEST get_raw_reg(const unsigned char *raw_regs, int regnum)
Definition: linux-aarch64-ipa.c:139
agent_tsv_read
int agent_tsv_read(struct eval_agent_expr_context *ctx, int n)
Definition: tracepoint.c:5044
get_set_tsv_func_addr
CORE_ADDR get_set_tsv_func_addr(void)
Definition: tracepoint.c:5908
agent_mem_read_string
int agent_mem_read_string(struct eval_agent_expr_context *ctx, unsigned char *to, CORE_ADDR from, ULONGEST len)
Definition: tracepoint.c:4982
fetch_traceframe_registers
int fetch_traceframe_registers(int tfnum, struct regcache *regcache, int regnum)
Definition: tracepoint.c:5185
get_get_tsv_func_addr
CORE_ADDR get_get_tsv_func_addr(void)
Definition: tracepoint.c:5895
gdb_agent_about_to_close
void gdb_agent_about_to_close(int pid)
Definition: tracepoint.c:3960
traceframe_read_sdata
int traceframe_read_sdata(int tfnum, ULONGEST offset, unsigned char *buf, ULONGEST length, ULONGEST *nbytes)
Definition: tracepoint.c:5361
current_traceframe
int current_traceframe
Definition: tracepoint.c:979
initialize_low_tracepoint
void initialize_low_tracepoint(void)
Definition: linux-aarch64-ipa.c:205
traceframe_read_mem
int traceframe_read_mem(int tfnum, CORE_ADDR addr, unsigned char *buf, ULONGEST length, ULONGEST *nbytes)
Definition: tracepoint.c:5236
target_desc
Definition: tdesc.h:33
have_fast_tracepoint_trampoline_buffer
int have_fast_tracepoint_trampoline_buffer(char *msgbuf)
Definition: tracepoint.c:2995
own_buf
char * own_buf
Definition: server.c:138
buffer
Definition: buffer.h:23
fast_tracepoint_collecting
fast_tpoint_collect_result fast_tracepoint_collecting(CORE_ADDR thread_area, CORE_ADDR stop_pc, struct fast_tpoint_collect_status *status)
Definition: tracepoint.c:5571
initialize_tracepoint
void initialize_tracepoint(void)
Definition: tracepoint.c:7406
fast_tpoint_collect_status::adjusted_insn_addr
CORE_ADDR adjusted_insn_addr
Definition: tracepoint.h:114
release_while_stepping_state_list
void release_while_stepping_state_list(struct thread_info *tinfo)
Definition: tracepoint.c:4349
ULONGEST
unsigned long long ULONGEST
Definition: common-types.h:53
agent_set_trace_state_variable_value
void agent_set_trace_state_variable_value(int num, LONGEST val)
Definition: tracepoint.c:2146
IP_AGENT_EXPORT_VAR_DECL
#define IP_AGENT_EXPORT_VAR_DECL
Definition: tracepoint.h:67
fast_tpoint_collect_result::at_insn
fast_tpoint_collect_result::before_insn
tracing
IP_AGENT_EXPORT_VAR_DECL int tracing
Definition: tracepoint.h:70
get_ipa_tdesc
const struct target_desc * get_ipa_tdesc(int idx)
Definition: linux-aarch64-ipa.c:153
claim_trampoline_space
int claim_trampoline_space(ULONGEST used, CORE_ADDR *trampoline)
Definition: tracepoint.c:2952
supply_fast_tracepoint_registers
void supply_fast_tracepoint_registers(struct regcache *regcache, const unsigned char *buf)
Definition: linux-aarch64-ipa.c:127
LONGEST
long long LONGEST
Definition: common-types.h:52
get_raw_reg_func_addr
CORE_ADDR get_raw_reg_func_addr(void)
Definition: tracepoint.c:5883
agent_mem_read
int agent_mem_read(struct eval_agent_expr_context *ctx, unsigned char *to, CORE_ADDR from, ULONGEST len)
Definition: tracepoint.c:4940