1349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Target operations for the Valgrind remote server for GDB.
2349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Copyright (C) 2002, 2003, 2004, 2005, 2012
33b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   Free Software Foundation, Inc.
4349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Philippe Waroquiers.
53b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
63b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   Contributed by MontaVista Software.
73b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
83b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   This file is part of GDB.
93b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   It has been modified to integrate it in valgrind
103b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
113b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   This program is free software; you can redistribute it and/or modify
123b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   it under the terms of the GNU General Public License as published by
133b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   the Free Software Foundation; either version 2 of the License, or
143b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   (at your option) any later version.
153b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
163b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   This program is distributed in the hope that it will be useful,
173b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   but WITHOUT ANY WARRANTY; without even the implied warranty of
183b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
193b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   GNU General Public License for more details.
203b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
213b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   You should have received a copy of the GNU General Public License
223b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   along with this program; if not, write to the Free Software
233b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   Foundation, Inc., 51 Franklin Street, Fifth Floor,
243b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   Boston, MA 02110-1301, USA.  */
253b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
263b290486cd4cd601b20e04340e593c9ed9717e5fsewardj#ifndef TARGET_H
273b290486cd4cd601b20e04340e593c9ed9717e5fsewardj#define TARGET_H
283b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
29535fb1b49a80f2e880f755ee618381de3e222ddfflorian#include "pub_core_basics.h"    // Addr
30535fb1b49a80f2e880f755ee618381de3e222ddfflorian#include "server.h"             // CORE_ADDR
31535fb1b49a80f2e880f755ee618381de3e222ddfflorian
32349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* This file defines the architecture independent Valgrind gdbserver
33349a39142e16d060936911c1792cc0a5d2fe63fephilippe   high level operations such as read memory, get/set registers, ...
343b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
35349a39142e16d060936911c1792cc0a5d2fe63fephilippe   These high level operations are called by the gdbserver
36349a39142e16d060936911c1792cc0a5d2fe63fephilippe   protocol implementation (e.g. typically server.c).
37349a39142e16d060936911c1792cc0a5d2fe63fephilippe
38349a39142e16d060936911c1792cc0a5d2fe63fephilippe   For some of these high level operations, target.c will call
39349a39142e16d060936911c1792cc0a5d2fe63fephilippe   low level operations dependent on the architecture.
40349a39142e16d060936911c1792cc0a5d2fe63fephilippe
41349a39142e16d060936911c1792cc0a5d2fe63fephilippe   For example, getting or setting the registers will work on a
42349a39142e16d060936911c1792cc0a5d2fe63fephilippe   register cache. The exact details of the registers (how much,
43349a39142e16d060936911c1792cc0a5d2fe63fephilippe   their size, etc) is not defined by target.c or the register cache.
443b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
45349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Such architecture dependent information is defined by
46349a39142e16d060936911c1792cc0a5d2fe63fephilippe   valgrind_low.h/valgrind-low-xxxxx.c providing 'low level operations'
47349a39142e16d060936911c1792cc0a5d2fe63fephilippe   specific to the xxxxx architecture (for example,
48349a39142e16d060936911c1792cc0a5d2fe63fephilippe   valgrind-low-x86.c, valgrind-low-armc.c). */
49349a39142e16d060936911c1792cc0a5d2fe63fephilippe
50349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
51349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* ------------------------ Initialisation ---------------------------------- */
52349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
533b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
54349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Initialize the Valgrind high target. This will in turn
55349a39142e16d060936911c1792cc0a5d2fe63fephilippe   initialise the low (architecture specific) target. */
56349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void valgrind_initialize_target(void);
573b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
58349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* initialize or re-initialize the register set of the low target.
59349a39142e16d060936911c1792cc0a5d2fe63fephilippe   if shadow_mode, then (re-)define the normal and valgrind shadow registers
60349a39142e16d060936911c1792cc0a5d2fe63fephilippe   else (re-)define only the normal registers. */
61349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void initialize_shadow_low (Bool shadow_mode);
623b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
63349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Returns the name of the xml target description file.
64419d5f2931a88d5e15e78fdaeac4d550aaf1e789philippe   returns NULL if no xml target description available.
65419d5f2931a88d5e15e78fdaeac4d550aaf1e789philippe   if shadow_mode, then returns the xml target description
66419d5f2931a88d5e15e78fdaeac4d550aaf1e789philippe   with the shadow registers
67419d5f2931a88d5e15e78fdaeac4d550aaf1e789philippe   else returns the xml target description only for
68419d5f2931a88d5e15e78fdaeac4d550aaf1e789philippe   the normal registers. */
696bd9dc18c043927c1196caba20a327238a179c42florianextern const char* valgrind_target_xml (Bool shadow_mode);
703b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
713b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
72349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
73349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* --------------------------- Execution control ---------------------------- */
74349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
753b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
76349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* This structure describes how to resume the execution.
77349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Currently, there is no way to resume only a specific thread.  */
78349a39142e16d060936911c1792cc0a5d2fe63fephilippestruct thread_resume
79349a39142e16d060936911c1792cc0a5d2fe63fephilippe{
80349a39142e16d060936911c1792cc0a5d2fe63fephilippe  /* If non-zero, we want to single-step.  */
81349a39142e16d060936911c1792cc0a5d2fe63fephilippe  int step;
823b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
83349a39142e16d060936911c1792cc0a5d2fe63fephilippe  /* If non-zero, send this signal when we resume.  */
84349a39142e16d060936911c1792cc0a5d2fe63fephilippe  int sig;
853b290486cd4cd601b20e04340e593c9ed9717e5fsewardj};
863b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
87349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Prepare to Resume (i.e. restart) the guest.
88349a39142e16d060936911c1792cc0a5d2fe63fephilippe   The resume info indicates how the resume will be done.
89349a39142e16d060936911c1792cc0a5d2fe63fephilippe   In case GDB has changed the program counter, valgrind_resume
90349a39142e16d060936911c1792cc0a5d2fe63fephilippe   will also ensure that the execution will be resumed at this
91349a39142e16d060936911c1792cc0a5d2fe63fephilippe   new program counter.
92349a39142e16d060936911c1792cc0a5d2fe63fephilippe   The Resume is really only executed once the gdbserver
93349a39142e16d060936911c1792cc0a5d2fe63fephilippe   returns (giving back the control to Valgrind). */
94349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void valgrind_resume (struct thread_resume *resume_info);
95349a39142e16d060936911c1792cc0a5d2fe63fephilippe
96349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* When Valgrind gets the control, it will execute the guest
97349a39142e16d060936911c1792cc0a5d2fe63fephilippe   process till there is a reason to call the gdbserver
98349a39142e16d060936911c1792cc0a5d2fe63fephilippe   again (e.g. because a breakpoint is encountered or the
99349a39142e16d060936911c1792cc0a5d2fe63fephilippe   tool reports an error).
100349a39142e16d060936911c1792cc0a5d2fe63fephilippe   In such case, the executionof guest code  stops, and the
101349a39142e16d060936911c1792cc0a5d2fe63fephilippe   control is given to gdbserver. Gdbserver will send a resume
102349a39142e16d060936911c1792cc0a5d2fe63fephilippe   reply packet to GDB.
103349a39142e16d060936911c1792cc0a5d2fe63fephilippe
104349a39142e16d060936911c1792cc0a5d2fe63fephilippe   valgrind_wait gets from Valgrind data structures the
105349a39142e16d060936911c1792cc0a5d2fe63fephilippe   information needed produce the resume reply for GDB:
106349a39142e16d060936911c1792cc0a5d2fe63fephilippe   a.o. OURSTATUS will be filled in with a response code to send to GDB.
107349a39142e16d060936911c1792cc0a5d2fe63fephilippe
108349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Returns the signal which caused the process to stop, in the
109349a39142e16d060936911c1792cc0a5d2fe63fephilippe   remote protocol numbering (e.g. TARGET_SIGNAL_STOP), or the
110349a39142e16d060936911c1792cc0a5d2fe63fephilippe   exit code as an integer if *OURSTATUS is 'W'.  */
111349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern unsigned char valgrind_wait (char *outstatus);
112349a39142e16d060936911c1792cc0a5d2fe63fephilippe
113349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* When execution is stopped and gdbserver has control, more
114349a39142e16d060936911c1792cc0a5d2fe63fephilippe   info about the stop reason can be retrieved using the following
115349a39142e16d060936911c1792cc0a5d2fe63fephilippe   functions. */
116349a39142e16d060936911c1792cc0a5d2fe63fephilippe
117349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* gets the addr at which a (possible) break must be ignored once.
118349a39142e16d060936911c1792cc0a5d2fe63fephilippe   If there is no such break to be ignored once, 0 is returned.
119349a39142e16d060936911c1792cc0a5d2fe63fephilippe   This is needed for the following case:
120349a39142e16d060936911c1792cc0a5d2fe63fephilippe   The user sets a break at address AAA.
121349a39142e16d060936911c1792cc0a5d2fe63fephilippe   The break is encountered. Then the user does stepi
122349a39142e16d060936911c1792cc0a5d2fe63fephilippe   (i.e. step one instruction).
123349a39142e16d060936911c1792cc0a5d2fe63fephilippe   In such a case, the already encountered break must be ignored
124349a39142e16d060936911c1792cc0a5d2fe63fephilippe   to ensure the stepi will advance by one instruction: a "break"
125349a39142e16d060936911c1792cc0a5d2fe63fephilippe   is implemented in valgrind by some helper code just after the
126349a39142e16d060936911c1792cc0a5d2fe63fephilippe   instruction mark at which the break is set. This helper code
127349a39142e16d060936911c1792cc0a5d2fe63fephilippe   verifies if either there is a break at the current PC
128349a39142e16d060936911c1792cc0a5d2fe63fephilippe   or if we are in stepping mode. If we are in stepping mode,
129349a39142e16d060936911c1792cc0a5d2fe63fephilippe   the already encountered break must be ignored once to advance
130349a39142e16d060936911c1792cc0a5d2fe63fephilippe   to the next instruction.
131349a39142e16d060936911c1792cc0a5d2fe63fephilippe   ??? need to check if this is *really* needed. */
132349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern Addr valgrind_get_ignore_break_once(void);
133349a39142e16d060936911c1792cc0a5d2fe63fephilippe
134349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* When addr > 0, ensures the next resume reply packet informs
135349a39142e16d060936911c1792cc0a5d2fe63fephilippe   gdb about the encountered watchpoint.
136349a39142e16d060936911c1792cc0a5d2fe63fephilippe   valgrind_stopped_by_watchpoint() will return 1 till reset.
137349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Use addr 0x0 to reset. */
138349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void VG_(set_watchpoint_stop_address) (Addr addr);
139349a39142e16d060936911c1792cc0a5d2fe63fephilippe
140349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise.  */
141349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_stopped_by_watchpoint (void);
142349a39142e16d060936911c1792cc0a5d2fe63fephilippe
143349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Returns the address associated with the watchpoint that hit, if any;
144349a39142e16d060936911c1792cc0a5d2fe63fephilippe   returns 0 otherwise.  */
145349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern CORE_ADDR valgrind_stopped_data_address (void);
146349a39142e16d060936911c1792cc0a5d2fe63fephilippe
147a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes
148a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes/* Inform GDB (if needed) that client is before (or after) syscall sysno.
149a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes   sysno -1 is used to clear the fact that a syscall has been encountered. */
150a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughesextern void gdbserver_syscall_encountered (Bool before, Int sysno);
151a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes
152a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes/* >= 0 if valgrind stopped due to syscall, -1 if not stopped due to syscall. */
153a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughesextern Int valgrind_stopped_by_syscall (void);
154a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes
155a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes/* if valgrind_stopped_by_syscall() >= 0, tells if stopped before or after
156a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes   syscall. */
157a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughesextern Bool valgrind_stopped_before_syscall (void);
158a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughes
159349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* True if gdbserver is single stepping the valgrind process */
160a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughesextern Bool valgrind_single_stepping (void);
161349a39142e16d060936911c1792cc0a5d2fe63fephilippe
162349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Set Valgrind in single stepping mode or not according to Bool. */
163a0664b9ca67b594bd6f570a61d3301167a24750cElliott Hughesextern void valgrind_set_single_stepping (Bool);
164349a39142e16d060936911c1792cc0a5d2fe63fephilippe
165349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
166349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* ----------------- Examining/modifying data while stopped ----------------- */
167349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
168349a39142e16d060936911c1792cc0a5d2fe63fephilippe
169349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Return 1 iff the thread with ID tid is alive.  */
170349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_thread_alive (unsigned long tid);
171349a39142e16d060936911c1792cc0a5d2fe63fephilippe
172349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Allows to controls the thread (current_inferior) used for following
173349a39142e16d060936911c1792cc0a5d2fe63fephilippe   valgrind_(fetch|store)_registers calls.
174349a39142e16d060936911c1792cc0a5d2fe63fephilippe   If USE_GENERAL,
175349a39142e16d060936911c1792cc0a5d2fe63fephilippe     current_inferior is set to general_thread
176349a39142e16d060936911c1792cc0a5d2fe63fephilippe   else
177349a39142e16d060936911c1792cc0a5d2fe63fephilippe     current_inferior is set to step_thread or else cont_thread.
178349a39142e16d060936911c1792cc0a5d2fe63fephilippe   If the above gives no valid thread, then current_inferior is
179349a39142e16d060936911c1792cc0a5d2fe63fephilippe   set to the first valid thread. */
180349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void set_desired_inferior (int use_general);
181349a39142e16d060936911c1792cc0a5d2fe63fephilippe
182349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Fetch registers from the current_inferior thread.
183349a39142e16d060936911c1792cc0a5d2fe63fephilippe   If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
184349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void valgrind_fetch_registers (int regno);
185349a39142e16d060936911c1792cc0a5d2fe63fephilippe
186349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Store registers to the current_inferior thread.
187349a39142e16d060936911c1792cc0a5d2fe63fephilippe   If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
188349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern void valgrind_store_registers (int regno);
189349a39142e16d060936911c1792cc0a5d2fe63fephilippe
190349a39142e16d060936911c1792cc0a5d2fe63fephilippe
191349a39142e16d060936911c1792cc0a5d2fe63fephilippe
192349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Read memory from the inferior process.
193349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Read LEN bytes at MEMADDR into a buffer at MYADDR.
194349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Returns 0 on success and errno on failure.  */
195349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_read_memory (CORE_ADDR memaddr,
196349a39142e16d060936911c1792cc0a5d2fe63fephilippe                                 unsigned char *myaddr, int len);
197349a39142e16d060936911c1792cc0a5d2fe63fephilippe
198349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Write memory to the inferior process.
199349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Write LEN bytes from the buffer at MYADDR to MEMADDR.
200349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Returns 0 on success and errno on failure.  */
201349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_write_memory (CORE_ADDR memaddr,
202349a39142e16d060936911c1792cc0a5d2fe63fephilippe                                  const unsigned char *myaddr, int len);
203349a39142e16d060936911c1792cc0a5d2fe63fephilippe
204349a39142e16d060936911c1792cc0a5d2fe63fephilippe
205349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* Insert and remove a hardware watchpoint.
206349a39142e16d060936911c1792cc0a5d2fe63fephilippe   Returns 0 on success, -1 on failure and 1 on unsupported.
207349a39142e16d060936911c1792cc0a5d2fe63fephilippe   The type is coded as follows:
208349a39142e16d060936911c1792cc0a5d2fe63fephilippe   2 = write watchpoint
209349a39142e16d060936911c1792cc0a5d2fe63fephilippe   3 = read watchpoint
210349a39142e16d060936911c1792cc0a5d2fe63fephilippe   4 = access watchpoint
211349a39142e16d060936911c1792cc0a5d2fe63fephilippe*/
212349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_insert_watchpoint (char type, CORE_ADDR addr, int len);
213349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern int valgrind_remove_watchpoint (char type, CORE_ADDR addr, int len);
214349a39142e16d060936911c1792cc0a5d2fe63fephilippe
2151670b05a4a415dbfd75b1a120713b4a206bb719ephilippe/* Get the address of a thread local variable.
2161670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   'tst' is the thread for which thread local address is searched for.
2171670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   'offset' is the offset of the variable in the tls data of the load
2181670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   module identified by 'lm'.
2191670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   'lm' is the link_map address of the loaded  module : it is the address
2201670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   of the data structure used by the dynamic linker to maintain various
2211670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   information about a loaded object.
2221670b05a4a415dbfd75b1a120713b4a206bb719ephilippe
2231670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   Returns True if the address of the variable could be found.
2241670b05a4a415dbfd75b1a120713b4a206bb719ephilippe      *tls_addr is then set to this address.
2251670b05a4a415dbfd75b1a120713b4a206bb719ephilippe   Returns False if tls support is not available for this arch, or
226ad4e979f408239dabbaae955d8ffcb84a51a5c85florian   if an error occurred. *tls_addr is set to NULL. */
2271670b05a4a415dbfd75b1a120713b4a206bb719ephilippeextern Bool valgrind_get_tls_addr (ThreadState *tst,
2281670b05a4a415dbfd75b1a120713b4a206bb719ephilippe                                   CORE_ADDR offset,
2291670b05a4a415dbfd75b1a120713b4a206bb719ephilippe                                   CORE_ADDR lm,
2301670b05a4a415dbfd75b1a120713b4a206bb719ephilippe                                   CORE_ADDR *tls_addr);
2311670b05a4a415dbfd75b1a120713b4a206bb719ephilippe
232349a39142e16d060936911c1792cc0a5d2fe63fephilippe
233349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
234349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* ----------- Utils functions for low level arch specific files ------------ */
235349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* -------------------------------------------------------------------------- */
236349a39142e16d060936911c1792cc0a5d2fe63fephilippe
2371670b05a4a415dbfd75b1a120713b4a206bb719ephilippe
238349a39142e16d060936911c1792cc0a5d2fe63fephilippe/* returns a pointer to the architecture state corresponding to
239349a39142e16d060936911c1792cc0a5d2fe63fephilippe   the provided register set: 0 => normal guest registers,
240349a39142e16d060936911c1792cc0a5d2fe63fephilippe                              1 => shadow1
241349a39142e16d060936911c1792cc0a5d2fe63fephilippe                              2 => shadow2
242349a39142e16d060936911c1792cc0a5d2fe63fephilippe*/
243349a39142e16d060936911c1792cc0a5d2fe63fephilippeextern VexGuestArchState* get_arch (int set, ThreadState* tst);
2443b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
2453b290486cd4cd601b20e04340e593c9ed9717e5fsewardj/* like memcpy but first check if content of destination and source
2463b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   differs. If no difference, no copy is done, *mod set to False.
2473b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   If different; copy is done, *mod set to True. */
2483b290486cd4cd601b20e04340e593c9ed9717e5fsewardjextern void* VG_(dmemcpy) ( void *d, const void *s, SizeT sz, Bool *mod );
2493b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
2503b290486cd4cd601b20e04340e593c9ed9717e5fsewardjtypedef
2513b290486cd4cd601b20e04340e593c9ed9717e5fsewardj   enum {
2523b290486cd4cd601b20e04340e593c9ed9717e5fsewardj      valgrind_to_gdbserver,
2533b290486cd4cd601b20e04340e593c9ed9717e5fsewardj      gdbserver_to_valgrind} transfer_direction;
2543b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
2553b290486cd4cd601b20e04340e593c9ed9717e5fsewardj// According to dir, calls VG_(dmemcpy)
2563b290486cd4cd601b20e04340e593c9ed9717e5fsewardj// to copy data from/to valgrind to/from gdbserver.
2573b290486cd4cd601b20e04340e593c9ed9717e5fsewardj// If the transferred data differs from what is currently stored,
2583b290486cd4cd601b20e04340e593c9ed9717e5fsewardj// sets *mod to True otherwise set *mod to False.
2593b290486cd4cd601b20e04340e593c9ed9717e5fsewardjextern void  VG_(transfer) (void *valgrind,
2603b290486cd4cd601b20e04340e593c9ed9717e5fsewardj                            void *gdbserver,
2613b290486cd4cd601b20e04340e593c9ed9717e5fsewardj                            transfer_direction dir,
2623b290486cd4cd601b20e04340e593c9ed9717e5fsewardj                            SizeT sz,
2633b290486cd4cd601b20e04340e593c9ed9717e5fsewardj                            Bool *mod);
2643b290486cd4cd601b20e04340e593c9ed9717e5fsewardj
265349a39142e16d060936911c1792cc0a5d2fe63fephilippe
266180a7500bf2464d5b16cddb5618b91fb3f095998philippe// True means gdbserver can access (internal) Valgrind memory.
267180a7500bf2464d5b16cddb5618b91fb3f095998philippe// Otherwise, only the client memory can be accessed.
268180a7500bf2464d5b16cddb5618b91fb3f095998philippeextern Bool hostvisibility;
269349a39142e16d060936911c1792cc0a5d2fe63fephilippe
2703b290486cd4cd601b20e04340e593c9ed9717e5fsewardj#endif /* TARGET_H */
271