GDBserver
Loading...
Searching...
No Matches
Macros | Enumerations | Functions
x86-dregs.c File Reference
#include "gdbsupport/common-defs.h"
#include "x86-dregs.h"
#include "gdbsupport/break-common.h"

Go to the source code of this file.

Macros

#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 bool x86_dr_low_can_set_addr ()
 
static void x86_dr_low_set_addr (struct x86_debug_reg_state *new_state, int i)
 
static CORE_ADDR x86_dr_low_get_addr (int i)
 
static bool x86_dr_low_can_set_control ()
 
static void x86_dr_low_set_control (struct x86_debug_reg_state *new_state)
 
static unsigned long x86_dr_low_get_control ()
 
static unsigned long x86_dr_low_get_status ()
 
static int x86_get_debug_register_length ()
 
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)
 
int x86_dr_stopped_by_hw_breakpoint (struct x86_debug_reg_state *state)
 

Macro Definition Documentation

◆ DR_CONTROL_RESERVED

#define DR_CONTROL_RESERVED   (0xFC00)

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

◆ DR_CONTROL_SHIFT

#define DR_CONTROL_SHIFT   16

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

◆ DR_CONTROL_SIZE

#define DR_CONTROL_SIZE   4

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

◆ DR_ENABLE_SIZE

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

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

◆ DR_GLOBAL_ENABLE_SHIFT

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

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

◆ DR_GLOBAL_SLOWDOWN

#define DR_GLOBAL_SLOWDOWN   (0x200)

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

◆ DR_LEN_1

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_LEN_2

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_LEN_4

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_LEN_8

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_LOCAL_ENABLE_SHIFT

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

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

◆ DR_LOCAL_SLOWDOWN

#define DR_LOCAL_SLOWDOWN   (0x100)

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

Referenced by x86_insert_aligned_watchpoint().

◆ DR_RW_EXECUTE

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_RW_IORW

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_RW_READ

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

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

Referenced by x86_length_and_rw_bits().

◆ DR_RW_WRITE

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

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

Referenced by x86_length_and_rw_bits().

◆ TARGET_HAS_DR_LEN_8

#define TARGET_HAS_DR_LEN_8   (x86_get_debug_register_length () == 8)

◆ X86_DR_CONTROL_MASK

#define X86_DR_CONTROL_MASK   (~DR_CONTROL_RESERVED)

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

Referenced by x86_insert_aligned_watchpoint().

◆ X86_DR_DISABLE

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

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

Referenced by x86_remove_aligned_watchpoint().

◆ X86_DR_GET_RW_LEN

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

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

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

◆ X86_DR_GLOBAL_ENABLE

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

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

◆ X86_DR_LOCAL_ENABLE

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

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

Referenced by x86_insert_aligned_watchpoint().

◆ X86_DR_SET_RW_LEN

#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)

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

Referenced by x86_insert_aligned_watchpoint(), and x86_remove_aligned_watchpoint().

◆ X86_DR_VACANT

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

◆ X86_DR_WATCH_HIT

#define X86_DR_WATCH_HIT ( dr6,
i )   ((dr6) & (1 << (i)))

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

Referenced by x86_dr_stopped_by_hw_breakpoint(), and x86_dr_stopped_data_address().

Enumeration Type Documentation

◆ x86_wp_op_t

Enumerator
WP_INSERT 
WP_REMOVE 
WP_COUNT 

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

Function Documentation

◆ x86_dr_insert_watchpoint()

int x86_dr_insert_watchpoint ( struct x86_debug_reg_state * state,
enum target_hw_bp_type type,
CORE_ADDR addr,
int len )

◆ x86_dr_low_can_set_addr()

static bool x86_dr_low_can_set_addr ( )
static

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

References x86_dr_low_type::set_addr, and x86_dr_low.

Referenced by x86_insert_aligned_watchpoint().

◆ x86_dr_low_can_set_control()

static bool x86_dr_low_can_set_control ( )
static

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

References x86_dr_low_type::set_control, and x86_dr_low.

Referenced by x86_insert_aligned_watchpoint().

◆ x86_dr_low_get_addr()

static CORE_ADDR x86_dr_low_get_addr ( int i)
static

◆ x86_dr_low_get_control()

static unsigned long x86_dr_low_get_control ( )
static

◆ x86_dr_low_get_status()

static unsigned long x86_dr_low_get_status ( )
static

◆ x86_dr_low_set_addr()

static void x86_dr_low_set_addr ( struct x86_debug_reg_state * new_state,
int i )
static

◆ x86_dr_low_set_control()

static void x86_dr_low_set_control ( struct x86_debug_reg_state * new_state)
static

◆ x86_dr_region_ok_for_watchpoint()

int x86_dr_region_ok_for_watchpoint ( struct x86_debug_reg_state * state,
CORE_ADDR addr,
int len )

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

References DR_NADDR, WP_COUNT, and x86_handle_nonaligned_watchpoint().

◆ x86_dr_remove_watchpoint()

int x86_dr_remove_watchpoint ( struct x86_debug_reg_state * state,
enum target_hw_bp_type type,
CORE_ADDR addr,
int len )

◆ x86_dr_stopped_by_hw_breakpoint()

int x86_dr_stopped_by_hw_breakpoint ( struct x86_debug_reg_state * state)

◆ x86_dr_stopped_by_watchpoint()

int x86_dr_stopped_by_watchpoint ( struct x86_debug_reg_state * state)

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

References x86_dr_stopped_data_address().

◆ x86_dr_stopped_data_address()

int x86_dr_stopped_data_address ( struct x86_debug_reg_state * state,
CORE_ADDR * addr_p )

◆ x86_get_debug_register_length()

static int x86_get_debug_register_length ( )
static

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

References x86_dr_low_type::debug_register_length, and x86_dr_low.

Referenced by x86_show_dr().

◆ x86_handle_nonaligned_watchpoint()

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

◆ x86_insert_aligned_watchpoint()

static int x86_insert_aligned_watchpoint ( struct x86_debug_reg_state * state,
CORE_ADDR addr,
unsigned len_rw_bits )
static

◆ x86_length_and_rw_bits()

static unsigned x86_length_and_rw_bits ( int len,
enum target_hw_bp_type type )
static

◆ x86_remove_aligned_watchpoint()

static int x86_remove_aligned_watchpoint ( struct x86_debug_reg_state * state,
CORE_ADDR addr,
unsigned len_rw_bits )
static

◆ x86_show_dr()

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

◆ x86_update_inferior_debug_regs()

static void x86_update_inferior_debug_regs ( struct x86_debug_reg_state * state,
struct x86_debug_reg_state * new_state )
static