From 2ec06d2e41be03b073bc2903804b8411258454f0 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Tue, 9 Apr 2002 22:44:43 +0000 Subject: [PATCH] 2002-04-09 Daniel Jacobowitz * linux-low.h: Remove obsolete prototypes. (struct linux_target_ops): New. (extern the_low_target): New. * linux-low.c (num_regs, regmap): Remove declarations. (register_addr): Use the_low_target explicitly. (fetch_register): Likewise. (usr_fetch_inferior_registers): Likewise. (usr_store_inferior_registers): Likewise. * linux-arm-low.c (num_regs): Remove. (arm_num_regs): Define. (arm_regmap): Renamed from regmap, made static. (arm_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (arm_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-i386-low.c (num_regs): Remove. (i386_num_regs): Define. (i386_regmap): Renamed from regmap, made static. (i386_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (i386_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-ia64-low.c (num_regs): Remove. (ia64_num_regs): Define. (ia64_regmap): Renamed from regmap, made static. (ia64_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (ia64_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-m68k-low.c (num_regs): Remove. (m68k_num_regs): Define. (m68k_regmap): Renamed from regmap, made static. (m68k_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (m68k_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-mips-low.c (num_regs): Remove. (mips_num_regs): Define. (mips_regmap): Renamed from regmap, made static. (mips_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (mips_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-ppc-low.c (num_regs): Remove. (ppc_num_regs): Define. (ppc_regmap): Renamed from regmap, made static. (ppc_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (ppc_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-s390-low.c (num_regs): Remove. (s390_num_regs): Define. (s390_regmap): Renamed from regmap, made static. (s390_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (s390_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-sh-low.c (num_regs): Remove. (sh_num_regs): Define. (sh_regmap): Renamed from regmap, made static. (sh_cannot_fetch_register): Renamed from cannot_fetch_register, made static. (sh_cannot_store_register): Renamed from cannot_store_register, made static. (the_low_target): New. * linux-x86-64-low.c (x86_64_regmap): Renamed from regmap. (the_low_target): New. --- gdb/ChangeLog | 77 ++++++++++++++++++++++++++++++++ gdb/gdbserver/linux-arm-low.c | 22 +++++---- gdb/gdbserver/linux-i386-low.c | 30 ++++++++----- gdb/gdbserver/linux-ia64-low.c | 18 +++++--- gdb/gdbserver/linux-low.c | 21 ++++----- gdb/gdbserver/linux-low.h | 17 ++++--- gdb/gdbserver/linux-m68k-low.c | 23 ++++++---- gdb/gdbserver/linux-mips-low.c | 23 ++++++---- gdb/gdbserver/linux-ppc-low.c | 18 +++++--- gdb/gdbserver/linux-s390-low.c | 23 ++++++---- gdb/gdbserver/linux-sh-low.c | 18 +++++--- gdb/gdbserver/linux-x86-64-low.c | 14 ++++-- 12 files changed, 218 insertions(+), 86 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d4eb5de41cd..a712c107c11 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,80 @@ +2002-04-09 Daniel Jacobowitz + + * linux-low.h: Remove obsolete prototypes. + (struct linux_target_ops): New. + (extern the_low_target): New. + * linux-low.c (num_regs, regmap): Remove declarations. + (register_addr): Use the_low_target explicitly. + (fetch_register): Likewise. + (usr_fetch_inferior_registers): Likewise. + (usr_store_inferior_registers): Likewise. + * linux-arm-low.c (num_regs): Remove. + (arm_num_regs): Define. + (arm_regmap): Renamed from regmap, made static. + (arm_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (arm_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-i386-low.c (num_regs): Remove. + (i386_num_regs): Define. + (i386_regmap): Renamed from regmap, made static. + (i386_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (i386_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-ia64-low.c (num_regs): Remove. + (ia64_num_regs): Define. + (ia64_regmap): Renamed from regmap, made static. + (ia64_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (ia64_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-m68k-low.c (num_regs): Remove. + (m68k_num_regs): Define. + (m68k_regmap): Renamed from regmap, made static. + (m68k_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (m68k_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-mips-low.c (num_regs): Remove. + (mips_num_regs): Define. + (mips_regmap): Renamed from regmap, made static. + (mips_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (mips_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-ppc-low.c (num_regs): Remove. + (ppc_num_regs): Define. + (ppc_regmap): Renamed from regmap, made static. + (ppc_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (ppc_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-s390-low.c (num_regs): Remove. + (s390_num_regs): Define. + (s390_regmap): Renamed from regmap, made static. + (s390_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (s390_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-sh-low.c (num_regs): Remove. + (sh_num_regs): Define. + (sh_regmap): Renamed from regmap, made static. + (sh_cannot_fetch_register): Renamed from cannot_fetch_register, + made static. + (sh_cannot_store_register): Renamed from cannot_store_register, + made static. + (the_low_target): New. + * linux-x86-64-low.c (x86_64_regmap): Renamed from regmap. + (the_low_target): New. + 2002-04-09 Andrew Cagney * frame.c (read_relative_register_raw_bytes_for_frame): Do not diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c index f873b071a81..2958fdf3129 100644 --- a/gdb/gdbserver/linux-arm-low.c +++ b/gdb/gdbserver/linux-arm-low.c @@ -26,22 +26,28 @@ #include #endif -int num_regs = 16; +#define arm_num_regs 16 -int regmap[] = { +static int arm_regmap[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, }; -int -cannot_store_register (int regno) +static int +arm_cannot_store_register (int regno) { - return (regno >= num_regs); + return (regno >= arm_num_regs); } -int -cannot_fetch_register (int regno) +static int +arm_cannot_fetch_register (int regno) { - return (regno >= num_regs); + return (regno >= arm_num_regs); } +struct linux_target_ops the_low_target = { + arm_num_regs, + arm_regmap, + arm_cannot_fetch_register, + arm_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-i386-low.c b/gdb/gdbserver/linux-i386-low.c index 2a66efaa70e..2a398d75510 100644 --- a/gdb/gdbserver/linux-i386-low.c +++ b/gdb/gdbserver/linux-i386-low.c @@ -29,13 +29,13 @@ /* This module only supports access to the general purpose registers. */ -int num_regs = 16; +#define i386_num_regs 16 /* This stuff comes from i386-linux-nat.c. */ /* Mapping between the general-purpose registers in `struct user' format and GDB's register array layout. */ -int regmap[] = +static int i386_regmap[] = { EAX * 4, ECX * 4, EDX * 4, EBX * 4, UESP * 4, EBP * 4, ESI * 4, EDI * 4, @@ -43,16 +43,16 @@ int regmap[] = DS * 4, ES * 4, FS * 4, GS * 4 }; -int -cannot_store_register (int regno) +static int +i386_cannot_store_register (int regno) { - return (regno >= num_regs); + return (regno >= i386_num_regs); } -int -cannot_fetch_register (int regno) +static int +i386_cannot_fetch_register (int regno) { - return (regno >= num_regs); + return (regno >= i386_num_regs); } @@ -65,8 +65,8 @@ i386_fill_gregset (void *buf) { int i; - for (i = 0; i < num_regs; i++) - collect_register (i, ((char *) buf) + regmap[i]); + for (i = 0; i < i386_num_regs; i++) + collect_register (i, ((char *) buf) + i386_regmap[i]); collect_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); } @@ -76,8 +76,8 @@ i386_store_gregset (void *buf) { int i; - for (i = 0; i < num_regs; i++) - supply_register (i, ((char *) buf) + regmap[i]); + for (i = 0; i < i386_num_regs; i++) + supply_register (i, ((char *) buf) + i386_regmap[i]); supply_register_by_name ("orig_eax", ((char *) buf) + ORIG_EAX * 4); } @@ -121,3 +121,9 @@ struct regset_info target_regsets[] = { #endif /* HAVE_LINUX_REGSETS */ +struct linux_target_ops the_low_target = { + i386_num_regs, + i386_regmap, + i386_cannot_fetch_register, + i386_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-ia64-low.c b/gdb/gdbserver/linux-ia64-low.c index f0f238f9320..9407e6cbcf7 100644 --- a/gdb/gdbserver/linux-ia64-low.c +++ b/gdb/gdbserver/linux-ia64-low.c @@ -26,11 +26,11 @@ #include #endif -int num_regs = 590; +#define ia64_num_regs 590 #include -int regmap[] = +static int ia64_regmap[] = { /* general registers */ -1, /* gr0 not available; i.e, it's always zero */ @@ -283,15 +283,21 @@ int regmap[] = -1, -1, -1, -1, -1, -1, -1, -1, }; -int -cannot_store_register (int regno) +static int +ia64_cannot_store_register (int regno) { return 0; } -int -cannot_fetch_register (int regno) +static int +ia64_cannot_fetch_register (int regno) { return 0; } +struct linux_target_ops the_low_target = { + ia64_num_regs, + ia64_regmap, + ia64_cannot_fetch_register, + ia64_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 7964f823248..307fab21a13 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -44,11 +44,6 @@ static int use_regsets_p = 1; extern int errno; -#ifdef HAVE_LINUX_USRREGS -extern int num_regs; -extern int regmap[]; -#endif - static int inferior_pid; /* Start an inferior process and returns its pid. @@ -175,10 +170,10 @@ register_addr (int regnum) { int addr; - if (regnum < 0 || regnum >= num_regs) + if (regnum < 0 || regnum >= the_low_target.num_regs) error ("Invalid register number %d.", regnum); - addr = regmap[regnum]; + addr = the_low_target.regmap[regnum]; if (addr == -1) addr = 0; @@ -192,9 +187,9 @@ fetch_register (int regno) CORE_ADDR regaddr; register int i; - if (regno >= num_regs) + if (regno >= the_low_target.num_regs) return; - if (cannot_fetch_register (regno)) + if ((*the_low_target.cannot_fetch_register) (regno)) return; regaddr = register_addr (regno); @@ -225,7 +220,7 @@ static void usr_fetch_inferior_registers (int regno) { if (regno == -1 || regno == 0) - for (regno = 0; regno < num_regs; regno++) + for (regno = 0; regno < the_low_target.num_regs; regno++) fetch_register (regno); else fetch_register (regno); @@ -242,10 +237,10 @@ usr_store_inferior_registers (int regno) if (regno >= 0) { - if (regno >= num_regs) + if (regno >= the_low_target.num_regs) return; - if (cannot_store_register (regno)) + if ((*the_low_target.cannot_store_register) (regno)) return; regaddr = register_addr (regno); @@ -272,7 +267,7 @@ usr_store_inferior_registers (int regno) } } else - for (regno = 0; regno < num_regs; regno++) + for (regno = 0; regno < the_low_target.num_regs; regno++) store_inferior_registers (regno); } #endif /* HAVE_LINUX_USRREGS */ diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index 5f06db14eb8..0d0050dcd58 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -18,13 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifdef HAVE_LINUX_USRREGS -extern int regmap[]; -extern int num_regs; -int cannot_fetch_register (int regno); -int cannot_store_register (int regno); -#endif - #ifdef HAVE_LINUX_REGSETS typedef void (*regset_func) (void *); struct regset_info @@ -35,3 +28,13 @@ struct regset_info }; extern struct regset_info target_regsets[]; #endif + +struct linux_target_ops +{ + int num_regs; + int *regmap; + int (*cannot_fetch_register) (int); + int (*cannot_store_register) (int); +}; + +extern struct linux_target_ops the_low_target; diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c index 9e59fbdeee9..760de6e0535 100644 --- a/gdb/gdbserver/linux-m68k-low.c +++ b/gdb/gdbserver/linux-m68k-low.c @@ -26,10 +26,10 @@ #include #endif -int num_regs = 31; +#define m68k_num_regs 31 /* This table must line up with REGISTER_NAMES in tm-m68k.h */ -int regmap[] = +static int m68k_regmap[] = { #ifdef PT_D0 PT_D0 * 4, PT_D1 * 4, PT_D2 * 4, PT_D3 * 4, @@ -52,14 +52,21 @@ int regmap[] = #endif }; -int -cannot_store_register (int regno) +static int +m68k_cannot_store_register (int regno) { - return (regno >= num_regs); + return (regno >= m68k_num_regs); } -int -cannot_fetch_register (int regno) +static int +m68k_cannot_fetch_register (int regno) { - return (regno >= num_regs); + return (regno >= m68k_num_regs); } + +struct linux_target_ops the_low_target = { + m68k_num_regs, + m68k_regmap, + m68k_cannot_fetch_register, + m68k_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index a9114d3fb64..f721ec94eeb 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -26,14 +26,14 @@ #include #endif -int num_regs = 90; +#define mips_num_regs 90 #include /* Return the ptrace ``address'' of register REGNO. */ /* Matches mips_generic32_regs */ -int regmap[] = { +static int mips_regmap[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, @@ -63,10 +63,10 @@ int regmap[] = { ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or FCRIR via ptrace(). */ -int -cannot_fetch_register (int regno) +static int +mips_cannot_fetch_register (int regno) { - if (regmap[regno] == -1) + if (mips_regmap[regno] == -1) return 1; if (find_regno ("zero") == regno) @@ -75,10 +75,10 @@ cannot_fetch_register (int regno) return 0; } -int -cannot_store_register (int regno) +static int +mips_cannot_store_register (int regno) { - if (regmap[regno] == -1) + if (mips_regmap[regno] == -1) return 1; if (find_regno ("zero") == regno) @@ -95,3 +95,10 @@ cannot_store_register (int regno) return 0; } + +struct linux_target_ops the_low_target = { + mips_num_regs, + mips_regmap, + mips_cannot_fetch_register, + mips_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index dcefa59a677..e626eab3cbc 100644 --- a/gdb/gdbserver/linux-ppc-low.c +++ b/gdb/gdbserver/linux-ppc-low.c @@ -25,10 +25,10 @@ #include -int num_regs = 71; +#define ppc_num_regs 71 /* Currently, don't check/send MQ. */ -int regmap[] = +static int ppc_regmap[] = {PT_R0 * 4, PT_R1 * 4, PT_R2 * 4, PT_R3 * 4, PT_R4 * 4, PT_R5 * 4, PT_R6 * 4, PT_R7 * 4, PT_R8 * 4, PT_R9 * 4, PT_R10 * 4, PT_R11 * 4, @@ -48,15 +48,21 @@ int regmap[] = PT_NIP * 4, PT_MSR * 4, PT_CCR * 4, PT_LNK * 4, PT_CTR * 4, PT_XER * 4, -1, }; -int -cannot_store_register (int regno) +static int +ppc_cannot_store_register (int regno) { return 0; } -int -cannot_fetch_register (int regno) +static int +ppc_cannot_fetch_register (int regno) { return 0; } +struct linux_target_ops the_low_target = { + ppc_num_regs, + ppc_regmap, + ppc_cannot_fetch_register, + ppc_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c index 1920b9c7ad4..8d800ae8b5f 100644 --- a/gdb/gdbserver/linux-s390-low.c +++ b/gdb/gdbserver/linux-s390-low.c @@ -27,9 +27,9 @@ #include -int num_regs = 67; +#define s390_num_regs 67 -int regmap[] = { +static int s390_regmap[] = { PT_PSWMASK, PT_PSWADDR, PT_GPR0, PT_GPR1, PT_GPR2, PT_GPR3, @@ -62,20 +62,27 @@ int regmap[] = { #endif }; -int -cannot_fetch_register (int regno) +static int +s390_cannot_fetch_register (int regno) { - if (regmap[regno] == -1) + if (s390_regmap[regno] == -1) return 1; return 0; } -int -cannot_store_register (int regno) +static int +s390_cannot_store_register (int regno) { - if (regmap[regno] == -1) + if (s390_regmap[regno] == -1) return 1; return 0; } + +struct linux_target_ops the_low_target = { + s390_num_regs, + s390_regmap, + s390_cannot_fetch_register, + s390_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-sh-low.c b/gdb/gdbserver/linux-sh-low.c index f763339e3d2..cdc390d2332 100644 --- a/gdb/gdbserver/linux-sh-low.c +++ b/gdb/gdbserver/linux-sh-low.c @@ -28,10 +28,10 @@ #include -int num_regs = 41; +#define sh_num_regs 41 /* Currently, don't check/send MQ. */ -int regmap[] = { +static int sh_regmap[] = { 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, @@ -45,15 +45,21 @@ int regmap[] = { REG_FPREG0+48, REG_FPREG0+52, REG_FPREG0+56, REG_FPREG0+60, }; -int -cannot_store_register (int regno) +static int +sh_cannot_store_register (int regno) { return 0; } -int -cannot_fetch_register (int regno) +static int +sh_cannot_fetch_register (int regno) { return 0; } +struct linux_target_ops the_low_target = { + sh_num_regs, + sh_regmap, + sh_cannot_fetch_register, + sh_cannot_store_register, +}; diff --git a/gdb/gdbserver/linux-x86-64-low.c b/gdb/gdbserver/linux-x86-64-low.c index d69b22ab361..e1248904aba 100644 --- a/gdb/gdbserver/linux-x86-64-low.c +++ b/gdb/gdbserver/linux-x86-64-low.c @@ -30,7 +30,7 @@ #define X86_64_NUM_GREGS 22 -static int regmap[X86_64_NUM_GREGS] = { +static int x86_64_regmap[X86_64_NUM_GREGS] = { RAX, RBX, RCX, RDX, RSI, RDI, RBP, RSP, R8, R9, R10, R11, @@ -45,7 +45,7 @@ x86_64_fill_gregset (void *buf) int i; for (i = 0; i < X86_64_NUM_GREGS; i++) - collect_register (i, ((char *) buf) + regmap[i]); + collect_register (i, ((char *) buf) + x86_64_regmap[i]); } static void @@ -54,7 +54,7 @@ x86_64_store_gregset (void *buf) int i; for (i = 0; i < X86_64_NUM_GREGS; i++) - supply_register (i, ((char *) buf) + regmap[i]); + supply_register (i, ((char *) buf) + x86_64_regmap[i]); } static void @@ -69,7 +69,6 @@ x86_64_store_fpregset (void *buf) i387_fxsave_to_cache (buf); } - struct regset_info target_regsets[] = { { PTRACE_GETREGS, PTRACE_SETREGS, sizeof (elf_gregset_t), x86_64_fill_gregset, x86_64_store_gregset }, @@ -77,3 +76,10 @@ struct regset_info target_regsets[] = { x86_64_fill_fpregset, x86_64_store_fpregset }, { 0, 0, -1, NULL, NULL } }; + +struct linux_target_ops the_low_target = { + -1, + NULL, + NULL, + NULL, +}; -- 2.30.2