Remove PREFIX_EVEX_0F3A3E and PREFIX_EVEX_0F3A3F
[deliverable/binutils-gdb.git] / gdb / gdbserver / target.h
CommitLineData
ce3a066d 1/* Target operations for the remote server for GDB.
28e7fd62 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
ce3a066d
DJ
3
4 Contributed by MontaVista Software.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
ce3a066d
DJ
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
ce3a066d
DJ
20
21#ifndef TARGET_H
22#define TARGET_H
23
3360c0bf
LM
24#include "target-common.h"
25
6a271cae 26struct emit_ops;
9accd112
MM
27struct btrace_target_info;
28struct buffer;
6a271cae 29
2bd7c093
PA
30/* This structure describes how to resume a particular thread (or all
31 threads) based on the client's request. If thread is -1, then this
32 entry applies to all threads. These are passed around as an
33 array. */
64386c31
DJ
34
35struct thread_resume
36{
95954743 37 ptid_t thread;
64386c31 38
bd99dc85
PA
39 /* How to "resume". */
40 enum resume_kind kind;
64386c31 41
bd99dc85
PA
42 /* If non-zero, send this signal when we resume, or to stop the
43 thread. If stopping a thread, and this is 0, the target should
44 stop the thread however it best decides to (e.g., SIGSTOP on
30d50328 45 linux; SuspendThread on win32). This is a host signal value (not
2ea28649 46 enum gdb_signal). */
64386c31 47 int sig;
c2d6af84
PA
48
49 /* Range to single step within. Valid only iff KIND is resume_step.
50
51 Single-step once, and then continuing stepping as long as the
52 thread stops in this range. (If the range is empty
53 [STEP_RANGE_START == STEP_RANGE_END], then this is a single-step
54 request.) */
55 CORE_ADDR step_range_start; /* Inclusive */
56 CORE_ADDR step_range_end; /* Exclusive */
64386c31
DJ
57};
58
ce3a066d
DJ
59struct target_ops
60{
61 /* Start a new process.
62
63 PROGRAM is a path to the program to execute.
64 ARGS is a standard NULL-terminated array of arguments,
65 to be passed to the inferior as ``argv''.
66
a9fa9f7d 67 Returns the new PID on success, -1 on failure. Registers the new
ce3a066d
DJ
68 process with the process list. */
69
70 int (*create_inferior) (char *program, char **args);
71
72 /* Attach to a running process.
73
74 PID is the process ID to attach to, specified by the user
1d5315fe
PA
75 or a higher layer.
76
77 Returns -1 if attaching is unsupported, 0 on success, and calls
78 error() otherwise. */
ce3a066d 79
a1928bad 80 int (*attach) (unsigned long pid);
ce3a066d 81
95954743 82 /* Kill inferior PID. Return -1 on failure, and 0 on success. */
ce3a066d 83
95954743 84 int (*kill) (int pid);
ce3a066d 85
95954743
PA
86 /* Detach from inferior PID. Return -1 on failure, and 0 on
87 success. */
6ad8ae5c 88
95954743 89 int (*detach) (int pid);
444d6139 90
8336d594
PA
91 /* The inferior process has died. Do what is right. */
92
93 void (*mourn) (struct process_info *proc);
94
95954743
PA
95 /* Wait for inferior PID to exit. */
96 void (*join) (int pid);
6ad8ae5c 97
ce3a066d
DJ
98 /* Return 1 iff the thread with process ID PID is alive. */
99
95954743 100 int (*thread_alive) (ptid_t pid);
ce3a066d 101
64386c31 102 /* Resume the inferior process. */
ce3a066d 103
2bd7c093 104 void (*resume) (struct thread_resume *resume_info, size_t n);
ce3a066d 105
5b1c542e 106 /* Wait for the inferior process or thread to change state. Store
95954743
PA
107 status through argument pointer STATUS.
108
109 PTID = -1 to wait for any pid to do something, PTID(pid,0,0) to
110 wait for any thread of process pid to do something. Return ptid
111 of child, or -1 in case of error; store status through argument
112 pointer STATUS. OPTIONS is a bit set of options defined as
113 TARGET_W* above. If options contains TARGET_WNOHANG and there's
114 no child stop to report, return is
115 null_ptid/TARGET_WAITKIND_IGNORE. */
ce3a066d 116
95954743 117 ptid_t (*wait) (ptid_t ptid, struct target_waitstatus *status, int options);
ce3a066d
DJ
118
119 /* Fetch registers from the inferior process.
120
121 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
122
442ea881 123 void (*fetch_registers) (struct regcache *regcache, int regno);
aa691b87 124
ce3a066d
DJ
125 /* Store registers to the inferior process.
126
127 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
128
442ea881 129 void (*store_registers) (struct regcache *regcache, int regno);
ce3a066d 130
90d74c30
PA
131 /* Prepare to read or write memory from the inferior process.
132 Targets use this to do what is necessary to get the state of the
133 inferior such that it is possible to access memory.
134
135 This should generally only be called from client facing routines,
136 such as gdb_read_memory/gdb_write_memory, or the insert_point
137 callbacks.
138
139 Like `read_memory' and `write_memory' below, returns 0 on success
140 and errno on failure. */
141
142 int (*prepare_to_access_memory) (void);
143
144 /* Undo the effects of prepare_to_access_memory. */
145
0146f85b 146 void (*done_accessing_memory) (void);
90d74c30 147
611cb4a5
DJ
148 /* Read memory from the inferior process. This should generally be
149 called through read_inferior_memory, which handles breakpoint shadowing.
ce3a066d 150
c3e735a6
DJ
151 Read LEN bytes at MEMADDR into a buffer at MYADDR.
152
153 Returns 0 on success and errno on failure. */
ce3a066d 154
f450004a 155 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
ce3a066d 156
611cb4a5
DJ
157 /* Write memory to the inferior process. This should generally be
158 called through write_inferior_memory, which handles breakpoint shadowing.
ce3a066d
DJ
159
160 Write LEN bytes from the buffer at MYADDR to MEMADDR.
161
162 Returns 0 on success and errno on failure. */
163
f450004a
DJ
164 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
165 int len);
2f2893d9
DJ
166
167 /* Query GDB for the values of any symbols we're interested in.
168 This function is called whenever we receive a "qSymbols::"
169 query, which corresponds to every time more symbols (might)
611cb4a5
DJ
170 become available. NULL if we aren't interested in any
171 symbols. */
2f2893d9
DJ
172
173 void (*look_up_symbols) (void);
e5379b03 174
ef57601b
PA
175 /* Send an interrupt request to the inferior process,
176 however is appropriate. */
177
178 void (*request_interrupt) (void);
aa691b87
RM
179
180 /* Read auxiliary vector data from the inferior process.
181
182 Read LEN bytes at OFFSET into a buffer at MYADDR. */
183
f450004a
DJ
184 int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
185 unsigned int len);
e013ee27 186
d993e290 187 /* Insert and remove a break or watchpoint.
1b3f6016 188 Returns 0 on success, -1 on failure and 1 on unsupported.
e013ee27 189 The type is coded as follows:
c6314022
AR
190 '0' - software-breakpoint
191 '1' - hardware-breakpoint
192 '2' - write watchpoint
193 '3' - read watchpoint
194 '4' - access watchpoint */
e013ee27 195
d993e290
PA
196 int (*insert_point) (char type, CORE_ADDR addr, int len);
197 int (*remove_point) (char type, CORE_ADDR addr, int len);
e013ee27
OF
198
199 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
200
201 int (*stopped_by_watchpoint) (void);
202
1b3f6016 203 /* Returns the address associated with the watchpoint that hit, if any;
e013ee27
OF
204 returns 0 otherwise. */
205
206 CORE_ADDR (*stopped_data_address) (void);
207
52fb6437
NS
208 /* Reports the text, data offsets of the executable. This is
209 needed for uclinux where the executable is relocated during load
210 time. */
1b3f6016 211
52fb6437 212 int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
dae5f5cf
DJ
213
214 /* Fetch the address associated with a specific thread local storage
215 area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
216 Stores it in *ADDRESS and returns zero on success; otherwise returns
217 an error code. A return value of -1 means this system does not
218 support the operation. */
219
220 int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
221 CORE_ADDR load_module, CORE_ADDR *address);
23181151 222
0e7f50da
UW
223 /* Read/Write from/to spufs using qXfer packets. */
224 int (*qxfer_spu) (const char *annex, unsigned char *readbuf,
225 unsigned const char *writebuf, CORE_ADDR offset, int len);
59a016f0
PA
226
227 /* Fill BUF with an hostio error packet representing the last hostio
228 error. */
229 void (*hostio_last_error) (char *buf);
07e059b5
VP
230
231 /* Read/Write OS data using qXfer packets. */
232 int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
1b3f6016 233 unsigned const char *writebuf, CORE_ADDR offset,
07e059b5 234 int len);
4aa995e1
PA
235
236 /* Read/Write extra signal info. */
237 int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
238 unsigned const char *writebuf,
239 CORE_ADDR offset, int len);
bd99dc85
PA
240
241 int (*supports_non_stop) (void);
242
243 /* Enables async target events. Returns the previous enable
244 state. */
245 int (*async) (int enable);
246
247 /* Switch to non-stop (1) or all-stop (0) mode. Return 0 on
248 success, -1 otherwise. */
249 int (*start_non_stop) (int);
cf8fd78b
PA
250
251 /* Returns true if the target supports multi-process debugging. */
252 int (*supports_multi_process) (void);
cdbfd419
PP
253
254 /* If not NULL, target-specific routine to process monitor command.
255 Returns 1 if handled, or 0 to perform default processing. */
256 int (*handle_monitor_command) (char *);
dc146f7c
VP
257
258 /* Returns the core given a thread, or -1 if not known. */
259 int (*core_of_thread) (ptid_t);
1570b33e 260
78d85199
YQ
261 /* Read loadmaps. Read LEN bytes at OFFSET into a buffer at MYADDR. */
262 int (*read_loadmap) (const char *annex, CORE_ADDR offset,
881127c9 263 unsigned char *myaddr, unsigned int len);
78d85199 264
1570b33e
L
265 /* Target specific qSupported support. */
266 void (*process_qsupported) (const char *);
219f2f23
PA
267
268 /* Return 1 if the target supports tracepoints, 0 (or leave the
269 callback NULL) otherwise. */
270 int (*supports_tracepoints) (void);
271
272 /* Read PC from REGCACHE. */
273 CORE_ADDR (*read_pc) (struct regcache *regcache);
274
275 /* Write PC to REGCACHE. */
276 void (*write_pc) (struct regcache *regcache, CORE_ADDR pc);
8336d594
PA
277
278 /* Return true if THREAD is known to be stopped now. */
279 int (*thread_stopped) (struct thread_info *thread);
280
711e434b
PM
281 /* Read Thread Information Block address. */
282 int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
7984d532 283
609086b1 284 /* Pause all threads. If FREEZE, arrange for any resume attempt to
7984d532
PA
285 be ignored until an unpause_all call unfreezes threads again.
286 There can be nested calls to pause_all, so a freeze counter
287 should be maintained. */
288 void (*pause_all) (int freeze);
289
290 /* Unpause all threads. Threads that hadn't been resumed by the
291 client should be left stopped. Basically a pause/unpause call
292 pair should not end up resuming threads that were stopped before
293 the pause call. */
294 void (*unpause_all) (int unfreeze);
295
296 /* Cancel all pending breakpoints hits in all threads. */
297 void (*cancel_breakpoints) (void);
fa593d66
PA
298
299 /* Stabilize all threads. That is, force them out of jump pads. */
300 void (*stabilize_threads) (void);
301
302 /* Install a fast tracepoint jump pad. TPOINT is the address of the
303 tracepoint internal object as used by the IPA agent. TPADDR is
304 the address of tracepoint. COLLECTOR is address of the function
305 the jump pad redirects to. LOCKADDR is the address of the jump
306 pad lock object. ORIG_SIZE is the size in bytes of the
307 instruction at TPADDR. JUMP_ENTRY points to the address of the
308 jump pad entry, and on return holds the address past the end of
405f8e94
SS
309 the created jump pad. If a trampoline is created by the function,
310 then TRAMPOLINE and TRAMPOLINE_SIZE return the address and size of
311 the trampoline, else they remain unchanged. JJUMP_PAD_INSN is a
312 buffer containing a copy of the instruction at TPADDR.
313 ADJUST_INSN_ADDR and ADJUST_INSN_ADDR_END are output parameters that
314 return the address range where the instruction at TPADDR was relocated
315 to. If an error occurs, the ERR may be used to pass on an error
316 message. */
fa593d66
PA
317 int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
318 CORE_ADDR collector,
319 CORE_ADDR lockaddr,
320 ULONGEST orig_size,
321 CORE_ADDR *jump_entry,
405f8e94
SS
322 CORE_ADDR *trampoline,
323 ULONGEST *trampoline_size,
fa593d66
PA
324 unsigned char *jjump_pad_insn,
325 ULONGEST *jjump_pad_insn_size,
326 CORE_ADDR *adjusted_insn_addr,
405f8e94
SS
327 CORE_ADDR *adjusted_insn_addr_end,
328 char *err);
6a271cae
PA
329
330 /* Return the bytecode operations vector for the current inferior.
331 Returns NULL if bytecode compilation is not supported. */
332 struct emit_ops *(*emit_ops) (void);
03583c20
UW
333
334 /* Returns true if the target supports disabling randomization. */
335 int (*supports_disable_randomization) (void);
405f8e94
SS
336
337 /* Return the minimum length of an instruction that can be safely overwritten
338 for use as a fast tracepoint. */
339 int (*get_min_fast_tracepoint_insn_len) (void);
2268b414
JK
340
341 /* Read solib info on SVR4 platforms. */
342 int (*qxfer_libraries_svr4) (const char *annex, unsigned char *readbuf,
343 unsigned const char *writebuf,
344 CORE_ADDR offset, int len);
d1feda86
YQ
345
346 /* Return true if target supports debugging agent. */
347 int (*supports_agent) (void);
9accd112
MM
348
349 /* Check whether the target supports branch tracing. */
350 int (*supports_btrace) (void);
351
352 /* Enable branch tracing for @ptid and allocate a branch trace target
353 information struct for reading and for disabling branch trace. */
354 struct btrace_target_info *(*enable_btrace) (ptid_t ptid);
355
356 /* Disable branch tracing. */
357 int (*disable_btrace) (struct btrace_target_info *tinfo);
358
359 /* Read branch trace data into buffer. We use an int to specify the type
360 to break a cyclic dependency. */
361 void (*read_btrace) (struct btrace_target_info *, struct buffer *, int type);
362
c2d6af84
PA
363 /* Return true if target supports range stepping. */
364 int (*supports_range_stepping) (void);
ce3a066d
DJ
365};
366
367extern struct target_ops *the_target;
368
369void set_target_ops (struct target_ops *);
370
371#define create_inferior(program, args) \
372 (*the_target->create_inferior) (program, args)
373
374#define myattach(pid) \
375 (*the_target->attach) (pid)
376
7255706c 377int kill_inferior (int);
ce3a066d 378
95954743
PA
379#define detach_inferior(pid) \
380 (*the_target->detach) (pid)
6ad8ae5c 381
8336d594
PA
382#define mourn_inferior(PROC) \
383 (*the_target->mourn) (PROC)
384
ce3a066d
DJ
385#define mythread_alive(pid) \
386 (*the_target->thread_alive) (pid)
387
442ea881
PA
388#define fetch_inferior_registers(regcache, regno) \
389 (*the_target->fetch_registers) (regcache, regno)
ce3a066d 390
442ea881
PA
391#define store_inferior_registers(regcache, regno) \
392 (*the_target->store_registers) (regcache, regno)
ce3a066d 393
95954743
PA
394#define join_inferior(pid) \
395 (*the_target->join) (pid)
444d6139 396
bd99dc85
PA
397#define target_supports_non_stop() \
398 (the_target->supports_non_stop ? (*the_target->supports_non_stop ) () : 0)
399
400#define target_async(enable) \
401 (the_target->async ? (*the_target->async) (enable) : 0)
402
cf8fd78b
PA
403#define target_supports_multi_process() \
404 (the_target->supports_multi_process ? \
405 (*the_target->supports_multi_process) () : 0)
406
8336d594
PA
407#define target_process_qsupported(query) \
408 do \
409 { \
410 if (the_target->process_qsupported) \
411 the_target->process_qsupported (query); \
412 } while (0)
1570b33e 413
219f2f23
PA
414#define target_supports_tracepoints() \
415 (the_target->supports_tracepoints \
416 ? (*the_target->supports_tracepoints) () : 0)
417
fa593d66
PA
418#define target_supports_fast_tracepoints() \
419 (the_target->install_fast_tracepoint_jump_pad != NULL)
420
405f8e94
SS
421#define target_get_min_fast_tracepoint_insn_len() \
422 (the_target->get_min_fast_tracepoint_insn_len \
423 ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0)
424
8336d594
PA
425#define thread_stopped(thread) \
426 (*the_target->thread_stopped) (thread)
427
7984d532
PA
428#define pause_all(freeze) \
429 do \
430 { \
431 if (the_target->pause_all) \
432 (*the_target->pause_all) (freeze); \
433 } while (0)
434
435#define unpause_all(unfreeze) \
436 do \
437 { \
438 if (the_target->unpause_all) \
439 (*the_target->unpause_all) (unfreeze); \
440 } while (0)
441
442#define cancel_breakpoints() \
443 do \
444 { \
445 if (the_target->cancel_breakpoints) \
446 (*the_target->cancel_breakpoints) (); \
8336d594
PA
447 } while (0)
448
fa593d66
PA
449#define stabilize_threads() \
450 do \
451 { \
452 if (the_target->stabilize_threads) \
453 (*the_target->stabilize_threads) (); \
454 } while (0)
455
456#define install_fast_tracepoint_jump_pad(tpoint, tpaddr, \
457 collector, lockaddr, \
458 orig_size, \
405f8e94
SS
459 jump_entry, \
460 trampoline, trampoline_size, \
461 jjump_pad_insn, \
fa593d66
PA
462 jjump_pad_insn_size, \
463 adjusted_insn_addr, \
405f8e94
SS
464 adjusted_insn_addr_end, \
465 err) \
fa593d66
PA
466 (*the_target->install_fast_tracepoint_jump_pad) (tpoint, tpaddr, \
467 collector,lockaddr, \
468 orig_size, jump_entry, \
405f8e94
SS
469 trampoline, \
470 trampoline_size, \
fa593d66
PA
471 jjump_pad_insn, \
472 jjump_pad_insn_size, \
473 adjusted_insn_addr, \
405f8e94
SS
474 adjusted_insn_addr_end, \
475 err)
fa593d66 476
6a271cae
PA
477#define target_emit_ops() \
478 (the_target->emit_ops ? (*the_target->emit_ops) () : NULL)
479
03583c20
UW
480#define target_supports_disable_randomization() \
481 (the_target->supports_disable_randomization ? \
482 (*the_target->supports_disable_randomization) () : 0)
483
d1feda86
YQ
484#define target_supports_agent() \
485 (the_target->supports_agent ? \
486 (*the_target->supports_agent) () : 0)
487
9accd112
MM
488#define target_supports_btrace() \
489 (the_target->supports_btrace ? (*the_target->supports_btrace) () : 0)
490
491#define target_enable_btrace(ptid) \
492 (*the_target->enable_btrace) (ptid)
493
494#define target_disable_btrace(tinfo) \
495 (*the_target->disable_btrace) (tinfo)
496
497#define target_read_btrace(tinfo, buffer, type) \
498 (*the_target->read_btrace) (tinfo, buffer, type)
499
c2d6af84
PA
500#define target_supports_range_stepping() \
501 (the_target->supports_range_stepping ? \
502 (*the_target->supports_range_stepping) () : 0)
503
bd99dc85
PA
504/* Start non-stop mode, returns 0 on success, -1 on failure. */
505
506int start_non_stop (int nonstop);
507
95954743
PA
508ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
509 int connected_wait);
0d62e5e8 510
90d74c30
PA
511#define prepare_to_access_memory() \
512 (the_target->prepare_to_access_memory \
513 ? (*the_target->prepare_to_access_memory) () \
514 : 0)
515
0146f85b 516#define done_accessing_memory() \
90d74c30
PA
517 do \
518 { \
0146f85b
PA
519 if (the_target->done_accessing_memory) \
520 (*the_target->done_accessing_memory) (); \
90d74c30
PA
521 } while (0)
522
3e10640f
YQ
523#define target_core_of_thread(ptid) \
524 (the_target->core_of_thread ? (*the_target->core_of_thread) (ptid) \
525 : -1)
526
f450004a 527int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
ce3a066d 528
f450004a
DJ
529int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
530 int len);
0d62e5e8
DJ
531
532void set_desired_inferior (int id);
ce3a066d 533
95954743
PA
534const char *target_pid_to_str (ptid_t);
535
ce3a066d 536#endif /* TARGET_H */
This page took 1.246474 seconds and 4 git commands to generate.