Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit

This patch adds a pair of new functions linux_get_pc_32bit and
linux_set_pc_32bit which get and set 32-bit register "pc" from
regcache.  This function can be used some targets and these own
$ARCH_{get,set}_pc are replaced by linux_{get,set}_pc_32bit
respectively.

This patch touches many targets, but I only have arm board to
test and no regression.  I also rebuilt nios2-linux GDBserver.
If it is right to go, I'll post the 64-bit counterpart later.

gdb/gdbserver:

2016-01-18  Yao Qi  <yao.qi@linaro.org>

	* linux-arm-low.c (debug_threads): Remove declaration.
	(arm_get_pc, arm_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-bfin-low.c (bfin_get_pc, bfin_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-cris-low.c (debug_threads): Remove declaration.
	(cris_get_pc, cris_set_pc,): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-crisv32-low.c (debug_threads): Remove declaration.
	(cris_get_pc, cris_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-low.c: Include inttypes.h.
	(linux_get_pc_32bit, linux_set_pc_32bit): New functions.
	* linux-low.h (linux_get_pc_32bit, linux_set_pc_32bit): Declare.
	* linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-m68k-low.c (m68k_get_pc, m68k_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-nios2-low.c (nios2_get_pc, nios2_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-sh-low.c (sh_get_pc, sh_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
	* linux-xtensa-low.c (xtensa_get_pc, xtensa_set_pc): Remove.
	(the_low_target): Use linux_get_pc_32bit and
	linux_set_pc_32bit.
This commit is contained in:
Yao Qi 2016-01-18 14:49:50 +00:00
parent b27896961a
commit 276d4552df
12 changed files with 83 additions and 180 deletions

View File

@ -1,3 +1,39 @@
2016-01-18 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c (debug_threads): Remove declaration.
(arm_get_pc, arm_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-bfin-low.c (bfin_get_pc, bfin_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-cris-low.c (debug_threads): Remove declaration.
(cris_get_pc, cris_set_pc,): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-crisv32-low.c (debug_threads): Remove declaration.
(cris_get_pc, cris_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-low.c: Include inttypes.h.
(linux_get_pc_32bit, linux_set_pc_32bit): New functions.
* linux-low.h (linux_get_pc_32bit, linux_set_pc_32bit): Declare.
* linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-m68k-low.c (m68k_get_pc, m68k_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-nios2-low.c (nios2_get_pc, nios2_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-sh-low.c (sh_get_pc, sh_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-xtensa-low.c (xtensa_get_pc, xtensa_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
2016-01-18 Gary Benson <gbenson@redhat.com>
* configure.ac (AC_FUNC_FORK): New check.

View File

@ -245,25 +245,6 @@ arm_store_vfpregset (struct regcache *regcache, const void *buf)
arm_store_vfpregset_num (regcache, buf, num);
}
extern int debug_threads;
static CORE_ADDR
arm_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}
static void
arm_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
/* Wrapper of arm_is_thumb_mode for get_next_pcs. */
static int
get_next_pcs_is_thumb (struct arm_get_next_pcs *self)
@ -1011,8 +992,8 @@ struct linux_target_ops the_low_target = {
arm_cannot_fetch_register,
arm_cannot_store_register,
NULL, /* fetch_register */
arm_get_pc,
arm_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
arm_breakpoint_kind_from_pc,
arm_sw_breakpoint_from_kind,
arm_gdbserver_get_next_pcs,

View File

@ -54,24 +54,6 @@ bfin_cannot_fetch_register (int regno)
return (regno >= bfin_num_regs);
}
static CORE_ADDR
bfin_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
return pc;
}
static void
bfin_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
#define bfin_breakpoint_len 2
static const gdb_byte bfin_breakpoint[bfin_breakpoint_len] = {0xa1, 0x00};
@ -137,8 +119,8 @@ struct linux_target_ops the_low_target = {
bfin_cannot_fetch_register,
bfin_cannot_store_register,
NULL, /* fetch_register */
bfin_get_pc,
bfin_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
bfin_sw_breakpoint_from_kind,
NULL, /* get_next_pcs */

View File

@ -59,25 +59,6 @@ cris_cannot_fetch_register (int regno)
return (regno >= cris_num_regs);
}
extern int debug_threads;
static CORE_ADDR
cris_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}
static void
cris_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
static const unsigned short cris_breakpoint = 0xe938;
#define cris_breakpoint_len 2
@ -135,8 +116,8 @@ struct linux_target_ops the_low_target = {
cris_cannot_fetch_register,
cris_cannot_store_register,
NULL, /* fetch_register */
cris_get_pc,
cris_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
cris_sw_breakpoint_from_kind,
NULL, /* get_next_pcs */

View File

@ -55,25 +55,6 @@ static int cris_regmap[] = {
};
extern int debug_threads;
static CORE_ADDR
cris_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}
static void
cris_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
static const unsigned short cris_breakpoint = 0xe938;
#define cris_breakpoint_len 2
@ -418,8 +399,8 @@ struct linux_target_ops the_low_target = {
NULL,
NULL,
NULL, /* fetch_register */
cris_get_pc,
cris_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
cris_sw_breakpoint_from_kind,
NULL, /* get_next_pcs */

View File

@ -46,6 +46,7 @@
#include "filestuff.h"
#include "tracepoint.h"
#include "hostio.h"
#include <inttypes.h>
#ifndef ELFMAG0
/* Don't include <linux/elf.h> here. If it got included by gdb_proc_service.h
then ELFMAG0 will have been defined. If it didn't get included by
@ -7257,6 +7258,31 @@ linux_breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
return linux_breakpoint_kind_from_pc (pcptr);
}
/* Default implementation of linux_target_ops method "set_pc" for
32-bit pc register which is literally named "pc". */
void
linux_set_pc_32bit (struct regcache *regcache, CORE_ADDR pc)
{
uint32_t newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
/* Default implementation of linux_target_ops method "get_pc" for
32-bit pc register which is literally named "pc". */
CORE_ADDR
linux_get_pc_32bit (struct regcache *regcache)
{
uint32_t pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is 0x%" PRIx32 "\n", pc);
return pc;
}
static struct target_ops linux_target_ops = {
linux_create_inferior,
linux_post_create_inferior,

View File

@ -392,6 +392,9 @@ void initialize_regsets_info (struct regsets_info *regsets_info);
void initialize_low_arch (void);
void linux_set_pc_32bit (struct regcache *regcache, CORE_ADDR pc);
CORE_ADDR linux_get_pc_32bit (struct regcache *regcache);
/* From thread-db.c */
int thread_db_init (void);
void thread_db_detach (struct process_info *);

View File

@ -53,23 +53,6 @@ m32r_cannot_fetch_register (int regno)
return (regno >= m32r_num_regs);
}
static CORE_ADDR
m32r_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
if (debug_threads)
debug_printf ("stop pc is %08lx\n", pc);
return pc;
}
static void
m32r_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
static const unsigned short m32r_breakpoint = 0x10f1;
#define m32r_breakpoint_len 2
@ -135,8 +118,8 @@ struct linux_target_ops the_low_target = {
m32r_cannot_fetch_register,
m32r_cannot_store_register,
NULL, /* fetch_register */
m32r_get_pc,
m32r_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_from_pc */
m32r_sw_breakpoint_from_kind,
NULL,

View File

@ -134,23 +134,6 @@ m68k_sw_breakpoint_from_kind (int kind, int *size)
return m68k_breakpoint;
}
static CORE_ADDR
m68k_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
return pc;
}
static void
m68k_set_pc (struct regcache *regcache, CORE_ADDR value)
{
unsigned long newpc = value;
supply_register_by_name (regcache, "pc", &newpc);
}
static int
m68k_breakpoint_at (CORE_ADDR pc)
{
@ -222,8 +205,8 @@ struct linux_target_ops the_low_target = {
m68k_cannot_fetch_register,
m68k_cannot_store_register,
NULL, /* fetch_register */
m68k_get_pc,
m68k_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
m68k_sw_breakpoint_from_kind,
NULL,

View File

@ -95,28 +95,6 @@ nios2_cannot_store_register (int regno)
return 0;
}
/* Implement the get_pc linux_target_ops method. */
static CORE_ADDR
nios2_get_pc (struct regcache *regcache)
{
union nios2_register pc;
collect_register_by_name (regcache, "pc", pc.buf);
return pc.reg32;
}
/* Implement the set_pc linux_target_ops method. */
static void
nios2_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
union nios2_register newpc;
newpc.reg32 = pc;
supply_register_by_name (regcache, "pc", newpc.buf);
}
/* Breakpoint support. Also see comments on nios2_breakpoint_from_pc
in nios2-tdep.c. */
@ -263,8 +241,8 @@ struct linux_target_ops the_low_target =
nios2_cannot_fetch_register,
nios2_cannot_store_register,
NULL,
nios2_get_pc,
nios2_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
nios2_sw_breakpoint_from_kind,
NULL, /* get_next_pcs */

View File

@ -58,21 +58,6 @@ sh_cannot_fetch_register (int regno)
return 0;
}
static CORE_ADDR
sh_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
return pc;
}
static void
sh_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
/* Correct in either endianness, obviously. */
static const unsigned short sh_breakpoint = 0xc3c3;
#define sh_breakpoint_len 2
@ -163,8 +148,8 @@ struct linux_target_ops the_low_target = {
sh_cannot_fetch_register,
sh_cannot_store_register,
NULL, /* fetch_register */
sh_get_pc,
sh_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
sh_sw_breakpoint_from_kind,
NULL,

View File

@ -163,22 +163,6 @@ xtensa_sw_breakpoint_from_kind (int kind, int *size)
return xtensa_breakpoint;
}
static CORE_ADDR
xtensa_get_pc (struct regcache *regcache)
{
unsigned long pc;
collect_register_by_name (regcache, "pc", &pc);
return pc;
}
static void
xtensa_set_pc (struct regcache *regcache, CORE_ADDR pc)
{
unsigned long newpc = pc;
supply_register_by_name (regcache, "pc", &newpc);
}
static int
xtensa_breakpoint_at (CORE_ADDR where)
{
@ -249,8 +233,8 @@ struct linux_target_ops the_low_target = {
0,
0,
NULL, /* fetch_register */
xtensa_get_pc,
xtensa_set_pc,
linux_get_pc_32bit,
linux_set_pc_32bit,
NULL, /* breakpoint_kind_from_pc */
xtensa_sw_breakpoint_from_kind,
NULL,