* mcheck.c: Avoid warning about undeclared abort fn.
authorJohn Gilmore <gnu@cygnus>
Tue, 20 Aug 1991 03:02:39 +0000 (03:02 +0000)
committerJohn Gilmore <gnu@cygnus>
Tue, 20 Aug 1991 03:02:39 +0000 (03:02 +0000)
* tm-sparc.h (PC_ADJUST):  Avoid calling error() from this;
it causes recursive calls to error() when used in cleanups.
To do so requires that we make it a function, so we do.
* sparc-tdep.c (sparc_pc_adjust):  New implem of PC_ADJUST.
* utils.c (do_cleanups):  Remove the current cleanup from the
chain *before* calling it, in case error() is called from it.
The result won't be pretty, but won't be an infinite loop either.

gdb/ChangeLog
gdb/mcheck.c
gdb/sparc-tdep.c
gdb/tm-sparc.h
gdb/utils.c

index 4556f3c..70ea3f0 100644 (file)
@@ -1,6 +1,13 @@
 Mon Aug 19 13:44:46 1991  John Gilmore  (gnu at cygint.cygnus.com)
 
-       * 
+       * mcheck.c:  Avoid warning about undeclared abort fn.
+       * tm-sparc.h (PC_ADJUST):  Avoid calling error() from this;
+       it causes recursive calls to error() when used in cleanups.
+       To do so requires that we make it a function, so we do.
+       * sparc-tdep.c (sparc_pc_adjust):  New implem of PC_ADJUST.
+       * utils.c (do_cleanups):  Remove the current cleanup from the
+       chain *before* calling it, in case error() is called from it.
+       The result won't be pretty, but won't be an infinite loop either.
 
 Mon Aug 19 00:41:04 1991  Michael Tiemann  (tiemann at cygint.cygnus.com)
 
@@ -147,7 +154,7 @@ Tue Aug  6 17:16:15 1991  Roland H. Pesch  (pesch at cygint.cygnus.com)
 
 Fri Aug  2 00:13:06 1991  John Gilmore  (gnu at cygint.cygnus.com)
 
-       * values.c (basetype_addr):  When reading target memory, use the
+       * values.c (baseclass_addr):  When reading target memory, use the
        length of the basetype, not the upper type.  We've only malloc'd
        enough space for the basetype, leading to errors in free().
 
index 2c4d2fc..611a378 100755 (executable)
@@ -28,8 +28,15 @@ static void EXFUN((*old_free_hook), (PTR ptr));
 static PTR EXFUN((*old_malloc_hook), (size_t size));
 static PTR EXFUN((*old_realloc_hook), (PTR ptr, size_t size));
 
+/* FIXME.  We cannot *declare* abort() as either being void or being
+   int, because if the system declares it as the other, we get a fatal
+   error.  It's senseless to configure the system for whether abort is
+   void or int.  So we simply fail to declare it, which works on all
+   systems, but might produce a warning on yours.  Please ignore the warning
+   and raise your middle finger in the general direction of the ANSI C
+   committee in tribute.  */
 /* Function to call when something awful happens. */
-static void EXFUN((*abortfunc), (void)) = abort;
+static void EXFUN((*abortfunc), (void)) = (void (*)()) abort;
 
 /* Arbitrary magical numbers.  */
 #define MAGICWORD      0xfedabeeb
index b718e4c..12ad9c5 100644 (file)
@@ -614,6 +614,26 @@ sparc_pop_frame ()
                                        read_pc ()));
 }
 
+/* On the Sun 4 under SunOS, the compile will leave a fake insn which
+   encodes the structure size being returned.  If we detect such
+   a fake insn, step past it.  */
+
+CORE_ADDR
+sparc_pc_adjust(pc)
+     CORE_ADDR pc;
+{
+  long insn;
+  int err;
+
+  err = target_read_memory (pc + 8, (char *)&insn, sizeof(long));
+  SWAP_TARGET_AND_HOST (&insn, sizeof(long));
+  if ((err == 0) && (insn & 0xfffffe00) == 0)
+    return pc+12;
+  else
+    return pc+8;
+}
+
+
 /* Structure of SPARC extended floating point numbers.
    This information is not currently used by GDB, since no current SPARC
    implementations support extended float.  */
index 7f0fb4e..d89781b 100644 (file)
@@ -84,8 +84,8 @@ extern CORE_ADDR skip_prologue ();
    encodes the structure size being returned.  If we detect such
    a fake insn, step past it.  */
 
-#define PC_ADJUST(pc) ((read_memory_integer (pc + 8, 4) & 0xfffffe00) == 0 ? \
-                      pc+12 : pc+8)
+#define PC_ADJUST(pc) sparc_pc_adjust(pc)
+extern CORE_ADDR sparc_pc_adjust();
 
 #define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM))
 
index 5fe3b1e..28a723b 100644 (file)
@@ -134,8 +134,8 @@ do_cleanups (old_chain)
   register struct cleanup *ptr;
   while ((ptr = cleanup_chain) != old_chain)
     {
+      cleanup_chain = ptr->next;       /* Do this first incase recursion */
       (*ptr->function) (ptr->arg);
-      cleanup_chain = ptr->next;
       free (ptr);
     }
 }