38 #define x86_dr_low_can_set_addr() (x86_dr_low.set_addr != NULL)
41 #define x86_dr_low_set_addr(new_state, i) \
42 (x86_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
45 #define x86_dr_low_get_addr(i) (x86_dr_low.get_addr ((i)))
48 #define x86_dr_low_can_set_control() (x86_dr_low.set_control != NULL)
51 #define x86_dr_low_set_control(new_state) \
52 (x86_dr_low.set_control ((new_state)->dr_control_mirror))
55 #define x86_dr_low_get_control() (x86_dr_low.get_control ())
58 #define x86_dr_low_get_status() (x86_dr_low.get_status ())
61 #define x86_get_debug_register_length() \
62 (x86_dr_low.debug_register_length)
65 #define TARGET_HAS_DR_LEN_8 (x86_get_debug_register_length () == 8)
70 #define DR_CONTROL_SHIFT 16
72 #define DR_CONTROL_SIZE 4
75 #define DR_RW_EXECUTE (0x0)
76 #define DR_RW_WRITE (0x1)
77 #define DR_RW_READ (0x3)
83 #define DR_RW_IORW (0x2)
88 #define DR_LEN_1 (0x0 << 2)
89 #define DR_LEN_2 (0x1 << 2)
90 #define DR_LEN_4 (0x3 << 2)
91 #define DR_LEN_8 (0x2 << 2)
104 #define DR_LOCAL_ENABLE_SHIFT 0
105 #define DR_GLOBAL_ENABLE_SHIFT 1
106 #define DR_ENABLE_SIZE 2
113 #define DR_LOCAL_SLOWDOWN (0x100)
114 #define DR_GLOBAL_SLOWDOWN (0x200)
121 #define DR_CONTROL_RESERVED (0xFC00)
126 #define X86_DR_CONTROL_MASK (~DR_CONTROL_RESERVED)
130 #define X86_DR_VACANT(state, i) \
131 (((state)->dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0)
134 #define X86_DR_LOCAL_ENABLE(state, i) \
136 (state)->dr_control_mirror |= \
137 (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i))); \
141 #define X86_DR_GLOBAL_ENABLE(state, i) \
143 (state)->dr_control_mirror |= \
144 (1 << (DR_GLOBAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i))); \
148 #define X86_DR_DISABLE(state, i) \
150 (state)->dr_control_mirror &= \
151 ~(3 << (DR_ENABLE_SIZE * (i))); \
155 #define X86_DR_SET_RW_LEN(state, i, rwlen) \
157 (state)->dr_control_mirror &= \
158 ~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))); \
159 (state)->dr_control_mirror |= \
160 ((rwlen) << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))); \
164 #define X86_DR_GET_RW_LEN(dr7, i) \
166 >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f)
169 #define X86_DR_WATCH_HIT(dr6, i) ((dr6) & (1 << (i)))
188 : (type ==
hw_read ?
"data-read"
202 \tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n",
232 _(
"The i386 doesn't support "
233 "data-read watchpoints.\n"));
245 Invalid hardware breakpoint type %d in x86_length_and_rw_bits.\n"),
263 Invalid hardware breakpoint length %d in x86_length_and_rw_bits.\n"), len);
393 static const int size_try_array[8][8] =
395 {1, 1, 1, 1, 1, 1, 1, 1},
396 {2, 1, 2, 1, 2, 1, 2, 1},
397 {2, 1, 2, 1, 2, 1, 2, 1},
398 {4, 1, 2, 1, 4, 1, 2, 1},
399 {4, 1, 2, 1, 4, 1, 2, 1},
400 {4, 1, 2, 1, 4, 1, 2, 1},
401 {4, 1, 2, 1, 4, 1, 2, 1},
402 {8, 1, 2, 1, 4, 1, 2, 1},
407 int align = addr % max_wp_len;
410 int attempt = (len > max_wp_len ? (max_wp_len - 1) : len - 1);
411 int size = size_try_array[attempt][align];
433 Invalid value %d of operation in x86_handle_nonaligned_watchpoint.\n"),
486 if (((len != 1 && len != 2 && len != 4)
506 x86_show_dr (state,
"insert_watchpoint", addr, len, type);
525 if (((len != 1 && len != 2 && len != 4)
545 x86_show_dr (state,
"remove_watchpoint", addr, len, type);
584 unsigned control = 0;
static void x86_update_inferior_debug_regs(struct x86_debug_reg_state *state, struct x86_debug_reg_state *new_state)
#define X86_DR_WATCH_HIT(dr6, i)
#define x86_dr_low_get_status()
#define x86_dr_low_set_control(new_state)
unsigned dr_control_mirror
#define DR_LOCAL_SLOWDOWN
char * phex(ULONGEST l, int sizeof_l)
#define TARGET_HAS_DR_LEN_8
void internal_error(const char *file, int line, const char *fmt,...)
#define x86_dr_low_get_control()
#define X86_DR_DISABLE(state, i)
static void x86_show_dr(struct x86_debug_reg_state *state, const char *func, CORE_ADDR addr, int len, enum target_hw_bp_type type)
int x86_dr_remove_watchpoint(struct x86_debug_reg_state *state, enum target_hw_bp_type type, CORE_ADDR addr, int len)
int x86_dr_stopped_data_address(struct x86_debug_reg_state *state, CORE_ADDR *addr_p)
#define x86_dr_low_can_set_addr()
static int x86_handle_nonaligned_watchpoint(struct x86_debug_reg_state *state, x86_wp_op_t what, CORE_ADDR addr, int len, enum target_hw_bp_type type)
#define X86_DR_CONTROL_MASK
int x86_dr_insert_watchpoint(struct x86_debug_reg_state *state, enum target_hw_bp_type type, CORE_ADDR addr, int len)
int x86_dr_region_ok_for_watchpoint(struct x86_debug_reg_state *state, CORE_ADDR addr, int len)
CORE_ADDR dr_mirror[DR_NADDR]
#define x86_dr_low_get_addr(i)
#define x86_dr_low_can_set_control()
int x86_dr_stopped_by_watchpoint(struct x86_debug_reg_state *state)
#define x86_dr_low_set_addr(new_state, i)
#define X86_DR_SET_RW_LEN(state, i, rwlen)
int dr_ref_count[DR_NADDR]
#define ALL_DEBUG_ADDRESS_REGISTERS(i)
static int x86_remove_aligned_watchpoint(struct x86_debug_reg_state *state, CORE_ADDR addr, unsigned len_rw_bits)
static unsigned x86_length_and_rw_bits(int len, enum target_hw_bp_type type)
#define X86_DR_GET_RW_LEN(dr7, i)
unsigned dr_status_mirror
void debug_printf(const char *fmt,...)
#define x86_get_debug_register_length()
static int x86_insert_aligned_watchpoint(struct x86_debug_reg_state *state, CORE_ADDR addr, unsigned len_rw_bits)
#define X86_DR_LOCAL_ENABLE(state, i)
#define X86_DR_VACANT(state, i)