From 5e5215eba77007511fb040ac842a935ec624b4a6 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Tue, 20 Aug 1991 03:02:39 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 11 +++++++++-- gdb/mcheck.c | 9 ++++++++- gdb/sparc-tdep.c | 20 ++++++++++++++++++++ gdb/tm-sparc.h | 4 ++-- gdb/utils.c | 2 +- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4556f3c21f..70ea3f0a59 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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(). diff --git a/gdb/mcheck.c b/gdb/mcheck.c index 2c4d2fc164..611a378ee9 100755 --- a/gdb/mcheck.c +++ b/gdb/mcheck.c @@ -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 diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c index b718e4c888..12ad9c564a 100644 --- a/gdb/sparc-tdep.c +++ b/gdb/sparc-tdep.c @@ -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. */ diff --git a/gdb/tm-sparc.h b/gdb/tm-sparc.h index 7f0fb4e6fb..d89781b884 100644 --- a/gdb/tm-sparc.h +++ b/gdb/tm-sparc.h @@ -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)) diff --git a/gdb/utils.c b/gdb/utils.c index 5fe3b1ebc1..28a723bfbd 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -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); } }