27#include <mach_error.h>
28#include <mach/message.h>
29#include <mach/exception.h>
35#include "floatformat.h"
44#define REG_OFFSET(reg) offsetof (struct i386_thread_state, reg)
56#define REG_ADDR(state, regnum) ((char *)(state) + reg_offset[regnum])
62#ifdef i386_DEBUG_STATE
82 mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT;
83 struct i386_float_state state;
86 err = thread_get_state (thread->
port, i386_FLOAT_STATE,
87 (thread_state_t) &state, &count);
90 warning (_(
"Couldn't fetch floating-point state from %s"),
95 if (!state.initialized)
119 error (_(
"Can't fetch registers from thread %s: No such thread"),
124 thread_state_t state;
130 warning (_(
"Couldn't fetch registers from %s"),
158 proc_debug (thread,
"fetching floating-point registers");
170 mach_msg_type_number_t count = i386_FLOAT_STATE_COUNT;
171 struct i386_float_state state;
174 err = thread_get_state (thread->
port, i386_FLOAT_STATE,
175 (thread_state_t) &state, &count);
178 warning (_(
"Couldn't fetch floating-point state from %s"),
187 err = thread_set_state (thread->
port, i386_FLOAT_STATE,
188 (thread_state_t) &state, i386_FLOAT_STATE_COUNT);
191 warning (_(
"Couldn't store floating-point state into %s"),
210 error (_(
"Couldn't store registers into thread %s: No such thread"),
215 thread_state_t state;
216 thread_state_data_t old_state;
217 int was_aborted = thread->
aborted;
221 if (!was_aborted && was_valid)
222 memcpy (&old_state, &thread->
state, sizeof (old_state));
227 warning (_(
"Couldn't store registers into %s"),
234 trace = ((
struct i386_thread_state *)state)->efl & 0x100;
236 if (!was_aborted && was_valid)
241 for (check_regno = 0; check_regno <
I386_NUM_GREGS; check_regno++)
243 && memcpy (
REG_ADDR (&old_state, check_regno),
248 warning (_(
"Register %s changed after the thread was aborted"),
250 if (regno >= 0 && regno != check_regno)
255 warning (_(
"... also writing this register! "
280 ((
struct i386_thread_state *)state)->efl &= ~0x100;
281 ((
struct i386_thread_state *)state)->efl |= trace;
286 proc_debug (thread,
"storing floating-point registers");
295#ifdef i386_DEBUG_STATE
299i386_gnu_dr_get (
struct i386_debug_state *regs,
struct proc *thread)
301 mach_msg_type_number_t count = i386_DEBUG_STATE_COUNT;
304 err = thread_get_state (thread->
port, i386_DEBUG_STATE,
305 (thread_state_t) regs, &count);
306 if (
err != 0 || count != i386_DEBUG_STATE_COUNT)
307 warning (_(
"Couldn't fetch debug state from %s"),
314i386_gnu_dr_set (
const struct i386_debug_state *regs,
struct proc *thread)
318 err = thread_set_state (thread->
port, i386_DEBUG_STATE,
319 (thread_state_t) regs, i386_DEBUG_STATE_COUNT);
321 warning (_(
"Couldn't store debug state into %s"),
328i386_gnu_dr_set_control_one (
struct proc *thread,
void *arg)
330 unsigned long *control = (
unsigned long *) arg;
331 struct i386_debug_state regs;
333 i386_gnu_dr_get (®s, thread);
335 i386_gnu_dr_set (®s, thread);
341i386_gnu_dr_set_control (
unsigned long control)
358i386_gnu_dr_set_addr_one (
struct proc *thread,
void *arg)
360 struct reg_addr *reg_addr = (
struct reg_addr *) arg;
361 struct i386_debug_state regs;
363 i386_gnu_dr_get (®s, thread);
364 regs.dr[reg_addr->regnum] = reg_addr->addr;
365 i386_gnu_dr_set (®s, thread);
371i386_gnu_dr_set_addr (
int regnum, CORE_ADDR addr)
373 struct reg_addr reg_addr;
378 reg_addr.addr = addr;
387i386_gnu_dr_get_reg (ptid_t ptid,
int regnum)
389 struct i386_debug_state regs;
396 i386_gnu_dr_get (®s, thread);
404i386_gnu_dr_get_addr (
int regnum)
414i386_gnu_dr_get_status (
void)
422i386_gnu_dr_get_control (
void)
432#ifdef i386_DEBUG_STATE
void raw_collect(int regnum, void *buf) const override
void raw_supply(int regnum, const void *buf) override
enum register_status get_register_status(int regnum) const override
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
struct inf * gnu_current_inf
char * proc_string(struct proc *proc)
struct proc * inf_tid_to_thread(struct inf *inf, int tid)
int inf_update_procs(struct inf *inf)
struct gnu_nat_target * gnu_target
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
void inf_threads(struct inf *inf, inf_threads_ftype *f, void *arg)
#define proc_debug(_proc, msg, args...)
static void store_fpregs(const struct regcache *regcache, struct proc *thread, int regno)
static i386_gnu_nat_target the_i386_gnu_nat_target
static void fetch_fpregs(struct regcache *regcache, struct proc *thread)
void _initialize_i386gnu_nat()
#define REG_ADDR(state, regnum)
void i387_supply_fsave(struct regcache *regcache, int regnum, const void *fsave)
void i387_collect_fsave(const struct regcache *regcache, int regnum, void *fsave)
void add_inf_child_target(inf_child_target *target)
int register_size(struct gdbarch *gdbarch, int regnum)
thread_state_t proc_get_state(struct proc *proc, int will_modify)
void store_registers(struct regcache *, int) override
void fetch_registers(struct regcache *, int) override
unsigned long fetched_regs
thread_state_data_t state
void(* set_addr)(int, CORE_ADDR)
unsigned long(* get_control)(void)
unsigned long(* get_status)(void)
void(* set_control)(unsigned long)
CORE_ADDR(* get_addr)(int)
std::string target_pid_to_str(ptid_t ptid)
struct x86_dr_low_type x86_dr_low
void x86_set_debug_register_length(int len)