23 #include "floatformat.h"
27 #include <mach_error.h>
28 #include <mach/message.h>
29 #include <mach/exception.h>
38 #define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
50 #define REG_ADDR(state, regnum) ((char *)(state) + reg_offset[regnum])
59 mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT;
60 struct i386_float_state state;
63 err = thread_get_state (thread->
port, i386_FLOAT_STATE,
64 (thread_state_t) &state, &count);
67 warning (
_(
"Couldn't fetch floating-point state from %s"),
72 if (!state.initialized)
97 error (
_(
"Can't fetch registers from thread %s: No such thread"),
102 thread_state_t
state;
108 warning (
_(
"Couldn't fetch registers from %s"),
137 proc_debug (thread,
"fetching floating-point registers");
149 mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT;
150 struct i386_float_state state;
153 err = thread_get_state (thread->
port, i386_FLOAT_STATE,
154 (thread_state_t) &state, &count);
157 warning (
_(
"Couldn't fetch floating-point state from %s"),
166 err = thread_set_state (thread->
port, i386_FLOAT_STATE,
167 (thread_state_t) &state, i386_FLOAT_STATE_COUNT);
170 warning (
_(
"Couldn't store floating-point state into %s"),
190 error (
_(
"Couldn't store registers into thread %s: No such thread"),
195 thread_state_t state;
196 thread_state_data_t old_state;
197 int was_aborted = thread->
aborted;
201 if (!was_aborted && was_valid)
202 memcpy (&old_state, &thread->
state, sizeof (old_state));
207 warning (
_(
"Couldn't store registers into %s"),
214 trace = ((
struct i386_thread_state *)state)->efl & 0x100;
216 if (!was_aborted && was_valid)
221 for (check_regno = 0; check_regno <
I386_NUM_GREGS; check_regno++)
223 && memcpy (
REG_ADDR (&old_state, check_regno),
228 warning (
_(
"Register %s changed after the thread was aborted"),
230 if (regno >= 0 && regno != check_regno)
235 warning (
_(
"... also writing this register! "
260 ((
struct i386_thread_state *)state)->efl &= ~0x100;
261 ((
struct i386_thread_state *)state)->efl |= trace;
266 proc_debug (thread,
"storing floating-point registers");
275 #ifdef i386_DEBUG_STATE
279 i386_gnu_dr_get (
struct i386_debug_state *regs,
struct proc *thread)
281 mach_msg_type_number_t count = i386_DEBUG_STATE_COUNT;
284 err = thread_get_state (thread->
port, i386_DEBUG_STATE,
285 (thread_state_t) regs, &count);
286 if (err != 0 || count != i386_DEBUG_STATE_COUNT)
287 warning (
_(
"Couldn't fetch debug state from %s"),
294 i386_gnu_dr_set (
const struct i386_debug_state *regs,
struct proc *thread)
298 err = thread_set_state (thread->
port, i386_DEBUG_STATE,
299 (thread_state_t) regs, i386_DEBUG_STATE_COUNT);
301 warning (
_(
"Couldn't store debug state into %s"),
308 i386_gnu_dr_set_control_one (
struct proc *thread,
void *arg)
310 unsigned long *control = arg;
311 struct i386_debug_state regs;
313 i386_gnu_dr_get (®s, thread);
315 i386_gnu_dr_set (®s, thread);
321 i386_gnu_dr_set_control (
unsigned long control)
338 i386_gnu_dr_set_addr_one (
struct proc *thread,
void *arg)
340 struct reg_addr *reg_addr = arg;
341 struct i386_debug_state regs;
343 i386_gnu_dr_get (®s, thread);
344 regs.dr[reg_addr->regnum] = reg_addr->addr;
345 i386_gnu_dr_set (®s, thread);
351 i386_gnu_dr_set_addr (
int regnum,
CORE_ADDR addr)
353 struct reg_addr reg_addr;
358 reg_addr.addr = addr;
367 i386_gnu_dr_get_reg (
ptid_t ptid,
int regnum)
369 struct i386_debug_state regs;
376 i386_gnu_dr_get (®s, thread);
384 i386_gnu_dr_get_addr (
int regnum)
394 i386_gnu_dr_get_status (
void)
402 i386_gnu_dr_get_control (
void)
419 #ifdef i386_DEBUG_STATE
void add_target(struct target_ops *t)
void i387_collect_fsave(const struct regcache *regcache, int regnum, void *fsave)
char * proc_string(struct proc *proc)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
void warning(const char *fmt,...)
unsigned long fetched_regs
static void store_fpregs(const struct regcache *regcache, struct proc *thread, int regno)
void inf_threads(struct inf *inf, inf_threads_ftype *f, void *arg)
void i387_supply_fsave(struct regcache *regcache, int regnum, const void *fsave)
char * target_pid_to_str(ptid_t ptid)
void(* set_control)(unsigned long)
struct x86_dr_low_type x86_dr_low
CORE_ADDR(* get_addr)(int)
static void gnu_store_registers(struct target_ops *ops, struct regcache *regcache, int regno)
static void gnu_fetch_registers(struct target_ops *ops, struct regcache *regcache, int regno)
initialize_file_ftype _initialize_i386gnu_nat
void(* set_addr)(int, CORE_ADDR)
void initialize_file_ftype(void)
unsigned long(* get_status)(void)
thread_state_data_t state
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t err
struct target_ops * gnu_target(void)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
static void fetch_fpregs(struct regcache *regcache, struct proc *thread)
unsigned long(* get_control)(void)
int inf_update_procs(struct inf *inf)
struct inf * gnu_current_inf
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
enum register_status regcache_register_status(const struct regcache *regcache, int regnum)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
void x86_set_debug_register_length(int len)
int register_size(struct gdbarch *gdbarch, int regnum)
long ptid_get_lwp(ptid_t ptid)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
void x86_use_watchpoints(struct target_ops *t)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
thread_state_t proc_get_state(struct proc *proc, int will_modify)
void error(const char *fmt,...)
#define REG_ADDR(state, regnum)
struct proc * inf_tid_to_thread(struct inf *inf, int tid)
#define proc_debug(_proc, msg, args...)