mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-26 07:19:16 +08:00
[GDBserver] Move Z packet defines and type convertion routines to shared code.
The Aarch64, MIPS and x86 Linux backends all have Z packet number defines and corresponding protocol number to internal type convertion routines. Factor them all out to gdbserver's core code, so we only have one shared copy. Tested on x86_64 Fedora 20, and also cross built for aarch64-linux-gnu and mips-linux-gnu. gdb/gdbserver/ 2014-05-20 Pedro Alves <palves@redhat.com> * mem-break.h: Include break-common.h. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): New defines. (Z_packet_to_target_hw_bp_type): New declaration. * mem-break.c (Z_packet_to_target_hw_bp_type): New function. * i386-low.c (Z_PACKET_HW_BP, Z_PACKET_WRITE_WP, Z_PACKET_READ_WP) (Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_hw_type): Delete function. * i386-low.h: Don't include break-common.h here. (Z_packet_to_hw_type): Delete declaration. * linux-x86-low.c (x86_insert_point, x86_insert_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * win32-i386-low.c (i386_insert_point, i386_remove_point): Call Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type. * linux-aarch64-low.c: Don't include break-common.h here. (Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP) (Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): Delete macros. (Z_packet_to_target_hw_bp_type): Delete function. * linux-mips-low.c (rsp_bp_type_to_target_hw_bp_type): Delete function. (mips_insert_point, mips_remove_point): Use Z_packet_to_target_hw_bp_type.
This commit is contained in:
@ -1,3 +1,28 @@
|
|||||||
|
2014-05-20 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* mem-break.h: Include break-common.h.
|
||||||
|
(Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP)
|
||||||
|
(Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): New defines.
|
||||||
|
(Z_packet_to_target_hw_bp_type): New declaration.
|
||||||
|
* mem-break.c (Z_packet_to_target_hw_bp_type): New function.
|
||||||
|
* i386-low.c (Z_PACKET_HW_BP, Z_PACKET_WRITE_WP, Z_PACKET_READ_WP)
|
||||||
|
(Z_PACKET_ACCESS_WP): Delete macros.
|
||||||
|
(Z_packet_to_hw_type): Delete function.
|
||||||
|
* i386-low.h: Don't include break-common.h here.
|
||||||
|
(Z_packet_to_hw_type): Delete declaration.
|
||||||
|
* linux-x86-low.c (x86_insert_point, x86_insert_point): Call
|
||||||
|
Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type.
|
||||||
|
* win32-i386-low.c (i386_insert_point, i386_remove_point): Call
|
||||||
|
Z_packet_to_target_hw_bp_type instead of Z_packet_to_hw_type.
|
||||||
|
* linux-aarch64-low.c: Don't include break-common.h here.
|
||||||
|
(Z_PACKET_SW_BP, Z_PACKET_HW_BP, Z_PACKET_WRITE_WP)
|
||||||
|
(Z_PACKET_READ_WP, Z_PACKET_ACCESS_WP): Delete macros.
|
||||||
|
(Z_packet_to_target_hw_bp_type): Delete function.
|
||||||
|
* linux-mips-low.c (rsp_bp_type_to_target_hw_bp_type): Delete
|
||||||
|
function.
|
||||||
|
(mips_insert_point, mips_remove_point): Use
|
||||||
|
Z_packet_to_target_hw_bp_type.
|
||||||
|
|
||||||
2014-05-20 Pedro Alves <palves@redhat.com>
|
2014-05-20 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* linux-aarch64-low.c: Include break-common.h.
|
* linux-aarch64-low.c: Include break-common.h.
|
||||||
|
@ -402,29 +402,6 @@ Invalid value %d of operation in i386_handle_nonaligned_watchpoint.\n",
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Z_PACKET_HW_BP '1'
|
|
||||||
#define Z_PACKET_WRITE_WP '2'
|
|
||||||
#define Z_PACKET_READ_WP '3'
|
|
||||||
#define Z_PACKET_ACCESS_WP '4'
|
|
||||||
|
|
||||||
enum target_hw_bp_type
|
|
||||||
Z_packet_to_hw_type (char type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case Z_PACKET_HW_BP:
|
|
||||||
return hw_execute;
|
|
||||||
case Z_PACKET_WRITE_WP:
|
|
||||||
return hw_write;
|
|
||||||
case Z_PACKET_READ_WP:
|
|
||||||
return hw_read;
|
|
||||||
case Z_PACKET_ACCESS_WP:
|
|
||||||
return hw_access;
|
|
||||||
default:
|
|
||||||
fatal ("Z_packet_to_hw_type: bad watchpoint type %c", type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Update the inferior debug registers state, in INF_STATE, with the
|
/* Update the inferior debug registers state, in INF_STATE, with the
|
||||||
new debug registers state, in NEW_STATE. */
|
new debug registers state, in NEW_STATE. */
|
||||||
|
|
||||||
|
@ -29,12 +29,6 @@
|
|||||||
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
|
||||||
#define DR_LASTADDR 3
|
#define DR_LASTADDR 3
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
||||||
#include "gdb_proc_service.h"
|
#include "gdb_proc_service.h"
|
||||||
#include "break-common.h"
|
|
||||||
|
|
||||||
/* Defined in auto-generated files. */
|
/* Defined in auto-generated files. */
|
||||||
void init_registers_aarch64 (void);
|
void init_registers_aarch64 (void);
|
||||||
@ -209,33 +208,6 @@ struct arch_lwp_info
|
|||||||
static int aarch64_num_bp_regs;
|
static int aarch64_num_bp_regs;
|
||||||
static int aarch64_num_wp_regs;
|
static int aarch64_num_wp_regs;
|
||||||
|
|
||||||
#define Z_PACKET_SW_BP '0'
|
|
||||||
#define Z_PACKET_HW_BP '1'
|
|
||||||
#define Z_PACKET_WRITE_WP '2'
|
|
||||||
#define Z_PACKET_READ_WP '3'
|
|
||||||
#define Z_PACKET_ACCESS_WP '4'
|
|
||||||
|
|
||||||
/* Map the protocol breakpoint/watchpoint type TYPE to enum
|
|
||||||
target_hw_bp_type. */
|
|
||||||
|
|
||||||
static enum target_hw_bp_type
|
|
||||||
Z_packet_to_target_hw_bp_type (char type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case Z_PACKET_HW_BP:
|
|
||||||
return hw_execute;
|
|
||||||
case Z_PACKET_WRITE_WP:
|
|
||||||
return hw_write;
|
|
||||||
case Z_PACKET_READ_WP:
|
|
||||||
return hw_read;
|
|
||||||
case Z_PACKET_ACCESS_WP:
|
|
||||||
return hw_access;
|
|
||||||
default:
|
|
||||||
fatal ("bad watchpoint type %c", type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aarch64_cannot_store_register (int regno)
|
aarch64_cannot_store_register (int regno)
|
||||||
{
|
{
|
||||||
|
@ -372,24 +372,6 @@ mips_linux_prepare_to_resume (struct lwp_info *lwp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translate breakpoint type TYPE in rsp to 'enum target_hw_bp_type'. */
|
|
||||||
|
|
||||||
static enum target_hw_bp_type
|
|
||||||
rsp_bp_type_to_target_hw_bp_type (char type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case '2':
|
|
||||||
return hw_write;
|
|
||||||
case '3':
|
|
||||||
return hw_read;
|
|
||||||
case '4':
|
|
||||||
return hw_access;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdb_assert_not_reached ("unhandled RSP breakpoint type");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is the implementation of linux_target_ops method
|
/* This is the implementation of linux_target_ops method
|
||||||
insert_point. */
|
insert_point. */
|
||||||
|
|
||||||
@ -434,7 +416,7 @@ mips_insert_point (char type, CORE_ADDR addr, int len)
|
|||||||
mips_linux_watch_populate_regs (private->current_watches, ®s);
|
mips_linux_watch_populate_regs (private->current_watches, ®s);
|
||||||
|
|
||||||
/* Now try to add the new watch. */
|
/* Now try to add the new watch. */
|
||||||
watch_type = rsp_bp_type_to_target_hw_bp_type (type);
|
watch_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
irw = mips_linux_watch_type_to_irw (watch_type);
|
irw = mips_linux_watch_type_to_irw (watch_type);
|
||||||
if (!mips_linux_watch_try_one_watch (®s, addr, len, irw))
|
if (!mips_linux_watch_try_one_watch (®s, addr, len, irw))
|
||||||
return -1;
|
return -1;
|
||||||
@ -490,7 +472,7 @@ mips_remove_point (char type, CORE_ADDR addr, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Search for a known watch that matches. Then unlink and free it. */
|
/* Search for a known watch that matches. Then unlink and free it. */
|
||||||
watch_type = rsp_bp_type_to_target_hw_bp_type (type);
|
watch_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
deleted_one = 0;
|
deleted_one = 0;
|
||||||
pw = &private->current_watches;
|
pw = &private->current_watches;
|
||||||
while ((w = *pw))
|
while ((w = *pw))
|
||||||
|
@ -668,7 +668,7 @@ x86_insert_point (char type, CORE_ADDR addr, int len)
|
|||||||
case '3': /* read watchpoint */
|
case '3': /* read watchpoint */
|
||||||
case '4': /* access watchpoint */
|
case '4': /* access watchpoint */
|
||||||
{
|
{
|
||||||
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
struct i386_debug_reg_state *state
|
struct i386_debug_reg_state *state
|
||||||
= &proc->private->arch_private->debug_reg_state;
|
= &proc->private->arch_private->debug_reg_state;
|
||||||
|
|
||||||
@ -703,7 +703,7 @@ x86_remove_point (char type, CORE_ADDR addr, int len)
|
|||||||
case '3': /* read watchpoint */
|
case '3': /* read watchpoint */
|
||||||
case '4': /* access watchpoint */
|
case '4': /* access watchpoint */
|
||||||
{
|
{
|
||||||
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
struct i386_debug_reg_state *state
|
struct i386_debug_reg_state *state
|
||||||
= &proc->private->arch_private->debug_reg_state;
|
= &proc->private->arch_private->debug_reg_state;
|
||||||
|
|
||||||
|
@ -138,6 +138,24 @@ struct breakpoint
|
|||||||
int (*handler) (CORE_ADDR);
|
int (*handler) (CORE_ADDR);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum target_hw_bp_type
|
||||||
|
Z_packet_to_target_hw_bp_type (char type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case Z_PACKET_HW_BP:
|
||||||
|
return hw_execute;
|
||||||
|
case Z_PACKET_WRITE_WP:
|
||||||
|
return hw_write;
|
||||||
|
case Z_PACKET_READ_WP:
|
||||||
|
return hw_read;
|
||||||
|
case Z_PACKET_ACCESS_WP:
|
||||||
|
return hw_access;
|
||||||
|
default:
|
||||||
|
fatal ("bad watchpoint type %c", type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
any_persistent_commands ()
|
any_persistent_commands ()
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,23 @@
|
|||||||
#ifndef MEM_BREAK_H
|
#ifndef MEM_BREAK_H
|
||||||
#define MEM_BREAK_H
|
#define MEM_BREAK_H
|
||||||
|
|
||||||
|
#include "break-common.h"
|
||||||
|
|
||||||
/* Breakpoints are opaque. */
|
/* Breakpoints are opaque. */
|
||||||
struct breakpoint;
|
struct breakpoint;
|
||||||
struct fast_tracepoint_jump;
|
struct fast_tracepoint_jump;
|
||||||
|
|
||||||
|
#define Z_PACKET_SW_BP '0'
|
||||||
|
#define Z_PACKET_HW_BP '1'
|
||||||
|
#define Z_PACKET_WRITE_WP '2'
|
||||||
|
#define Z_PACKET_READ_WP '3'
|
||||||
|
#define Z_PACKET_ACCESS_WP '4'
|
||||||
|
|
||||||
|
/* Map the protocol breakpoint/watchpoint type TYPE to enum
|
||||||
|
target_hw_bp_type. */
|
||||||
|
|
||||||
|
enum target_hw_bp_type Z_packet_to_target_hw_bp_type (char type);
|
||||||
|
|
||||||
/* Create a new GDB breakpoint at WHERE. Returns -1 if breakpoints
|
/* Create a new GDB breakpoint at WHERE. Returns -1 if breakpoints
|
||||||
are not supported on this target, 0 otherwise. */
|
are not supported on this target, 0 otherwise. */
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ i386_insert_point (char type, CORE_ADDR addr, int len)
|
|||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
{
|
{
|
||||||
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
|
|
||||||
return i386_low_insert_watchpoint (&debug_reg_state,
|
return i386_low_insert_watchpoint (&debug_reg_state,
|
||||||
hw_type, addr, len);
|
hw_type, addr, len);
|
||||||
@ -126,7 +126,7 @@ i386_remove_point (char type, CORE_ADDR addr, int len)
|
|||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
{
|
{
|
||||||
enum target_hw_bp_type hw_type = Z_packet_to_hw_type (type);
|
enum target_hw_bp_type hw_type = Z_packet_to_target_hw_bp_type (type);
|
||||||
|
|
||||||
return i386_low_remove_watchpoint (&debug_reg_state,
|
return i386_low_remove_watchpoint (&debug_reg_state,
|
||||||
hw_type, addr, len);
|
hw_type, addr, len);
|
||||||
|
Reference in New Issue
Block a user