* [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux
@ 2007-04-23 15:47 Ulrich Weigand
2007-04-24 21:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2007-04-23 15:47 UTC (permalink / raw)
To: gdb-patches
Hello,
this is the updated mips-linux patch. Main difference is moving
mips_linux_cannot_fetch_register and mips_linux_cannot_store_register
to mips-linux-tdep.c and installing them as gdbarch callbacks.
Tested by building --target=mips-linux and --host=mips-linux.
Bye,
Ulrich
ChangeLog:
* config/mips/linux.mh (NAT_FILE): Set to config/nm-linux.h.
* config/mips/nm-linux.h: Delete file.
* mips-linux-nat.c: No longer include "gdbcore.h".
(mips_linux_cannot_fetch_register): Move to mips-linux-tdep.c
(mips_linux_cannot_store_register): Likewise.
(mips_linux_register_addr): Move from mips-linux-tdep.c.
(mips64_linux_register_addr): Likewise.
(mips_linux_register_u_offset): Call mips_linux_cannot_fetch_register
and mips_linux_cannot_store_register instead of CANNOT_FETCH_REGISTER
and CANNOT_STORE_REGISTER. Call mips_linux_register_addr or
mips64_linux_register_addr instead of register_addr.
* mips-linux-tdep.c (mips_linux_cannot_fetch_register,
mips_linux_cannot_store_register): Move from mips-linux-nat.c.
(mips_linux_register_addr, mips64_linux_register_addr): Move to
mips-linux-nat.c.
(register_addr): Remove.
(register_addr_data, init_register_addr_data): Remove.
(_initialize_mips_linux_tdep): Do not initialize register_addr_data.
(set_mips_linux_register_addr): Remove.
(mips_linux_init_abi): Do not call set_mips_linux_register_addr.
Register mips_linux_cannot_fetch/store_register.
diff -urNp gdb-orig/gdb/config/mips/linux.mh gdb-head/gdb/config/mips/linux.mh
--- gdb-orig/gdb/config/mips/linux.mh 2007-04-14 18:08:00.000000000 +0200
+++ gdb-head/gdb/config/mips/linux.mh 2007-04-23 16:10:42.934002816 +0200
@@ -1,5 +1,5 @@
# Host: Linux/MIPS
-NAT_FILE= nm-linux.h
+NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
linux-thread-db.o proc-service.o gcore.o \
linux-nat.o linux-fork.o
diff -urNp gdb-orig/gdb/config/mips/nm-linux.h gdb-head/gdb/config/mips/nm-linux.h
--- gdb-orig/gdb/config/mips/nm-linux.h 2007-04-23 16:14:22.639140002 +0200
+++ gdb-head/gdb/config/mips/nm-linux.h 1970-01-01 01:00:00.000000000 +0100
@@ -1,32 +0,0 @@
-/* Native-dependent definitions for GNU/Linux on MIPS.
-
- Copyright 1996, 2001, 2002, 2003, 2007 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef NM_MIPSLINUX_H
-#define NM_MIPSLINUX_H
-
-#include "config/nm-linux.h"
-
-int mips_linux_cannot_fetch_register (int regno);
-int mips_linux_cannot_store_register (int regno);
-#define CANNOT_FETCH_REGISTER(regno) mips_linux_cannot_fetch_register (regno)
-#define CANNOT_STORE_REGISTER(regno) mips_linux_cannot_store_register (regno)
-
-#endif /* NM_MIPSLINUX_H */
diff -urNp gdb-orig/gdb/mips-linux-nat.c gdb-head/gdb/mips-linux-nat.c
--- gdb-orig/gdb/mips-linux-nat.c 2007-04-23 16:14:30.098275103 +0200
+++ gdb-head/gdb/mips-linux-nat.c 2007-04-23 16:12:18.789000720 +0200
@@ -26,7 +26,6 @@
#include "target.h"
#include "linux-nat.h"
#include "mips-linux-tdep.h"
-#include "gdbcore.h"
#include "gdb_proc_service.h"
@@ -46,45 +45,73 @@ static int have_ptrace_regsets = 1;
void (*super_fetch_registers) (int);
void (*super_store_registers) (int);
-/* Pseudo registers can not be read. ptrace does not provide a way to
- read (or set) MIPS_PS_REGNUM, and there's no point in reading or
- setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
- FCRIR via ptrace(). */
-
-int
-mips_linux_cannot_fetch_register (int regno)
-{
- if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32)
- return 0;
- else if (regno >= mips_regnum (current_gdbarch)->fp0
- && regno <= mips_regnum (current_gdbarch)->fp0 + 32)
- return 0;
- else if (regno == mips_regnum (current_gdbarch)->lo
- || regno == mips_regnum (current_gdbarch)->hi
- || regno == mips_regnum (current_gdbarch)->badvaddr
- || regno == mips_regnum (current_gdbarch)->cause
- || regno == mips_regnum (current_gdbarch)->pc
- || regno == mips_regnum (current_gdbarch)->fp_control_status
- || regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
- return 0;
+/* Map gdb internal register number to ptrace ``address''.
+ These ``addresses'' are normally defined in <asm/ptrace.h>. */
+
+static CORE_ADDR
+mips_linux_register_addr (int regno)
+{
+ int regaddr;
+
+ if (regno < 0 || regno >= NUM_REGS)
+ error (_("Bogon register number %d."), regno);
+
+ if (regno < 32)
+ regaddr = regno;
+ else if ((regno >= mips_regnum (current_gdbarch)->fp0)
+ && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
+ regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0);
+ else if (regno == mips_regnum (current_gdbarch)->pc)
+ regaddr = PC;
+ else if (regno == mips_regnum (current_gdbarch)->cause)
+ regaddr = CAUSE;
+ else if (regno == mips_regnum (current_gdbarch)->badvaddr)
+ regaddr = BADVADDR;
+ else if (regno == mips_regnum (current_gdbarch)->lo)
+ regaddr = MMLO;
+ else if (regno == mips_regnum (current_gdbarch)->hi)
+ regaddr = MMHI;
+ else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
+ regaddr = FPC_CSR;
+ else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
+ regaddr = FPC_EIR;
else
- return 1;
+ error (_("Unknowable register number %d."), regno);
+
+ return regaddr;
}
-int
-mips_linux_cannot_store_register (int regno)
+static CORE_ADDR
+mips64_linux_register_addr (int regno)
{
- if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32)
- return 0;
- else if (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 32)
- return 0;
- else if (regno == mips_regnum (current_gdbarch)->lo
- || regno == mips_regnum (current_gdbarch)->hi
- || regno == mips_regnum (current_gdbarch)->pc
- || regno == mips_regnum (current_gdbarch)->fp_control_status)
- return 0;
+ int regaddr;
+
+ if (regno < 0 || regno >= NUM_REGS)
+ error (_("Bogon register number %d."), regno);
+
+ if (regno < 32)
+ regaddr = regno;
+ else if ((regno >= mips_regnum (current_gdbarch)->fp0)
+ && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
+ regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM);
+ else if (regno == mips_regnum (current_gdbarch)->pc)
+ regaddr = MIPS64_PC;
+ else if (regno == mips_regnum (current_gdbarch)->cause)
+ regaddr = MIPS64_CAUSE;
+ else if (regno == mips_regnum (current_gdbarch)->badvaddr)
+ regaddr = MIPS64_BADVADDR;
+ else if (regno == mips_regnum (current_gdbarch)->lo)
+ regaddr = MIPS64_MMLO;
+ else if (regno == mips_regnum (current_gdbarch)->hi)
+ regaddr = MIPS64_MMHI;
+ else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
+ regaddr = MIPS64_FPC_CSR;
+ else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
+ regaddr = MIPS64_FPC_EIR;
else
- return 1;
+ error (_("Unknowable register number %d."), regno);
+
+ return regaddr;
}
/* Fetch the thread-local storage pointer for libthread_db. */
@@ -253,10 +280,10 @@ mips64_linux_store_registers (int regnum
static CORE_ADDR
mips_linux_register_u_offset (int regno)
{
- /* FIXME drow/2005-09-04: The hardcoded use of register_addr should go
- away. This requires disentangling the various definitions of it
- (particularly alpha-nat.c's). */
- return register_addr (regno, 0);
+ if (mips_abi_regsize (current_gdbarch) == 8)
+ return mips64_linux_register_addr (regno);
+ else
+ return mips_linux_register_addr (regno);
}
void _initialize_mips_linux_nat (void);
diff -urNp gdb-orig/gdb/mips-linux-tdep.c gdb-head/gdb/mips-linux-tdep.c
--- gdb-orig/gdb/mips-linux-tdep.c 2007-04-14 18:08:00.000000000 +0200
+++ gdb-head/gdb/mips-linux-tdep.c 2007-04-23 16:13:52.199813455 +0200
@@ -218,42 +218,6 @@ mips_fill_fpregset (mips_elf_fpregset_t
}
}
-/* Map gdb internal register number to ptrace ``address''.
- These ``addresses'' are normally defined in <asm/ptrace.h>. */
-
-static CORE_ADDR
-mips_linux_register_addr (int regno, CORE_ADDR blockend)
-{
- int regaddr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error (_("Bogon register number %d."), regno);
-
- if (regno < 32)
- regaddr = regno;
- else if ((regno >= mips_regnum (current_gdbarch)->fp0)
- && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
- regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0);
- else if (regno == mips_regnum (current_gdbarch)->pc)
- regaddr = PC;
- else if (regno == mips_regnum (current_gdbarch)->cause)
- regaddr = CAUSE;
- else if (regno == mips_regnum (current_gdbarch)->badvaddr)
- regaddr = BADVADDR;
- else if (regno == mips_regnum (current_gdbarch)->lo)
- regaddr = MMLO;
- else if (regno == mips_regnum (current_gdbarch)->hi)
- regaddr = MMHI;
- else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
- regaddr = FPC_CSR;
- else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
- regaddr = FPC_EIR;
- else
- error (_("Unknowable register number %d."), regno);
-
- return regaddr;
-}
-
/* Support for 64-bit ABIs. */
/* Figure out where the longjmp will land.
@@ -487,42 +451,6 @@ mips64_fill_fpregset (mips64_elf_fpregse
}
-/* Map gdb internal register number to ptrace ``address''.
- These ``addresses'' are normally defined in <asm/ptrace.h>. */
-
-static CORE_ADDR
-mips64_linux_register_addr (int regno, CORE_ADDR blockend)
-{
- int regaddr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error (_("Bogon register number %d."), regno);
-
- if (regno < 32)
- regaddr = regno;
- else if ((regno >= mips_regnum (current_gdbarch)->fp0)
- && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
- regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM);
- else if (regno == mips_regnum (current_gdbarch)->pc)
- regaddr = MIPS64_PC;
- else if (regno == mips_regnum (current_gdbarch)->cause)
- regaddr = MIPS64_CAUSE;
- else if (regno == mips_regnum (current_gdbarch)->badvaddr)
- regaddr = MIPS64_BADVADDR;
- else if (regno == mips_regnum (current_gdbarch)->lo)
- regaddr = MIPS64_MMLO;
- else if (regno == mips_regnum (current_gdbarch)->hi)
- regaddr = MIPS64_MMHI;
- else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
- regaddr = MIPS64_FPC_CSR;
- else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
- regaddr = MIPS64_FPC_EIR;
- else
- error (_("Unknowable register number %d."), regno);
-
- return regaddr;
-}
-
/* Use a local version of this function to get the correct types for
regsets, until multi-arch core support is ready. */
@@ -584,35 +512,6 @@ static struct core_fns regset_core_fns =
NULL /* next */
};
-/* Handle for obtaining pointer to the current register_addr()
- function for a given architecture. */
-static struct gdbarch_data *register_addr_data;
-
-CORE_ADDR
-register_addr (int regno, CORE_ADDR blockend)
-{
- CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR) =
- gdbarch_data (current_gdbarch, register_addr_data);
-
- gdb_assert (register_addr_ptr != 0);
-
- return register_addr_ptr (regno, blockend);
-}
-
-static void
-set_mips_linux_register_addr (struct gdbarch *gdbarch,
- CORE_ADDR (*register_addr_ptr) (int,
- CORE_ADDR))
-{
- deprecated_set_gdbarch_data (gdbarch, register_addr_data,
- register_addr_ptr);
-}
-
-static void *
-init_register_addr_data (struct gdbarch *gdbarch)
-{
- return 0;
-}
/* Check the code at PC for a dynamic linker lazy resolution stub.
Because they aren't in the .plt section, we pattern-match on the
@@ -1123,6 +1022,49 @@ fill_fpregset (mips_elf_fpregset_t *fpre
mips64_fill_fpregset ((void *) fpregsetp, regno);
}
+
+/* Pseudo registers can not be read. ptrace does not provide a way to
+ read (or set) MIPS_PS_REGNUM, and there's no point in reading or
+ setting MIPS_ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or
+ FCRIR via ptrace(). */
+
+static int
+mips_linux_cannot_fetch_register (int regno)
+{
+ if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32)
+ return 0;
+ else if (regno >= mips_regnum (current_gdbarch)->fp0
+ && regno <= mips_regnum (current_gdbarch)->fp0 + 32)
+ return 0;
+ else if (regno == mips_regnum (current_gdbarch)->lo
+ || regno == mips_regnum (current_gdbarch)->hi
+ || regno == mips_regnum (current_gdbarch)->badvaddr
+ || regno == mips_regnum (current_gdbarch)->cause
+ || regno == mips_regnum (current_gdbarch)->pc
+ || regno == mips_regnum (current_gdbarch)->fp_control_status
+ || regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
+ return 0;
+ else
+ return 1;
+}
+
+static int
+mips_linux_cannot_store_register (int regno)
+{
+ if (regno > MIPS_ZERO_REGNUM && regno < MIPS_ZERO_REGNUM + 32)
+ return 0;
+ else if (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 32)
+ return 0;
+ else if (regno == mips_regnum (current_gdbarch)->lo
+ || regno == mips_regnum (current_gdbarch)->hi
+ || regno == mips_regnum (current_gdbarch)->pc
+ || regno == mips_regnum (current_gdbarch)->fp_control_status)
+ return 0;
+ else
+ return 1;
+}
+
+
/* Initialize one of the GNU/Linux OS ABIs. */
static void
@@ -1139,7 +1081,6 @@ mips_linux_init_abi (struct gdbarch_info
mips_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips_linux_register_addr);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
break;
@@ -1148,7 +1089,6 @@ mips_linux_init_abi (struct gdbarch_info
mips_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr);
set_gdbarch_long_double_bit (gdbarch, 128);
/* These floatformats should probably be renamed. MIPS uses
the same 128-bit IEEE floating point format that IA-64 uses,
@@ -1162,7 +1102,6 @@ mips_linux_init_abi (struct gdbarch_info
mips64_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_lp64_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr);
set_gdbarch_long_double_bit (gdbarch, 128);
/* These floatformats should probably be renamed. MIPS uses
the same 128-bit IEEE floating point format that IA-64 uses,
@@ -1179,6 +1118,9 @@ mips_linux_init_abi (struct gdbarch_info
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver);
+ set_gdbarch_cannot_fetch_register (gdbarch, mips_linux_cannot_fetch_register);
+ set_gdbarch_cannot_store_register (gdbarch, mips_linux_cannot_store_register);
+
set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
/* Enable TLS support. */
@@ -1191,9 +1133,6 @@ _initialize_mips_linux_tdep (void)
{
const struct bfd_arch_info *arch_info;
- register_addr_data =
- gdbarch_data_register_post_init (init_register_addr_data);
-
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
arch_info = arch_info->next)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux
2007-04-23 15:47 [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux Ulrich Weigand
@ 2007-04-24 21:53 ` Daniel Jacobowitz
2007-04-25 0:26 ` Ulrich Weigand
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-04-24 21:53 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Mon, Apr 23, 2007 at 05:45:32PM +0200, Ulrich Weigand wrote:
> Hello,
>
> this is the updated mips-linux patch. Main difference is moving
> mips_linux_cannot_fetch_register and mips_linux_cannot_store_register
> to mips-linux-tdep.c and installing them as gdbarch callbacks.
>
> Tested by building --target=mips-linux and --host=mips-linux.
Well, no, I don't think this will do. Sorry I didn't get to look at
this before you redid it. The cannot_store_register callback refused
stores to badvaddr and cause. If you're using a mips-linux native
debugger, or talking to gdbserver, that's fine. But if you're using a
mips-linux debugger and talking to kgdb over a JTAG unit, it's less
fine. You should be able to write to cause if your target_ops permits.
That's probably typical of user-readable supervisor mode registers.
I bet there are plenty more targets with this situation where GDB just
doesn't support the register in question.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux
2007-04-24 21:53 ` Daniel Jacobowitz
@ 2007-04-25 0:26 ` Ulrich Weigand
2007-04-25 19:45 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2007-04-25 0:26 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> Well, no, I don't think this will do. Sorry I didn't get to look at
> this before you redid it. The cannot_store_register callback refused
> stores to badvaddr and cause. If you're using a mips-linux native
> debugger, or talking to gdbserver, that's fine. But if you're using a
> mips-linux debugger and talking to kgdb over a JTAG unit, it's less
> fine. You should be able to write to cause if your target_ops permits.
I had assumed people would be building GDB for a different target in
such cases -- if the mips-linux target is used, I agree my proposed
patch is broken.
So I guess we're back to distinguishing between a gdbarch method of
providing registers that cannot be fetched and stored, and in addition
a target_ops method -- which in the case of a target using the
trad_ptrace helpers should be made available somehow ...
In any case, I still like to get the bulk of the register_addr patch
set committed soon -- the whole cannot_fetch_register discussion is
really an independent topic. The following patch contains just the
part to move register_addr to mips-linux-nat.c and leaves the
CANNOT_FETCH_REGISTER situation completely unchanged. Would that
be OK with you for now?
Bye,
Ulrich
ChangeLog:
* mips-linux-nat.c: No longer include "gdbcore.h".
(mips_linux_register_addr): Move from mips-linux-tdep.c.
(mips64_linux_register_addr): Likewise.
(mips_linux_register_u_offset): Call mips_linux_register_addr or
mips64_linux_register_addr instead of register_addr.
* mips-linux-tdep.c (mips_linux_register_addr,
mips64_linux_register_addr): Move to mips-linux-nat.c.
(register_addr): Remove.
(register_addr_data, init_register_addr_data): Remove.
(_initialize_mips_linux_tdep): Do not initialize register_addr_data.
(set_mips_linux_register_addr): Remove.
(mips_linux_init_abi): Do not call set_mips_linux_register_addr.
diff -urNp gdb-orig/gdb/mips-linux-nat.c gdb-head/gdb/mips-linux-nat.c
--- gdb-orig/gdb/mips-linux-nat.c 2007-04-25 01:32:03.169405714 +0200
+++ gdb-head/gdb/mips-linux-nat.c 2007-04-25 01:35:24.094448682 +0200
@@ -26,7 +26,6 @@
#include "target.h"
#include "linux-nat.h"
#include "mips-linux-tdep.h"
-#include "gdbcore.h"
#include "gdb_proc_service.h"
@@ -87,6 +86,75 @@ mips_linux_cannot_store_register (int re
return 1;
}
+/* Map gdb internal register number to ptrace ``address''.
+ These ``addresses'' are normally defined in <asm/ptrace.h>. */
+
+static CORE_ADDR
+mips_linux_register_addr (int regno)
+{
+ int regaddr;
+
+ if (regno < 0 || regno >= NUM_REGS)
+ error (_("Bogon register number %d."), regno);
+
+ if (regno < 32)
+ regaddr = regno;
+ else if ((regno >= mips_regnum (current_gdbarch)->fp0)
+ && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
+ regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0);
+ else if (regno == mips_regnum (current_gdbarch)->pc)
+ regaddr = PC;
+ else if (regno == mips_regnum (current_gdbarch)->cause)
+ regaddr = CAUSE;
+ else if (regno == mips_regnum (current_gdbarch)->badvaddr)
+ regaddr = BADVADDR;
+ else if (regno == mips_regnum (current_gdbarch)->lo)
+ regaddr = MMLO;
+ else if (regno == mips_regnum (current_gdbarch)->hi)
+ regaddr = MMHI;
+ else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
+ regaddr = FPC_CSR;
+ else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
+ regaddr = FPC_EIR;
+ else
+ error (_("Unknowable register number %d."), regno);
+
+ return regaddr;
+}
+
+static CORE_ADDR
+mips64_linux_register_addr (int regno)
+{
+ int regaddr;
+
+ if (regno < 0 || regno >= NUM_REGS)
+ error (_("Bogon register number %d."), regno);
+
+ if (regno < 32)
+ regaddr = regno;
+ else if ((regno >= mips_regnum (current_gdbarch)->fp0)
+ && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
+ regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM);
+ else if (regno == mips_regnum (current_gdbarch)->pc)
+ regaddr = MIPS64_PC;
+ else if (regno == mips_regnum (current_gdbarch)->cause)
+ regaddr = MIPS64_CAUSE;
+ else if (regno == mips_regnum (current_gdbarch)->badvaddr)
+ regaddr = MIPS64_BADVADDR;
+ else if (regno == mips_regnum (current_gdbarch)->lo)
+ regaddr = MIPS64_MMLO;
+ else if (regno == mips_regnum (current_gdbarch)->hi)
+ regaddr = MIPS64_MMHI;
+ else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
+ regaddr = MIPS64_FPC_CSR;
+ else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
+ regaddr = MIPS64_FPC_EIR;
+ else
+ error (_("Unknowable register number %d."), regno);
+
+ return regaddr;
+}
+
/* Fetch the thread-local storage pointer for libthread_db. */
ps_err_e
@@ -253,10 +321,10 @@ mips64_linux_store_registers (int regnum
static CORE_ADDR
mips_linux_register_u_offset (int regno)
{
- /* FIXME drow/2005-09-04: The hardcoded use of register_addr should go
- away. This requires disentangling the various definitions of it
- (particularly alpha-nat.c's). */
- return register_addr (regno, 0);
+ if (mips_abi_regsize (current_gdbarch) == 8)
+ return mips64_linux_register_addr (regno);
+ else
+ return mips_linux_register_addr (regno);
}
void _initialize_mips_linux_nat (void);
diff -urNp gdb-orig/gdb/mips-linux-tdep.c gdb-head/gdb/mips-linux-tdep.c
--- gdb-orig/gdb/mips-linux-tdep.c 2007-04-25 01:28:13.454193000 +0200
+++ gdb-head/gdb/mips-linux-tdep.c 2007-04-25 01:34:50.385051211 +0200
@@ -218,42 +218,6 @@ mips_fill_fpregset (mips_elf_fpregset_t
}
}
-/* Map gdb internal register number to ptrace ``address''.
- These ``addresses'' are normally defined in <asm/ptrace.h>. */
-
-static CORE_ADDR
-mips_linux_register_addr (int regno, CORE_ADDR blockend)
-{
- int regaddr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error (_("Bogon register number %d."), regno);
-
- if (regno < 32)
- regaddr = regno;
- else if ((regno >= mips_regnum (current_gdbarch)->fp0)
- && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
- regaddr = FPR_BASE + (regno - mips_regnum (current_gdbarch)->fp0);
- else if (regno == mips_regnum (current_gdbarch)->pc)
- regaddr = PC;
- else if (regno == mips_regnum (current_gdbarch)->cause)
- regaddr = CAUSE;
- else if (regno == mips_regnum (current_gdbarch)->badvaddr)
- regaddr = BADVADDR;
- else if (regno == mips_regnum (current_gdbarch)->lo)
- regaddr = MMLO;
- else if (regno == mips_regnum (current_gdbarch)->hi)
- regaddr = MMHI;
- else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
- regaddr = FPC_CSR;
- else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
- regaddr = FPC_EIR;
- else
- error (_("Unknowable register number %d."), regno);
-
- return regaddr;
-}
-
/* Support for 64-bit ABIs. */
/* Figure out where the longjmp will land.
@@ -487,42 +451,6 @@ mips64_fill_fpregset (mips64_elf_fpregse
}
-/* Map gdb internal register number to ptrace ``address''.
- These ``addresses'' are normally defined in <asm/ptrace.h>. */
-
-static CORE_ADDR
-mips64_linux_register_addr (int regno, CORE_ADDR blockend)
-{
- int regaddr;
-
- if (regno < 0 || regno >= NUM_REGS)
- error (_("Bogon register number %d."), regno);
-
- if (regno < 32)
- regaddr = regno;
- else if ((regno >= mips_regnum (current_gdbarch)->fp0)
- && (regno < mips_regnum (current_gdbarch)->fp0 + 32))
- regaddr = MIPS64_FPR_BASE + (regno - FP0_REGNUM);
- else if (regno == mips_regnum (current_gdbarch)->pc)
- regaddr = MIPS64_PC;
- else if (regno == mips_regnum (current_gdbarch)->cause)
- regaddr = MIPS64_CAUSE;
- else if (regno == mips_regnum (current_gdbarch)->badvaddr)
- regaddr = MIPS64_BADVADDR;
- else if (regno == mips_regnum (current_gdbarch)->lo)
- regaddr = MIPS64_MMLO;
- else if (regno == mips_regnum (current_gdbarch)->hi)
- regaddr = MIPS64_MMHI;
- else if (regno == mips_regnum (current_gdbarch)->fp_control_status)
- regaddr = MIPS64_FPC_CSR;
- else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision)
- regaddr = MIPS64_FPC_EIR;
- else
- error (_("Unknowable register number %d."), regno);
-
- return regaddr;
-}
-
/* Use a local version of this function to get the correct types for
regsets, until multi-arch core support is ready. */
@@ -584,35 +512,6 @@ static struct core_fns regset_core_fns =
NULL /* next */
};
-/* Handle for obtaining pointer to the current register_addr()
- function for a given architecture. */
-static struct gdbarch_data *register_addr_data;
-
-CORE_ADDR
-register_addr (int regno, CORE_ADDR blockend)
-{
- CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR) =
- gdbarch_data (current_gdbarch, register_addr_data);
-
- gdb_assert (register_addr_ptr != 0);
-
- return register_addr_ptr (regno, blockend);
-}
-
-static void
-set_mips_linux_register_addr (struct gdbarch *gdbarch,
- CORE_ADDR (*register_addr_ptr) (int,
- CORE_ADDR))
-{
- deprecated_set_gdbarch_data (gdbarch, register_addr_data,
- register_addr_ptr);
-}
-
-static void *
-init_register_addr_data (struct gdbarch *gdbarch)
-{
- return 0;
-}
/* Check the code at PC for a dynamic linker lazy resolution stub.
Because they aren't in the .plt section, we pattern-match on the
@@ -1139,7 +1038,6 @@ mips_linux_init_abi (struct gdbarch_info
mips_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips_linux_register_addr);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
break;
@@ -1148,7 +1046,6 @@ mips_linux_init_abi (struct gdbarch_info
mips_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr);
set_gdbarch_long_double_bit (gdbarch, 128);
/* These floatformats should probably be renamed. MIPS uses
the same 128-bit IEEE floating point format that IA-64 uses,
@@ -1162,7 +1059,6 @@ mips_linux_init_abi (struct gdbarch_info
mips64_linux_get_longjmp_target);
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_lp64_fetch_link_map_offsets);
- set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr);
set_gdbarch_long_double_bit (gdbarch, 128);
/* These floatformats should probably be renamed. MIPS uses
the same 128-bit IEEE floating point format that IA-64 uses,
@@ -1191,9 +1087,6 @@ _initialize_mips_linux_tdep (void)
{
const struct bfd_arch_info *arch_info;
- register_addr_data =
- gdbarch_data_register_post_init (init_register_addr_data);
-
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
arch_info = arch_info->next)
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux
2007-04-25 0:26 ` Ulrich Weigand
@ 2007-04-25 19:45 ` Daniel Jacobowitz
2007-04-25 22:40 ` Ulrich Weigand
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-04-25 19:45 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
On Wed, Apr 25, 2007 at 02:16:44AM +0200, Ulrich Weigand wrote:
> I had assumed people would be building GDB for a different target in
> such cases -- if the mips-linux target is used, I agree my proposed
> patch is broken.
I can't say for sure whether they should be, but I know I and others
use a foo-linux gdb to talk to kgdb, or to talk to associated JTAG
stubs. Of course, we might be able to make GDB consider that a
different OSABI. But it's not easy to tell a static linked program
from a kernel image.
>
> So I guess we're back to distinguishing between a gdbarch method of
> providing registers that cannot be fetched and stored, and in addition
> a target_ops method -- which in the case of a target using the
> trad_ptrace helpers should be made available somehow ...
>
> In any case, I still like to get the bulk of the register_addr patch
> set committed soon -- the whole cannot_fetch_register discussion is
> really an independent topic. The following patch contains just the
> part to move register_addr to mips-linux-nat.c and leaves the
> CANNOT_FETCH_REGISTER situation completely unchanged. Would that
> be OK with you for now?
Yes, this patch looks fine to me (with the Makefile.in dependency
update, of course).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux
2007-04-25 19:45 ` Daniel Jacobowitz
@ 2007-04-25 22:40 ` Ulrich Weigand
0 siblings, 0 replies; 5+ messages in thread
From: Ulrich Weigand @ 2007-04-25 22:40 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Apr 25, 2007 at 02:16:44AM +0200, Ulrich Weigand wrote:
> > In any case, I still like to get the bulk of the register_addr patch
> > set committed soon -- the whole cannot_fetch_register discussion is
> > really an independent topic. The following patch contains just the
> > part to move register_addr to mips-linux-nat.c and leaves the
> > CANNOT_FETCH_REGISTER situation completely unchanged. Would that
> > be OK with you for now?
>
> Yes, this patch looks fine to me (with the Makefile.in dependency
> update, of course).
OK, thanks! I've committed this now.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-04-25 22:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-23 15:47 [rfc/rft] [3/4] Untangle register_addr - v2 - mips-linux Ulrich Weigand
2007-04-24 21:53 ` Daniel Jacobowitz
2007-04-25 0:26 ` Ulrich Weigand
2007-04-25 19:45 ` Daniel Jacobowitz
2007-04-25 22:40 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox