GDBserver
Macros | Enumerations | Functions
x86-dregs.c File Reference
#include "common-defs.h"
#include "x86-dregs.h"
#include "break-common.h"

Go to the source code of this file.

Macros

#define x86_dr_low_can_set_addr()   (x86_dr_low.set_addr != NULL)
 
#define x86_dr_low_set_addr(new_state, i)   (x86_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
 
#define x86_dr_low_get_addr(i)   (x86_dr_low.get_addr ((i)))
 
#define x86_dr_low_can_set_control()   (x86_dr_low.set_control != NULL)
 
#define x86_dr_low_set_control(new_state)   (x86_dr_low.set_control ((new_state)->dr_control_mirror))
 
#define x86_dr_low_get_control()   (x86_dr_low.get_control ())
 
#define x86_dr_low_get_status()   (x86_dr_low.get_status ())
 
#define x86_get_debug_register_length()   (x86_dr_low.debug_register_length)
 
#define TARGET_HAS_DR_LEN_8   (x86_get_debug_register_length () == 8)
 
#define DR_CONTROL_SHIFT   16
 
#define DR_CONTROL_SIZE   4
 
#define DR_RW_EXECUTE   (0x0) /* Break on instruction execution. */
 
#define DR_RW_WRITE   (0x1) /* Break on data writes. */
 
#define DR_RW_READ   (0x3) /* Break on data reads or writes. */
 
#define DR_RW_IORW   (0x2) /* Break on I/O reads or writes. */
 
#define DR_LEN_1   (0x0 << 2) /* 1-byte region watch or breakpoint. */
 
#define DR_LEN_2   (0x1 << 2) /* 2-byte region watch. */
 
#define DR_LEN_4   (0x3 << 2) /* 4-byte region watch. */
 
#define DR_LEN_8   (0x2 << 2) /* 8-byte region watch (AMD64). */
 
#define DR_LOCAL_ENABLE_SHIFT   0 /* Extra shift to the local enable bit. */
 
#define DR_GLOBAL_ENABLE_SHIFT   1 /* Extra shift to the global enable bit. */
 
#define DR_ENABLE_SIZE   2 /* Two enable bits per debug register. */
 
#define DR_LOCAL_SLOWDOWN   (0x100)
 
#define DR_GLOBAL_SLOWDOWN   (0x200)
 
#define DR_CONTROL_RESERVED   (0xFC00)
 
#define X86_DR_CONTROL_MASK   (~DR_CONTROL_RESERVED)
 
#define X86_DR_VACANT(state, i)   (((state)->dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0)
 
#define X86_DR_LOCAL_ENABLE(state, i)
 
#define X86_DR_GLOBAL_ENABLE(state, i)
 
#define X86_DR_DISABLE(state, i)
 
#define X86_DR_SET_RW_LEN(state, i, rwlen)
 
#define X86_DR_GET_RW_LEN(dr7, i)
 
#define X86_DR_WATCH_HIT(dr6, i)   ((dr6) & (1 << (i)))
 

Enumerations

enum  x86_wp_op_t { WP_INSERT, WP_REMOVE, WP_COUNT }
 

Functions

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)
 
static unsigned x86_length_and_rw_bits (int len, enum target_hw_bp_type type)
 
static int x86_insert_aligned_watchpoint (struct x86_debug_reg_state *state, CORE_ADDR addr, unsigned len_rw_bits)
 
static int x86_remove_aligned_watchpoint (struct x86_debug_reg_state *state, CORE_ADDR addr, unsigned len_rw_bits)
 
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)
 
static void x86_update_inferior_debug_regs (struct x86_debug_reg_state *state, struct x86_debug_reg_state *new_state)
 
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_remove_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)
 
int x86_dr_stopped_data_address (struct x86_debug_reg_state *state, CORE_ADDR *addr_p)
 
int x86_dr_stopped_by_watchpoint (struct x86_debug_reg_state *state)
 

Macro Definition Documentation

#define DR_CONTROL_RESERVED   (0xFC00)

Definition at line 121 of file x86-dregs.c.

#define DR_CONTROL_SHIFT   16

Definition at line 70 of file x86-dregs.c.

#define DR_CONTROL_SIZE   4

Definition at line 72 of file x86-dregs.c.

#define DR_ENABLE_SIZE   2 /* Two enable bits per debug register. */

Definition at line 106 of file x86-dregs.c.

#define DR_GLOBAL_ENABLE_SHIFT   1 /* Extra shift to the global enable bit. */

Definition at line 105 of file x86-dregs.c.

#define DR_GLOBAL_SLOWDOWN   (0x200)

Definition at line 114 of file x86-dregs.c.

#define DR_LEN_1   (0x0 << 2) /* 1-byte region watch or breakpoint. */

Definition at line 88 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_LEN_2   (0x1 << 2) /* 2-byte region watch. */

Definition at line 89 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_LEN_4   (0x3 << 2) /* 4-byte region watch. */

Definition at line 90 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_LEN_8   (0x2 << 2) /* 8-byte region watch (AMD64). */

Definition at line 91 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_LOCAL_ENABLE_SHIFT   0 /* Extra shift to the local enable bit. */

Definition at line 104 of file x86-dregs.c.

#define DR_LOCAL_SLOWDOWN   (0x100)

Definition at line 113 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint(), and x86_remove_aligned_watchpoint().

#define DR_RW_EXECUTE   (0x0) /* Break on instruction execution. */

Definition at line 75 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_RW_IORW   (0x2) /* Break on I/O reads or writes. */

Definition at line 83 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_RW_READ   (0x3) /* Break on data reads or writes. */

Definition at line 77 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define DR_RW_WRITE   (0x1) /* Break on data writes. */

Definition at line 76 of file x86-dregs.c.

Referenced by x86_length_and_rw_bits().

#define TARGET_HAS_DR_LEN_8   (x86_get_debug_register_length () == 8)
#define X86_DR_CONTROL_MASK   (~DR_CONTROL_RESERVED)

Definition at line 126 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint().

#define X86_DR_DISABLE (   state,
 
)
Value:
do { \
(state)->dr_control_mirror &= \
~(3 << (DR_ENABLE_SIZE * (i))); \
} while (0)
#define DR_ENABLE_SIZE
Definition: x86-dregs.c:106

Definition at line 148 of file x86-dregs.c.

Referenced by x86_remove_aligned_watchpoint().

#define X86_DR_GET_RW_LEN (   dr7,
 
)
Value:
(((dr7) \
>> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f)
#define DR_CONTROL_SIZE
Definition: x86-dregs.c:72
#define DR_CONTROL_SHIFT
Definition: x86-dregs.c:70

Definition at line 164 of file x86-dregs.c.

Referenced by x86_dr_stopped_data_address(), x86_insert_aligned_watchpoint(), and x86_remove_aligned_watchpoint().

#define X86_DR_GLOBAL_ENABLE (   state,
 
)
Value:
do { \
(state)->dr_control_mirror |= \
} while (0)
#define DR_ENABLE_SIZE
Definition: x86-dregs.c:106
#define DR_GLOBAL_ENABLE_SHIFT
Definition: x86-dregs.c:105

Definition at line 141 of file x86-dregs.c.

#define X86_DR_LOCAL_ENABLE (   state,
 
)
Value:
do { \
(state)->dr_control_mirror |= \
} while (0)
#define DR_ENABLE_SIZE
Definition: x86-dregs.c:106
#define DR_LOCAL_ENABLE_SHIFT
Definition: x86-dregs.c:104

Definition at line 134 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint().

#define x86_dr_low_can_set_addr ( )    (x86_dr_low.set_addr != NULL)

Definition at line 38 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint().

#define x86_dr_low_can_set_control ( )    (x86_dr_low.set_control != NULL)

Definition at line 48 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint().

#define x86_dr_low_get_addr (   i)    (x86_dr_low.get_addr ((i)))

Definition at line 45 of file x86-dregs.c.

Referenced by x86_dr_stopped_data_address().

#define x86_dr_low_get_control (   void)    (x86_dr_low.get_control ())

Definition at line 55 of file x86-dregs.c.

Referenced by x86_dr_stopped_data_address().

#define x86_dr_low_get_status (   void)    (x86_dr_low.get_status ())

Definition at line 58 of file x86-dregs.c.

Referenced by x86_dr_stopped_data_address().

#define x86_dr_low_set_addr (   new_state,
 
)    (x86_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))

Definition at line 41 of file x86-dregs.c.

Referenced by x86_update_inferior_debug_regs().

#define x86_dr_low_set_control (   new_state)    (x86_dr_low.set_control ((new_state)->dr_control_mirror))

Definition at line 51 of file x86-dregs.c.

Referenced by x86_update_inferior_debug_regs().

#define X86_DR_SET_RW_LEN (   state,
  i,
  rwlen 
)
Value:
do { \
(state)->dr_control_mirror &= \
~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))); \
(state)->dr_control_mirror |= \
((rwlen) << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))); \
} while (0)
#define DR_CONTROL_SIZE
Definition: x86-dregs.c:72
#define DR_CONTROL_SHIFT
Definition: x86-dregs.c:70

Definition at line 155 of file x86-dregs.c.

Referenced by x86_insert_aligned_watchpoint(), and x86_remove_aligned_watchpoint().

#define X86_DR_VACANT (   state,
 
)    (((state)->dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0)
#define X86_DR_WATCH_HIT (   dr6,
 
)    ((dr6) & (1 << (i)))

Definition at line 169 of file x86-dregs.c.

Referenced by x86_dr_stopped_data_address().

#define x86_get_debug_register_length ( )    (x86_dr_low.debug_register_length)

Definition at line 61 of file x86-dregs.c.

Referenced by x86_show_dr().

Enumeration Type Documentation

Enumerator
WP_INSERT 
WP_REMOVE 
WP_COUNT 

Definition at line 172 of file x86-dregs.c.

Function Documentation

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 
)

Definition at line 554 of file x86-dregs.c.

References DR_NADDR, hw_write, WP_COUNT, and x86_handle_nonaligned_watchpoint().

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_by_watchpoint ( struct x86_debug_reg_state state)

Definition at line 651 of file x86-dregs.c.

References x86_dr_stopped_data_address().

Referenced by x86_stopped_by_watchpoint().

int x86_dr_stopped_data_address ( struct x86_debug_reg_state state,
CORE_ADDR addr_p 
)
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 
)
static
static int x86_insert_aligned_watchpoint ( struct x86_debug_reg_state state,
CORE_ADDR  addr,
unsigned  len_rw_bits 
)
static
static unsigned x86_length_and_rw_bits ( int  len,
enum target_hw_bp_type  type 
)
static
static int x86_remove_aligned_watchpoint ( struct x86_debug_reg_state state,
CORE_ADDR  addr,
unsigned  len_rw_bits 
)
static
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 
)
static
static void x86_update_inferior_debug_regs ( struct x86_debug_reg_state state,
struct x86_debug_reg_state new_state 
)
static