This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Eliminate the config/pa/tm-hppah.h file


Hello,

this eliminates the config/pa/tm-hppah.h file.  Except for obsolete
definitions of CHILD_ENABLE_EXCEPTION_CALLBACK and 
CHILD_GET_CURRENT_EXCEPTION_EVENT, the file only contained a
definition of SKIP_PERMANENT_BREAKPOINT.

The patch converts this to a gdbarch method, and adds a REGCACHE
parameter that allows removing the use of read/write_register
in the hppa-hpux-tdep.c implementation.

Unfortunately I'm unable to test this on hppa-hpux.  It's not even
possible to build a cross-GDB targetting hppa-hpux, as native header
files are required to build the -tdep file (and somread.c).

Tested on s390-ibm-linux, and by inspection.

Any opinions?  Do you think this is OK to commit?

Bye,
Ulrich


ChangeLog:

	* gdbarch.sh: Add skip_permanent_breakpoint callback.
	* gdbarch.h, gdbarch.c: Regenerate.

	* infrun.c (SKIP_PERMANENT_BREAKPOINT): Remove default definition.
	(resume): Call gdbarch_skip_permanent_breakpoint instead of
	SKIP_PERMANENT_BREAKPOINT.  Inline default case.

	* hppa-hpux-tdep.c (hppa_skip_permanent_breakpoint): Make static.
	Add REGCACHE argument.  Use it instead of read/write_register.
	(hppa_hpux_init_abi): Install hppa_skip_permanent_breakpoint.

	* config/pa/tm-hppah.h: Delete file.
	* config/pa/hppa64.mt (DEPRECATED_TM_FILE): Set to tm-hppa.h.
	* config/pa/hppahpux.mt (DEPRECATED_TM_FILE): Likewise.


diff -urNp gdb-orig/gdb/config/pa/hppa64.mt gdb-head/gdb/config/pa/hppa64.mt
--- gdb-orig/gdb/config/pa/hppa64.mt	2007-05-05 00:37:10.000000000 +0200
+++ gdb-head/gdb/config/pa/hppa64.mt	2007-05-06 22:36:06.513401075 +0200
@@ -1,3 +1,3 @@
 # Target: HP PA-RISC 2.0 running HPUX 11.00 in wide mode
 TDEPFILES= hppa-tdep.o hppa-hpux-tdep.o solib-som.o solib-pa64.o somread.o solib.o
-DEPRECATED_TM_FILE= tm-hppah.h
+DEPRECATED_TM_FILE= tm-hppa.h
diff -urNp gdb-orig/gdb/config/pa/hppahpux.mt gdb-head/gdb/config/pa/hppahpux.mt
--- gdb-orig/gdb/config/pa/hppahpux.mt	2007-05-05 00:37:10.000000000 +0200
+++ gdb-head/gdb/config/pa/hppahpux.mt	2007-05-06 22:36:06.517400500 +0200
@@ -1,4 +1,4 @@
 # Target: HP PA-RISC running hpux
 MT_CFLAGS = -DPA_SOM_ONLY=1
 TDEPFILES= hppa-tdep.o hppa-hpux-tdep.o corelow.o somread.o solib-som.o solib-pa64.o solib.o
-DEPRECATED_TM_FILE= tm-hppah.h
+DEPRECATED_TM_FILE= tm-hppa.h
diff -urNp gdb-orig/gdb/config/pa/tm-hppah.h gdb-head/gdb/config/pa/tm-hppah.h
--- gdb-orig/gdb/config/pa/tm-hppah.h	2007-05-06 16:07:08.682673000 +0200
+++ gdb-head/gdb/config/pa/tm-hppah.h	1970-01-01 01:00:00.000000000 +0100
@@ -1,37 +0,0 @@
-/* Parameters for execution on an HP PA-RISC machine, running HPUX, for GDB.
-   Copyright 1991, 1992, 1995, 1998, 2002, 2003, 2004, 2007
-   Free Software Foundation, Inc.
-
-   Contributed by the Center for Software Science at the
-   University of Utah (pa-gdb-bugs@cs.utah.edu).
-
-   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.  */
-
-struct frame_info;
-
-/* For HP-UX on PA-RISC we have an implementation
-   for the exception handling target op (in hppa-tdep.c) */
-#define CHILD_ENABLE_EXCEPTION_CALLBACK
-#define CHILD_GET_CURRENT_EXCEPTION_EVENT
-
-/* Here's how to step off a permanent breakpoint.  */
-#define SKIP_PERMANENT_BREAKPOINT (hppa_skip_permanent_breakpoint)
-extern void hppa_skip_permanent_breakpoint (void);
-
-/* Mostly it's common to all HPPA's.  */
-#include "pa/tm-hppa.h"
diff -urNp gdb-orig/gdb/gdbarch.c gdb-head/gdb/gdbarch.c
--- gdb-orig/gdb/gdbarch.c	2007-05-05 01:03:15.000000000 +0200
+++ gdb-head/gdb/gdbarch.c	2007-05-06 22:36:06.558394606 +0200
@@ -237,6 +237,7 @@ struct gdbarch
   gdbarch_regset_from_core_section_ftype *regset_from_core_section;
   int vtable_function_descriptors;
   int vbit_in_delta;
+  gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint;
 };
 
 
@@ -364,6 +365,7 @@ struct gdbarch startup_gdbarch =
   0,  /* regset_from_core_section */
   0,  /* vtable_function_descriptors */
   0,  /* vbit_in_delta */
+  0,  /* skip_permanent_breakpoint */
   /* startup_gdbarch() */
 };
 
@@ -618,6 +620,7 @@ verify_gdbarch (struct gdbarch *current_
   /* Skip verify of regset_from_core_section, has predicate */
   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
   /* Skip verify of vbit_in_delta, invalid_p == 0 */
+  /* Skip verify of skip_permanent_breakpoint, has predicate */
   buf = ui_file_xstrdup (log, &dummy);
   make_cleanup (xfree, buf);
   if (strlen (buf) > 0)
@@ -1458,6 +1461,12 @@ gdbarch_dump (struct gdbarch *current_gd
   fprintf_unfiltered (file,
                       "gdbarch_dump: single_step_through_delay = <0x%lx>\n",
                       (long) current_gdbarch->single_step_through_delay);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_skip_permanent_breakpoint_p() = %d\n",
+                      gdbarch_skip_permanent_breakpoint_p (current_gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: skip_permanent_breakpoint = <0x%lx>\n",
+                      (long) current_gdbarch->skip_permanent_breakpoint);
 #ifdef SKIP_PROLOGUE
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
@@ -3641,6 +3650,30 @@ set_gdbarch_vbit_in_delta (struct gdbarc
   gdbarch->vbit_in_delta = vbit_in_delta;
 }
 
+int
+gdbarch_skip_permanent_breakpoint_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->skip_permanent_breakpoint != NULL;
+}
+
+void
+gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->skip_permanent_breakpoint != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_skip_permanent_breakpoint called\n");
+  gdbarch->skip_permanent_breakpoint (regcache);
+}
+
+void
+set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch,
+                                       gdbarch_skip_permanent_breakpoint_ftype skip_permanent_breakpoint)
+{
+  gdbarch->skip_permanent_breakpoint = skip_permanent_breakpoint;
+}
+
 
 /* Keep a registry of per-architecture data-pointers required by GDB
    modules. */
diff -urNp gdb-orig/gdb/gdbarch.h gdb-head/gdb/gdbarch.h
--- gdb-orig/gdb/gdbarch.h	2007-05-05 01:03:15.000000000 +0200
+++ gdb-head/gdb/gdbarch.h	2007-05-06 22:36:06.615386411 +0200
@@ -1368,6 +1368,14 @@ extern void set_gdbarch_vtable_function_
 extern int gdbarch_vbit_in_delta (struct gdbarch *gdbarch);
 extern void set_gdbarch_vbit_in_delta (struct gdbarch *gdbarch, int vbit_in_delta);
 
+/* Advance PC to next instruction in order to skip a permanent breakpoint. */
+
+extern int gdbarch_skip_permanent_breakpoint_p (struct gdbarch *gdbarch);
+
+typedef void (gdbarch_skip_permanent_breakpoint_ftype) (struct regcache *regcache);
+extern void gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache);
+extern void set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint);
+
 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
 
 
diff -urNp gdb-orig/gdb/gdbarch.sh gdb-head/gdb/gdbarch.sh
--- gdb-orig/gdb/gdbarch.sh	2007-05-05 01:03:15.000000000 +0200
+++ gdb-head/gdb/gdbarch.sh	2007-05-06 22:36:06.634383679 +0200
@@ -682,6 +682,9 @@ v::int:vtable_function_descriptors:::0:0
 # Set if the least significant bit of the delta is used instead of the least
 # significant bit of the pfn for pointers to virtual member functions.
 v::int:vbit_in_delta:::0:0::0
+
+# Advance PC to next instruction in order to skip a permanent breakpoint.
+F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache
 EOF
 }
 
diff -urNp gdb-orig/gdb/hppa-hpux-tdep.c gdb-head/gdb/hppa-hpux-tdep.c
--- gdb-orig/gdb/hppa-hpux-tdep.c	2007-05-05 00:37:09.000000000 +0200
+++ gdb-head/gdb/hppa-hpux-tdep.c	2007-05-06 22:36:06.691375484 +0200
@@ -548,8 +548,8 @@ hppa_hpux_skip_trampoline_code (CORE_ADD
     }
 }
 
-void
-hppa_skip_permanent_breakpoint (void)
+static void
+hppa_skip_permanent_breakpoint (struct regcache *regcache)
 {
   /* To step over a breakpoint instruction on the PA takes some
      fiddling with the instruction address queue.
@@ -565,10 +565,15 @@ hppa_skip_permanent_breakpoint (void)
      front to the back.  But what do we put in the back?  What
      instruction comes after that one?  Because of the branch delay
      slot, the next insn is always at the back + 4.  */
-  write_register (HPPA_PCOQ_HEAD_REGNUM, read_register (HPPA_PCOQ_TAIL_REGNUM));
-  write_register (HPPA_PCSQ_HEAD_REGNUM, read_register (HPPA_PCSQ_TAIL_REGNUM));
 
-  write_register (HPPA_PCOQ_TAIL_REGNUM, read_register (HPPA_PCOQ_TAIL_REGNUM) + 4);
+  ULONGEST pcoq_tail, pcsq_tail;
+  regcache_cooked_read_unsigned (regcache, HPPA_PCOQ_TAIL_REGNUM, &pcoq_tail);
+  regcache_cooked_read_unsigned (regcache, HPPA_PCSQ_TAIL_REGNUM, &pcsq_tail);
+
+  regcache_cooked_write_unsigned (regcache, HPPA_PCOQ_HEAD_REGNUM, pcoq_tail);
+  regcache_cooked_write_unsigned (regcache, HPPA_PCSQ_HEAD_REGNUM, pcsq_tail);
+
+  regcache_cooked_write_unsigned (regcache, HPPA_PCOQ_TAIL_REGNUM, pcoq_tail + 4);
   /* We can leave the tail's space the same, since there's no jump.  */
 }
 
@@ -2037,6 +2042,8 @@ hppa_hpux_init_abi (struct gdbarch_info 
   set_gdbarch_read_pc (gdbarch, hppa_hpux_read_pc);
   set_gdbarch_write_pc (gdbarch, hppa_hpux_write_pc);
   set_gdbarch_unwind_pc (gdbarch, hppa_hpux_unwind_pc);
+  set_gdbarch_skip_permanent_breakpoint
+    (gdbarch, hppa_skip_permanent_breakpoint);
 
   set_gdbarch_regset_from_core_section
     (gdbarch, hppa_hpux_regset_from_core_section);
diff -urNp gdb-orig/gdb/infrun.c gdb-head/gdb/infrun.c
--- gdb-orig/gdb/infrun.c	2007-05-05 01:03:15.000000000 +0200
+++ gdb-head/gdb/infrun.c	2007-05-06 22:45:51.421151263 +0200
@@ -176,23 +176,6 @@ show_debug_infrun (struct ui_file *file,
 #define SOLIB_IN_DYNAMIC_LINKER(pid,pc) 0
 #endif
 
-/* We can't step off a permanent breakpoint in the ordinary way, because we
-   can't remove it.  Instead, we have to advance the PC to the next
-   instruction.  This macro should expand to a pointer to a function that
-   does that, or zero if we have no such function.  If we don't have a
-   definition for it, we have to report an error.  */
-#ifndef SKIP_PERMANENT_BREAKPOINT
-#define SKIP_PERMANENT_BREAKPOINT (default_skip_permanent_breakpoint)
-static void
-default_skip_permanent_breakpoint (void)
-{
-  error (_("\
-The program is stopped at a permanent breakpoint, but GDB does not know\n\
-how to step past a permanent breakpoint on this architecture.  Try using\n\
-a command like `return' or `jump' to continue execution."));
-}
-#endif
-
 
 /* Convert the #defines into values.  This is temporary until wfi control
    flow is completely sorted out.  */
@@ -543,7 +526,15 @@ resume (int step, enum target_signal sig
      at a permanent breakpoint; we need to step over it, but permanent
      breakpoints can't be removed.  So we have to test for it here.  */
   if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here)
-    SKIP_PERMANENT_BREAKPOINT ();
+    {
+      if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch))
+	gdbarch_skip_permanent_breakpoint (current_gdbarch, current_regcache);
+      else
+	error (_("\
+The program is stopped at a permanent breakpoint, but GDB does not know\n\
+how to step past a permanent breakpoint on this architecture.  Try using\n\
+a command like `return' or `jump' to continue execution."));
+    }
 
   if (SOFTWARE_SINGLE_STEP_P () && step)
     {
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]