Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH/RFA] NetBSD/i386 signal trampoline fixes
@ 2002-08-31 15:43 Jason R Thorpe
  2002-09-01 15:00 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Jason R Thorpe @ 2002-08-31 15:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: kettenis

[-- Attachment #1: Type: text/plain, Size: 1856 bytes --]

This is a companion to the change I just checked in for a bunch of
other NetBSD targets, but since this touches shared-by-other-BSDs code,
I think I need approval for it (the shared-code change is actually to
move the NetBSD-specific bits into a NetBSD-specifc tdep file).

The main reasons for moving the code are:

	1. The shared BSD code is not nearly as applicable to NetBSD
	   today as it once was.

	2. The signal trampoline fixes involve calling a function in
	   nbsd-tdep.c, and having that function call in shared code
	   is not appropriate.

	3. It will make it easier for me to maintain the NetBSD code
	   if it's not in a shared source file (and if it's only
	   applicable to NetBSD, it shouldn't be in a shared source file :-)

Once this change is in, I will be making additional changes to the signal
handling for NetBSD/i386, so I consider bullet #3 above to be pretty
important.

	* Makefile.in (i386nbsd-tdep.o): Add $(arch_utils_h),
	$(i386_tdep_h), and nbsd-tdep.h to dependency list.
	* i386-tdep.h (i386bsd_init_abi): New prototype.
	* i386bsd-tdep.c (i386bsd_init_abi): Remove "static" from
	function declaration.
	(_initialize_i386bsd_tdep): Don't register OS ABI handlers
	for NetBSD-a.out or NetBSD-ELF.
	(i386nbsd_sigtramp_start, i386nbsd_sigtramp_end)
	(i386nbsd_sc_pc_offset, i386nbsd_sc_sp_offset)
	(i386nbsd_init_abi, i386nbsdelf_init_abi): Move to...
	* i386nbsd-tdep.c: ...here.  Include arch-utils.h, i386-tdep.h,
	and nbsd-tdep.h.
	(i386nbsd_pc_in_sigtramp): New function.
	(i386nbsd_init_abi): Set gdbarch_pc_in_sigtramp to
	i386nbsd_pc_in_sigtramp.
	(_initialize_i386nbsd_tdep): Register i386nbsd_init_abi
	and i386nbsdelf_init_abi OS ABI handlers.
	* config/i386/nbsdaout.mt (TDEPFILES): Add nbsd-tdep.o.
	* config/i386/nbsdelf.mt (TDEPFILES): Likewise.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

[-- Attachment #2: i386-nbsd-sigtramp-patch --]
[-- Type: text/plain, Size: 9451 bytes --]

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.253
diff -c -r1.253 Makefile.in
*** Makefile.in	31 Aug 2002 20:28:36 -0000	1.253
--- Makefile.in	31 Aug 2002 20:31:30 -0000
***************
*** 1755,1761 ****
  # OBSOLETE i386m3-nat.o: i386m3-nat.c
  # OBSOLETE i386mach-nat.o: i386mach-nat.c
  i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(gdbtypes_h) $(gdbcore_h) \
! 	$(regcache_h) $(i387_tdep_h)
  i386obsd-nat.o: i386obsd-nat.c $(defs_h)
  i386v-nat.o: i386v-nat.c $(defs_h) $(frame_h) $(inferior_h) $(language_h) \
  	$(gdbcore_h) $(gdb_stat_h) $(floatformat_h) $(target_h)
--- 1755,1762 ----
  # OBSOLETE i386m3-nat.o: i386m3-nat.c
  # OBSOLETE i386mach-nat.o: i386mach-nat.c
  i386nbsd-tdep.o: i386nbsd-tdep.c $(defs_h) $(gdbtypes_h) $(gdbcore_h) \
! 	$(regcache_h) $(arch_utils_h) $(i386_tdep_h) $(i387_tdep_h) \
! 	nbsd-tdep.h
  i386obsd-nat.o: i386obsd-nat.c $(defs_h)
  i386v-nat.o: i386v-nat.c $(defs_h) $(frame_h) $(inferior_h) $(language_h) \
  	$(gdbcore_h) $(gdb_stat_h) $(floatformat_h) $(target_h)
Index: i386-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.h,v
retrieving revision 1.13
diff -c -r1.13 i386-tdep.h
*** i386-tdep.h	20 Aug 2002 17:59:50 -0000	1.13
--- i386-tdep.h	31 Aug 2002 20:31:32 -0000
***************
*** 175,179 ****
--- 175,180 ----
  /* Functions exported from i386bsd-tdep.c.  */
  
  extern CORE_ADDR i386bsd_sigcontext_addr (struct frame_info *frame);
+ extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *);
  
  #endif /* i386-tdep.h */
Index: i386bsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-tdep.c,v
retrieving revision 1.8
diff -c -r1.8 i386bsd-tdep.c
*** i386bsd-tdep.c	4 Jul 2002 22:59:01 -0000	1.8
--- i386bsd-tdep.c	31 Aug 2002 20:31:32 -0000
***************
*** 93,99 ****
  int i386bsd_sc_pc_offset = 20;
  int i386bsd_sc_sp_offset = 8;
  
! static void
  i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
--- 93,99 ----
  int i386bsd_sc_pc_offset = 20;
  int i386bsd_sc_sp_offset = 8;
  
! void
  i386bsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
  {
    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
***************
*** 113,173 ****
    tdep->sc_sp_offset = i386bsd_sc_sp_offset;
  }
  
- /* NetBSD 1.0 or later.  */
- 
- CORE_ADDR i386nbsd_sigtramp_start = 0xbfbfdf20;
- CORE_ADDR i386nbsd_sigtramp_end = 0xbfbfdff0;
- 
- /* From <machine/signal.h>.  */
- int i386nbsd_sc_pc_offset = 44;
- int i386nbsd_sc_sp_offset = 56;
- 
- static void
- i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- {
-   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- 
-   /* Obviously NetBSD is BSD-based.  */
-   i386bsd_init_abi (info, gdbarch);
- 
-   /* NetBSD uses -freg-struct-return by default.  */
-   tdep->struct_return = reg_struct_return;
- 
-   /* NetBSD uses a different memory layout.  */
-   tdep->sigtramp_start = i386nbsd_sigtramp_start;
-   tdep->sigtramp_end = i386nbsd_sigtramp_end;
- 
-   /* NetBSD has a `struct sigcontext' that's different from the
-      origional 4.3 BSD.  */
-   tdep->sc_pc_offset = i386nbsd_sc_pc_offset;
-   tdep->sc_sp_offset = i386nbsd_sc_sp_offset;
- }
- 
- /* NetBSD ELF.  */
- static void
- i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
- {
-   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
- 
-   /* It's still NetBSD.  */
-   i386nbsd_init_abi (info, gdbarch);
- 
-   /* But ELF-based.  */
-   i386_elf_init_abi (info, gdbarch);
- 
-   /* NetBSD ELF uses SVR4-style shared libraries.  */
-   set_gdbarch_in_solib_call_trampoline (gdbarch,
- 					generic_in_solib_call_trampoline);
- 
-   /* NetBSD ELF uses -fpcc-struct-return by default.  */
-   tdep->struct_return = pcc_struct_return;
- 
-   /* We support the SSE registers on NetBSD ELF.  */
-   tdep->num_xmm_regs = I386_NUM_XREGS - 1;
-   set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS
- 			+ I386_NUM_XREGS);
- }
- 
  /* FreeBSD 3.0-RELEASE or later.  */
  
  CORE_ADDR i386fbsd_sigtramp_start = 0xbfbfdf20;
--- 113,118 ----
***************
*** 246,255 ****
    gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_aout_flavour,
  				  i386bsd_aout_osabi_sniffer);
  
-   gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_AOUT,
- 			  i386nbsd_init_abi);
-   gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_ELF,
-  			  i386nbsdelf_init_abi);
    gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_AOUT,
  			  i386fbsdaout_init_abi);
    gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_FREEBSD_ELF,
--- 191,196 ----
Index: i386nbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-tdep.c,v
retrieving revision 1.6
diff -c -r1.6 i386nbsd-tdep.c
*** i386nbsd-tdep.c	2 Jul 2002 08:39:54 -0000	1.6
--- i386nbsd-tdep.c	31 Aug 2002 20:31:32 -0000
***************
*** 23,30 ****
--- 23,33 ----
  #include "gdbtypes.h"
  #include "gdbcore.h"
  #include "regcache.h"
+ #include "arch-utils.h"
  
+ #include "i386-tdep.h"
  #include "i387-tdep.h"
+ #include "nbsd-tdep.h"
  
  /* Map a GDB register number to an offset in the reg structure.  */
  static int regmap[] =
***************
*** 137,145 ****
--- 140,224 ----
    NULL					/* next */
  };
  
+ static int
+ i386nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+ {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+ 
+   /* Check for libc-provided signal trampoline.  */
+   if (nbsd_pc_in_sigtramp (pc, name))
+     return 1;
+ 
+   /* FIXME: sigtramp_start/sigtramp_end need to go away; we should
+      not be assuming the location of the kernel-provided trampoline!  */
+ 
+   return (pc >= tdep->sigtramp_start && pc < tdep->sigtramp_end);
+ }
+ 
+ CORE_ADDR i386nbsd_sigtramp_start = 0xbfbfdf20;
+ CORE_ADDR i386nbsd_sigtramp_end = 0xbfbfdff0;
+ 
+ /* From <machine/signal.h>.  */
+ int i386nbsd_sc_pc_offset = 44;
+ int i386nbsd_sc_sp_offset = 56;
+ 
+ static void 
+ i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ 
+   /* Obviously NetBSD is BSD-based.  */
+   i386bsd_init_abi (info, gdbarch);
+ 
+   /* NetBSD has different signal trampoline conventions.  */
+   set_gdbarch_pc_in_sigtramp (gdbarch, i386nbsd_pc_in_sigtramp);
+ 
+   /* NetBSD uses -freg-struct-return by default.  */
+   tdep->struct_return = reg_struct_return;
+ 
+   /* NetBSD uses a different memory layout.  */
+   tdep->sigtramp_start = i386nbsd_sigtramp_start;
+   tdep->sigtramp_end = i386nbsd_sigtramp_end;
+ 
+   /* NetBSD has a `struct sigcontext' that's different from the
+      origional 4.3 BSD.  */
+   tdep->sc_pc_offset = i386nbsd_sc_pc_offset;
+   tdep->sc_sp_offset = i386nbsd_sc_sp_offset;
+ }
+ 
+ /* NetBSD ELF.  */
+ static void
+ i386nbsdelf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
+ {
+   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ 
+   /* It's still NetBSD.  */
+   i386nbsd_init_abi (info, gdbarch);
+ 
+   /* But ELF-based.  */
+   i386_elf_init_abi (info, gdbarch);
+ 
+   /* NetBSD ELF uses SVR4-style shared libraries.  */
+   set_gdbarch_in_solib_call_trampoline (gdbarch,
+                                         generic_in_solib_call_trampoline);
+ 
+   /* NetBSD ELF uses -fpcc-struct-return by default.  */
+   tdep->struct_return = pcc_struct_return;
+ 
+   /* We support the SSE registers on NetBSD ELF.  */
+   tdep->num_xmm_regs = I386_NUM_XREGS - 1;
+   set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I386_NUM_FREGS
+                         + I386_NUM_XREGS);
+ }
+ 
  void
  _initialize_i386nbsd_tdep (void)
  {
    add_core_fns (&i386nbsd_core_fns);
    add_core_fns (&i386nbsd_elfcore_fns);
+ 
+   gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_AOUT,
+ 			  i386nbsd_init_abi);
+   gdbarch_register_osabi (bfd_arch_i386, GDB_OSABI_NETBSD_ELF,
+ 			  i386nbsdelf_init_abi);
  }
Index: config/i386/nbsdaout.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nbsdaout.mt,v
retrieving revision 1.1
diff -c -r1.1 nbsdaout.mt
*** config/i386/nbsdaout.mt	22 May 2002 03:59:54 -0000	1.1
--- config/i386/nbsdaout.mt	31 Aug 2002 20:31:33 -0000
***************
*** 1,3 ****
  # Target: Intel 386 running NetBSD
! TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o i386nbsd-tdep.o corelow.o
  TM_FILE= tm-nbsdaout.h
--- 1,4 ----
  # Target: Intel 386 running NetBSD
! TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o i386nbsd-tdep.o corelow.o \
! 	nbsd-tdep.o
  TM_FILE= tm-nbsdaout.h
Index: config/i386/nbsdelf.mt
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nbsdelf.mt,v
retrieving revision 1.9
diff -c -r1.9 nbsdelf.mt
*** config/i386/nbsdelf.mt	22 May 2002 03:59:54 -0000	1.9
--- config/i386/nbsdelf.mt	31 Aug 2002 20:31:33 -0000
***************
*** 1,3 ****
  # Target: Intel 386 running NetBSD
! TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o i386nbsd-tdep.o corelow.o
  TM_FILE= tm-nbsd.h
--- 1,4 ----
  # Target: Intel 386 running NetBSD
! TDEPFILES= i386-tdep.o i387-tdep.o i386bsd-tdep.o i386nbsd-tdep.o corelow.o \
! 	nbsd-tdep.o
  TM_FILE= tm-nbsd.h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFA] NetBSD/i386 signal trampoline fixes
  2002-08-31 15:43 [PATCH/RFA] NetBSD/i386 signal trampoline fixes Jason R Thorpe
@ 2002-09-01 15:00 ` Mark Kettenis
  2002-09-01 15:13   ` Jason R Thorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2002-09-01 15:00 UTC (permalink / raw)
  To: thorpej; +Cc: gdb-patches

Makes sense to me, although I hope you're open to moving code back
into the generic BSD file if it turns out to be relevant for other
*BSD's too.

So please go ahead.

Mark


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH/RFA] NetBSD/i386 signal trampoline fixes
  2002-09-01 15:00 ` Mark Kettenis
@ 2002-09-01 15:13   ` Jason R Thorpe
  0 siblings, 0 replies; 3+ messages in thread
From: Jason R Thorpe @ 2002-09-01 15:13 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

On Mon, Sep 02, 2002 at 12:00:00AM +0200, Mark Kettenis wrote:

 > Makes sense to me, although I hope you're open to moving code back
 > into the generic BSD file if it turns out to be relevant for other
 > *BSD's too.

Yah, that's fine... but the stuff I'm doing is definitely NetBSD-specific
at the moment.

 > So please go ahead.

Ok, will do, thanks.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-01 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-31 15:43 [PATCH/RFA] NetBSD/i386 signal trampoline fixes Jason R Thorpe
2002-09-01 15:00 ` Mark Kettenis
2002-09-01 15:13   ` Jason R Thorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox