gdbserver: decouple x86 watchpoint / hw breakpoint routines from Z packet numbers.
My main motivation here is moving in the direction of decoupling insert_point/remove_point from packet numbers, though this bit alone should make it a little bit easier to merge gdb/gdbserver/i386-low.c and gdb/i386-nat.c (which are largely the same). Tested on x86_64 Fedora 17, and cross built for i686-mingw32 too. gdb/gdbserver/ 2014-04-23 Pedro Alves <palves@redhat.com> * i386-low.c: Don't include break-common.h here. (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change prototype to take target_hw_bp_type as argument instead of a Z packet char. * i386-low.h: Include break-common.h here. (Z_packet_to_hw_type): Declare. (i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change prototypes. * linux-x86-low.c (x86_insert_point): Convert the packet number to a target_hw_bp_type before calling i386_low_insert_watchpoint. (x86_remove_point): Convert the packet number to a target_hw_bp_type before calling i386_low_remove_watchpoint. * win32-i386-low.c (i386_insert_point): Convert the packet number to a target_hw_bp_type before calling i386_low_insert_watchpoint. (i386_remove_point): Convert the packet number to a target_hw_bp_type before calling i386_low_remove_watchpoint.
This commit is contained in:
parent
b8acf84369
commit
a4165e94f4
|
@ -1,3 +1,22 @@
|
||||||
|
2014-04-23 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* i386-low.c: Don't include break-common.h here.
|
||||||
|
(i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
|
||||||
|
prototype to take target_hw_bp_type as argument instead of a Z
|
||||||
|
packet char.
|
||||||
|
* i386-low.h: Include break-common.h here.
|
||||||
|
(Z_packet_to_hw_type): Declare.
|
||||||
|
(i386_low_insert_watchpoint, i386_low_remove_watchpoint): Change
|
||||||
|
prototypes.
|
||||||
|
* linux-x86-low.c (x86_insert_point): Convert the packet number to
|
||||||
|
a target_hw_bp_type before calling i386_low_insert_watchpoint.
|
||||||
|
(x86_remove_point): Convert the packet number to a
|
||||||
|
target_hw_bp_type before calling i386_low_remove_watchpoint.
|
||||||
|
* win32-i386-low.c (i386_insert_point): Convert the packet number
|
||||||
|
to a target_hw_bp_type before calling i386_low_insert_watchpoint.
|
||||||
|
(i386_remove_point): Convert the packet number to a
|
||||||
|
target_hw_bp_type before calling i386_low_remove_watchpoint.
|
||||||
|
|
||||||
2014-04-23 Pedro Alves <palves@redhat.com>
|
2014-04-23 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* utils.h (perror_with_name): Add ATTRIBUTE_NORETURN.
|
* utils.h (perror_with_name): Add ATTRIBUTE_NORETURN.
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "i386-low.h"
|
#include "i386-low.h"
|
||||||
#include "break-common.h"
|
|
||||||
|
|
||||||
/* Support for 8-byte wide hw watchpoints. */
|
/* Support for 8-byte wide hw watchpoints. */
|
||||||
#ifndef TARGET_HAS_DR_LEN_8
|
#ifndef TARGET_HAS_DR_LEN_8
|
||||||
|
@ -408,9 +407,7 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n",
|
||||||
#define Z_PACKET_READ_WP '3'
|
#define Z_PACKET_READ_WP '3'
|
||||||
#define Z_PACKET_ACCESS_WP '4'
|
#define Z_PACKET_ACCESS_WP '4'
|
||||||
|
|
||||||
/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type. */
|
enum target_hw_bp_type
|
||||||
|
|
||||||
static enum target_hw_bp_type
|
|
||||||
Z_packet_to_hw_type (char type)
|
Z_packet_to_hw_type (char type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -457,10 +454,10 @@ i386_update_inferior_debug_regs (struct i386_debug_reg_state *inf_state,
|
||||||
|
|
||||||
int
|
int
|
||||||
i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
|
i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
|
||||||
char type_from_packet, CORE_ADDR addr, int len)
|
enum target_hw_bp_type type,
|
||||||
|
CORE_ADDR addr, int len)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet);
|
|
||||||
/* Work on a local copy of the debug registers, and on success,
|
/* Work on a local copy of the debug registers, and on success,
|
||||||
commit the change back to the inferior. */
|
commit the change back to the inferior. */
|
||||||
struct i386_debug_reg_state local_state = *state;
|
struct i386_debug_reg_state local_state = *state;
|
||||||
|
@ -493,14 +490,14 @@ i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
|
||||||
|
|
||||||
/* Remove a watchpoint that watched the memory region which starts at
|
/* Remove a watchpoint that watched the memory region which starts at
|
||||||
address ADDR, whose length is LEN bytes, and for accesses of the
|
address ADDR, whose length is LEN bytes, and for accesses of the
|
||||||
type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */
|
type TYPE. Return 0 on success, -1 on failure. */
|
||||||
|
|
||||||
int
|
int
|
||||||
i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
|
i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
|
||||||
char type_from_packet, CORE_ADDR addr, int len)
|
enum target_hw_bp_type type,
|
||||||
|
CORE_ADDR addr, int len)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
enum target_hw_bp_type type = Z_packet_to_hw_type (type_from_packet);
|
|
||||||
/* Work on a local copy of the debug registers, and on success,
|
/* Work on a local copy of the debug registers, and on success,
|
||||||
commit the change back to the inferior. */
|
commit the change back to the inferior. */
|
||||||
struct i386_debug_reg_state local_state = *state;
|
struct i386_debug_reg_state local_state = *state;
|
||||||
|
|
|
@ -29,6 +29,11 @@
|
||||||
counts, and allow to watch regions up to 16 bytes long
|
counts, and allow to watch regions up to 16 bytes long
|
||||||
(32 bytes on 64 bit hosts). */
|
(32 bytes on 64 bit hosts). */
|
||||||
|
|
||||||
|
#include "break-common.h"
|
||||||
|
|
||||||
|
/* Map the protocol watchpoint type TYPE to enum target_hw_bp_type. */
|
||||||
|
|
||||||
|
enum target_hw_bp_type Z_packet_to_hw_type (char type);
|
||||||
|
|
||||||
/* Debug registers' indices. */
|
/* Debug registers' indices. */
|
||||||
#define DR_FIRSTADDR 0
|
#define DR_FIRSTADDR 0
|
||||||
|
@ -58,16 +63,18 @@ extern void i386_low_init_dregs (struct i386_debug_reg_state *state);
|
||||||
|
|
||||||
/* Insert a watchpoint to watch a memory region which starts at
|
/* Insert a watchpoint to watch a memory region which starts at
|
||||||
address ADDR and whose length is LEN bytes. Watch memory accesses
|
address ADDR and whose length is LEN bytes. Watch memory accesses
|
||||||
of the type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */
|
of the type TYPE. Return 0 on success, -1 on failure. */
|
||||||
extern int i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
|
extern int i386_low_insert_watchpoint (struct i386_debug_reg_state *state,
|
||||||
char type_from_packet, CORE_ADDR addr,
|
enum target_hw_bp_type type,
|
||||||
|
CORE_ADDR addr,
|
||||||
int len);
|
int len);
|
||||||
|
|
||||||
/* Remove a watchpoint that watched the memory region which starts at
|
/* Remove a watchpoint that watched the memory region which starts at
|
||||||
address ADDR, whose length is LEN bytes, and for accesses of the
|
address ADDR, whose length is LEN bytes, and for accesses of the
|
||||||
type TYPE_FROM_PACKET. Return 0 on success, -1 on failure. */
|
type TYPE. Return 0 on success, -1 on failure. */
|
||||||
extern int i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
|
extern int i386_low_remove_watchpoint (struct i386_debug_reg_state *state,
|
||||||
char type_from_packet, CORE_ADDR addr,
|
enum target_hw_bp_type type,
|
||||||
|
CORE_ADDR addr,
|
||||||
int len);
|
int len);
|
||||||
|
|
||||||
/* Return non-zero if we can watch a memory region that starts at
|
/* Return non-zero if we can watch a memory region that starts at
|
||||||
|
|
|
@ -641,8 +641,13 @@ x86_insert_point (char type, CORE_ADDR addr, int len)
|
||||||
case '2': /* write watchpoint */
|
case '2': /* write watchpoint */
|
||||||
case '3': /* read watchpoint */
|
case '3': /* read watchpoint */
|
||||||
case '4': /* access watchpoint */
|
case '4': /* access watchpoint */
|
||||||
return i386_low_insert_watchpoint (&proc->private->arch_private->debug_reg_state,
|
{
|
||||||
type, addr, len);
|
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
||||||
|
struct i386_debug_reg_state *state
|
||||||
|
= &proc->private->arch_private->debug_reg_state;
|
||||||
|
|
||||||
|
return i386_low_insert_watchpoint (state, hw_type, addr, len);
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Unsupported. */
|
/* Unsupported. */
|
||||||
|
@ -671,8 +676,13 @@ x86_remove_point (char type, CORE_ADDR addr, int len)
|
||||||
case '2': /* write watchpoint */
|
case '2': /* write watchpoint */
|
||||||
case '3': /* read watchpoint */
|
case '3': /* read watchpoint */
|
||||||
case '4': /* access watchpoint */
|
case '4': /* access watchpoint */
|
||||||
return i386_low_remove_watchpoint (&proc->private->arch_private->debug_reg_state,
|
{
|
||||||
type, addr, len);
|
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
||||||
|
struct i386_debug_reg_state *state
|
||||||
|
= &proc->private->arch_private->debug_reg_state;
|
||||||
|
|
||||||
|
return i386_low_remove_watchpoint (state, hw_type, addr, len);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
/* Unsupported. */
|
/* Unsupported. */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -105,8 +105,12 @@ i386_insert_point (char type, CORE_ADDR addr, int len)
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
return i386_low_insert_watchpoint (&debug_reg_state,
|
{
|
||||||
type, addr, len);
|
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
||||||
|
|
||||||
|
return i386_low_insert_watchpoint (&debug_reg_state,
|
||||||
|
hw_type, addr, len);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
/* Unsupported. */
|
/* Unsupported. */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -121,8 +125,12 @@ i386_remove_point (char type, CORE_ADDR addr, int len)
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
return i386_low_remove_watchpoint (&debug_reg_state,
|
{
|
||||||
type, addr, len);
|
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
||||||
|
|
||||||
|
return i386_low_remove_watchpoint (&debug_reg_state,
|
||||||
|
hw_type, addr, len);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
/* Unsupported. */
|
/* Unsupported. */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue