aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog15
-rw-r--r--gdb/frv-tdep.c1
-rw-r--r--gdb/gdbarch.c19
-rw-r--r--gdb/gdbarch.h22
-rwxr-xr-xgdb/gdbarch.sh2
-rw-r--r--gdb/inferior.h2
-rw-r--r--gdb/m68hc11-tdep.c1
-rw-r--r--gdb/regcache.c61
-rw-r--r--gdb/rs6000-tdep.c1
-rw-r--r--gdb/sh-tdep.c1
-rw-r--r--gdb/sparc-tdep.c1
11 files changed, 80 insertions, 46 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4f817ee..df7d64c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,20 @@
2003-06-07 Andrew Cagney <cagney@redhat.com>
+ * gdbarch.sh (TARGET_READ_PC): Add predicate, remove default.
+ * gdbarch.h, gdbarch.c: Re-generate.
+ * regcache.c: Update comments on read_pc et.al.
+ (generic_target_read_pc): Delete function.
+ (read_pc_pid): Try TARGET_READ_PC and PC_REGNUM for a PC register.
+ * inferior.h (generic_target_read_pc): Delete declaration.
+ * frv-tdep.c (frv_gdbarch_init): Do not set read_pc to
+ generic_target_read_pc.
+ * sparc-tdep.c (sparc_gdbarch_init): Ditto.
+ * sh-tdep.c (sh_gdbarch_init): Ditto.
+ * rs6000-tdep.c (rs6000_gdbarch_init): Ditto.
+ * m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto.
+
+2003-06-07 Andrew Cagney <cagney@redhat.com>
+
* elfread.c (elf_symtab_read): Replace "special_local_sym_p" and
"index" with "special_local_sect". Use strcmp instead of STREQ.
Append period to coments.
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index 666aa25..763be72 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -1099,7 +1099,6 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Settings that should be unnecessary. */
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
- set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 7c0a8fd..ab6e6ec 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -501,7 +501,6 @@ gdbarch_alloc (const struct gdbarch_info *info,
current_gdbarch->ptr_bit = TARGET_INT_BIT;
current_gdbarch->bfd_vma_bit = TARGET_ARCHITECTURE->bits_per_address;
current_gdbarch->char_signed = -1;
- current_gdbarch->read_pc = generic_target_read_pc;
current_gdbarch->write_pc = generic_target_write_pc;
current_gdbarch->read_sp = generic_target_read_sp;
current_gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer;
@@ -620,7 +619,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of bfd_vma_bit, invalid_p == 0 */
if (gdbarch->char_signed == -1)
gdbarch->char_signed = 1;
- /* Skip verify of read_pc, invalid_p == 0 */
+ /* Skip verify of read_pc, has predicate */
/* Skip verify of write_pc, invalid_p == 0 */
/* Skip verify of deprecated_target_read_fp, has predicate */
/* Skip verify of read_sp, invalid_p == 0 */
@@ -2546,6 +2545,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: TARGET_PTR_BIT = %d\n",
TARGET_PTR_BIT);
#endif
+#ifdef TARGET_READ_PC_P
+ fprintf_unfiltered (file,
+ "gdbarch_dump: %s # %s\n",
+ "TARGET_READ_PC_P()",
+ XSTRING (TARGET_READ_PC_P ()));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: TARGET_READ_PC_P() = %d\n",
+ TARGET_READ_PC_P ());
+#endif
#ifdef TARGET_READ_PC
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
@@ -2876,6 +2884,13 @@ set_gdbarch_char_signed (struct gdbarch *gdbarch,
gdbarch->char_signed = char_signed;
}
+int
+gdbarch_read_pc_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->read_pc != 0;
+}
+
CORE_ADDR
gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid)
{
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 9678f4f..db40c66 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -283,9 +283,29 @@ extern void set_gdbarch_char_signed (struct gdbarch *gdbarch, int char_signed);
#define TARGET_CHAR_SIGNED (gdbarch_char_signed (current_gdbarch))
#endif
+#if defined (TARGET_READ_PC)
+/* Legacy for systems yet to multi-arch TARGET_READ_PC */
+#if !defined (TARGET_READ_PC_P)
+#define TARGET_READ_PC_P() (1)
+#endif
+#endif
+
+/* Default predicate for non- multi-arch targets. */
+#if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_PC_P)
+#define TARGET_READ_PC_P() (0)
+#endif
+
+extern int gdbarch_read_pc_p (struct gdbarch *gdbarch);
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (TARGET_READ_PC_P)
+#error "Non multi-arch definition of TARGET_READ_PC"
+#endif
+#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_READ_PC_P)
+#define TARGET_READ_PC_P() (gdbarch_read_pc_p (current_gdbarch))
+#endif
+
/* Default (function) for non- multi-arch platforms. */
#if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_PC)
-#define TARGET_READ_PC(ptid) (generic_target_read_pc (ptid))
+#define TARGET_READ_PC(ptid) (internal_error (__FILE__, __LINE__, "TARGET_READ_PC"), 0)
#endif
typedef CORE_ADDR (gdbarch_read_pc_ftype) (ptid_t ptid);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 006ec96..9e41f5a 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -426,7 +426,7 @@ v:2:TARGET_BFD_VMA_BIT:int:bfd_vma_bit::::8 * sizeof (void*):TARGET_ARCHITECTURE
# One if \`char' acts like \`signed char', zero if \`unsigned char'.
v:2:TARGET_CHAR_SIGNED:int:char_signed::::1:-1:1::::
#
-f:2:TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid::0:generic_target_read_pc::0
+F:2:TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid
f:2:TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0
# This is simply not needed. See value_of_builtin_frame_fp_reg and
# call_function_by_hand.
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 1de3b25..4f3db64 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -168,8 +168,6 @@ extern CORE_ADDR read_pc (void);
extern CORE_ADDR read_pc_pid (ptid_t);
-extern CORE_ADDR generic_target_read_pc (ptid_t);
-
extern void write_pc (CORE_ADDR);
extern void write_pc_pid (CORE_ADDR, ptid_t);
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index b35c30c..133ef05 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -1365,7 +1365,6 @@ m68hc11_gdbarch_init (struct gdbarch_info info,
set_gdbarch_deprecated_frame_init_saved_regs (gdbarch, m68hc11_frame_init_saved_regs);
set_gdbarch_frame_args_skip (gdbarch, 0);
- set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 09b48f0..6493fbb 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1267,41 +1267,22 @@ regcache_collect (int regnum, void *buf)
/* read_pc, write_pc, read_sp, deprecated_read_fp, etc. Special
handling for registers PC, SP, and FP. */
-/* NOTE: cagney/2001-02-18: The functions generic_target_read_pc(),
- read_pc_pid(), read_pc(), generic_target_write_pc(),
- write_pc_pid(), write_pc(), generic_target_read_sp(), read_sp(),
- generic_target_write_sp(), and deprecated_read_fp(), will
- eventually be moved out of the reg-cache into either frame.[hc] or
- to the multi-arch framework. The are not part of the raw register
- cache. */
-
-/* This routine is getting awfully cluttered with #if's. It's probably
- time to turn this into READ_PC and define it in the tm.h file.
- Ditto for write_pc.
-
- 1999-06-08: The following were re-written so that it assumes the
- existence of a TARGET_READ_PC et.al. macro. A default generic
- version of that macro is made available where needed.
-
- Since the ``TARGET_READ_PC'' et.al. macro is going to be controlled
- by the multi-arch framework, it will eventually be possible to
- eliminate the intermediate read_pc_pid(). The client would call
- TARGET_READ_PC directly. (cagney). */
+/* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc(),
+ read_sp(), and deprecated_read_fp(), will eventually be replaced by
+ per-frame methods. Instead of relying on the global INFERIOR_PTID,
+ they will use the contextual information provided by the FRAME.
+ These functions do not belong in the register cache. */
-CORE_ADDR
-generic_target_read_pc (ptid_t ptid)
-{
-#ifdef PC_REGNUM
- if (PC_REGNUM >= 0)
- {
- CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, ptid));
- return pc_val;
- }
-#endif
- internal_error (__FILE__, __LINE__,
- "generic_target_read_pc");
- return 0;
-}
+/* NOTE: cagney/2003-06-07: The function generic_target_read_sp()
+ should be deleted. */
+
+/* NOTE: cagney/2003-06-07: The function generic_target_write_sp()
+ should be deleted. */
+
+/* NOTE: cagney/2003-06-07: The functions generic_target_write_pc(),
+ write_pc_pid(), write_pc(), and deprecated_read_fp(), all need to
+ be replaced by something that does not rely on global state. But
+ what? */
CORE_ADDR
read_pc_pid (ptid_t ptid)
@@ -1313,7 +1294,17 @@ read_pc_pid (ptid_t ptid)
saved_inferior_ptid = inferior_ptid;
inferior_ptid = ptid;
- pc_val = TARGET_READ_PC (ptid);
+ if (TARGET_READ_PC_P ())
+ pc_val = TARGET_READ_PC (ptid);
+ /* Else use per-frame method on get_current_frame. */
+ else if (PC_REGNUM >= 0)
+ {
+ CORE_ADDR raw_val = read_register_pid (PC_REGNUM, ptid);
+ CORE_ADDR pc_val = ADDR_BITS_REMOVE (raw_val);
+ return pc_val;
+ }
+ else
+ internal_error (__FILE__, __LINE__, "read_pc_pid: Unable to find PC");
inferior_ptid = saved_inferior_ptid;
return pc_val;
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 98e1a0c..03946d3 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -2910,7 +2910,6 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
else
set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc);
- set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 57c3f48..af23ffb 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -4637,7 +4637,6 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
break;
}
- set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index ccd3a3b..4b7279c 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -3321,7 +3321,6 @@ sparc_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_deprecated_pop_frame (gdbarch, sparc_pop_frame);
set_gdbarch_deprecated_push_return_address (gdbarch, sparc_push_return_address);
set_gdbarch_deprecated_push_dummy_frame (gdbarch, sparc_push_dummy_frame);
- set_gdbarch_read_pc (gdbarch, generic_target_read_pc);
set_gdbarch_reg_struct_has_addr (gdbarch, sparc_reg_struct_has_addr);
set_gdbarch_return_value_on_stack (gdbarch, sparc_return_value_on_stack);
set_gdbarch_deprecated_saved_pc_after_call (gdbarch, sparc_saved_pc_after_call);