1 /* Target operations for the remote server for GDB.
2 Copyright (C) 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
5 Contributed by MontaVista Software.
7 This file is part of GDB.
8 It has been modified to integrate it in valgrind
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
28 /* This structure describes how to resume a particular thread (or
29 all threads) based on the client's request. If thread is -1, then
30 this entry applies to all threads. These are generally passed around
31 as an array, and terminated by a thread == -1 entry. */
37 /* If non-zero, leave this thread stopped. */
40 /* If non-zero, we want to single-step. */
43 /* If non-zero, send this signal when we resume. */
49 /* Return 1 iff the thread with process ID PID is alive. */
51 int (*thread_alive) (unsigned long pid);
53 /* Resume the inferior process. */
55 void (*resume) (struct thread_resume *resume_info);
57 /* Wait for the inferior process to change state.
59 STATUS will be filled in with a response code to send to GDB.
61 Returns the signal which caused the process to stop, in the
62 remote protocol numbering (e.g. TARGET_SIGNAL_STOP), or the
63 exit code as an integer if *STATUS is 'W'. */
65 unsigned char (*wait) (char *status);
67 /* Fetch registers from the inferior process.
69 If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO. */
71 void (*fetch_registers) (int regno);
73 /* Store registers to the inferior process.
75 If REGNO is -1, store all registers; otherwise, store at least REGNO. */
77 void (*store_registers) (int regno);
79 /* Read memory from the inferior process. This should generally be
80 called through read_inferior_memory, which handles breakpoint shadowing.
82 Read LEN bytes at MEMADDR into a buffer at MYADDR.
84 Returns 0 on success and errno on failure. */
86 int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
88 /* Write memory to the inferior process. This should generally be
89 called through write_inferior_memory, which handles breakpoint shadowing.
91 Write LEN bytes from the buffer at MYADDR to MEMADDR.
93 Returns 0 on success and errno on failure. */
95 int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
98 /* Send a signal to the inferior process, however is appropriate. */
99 void (*send_signal) (int);
101 /* Returns the name of the xml target description file.
102 returns NULL if no xml target description available. */
103 char* (*target_xml)(void);
105 /* Same but describes also the shadow registers. */
106 char* (*shadow_target_xml)(void);
108 /* Insert and remove a hardware watchpoint.
109 Returns 0 on success, -1 on failure and 1 on unsupported.
110 The type is coded as follows:
113 4 = access watchpoint
116 int (*insert_watchpoint) (char type, CORE_ADDR addr, int len);
117 int (*remove_watchpoint) (char type, CORE_ADDR addr, int len);
119 /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise. */
121 int (*stopped_by_watchpoint) (void);
123 /* Returns the address associated with the watchpoint that hit, if any;
124 returns 0 otherwise. */
126 CORE_ADDR (*stopped_data_address) (void);
130 extern struct target_ops *the_target;
132 void set_target_ops (struct target_ops *);
134 #define detach_inferior() \
135 (*the_target->detach) ()
137 #define mythread_alive(pid) \
138 (*the_target->thread_alive) (pid)
140 #define fetch_inferior_registers(regno) \
141 (*the_target->fetch_registers) (regno)
143 #define store_inferior_registers(regno) \
144 (*the_target->store_registers) (regno)
146 #define mywait(statusp) \
147 (*the_target->wait) (statusp)
149 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
151 int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
154 void set_desired_inferior (int id);
156 /* like memcpy but first check if content of destination and source
157 differs. If no difference, no copy is done, *mod set to False.
158 If different; copy is done, *mod set to True. */
159 extern void* VG_(dmemcpy) ( void *d, const void *s, SizeT sz, Bool *mod );
163 valgrind_to_gdbserver,
164 gdbserver_to_valgrind} transfer_direction;
166 // According to dir, calls VG_(dmemcpy)
167 // to copy data from/to valgrind to/from gdbserver.
168 // If the transferred data differs from what is currently stored,
169 // sets *mod to True otherwise set *mod to False.
170 extern void VG_(transfer) (void *valgrind,
172 transfer_direction dir,
176 #endif /* TARGET_H */