This is the mail archive of the gdb-patches@sourceware.cygnus.com 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]

PATCH to define TARGET_READ_PC for MIPS


2000-01-13  Greg McGary  <gkm@gnu.org>

	* gdb/config/mips/tm-mips.h (TARGET_READ_PC): if PC==BADVA, return RA.

Index: config/mips/tm-mips.h
===================================================================
RCS file: /cvs/gdb/gdb/gdb/config/mips/tm-mips.h,v
retrieving revision 1.1.1.11
diff -u -p -r1.1.1.11 tm-mips.h
--- tm-mips.h	1999/12/22 21:45:14	1.1.1.11
+++ tm-mips.h	2000/01/14 02:01:22
@@ -1,5 +1,5 @@
 /* Definitions to make GDB run on a mips box under 4.3bsd.
-   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995
+   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 2000
    Free Software Foundation, Inc.
    Contributed by Per Bothner (bothner@cs.wisc.edu) at U.Wisconsin
    and by Alessandro Forin (af@cs.cmu.edu) at CMU..
@@ -73,6 +73,18 @@ CORE_ADDR mips_addr_bits_remove PARAMS (
 /* Remove useless bits from the stack pointer.  */
 
 #define TARGET_READ_SP() ADDR_BITS_REMOVE (read_register (SP_REGNUM))
+
+/* If the value of PC_REGNUM equals that of BADVADDR_REGNUM, then we
+   crashed because of a function call through a stray pointer, and
+   we're doomed to fail if we try to trace the stack from that PC.
+   When this happens, RA_REGNUM contains the return address from which
+   the bad call was made, and is a fine place to start tracing.  */
+
+#define TARGET_READ_PC(PID)						\
+  ADDR_BITS_REMOVE ((read_register_pid (PC_REGNUM, (PID))		\
+		     == read_register_pid (BADVADDR_REGNUM, (PID)))	\
+		    ? read_register_pid (RA_REGNUM, (PID))		\
+		    : read_register_pid (PC_REGNUM, (PID)))
 
 /* Offset from address of function to start of its code.
    Zero on most machines.  */

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