This is the mail archive of the gdb-patches@sources.redhat.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]
Other format: [Raw text]

[RFA] Sparc/Linux patch 5



This adds signal frame, longjmp, and dynamic linker support to
Sparc/Linux.  This code is GDB_TARGET_IS_SPARC64 agnostic.

Before we have a repeat of yesterdays conversations, yes I know
these things should be multi-arch'd, but they currently cannot be
because there is no way to specify an OS level gdbarch_init
callbacks.  Currently, one can only register a single gdbarch init for
a particular bfd arch, sparc-tdep.c takes bfd_arch_sparc.

So for the time being can we get my changes installed to fix up
the Sparc/Linux platform, then I will clean it up.  Hey I'll even do
the work necessary to add in the register_os_gdbarch() or whatever
infrastructure.  Deal?  One requirement of such an interface is that
it would run after the existing gdbarch_init callback.

We are now down to 87 sparc32/linux testcase failures.  Sparc64
is almost at a state of initial usability under Linux, taking care
of that is forthcoming.

2002-04-19  David S. Miller  <davem@redhat.com>

	Sparc/Linux signal frame, longjmp, dynamic linker support
	* sparc-linux-tdep.c: New file.
	* Makefile.in (ALLDEPFILES): Add sparc-linux-tdep.c.
	(sparc-linux-tdep.o): Add dependencies.
	* config/sparc/linux.mt (TDEPFILES): Add sparc-linux-tdep.o
	* config/sparc/sp64linux.mt (TDEPFILES): Likewise.
	* sparc-tdep.c (get_longjmp_target): Allow LONGJMP_TARGET_SIZE to
	be calculated at runtime.
	* config/sparc/tm-linux.h (LONGJMP_TARGET_SIZE, JB_PC,
	JB_ELEMENT_SIZE, GET_LONGJMP_TARGET): Define.
	(get_longjmp_target): Declare.
	(IN_SIGTRAMP, FRAME_SAVED_PC, FRAME_CHAIN, SAVED_PC_AFTER_CALL,
	SKIP_SOLIB_RESOLVER, SKIP_PROLOGUE_FRAMELESS_P,
	SVR4_FETCH_LINK_MAP_OFFSETS): Define.
	(sparc_linux_in_sigtramp, sparc_linux_frame_saved_pc,
	sparc_linux_frame_chain, sparc_linux_saved_pc_after_call,
	sparc_linux_skip_solib_resolver,
	sparc_linux_skip_prologue_frameless_p,
	sparc_linux_svr4_fetch_link_map_offsets): Declare.
	* config/sparc/tm-sp64linux.h (LONGJMP_TARGET_SIZE, JB_PC,
	JB_ELEMENT_SIZE, GET_LONGJMP_TARGET): Define.
	(get_longjmp_target): Declare.
	(IN_SIGTRAMP, FRAME_SAVED_PC, FRAME_CHAIN, SAVED_PC_AFTER_CALL,
	SKIP_SOLIB_RESOLVER, SKIP_PROLOGUE_FRAMELESS_P,
	SVR4_FETCH_LINK_MAP_OFFSETS): Define.
	(sparc_linux_in_sigtramp, sparc_linux_frame_saved_pc,
	sparc_linux_frame_chain, sparc_linux_saved_pc_after_call,
	sparc_linux_skip_solib_resolver,
	sparc_linux_skip_prologue_frameless_p,
	sparc_linux_svr4_fetch_link_map_offsets): Declare.
	(tm-sysv4.h): Don't include.
	(tm-linux.h): Include this instead.
	
--- ./config/sparc/linux.mt.~1~	Fri Mar  9 22:17:24 2001
+++ ./config/sparc/linux.mt	Fri Apr 19 22:36:52 2002
@@ -1,3 +1,3 @@
 # Target: Sparcstation, running Linux
-TDEPFILES= sparc-tdep.o solib.o solib-svr4.o solib-legacy.o
+TDEPFILES= sparc-tdep.o sparc-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
 TM_FILE= tm-linux.h
--- ./config/sparc/tm-linux.h.~1~	Fri Apr 19 14:54:47 2002
+++ ./config/sparc/tm-linux.h	Fri Apr 19 22:37:41 2002
@@ -30,8 +30,51 @@
 #undef SPARC_TARGET_LONG_DOUBLE_BYTES
 #define SPARC_TARGET_LONG_DOUBLE_BYTES 8
 
-#define SIGCONTEXT_PC_OFFSET 12
-
 #include "tm-linux.h"
+
+#define LONGJMP_TARGET_SIZE 4
+#define JB_PC 2
+#define JB_ELEMENT_SIZE 4
+
+extern int get_longjmp_target (CORE_ADDR *);
+#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
+
+/* When the sparc Linux kernel calls a signal handler, the return
+   address points to a bit of code on the stack.  These definitions
+   are used to identify this bit of code as a signal trampoline in
+   order to support backtracing through calls to signal handlers.  */
+
+#define IN_SIGTRAMP(pc, name) sparc_linux_in_sigtramp (pc, name)
+extern int sparc_linux_in_sigtramp (CORE_ADDR, char *);
+
+#undef FRAME_SAVED_PC
+#define FRAME_SAVED_PC(frame) sparc_linux_frame_saved_pc (frame)
+extern CORE_ADDR sparc_linux_frame_saved_pc (struct frame_info *frame);
+
+#define FRAME_CHAIN(THISFRAME) (sparc_linux_frame_chain (THISFRAME))
+extern CORE_ADDR sparc_linux_frame_chain (struct frame_info *);
+
+#undef SAVED_PC_AFTER_CALL
+#define SAVED_PC_AFTER_CALL(frame) sparc_linux_saved_pc_after_call (frame)
+extern CORE_ADDR sparc_linux_saved_pc_after_call (struct frame_info *);
+
+/* When we call a function in a shared library, and the PLT sends us
+   into the dynamic linker to find the function's real address, we
+   need to skip over the dynamic linker call.  This function decides
+   when to skip, and where to skip to.  See the comments for
+   SKIP_SOLIB_RESOLVER at the top of infrun.c.  */
+#define SKIP_SOLIB_RESOLVER sparc_linux_skip_solib_resolver
+extern CORE_ADDR sparc_linux_skip_solib_resolver (CORE_ADDR pc);
+
+#undef SKIP_PROLOGUE_FRAMELESS_P
+#define SKIP_PROLOGUE_FRAMELESS_P(PC) sparc_linux_skip_prologue_frameless_p (PC)
+extern CORE_ADDR sparc_linux_skip_prologue_frameless_p (CORE_ADDR pc);
+
+/* ??? Should be doing this with gdbarch but that is not easy from
+   ??? ${cpu}-${os}-tdep.c files currently.  */
+
+extern struct link_map_offsets *sparc_linux_svr4_fetch_link_map_offsets (void);
+#define SVR4_FETCH_LINK_MAP_OFFSETS() \
+  sparc_linux_svr4_fetch_link_map_offsets ()
 
 #endif /* TM_SPARCLINUX_H */
--- ./config/sparc/sp64linux.mt.~1~	Fri Mar  9 22:17:24 2001
+++ ./config/sparc/sp64linux.mt	Fri Apr 19 22:36:58 2002
@@ -1,3 +1,3 @@
 # Target: UltraSPARC, running Linux 64bit programs
-TDEPFILES= sparc-tdep.o solib.o solib-svr4.o solib-legacy.o
+TDEPFILES= sparc-tdep.o sparc-linux-tdep.o solib.o solib-svr4.o solib-legacy.o
 TM_FILE= tm-sp64linux.h
--- ./config/sparc/tm-sp64linux.h.~1~	Fri Apr 19 14:58:09 2002
+++ ./config/sparc/tm-sp64linux.h	Fri Apr 19 22:38:31 2002
@@ -27,7 +27,20 @@ Foundation, Inc., 59 Temple Place - Suit
 #define SPARC_TARGET_LONG_DOUBLE_BYTES \
 	(GDB_TARGET_IS_SPARC64 ? 16 : 8)
 
-#define SIGCONTEXT_PC_OFFSET 16  /* See asm-sparc64/sigcontext.h */
+#undef LONGJMP_TARGE_TSIZE
+#define LONGJMP_TARGET_SIZE (GDB_TARGET_IS_SPARC64 ? 8 : 4)
+
+#undef JB_PC
+#define JB_PC (GDB_TARGET_IS_SPARC64 ? 24 : 2)
+
+#undef JB_ELEMENT_SIZE
+#define JB_ELEMENT_SIZE (GDB_TARGET_IS_SPARC64 ? 8 : 4)
+
+#undef GET_LONGJMP_TARGET
+#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
+extern int get_longjmp_target (CORE_ADDR *);
+
+#define SIGCONTEXT_PC_OFFSET (128 + (16 * 8) + 8)  /* See asm-sparc64/sigcontext.h */
 
 /* We always want full V9 + Ultra VIS stuff... */
 #undef TM_PRINT_INSN_MACH
@@ -35,6 +48,44 @@ Foundation, Inc., 59 Temple Place - Suit
 
 #define GDB_PTRACE_REGS64
 
-#include "tm-sysv4.h"
+#include "tm-linux.h"
+
+/* When the sparc Linux kernel calls a signal handler, the return
+   address points to a bit of code on the stack.  These definitions
+   are used to identify this bit of code as a signal trampoline in
+   order to support backtracing through calls to signal handlers.  */
+
+#define IN_SIGTRAMP(pc, name) sparc_linux_in_sigtramp (pc, name)
+extern int sparc_linux_in_sigtramp (CORE_ADDR, char *);
+
+#undef FRAME_SAVED_PC
+#define FRAME_SAVED_PC(frame) sparc_linux_frame_saved_pc (frame)
+extern CORE_ADDR sparc_linux_frame_saved_pc (struct frame_info *frame);
+
+#define FRAME_CHAIN(THISFRAME) (sparc_linux_frame_chain (THISFRAME))
+extern CORE_ADDR sparc_linux_frame_chain (struct frame_info *);
+
+#undef SAVED_PC_AFTER_CALL
+#define SAVED_PC_AFTER_CALL(frame) sparc_linux_saved_pc_after_call (frame)
+extern CORE_ADDR sparc_linux_saved_pc_after_call (struct frame_info *);
+
+/* When we call a function in a shared library, and the PLT sends us
+   into the dynamic linker to find the function's real address, we
+   need to skip over the dynamic linker call.  This function decides
+   when to skip, and where to skip to.  See the comments for
+   SKIP_SOLIB_RESOLVER at the top of infrun.c.  */
+#define SKIP_SOLIB_RESOLVER sparc_linux_skip_solib_resolver
+extern CORE_ADDR sparc_linux_skip_solib_resolver (CORE_ADDR pc);
+
+#undef SKIP_PROLOGUE_FRAMELESS_P
+#define SKIP_PROLOGUE_FRAMELESS_P(PC) sparc_linux_skip_prologue_frameless_p (PC)
+extern CORE_ADDR sparc_linux_skip_prologue_frameless_p (CORE_ADDR pc);
+
+/* ??? Should be doing this with gdbarch but that is not easy from
+   ??? ${cpu}-${os}-tdep.c files currently.  */
+
+extern struct link_map_offsets *sparc_linux_svr4_fetch_link_map_offsets (void);
+#define SVR4_FETCH_LINK_MAP_OFFSETS() \
+  sparc_linux_svr4_fetch_link_map_offsets ()
 
-#endif TM_SPARC_LIN64_H
+#endif /* TM_SPARC_LIN64_H */
--- ./sparc-tdep.c.~1~	Fri Apr 19 13:57:40 2002
+++ ./sparc-tdep.c	Fri Apr 19 22:38:57 2002
@@ -1720,8 +1720,12 @@ int
 get_longjmp_target (CORE_ADDR *pc)
 {
   CORE_ADDR jb_addr;
+#ifndef LONGJMP_TARGET_SIZE
 #define LONGJMP_TARGET_SIZE 4
-  char buf[LONGJMP_TARGET_SIZE];
+#endif
+  char *buf;
+
+  buf = alloca(LONGJMP_TARGET_SIZE);
 
   jb_addr = read_register (O0_REGNUM);
 
--- ./Makefile.in.~1~	Fri Apr 19 22:16:02 2002
+++ ./Makefile.in	Fri Apr 19 22:39:42 2002
@@ -1213,7 +1213,7 @@ ALLDEPFILES = 29k-share/udi/udip2soc.c 2
 	ser-go32.c ser-pipe.c ser-tcp.c \
 	sh-tdep.c solib.c solib-svr4.c solib-sunos.c sparc-linux-nat.c \
 	sparc-nat.c \
-	sparc-tdep.c sparcl-tdep.c sun3-nat.c \
+	sparc-tdep.c sparcl-tdep.c sparc-linux-tdep.c sun3-nat.c \
 	symm-tdep.c symm-nat.c \
 	vax-tdep.c \
 	vx-share/xdr_ld.c vx-share/xdr_ptrace.c vx-share/xdr_rdb.c \
@@ -2048,6 +2048,11 @@ source.o: source.c $(defs_h) $(expressio
 
 sparc-linux-nat.o: sparc-linux-nat.c $(defs_h) $(regcache_h) $(gdbcore_h) \
 	$(gdb_string_h) $(inferior_h) $(target_h) gregset.h
+
+sparc-linux-tdep.o: sparc-linux-tdep.c $(defs_h) $(arch_utils_h) $(frame_h) \
+	$(inferior_h) $(obstack_h) $(target_h) $(value_h) $(bfd_h) \
+	$(gdb_string_h) $(regcache_h) $(gdbcore_h) $(symtab_h) $(symfile_h) \
+	$(objdiles_h) $(solib_svr4_h)
 
 sparc-nat.o: sparc-nat.c $(bfd_h) $(defs_h) $(inferior_h) $(gdbcore_h) \
 	$(target_h) $(regcache_h)


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