From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29432 invoked by alias); 21 Apr 2002 08:20:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 29424 invoked from network); 21 Apr 2002 08:20:44 -0000 Received: from unknown (HELO pizda.ninka.net) (216.101.162.242) by sources.redhat.com with SMTP; 21 Apr 2002 08:20:44 -0000 Received: from localhost (IDENT:davem@localhost.localdomain [127.0.0.1]) by pizda.ninka.net (8.9.3/8.9.3) with ESMTP id BAA20783 for ; Sun, 21 Apr 2002 01:11:53 -0700 Date: Sun, 21 Apr 2002 01:20:00 -0000 Message-Id: <20020421.011153.14656372.davem@redhat.com> To: gdb-patches@sources.redhat.com Subject: [RFA] Multi-arch IN_SIGTRAMP From: "David S. Miller" Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2002-04/txt/msg00724.txt.bz2 I'm just basically walking one by one down the sparc-linux-tdep.c non-multi-arch'able target routines and making them multi-arch capable. This time IN_SIGTRAMP, notes: 1) I chose the !stramp(name, "_sigtramp") version as the default. 2) Others wanting the default based upon SIGTRAMP_{START,END} got a IN_SIGTRAMP define in their target header. Ok to install? 2002-04-21 David S. Miller * arch-utils.c (generic_in_sigtramp): New. * arch-utils.h (generic_in_sigtramp): Declare. * gdbarch.sh (IN_SIGTRAMP): Add, document, default to generic_in_sigtramp. * gdbarch.c, gdbarch.h: Regenerate. * inferior.h (IN_SIGTRAMP): Kill. * config/alpha/tm-alphalinux.h, config/i386/tm-fbsd.h, config/i386/tm-i386bsd.h, config/i386/tm-i386os9k.h, config/i386/tm-nbsd.h, config/i386/tm-obsd.h, config/m68k/tm-hp300bsd.h, config/m68k/tm-nbsd.h (IN_SIGTRAMP): Define non-multiarch version using SIGTRAMP_START and SIGTRAMP_END. * sparc-linux-tdep.c (sparc_linux_is_sigtramp): Mark it static. (sparc_linux_gdbarch_os_init): Pass it to set_gdbarch_in_sigtramp. * config/sparc/tm-linux.h config/sparc/tm-sp64linux.h (sparc_linux_in_sigtramp, IN_SIGTRAMP): Delete. --- ./config/alpha/tm-alphalinux.h.~1~ Sun Feb 24 14:56:04 2002 +++ ./config/alpha/tm-alphalinux.h Sun Apr 21 00:30:11 2002 @@ -38,6 +38,10 @@ extern long alpha_linux_sigtramp_offset #define SIGTRAMP_START(pc) (pc - alpha_linux_sigtramp_offset (pc)) #define SIGTRAMP_END(pc) (SIGTRAMP_START(pc) + 3*4) +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) /* Number of traps that happen between exec'ing the shell to run an inferior, and when we finally get to the inferior code. This is 2 --- ./config/i386/tm-fbsd.h.~1~ Sat Jul 28 10:03:38 2001 +++ ./config/i386/tm-fbsd.h Sun Apr 21 00:30:31 2002 @@ -68,6 +68,11 @@ extern int i386bsd_in_sigtramp (CORE_ADD extern CORE_ADDR i386bsd_sigtramp_start; extern CORE_ADDR i386bsd_sigtramp_end; +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Override FRAME_SAVED_PC to enable the recognition of signal handlers. */ #undef FRAME_SAVED_PC --- ./config/i386/tm-i386bsd.h.~1~ Tue Mar 6 00:21:29 2001 +++ ./config/i386/tm-i386bsd.h Sun Apr 21 00:30:52 2002 @@ -37,6 +37,11 @@ #define SIGTRAMP_START(pc) 0xfdbfdfc0 #define SIGTRAMP_END(pc) 0xfdbfe000 +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Saved Pc. Get it from sigcontext if within sigtramp. */ /* Offset to saved PC in sigcontext, from . */ --- ./config/i386/tm-i386os9k.h.~1~ Wed Oct 31 14:24:06 2001 +++ ./config/i386/tm-i386os9k.h Sun Apr 21 00:30:59 2002 @@ -55,6 +55,11 @@ #define SIGTRAMP_START(pc) 0xfdbfdfc0 #define SIGTRAMP_END(pc) 0xfdbfe000 +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Saved Pc. Get it from sigcontext if within sigtramp. */ /* Offset to saved PC in sigcontext, from . */ --- ./config/i386/tm-nbsd.h.~1~ Sat Jan 5 10:36:32 2002 +++ ./config/i386/tm-nbsd.h Sun Apr 21 00:31:08 2002 @@ -61,6 +61,11 @@ extern int i386bsd_in_sigtramp (CORE_ADD extern CORE_ADDR i386bsd_sigtramp_start; extern CORE_ADDR i386bsd_sigtramp_end; +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Override FRAME_SAVED_PC to enable the recognition of signal handlers. */ #undef FRAME_SAVED_PC --- ./config/i386/tm-obsd.h.~1~ Fri Nov 23 15:01:54 2001 +++ ./config/i386/tm-obsd.h Sun Apr 21 00:31:14 2002 @@ -60,6 +60,11 @@ extern int i386bsd_in_sigtramp (CORE_ADD extern CORE_ADDR i386bsd_sigtramp_start; extern CORE_ADDR i386bsd_sigtramp_end; +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Override FRAME_SAVED_PC to enable the recognition of signal handlers. */ #undef FRAME_SAVED_PC --- ./config/m68k/tm-hp300bsd.h.~1~ Tue Mar 6 00:21:30 2001 +++ ./config/m68k/tm-hp300bsd.h Sun Apr 21 00:31:24 2002 @@ -57,6 +57,11 @@ #define SIGTRAMP_START(pc) (STACK_END_ADDR - 20) #define SIGTRAMP_END(pc) (STACK_END_ADDR + TARGET_UPAGES * TARGET_NBPG) +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Address of end of stack space. */ #define STACK_END_ADDR 0xfff00000 --- ./config/m68k/tm-nbsd.h.~1~ Tue Mar 6 00:21:30 2001 +++ ./config/m68k/tm-nbsd.h Sun Apr 21 00:31:30 2002 @@ -36,6 +36,11 @@ #define SIGTRAMP_START(pc) (STACK_END_ADDR - 32) #define SIGTRAMP_END(pc) (STACK_END_ADDR) +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + #include "m68k/tm-m68k.h" #include "tm-nbsd.h" --- ./config/sparc/tm-linux.h.~1~ Sat Apr 20 20:53:49 2002 +++ ./config/sparc/tm-linux.h Sun Apr 21 00:55:00 2002 @@ -29,14 +29,6 @@ #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 *); - /* 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 --- ./config/sparc/tm-sp64linux.h.~1~ Sat Apr 20 20:54:24 2002 +++ ./config/sparc/tm-sp64linux.h Sun Apr 21 00:55:05 2002 @@ -29,15 +29,6 @@ Foundation, Inc., 59 Temple Place - Suit #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 *); - /* 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 --- ./config/vax/tm-vax.h.~1~ Mon Jan 28 20:42:45 2002 +++ ./config/vax/tm-vax.h Sun Apr 21 00:31:37 2002 @@ -49,6 +49,11 @@ extern CORE_ADDR vax_skip_prologue (CORE #define SIGTRAMP_START(pc) STACK_END_ADDR #define SIGTRAMP_END(pc) 0x80000000 +/* Whether we are in a sigtramp. */ + +#define IN_SIGTRAMP(pc, name) \ + ((pc) >= SIGTRAMP_START(pc) && (pc) < SIGTRAMP_END(pc)) + /* Stack grows downward. */ #define INNER_THAN(lhs,rhs) ((lhs) < (rhs)) --- ./gdbarch.c.~1~ Sat Apr 20 10:41:18 2002 +++ ./gdbarch.c Sun Apr 21 00:57:19 2002 @@ -250,6 +250,7 @@ struct gdbarch gdbarch_print_insn_ftype *print_insn; gdbarch_skip_trampoline_code_ftype *skip_trampoline_code; gdbarch_in_solib_call_trampoline_ftype *in_solib_call_trampoline; + gdbarch_in_sigtramp_ftype *in_sigtramp; gdbarch_in_function_epilogue_p_ftype *in_function_epilogue_p; gdbarch_construct_inferior_arguments_ftype *construct_inferior_arguments; gdbarch_dwarf2_build_frame_info_ftype *dwarf2_build_frame_info; @@ -396,6 +397,7 @@ struct gdbarch startup_gdbarch = 0, 0, 0, + 0, generic_in_function_epilogue_p, construct_inferior_arguments, 0, @@ -764,6 +766,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of print_insn, invalid_p == 0 */ /* Skip verify of skip_trampoline_code, invalid_p == 0 */ /* Skip verify of in_solib_call_trampoline, invalid_p == 0 */ + if (gdbarch->in_sigtramp == 0) + gdbarch->in_sigtramp = generic_in_sigtramp; /* Skip verify of in_function_epilogue_p, invalid_p == 0 */ /* Skip verify of construct_inferior_arguments, invalid_p == 0 */ /* Skip verify of dwarf2_build_frame_info, has predicate */ @@ -1361,6 +1365,17 @@ gdbarch_dump (struct gdbarch *gdbarch, s (long) current_gdbarch->integer_to_address /*INTEGER_TO_ADDRESS ()*/); #endif +#ifdef IN_SIGTRAMP + fprintf_unfiltered (file, + "gdbarch_dump: %s # %s\n", + "IN_SIGTRAMP(pc, name)", + XSTRING (IN_SIGTRAMP (pc, name))); + if (GDB_MULTI_ARCH) + fprintf_unfiltered (file, + "gdbarch_dump: IN_SIGTRAMP = 0x%08lx\n", + (long) current_gdbarch->in_sigtramp + /*IN_SIGTRAMP ()*/); +#endif #ifdef IN_SOLIB_CALL_TRAMPOLINE fprintf_unfiltered (file, "gdbarch_dump: %s # %s\n", @@ -4406,6 +4421,24 @@ set_gdbarch_in_solib_call_trampoline (st gdbarch_in_solib_call_trampoline_ftype in_solib_call_trampoline) { gdbarch->in_solib_call_trampoline = in_solib_call_trampoline; +} + +int +gdbarch_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name) +{ + if (gdbarch->in_sigtramp == 0) + internal_error (__FILE__, __LINE__, + "gdbarch: gdbarch_in_sigtramp invalid"); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_in_sigtramp called\n"); + return gdbarch->in_sigtramp (pc, name); +} + +void +set_gdbarch_in_sigtramp (struct gdbarch *gdbarch, + gdbarch_in_sigtramp_ftype in_sigtramp) +{ + gdbarch->in_sigtramp = in_sigtramp; } int --- ./sparc-linux-tdep.c.~1~ Sat Apr 20 21:50:48 2002 +++ ./sparc-linux-tdep.c Sun Apr 21 00:54:02 2002 @@ -165,11 +165,9 @@ sparc_linux_rt_sigtramp_start (CORE_ADDR return pc; } -/* Return whether PC is in a GNU/Linux sigtramp routine. +/* Return whether PC is in a GNU/Linux sigtramp routine. */ - TODO Need to generically multi-arch this. */ - -int +static int sparc_linux_in_sigtramp (CORE_ADDR pc, char *name) { int ret; @@ -485,6 +483,7 @@ sparc_linux_gdbarch_os_init(struct gdbar set_gdbarch_frame_chain (gdbarch, sparc_linux_frame_chain); set_gdbarch_frame_saved_pc (gdbarch, sparc_linux_frame_saved_pc); set_gdbarch_saved_pc_after_call (gdbarch, sparc_linux_saved_pc_after_call); + set_gdbarch_in_sigtramp (gdbarch, sparc_linux_in_sigtramp); if (gdbarch_tdep (gdbarch)->intreg_size == 4) { --- ./inferior.h.~1~ Wed Apr 10 15:00:20 2002 +++ ./inferior.h Sun Apr 21 00:52:23 2002 @@ -403,29 +403,6 @@ extern char *stop_registers; extern int attach_flag; -/* Sigtramp is a routine that the kernel calls (which then calls the - signal handler). On most machines it is a library routine that - is linked into the executable. - - This macro, given a program counter value and the name of the - function in which that PC resides (which can be null if the - name is not known), returns nonzero if the PC and name show - that we are in sigtramp. - - On most machines just see if the name is sigtramp (and if we have - no name, assume we are not in sigtramp). */ -#if !defined (IN_SIGTRAMP) -#if defined (SIGTRAMP_START) -#define IN_SIGTRAMP(pc, name) \ - ((pc) >= SIGTRAMP_START(pc) \ - && (pc) < SIGTRAMP_END(pc) \ - ) -#else -#define IN_SIGTRAMP(pc, name) \ - (name && STREQ ("_sigtramp", name)) -#endif -#endif - /* Possible values for CALL_DUMMY_LOCATION. */ #define ON_STACK 1 #define BEFORE_TEXT_END 2 --- ./gdbarch.sh.~1~ Sat Apr 20 10:41:18 2002 +++ ./gdbarch.sh Sun Apr 21 00:51:11 2002 @@ -608,6 +608,13 @@ f:2:SKIP_TRAMPOLINE_CODE:CORE_ADDR:skip_ # trampoline code in the ".plt" section. IN_SOLIB_CALL_TRAMPOLINE evaluates # to nonzero if we are current stopped in one of these. f:2:IN_SOLIB_CALL_TRAMPOLINE:int:in_solib_call_trampoline:CORE_ADDR pc, char *name:pc, name:::generic_in_solib_call_trampoline::0 +# Sigtramp is a routine that the kernel calls (which then calls the +# signal handler). On most machines it is a library routine that +# is linked into the executable. +# Say whether the program counter value PC is in a signal trampoline. The +# NAME argument, if non-NULL, is the name of the function in which +# PC resides. +f:2:IN_SIGTRAMP:int:in_sigtramp:CORE_ADDR pc, char *name:pc, name::::generic_in_sigtramp::0 # A target might have problems with watchpoints as soon as the stack # frame of the current function has been destroyed. This mostly happens # as the first action in a funtion's epilogue. in_function_epilogue_p() --- ./arch-utils.h.~1~ Wed Feb 6 05:00:44 2002 +++ ./arch-utils.h Sun Apr 21 00:52:05 2002 @@ -144,6 +144,8 @@ extern CORE_ADDR generic_skip_trampoline extern int generic_in_solib_call_trampoline (CORE_ADDR pc, char *name); +extern int generic_in_sigtramp (CORE_ADDR pc, char *name); + extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc); extern void default_print_float_info (void); --- ./arch-utils.c.~1~ Thu Apr 18 11:08:58 2002 +++ ./arch-utils.c Sun Apr 21 00:50:49 2002 @@ -115,6 +115,12 @@ generic_in_solib_call_trampoline (CORE_A } int +generic_in_sigtramp (CORE_ADDR pc, char *name) +{ + return (name && STREQ ("_sigtramp", name)); +} + +int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc) { return 0; --- ./gdbarch.h.~1~ Sat Apr 20 10:41:18 2002 +++ ./gdbarch.h Sun Apr 21 00:56:38 2002 @@ -2268,6 +2268,30 @@ extern void set_gdbarch_in_solib_call_tr #endif #endif +/* Sigtramp is a routine that the kernel calls (which then calls the + signal handler). On most machines it is a library routine that + is linked into the executable. + Say whether the program counter value PC is in a signal trampoline. The + NAME argument, if non-NULL, is the name of the function in which + PC resides. */ + +/* Default (function) for non- multi-arch platforms. */ +#if (!GDB_MULTI_ARCH) && !defined (IN_SIGTRAMP) +#define IN_SIGTRAMP(pc, name) (generic_in_sigtramp (pc, name)) +#endif + +typedef int (gdbarch_in_sigtramp_ftype) (CORE_ADDR pc, char *name); +extern int gdbarch_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name); +extern void set_gdbarch_in_sigtramp (struct gdbarch *gdbarch, gdbarch_in_sigtramp_ftype *in_sigtramp); +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (IN_SIGTRAMP) +#error "Non multi-arch definition of IN_SIGTRAMP" +#endif +#if GDB_MULTI_ARCH +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (IN_SIGTRAMP) +#define IN_SIGTRAMP(pc, name) (gdbarch_in_sigtramp (current_gdbarch, pc, name)) +#endif +#endif + /* A target might have problems with watchpoints as soon as the stack frame of the current function has been destroyed. This mostly happens as the first action in a funtion's epilogue. in_function_epilogue_p()