Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Patches for FreeBSD 4.2
@ 2001-07-10 23:39 Stu Grossman
  2001-07-11  8:46 ` Andrew Cagney
  2001-07-12 13:50 ` Mark Kettenis
  0 siblings, 2 replies; 7+ messages in thread
From: Stu Grossman @ 2001-07-10 23:39 UTC (permalink / raw)
  To: gdb-patches

Here is a set of patches that fixes a bunch of problems (and some testsuite
failures) for FreeBSD 4.2.

		      Stu

Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.1410
diff -c -p -r1.1410 ChangeLog
*** ChangeLog	2001/07/04 21:14:05	1.1410
--- ChangeLog	2001/07/11 00:06:34
***************
*** 1,3 ****
--- 1,29 ----
+ 2001-07-10  Stu Grossman  <grossman@juniper.net>
+ 
+ 	* Makefile.in (SUBDIR_MI_INITS): Add $(srcdir) to source file names for
+ 	old makes.
+ 	* i386-tdep.c (i386_store_return_value):  Make sure that floats get
+ 	stored at the top of the FP stack.
+ 	* infrun.c (handle_inferior_event):  Change the way stepping over
+ 	signals works.  It's much more general, and works for systems that
+ 	don't use signal trampolines on entry.
+ 	* i386-freebsd-nat.c:  New file to support FreeBSD specific stuff.
+ 	* config/i386/fbsd.mh (NATDEPFILES):  Add i386-freebsd-nat.o.
+ 	* config/i386/nm-fbsd.h:  Define CHILD_RESUME 'cuz FreeBSD can't use
+ 	the stock one.
+ 	* config/i386/tm-fbsd.h:  Define FRAME_SAVED_PC to use FreeBSD specific
+ 	code to extract return PC from signal frames.
+ 	* Define FRAME_CHAIN_VALID to use func_frame_chain_valid, since ELF
+ 	doesn't generate N_TEXT object file markers.
+ 	* Remove SIGTRAMP_START and SIGTRAMP_END.  Move all of that logic into
+ 	a FreeBSD specific function invoke via IN_SIGTRAMP.
+ 	* testsuite/gdb.base/completion.exp:  Fix completion test of things
+ 	beginning with "a".  FreeBSD's libc includes many things beginning with
+ 	"a", which confused the test.  Fix various other completion tests as
+ 	well.
+ 	* testsuite/gdb.base/selftest.exp(backtrace through signal handler):
+ 	Update expected string to match current reality.
+ 
  2001-07-04  Mark Kettenis  <kettenis@gnu.org>
  
  	* i387-tdep.c (print_i387_value): Add extra space after final full
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.91
diff -c -p -r1.91 Makefile.in
*** Makefile.in	2001/06/28 03:33:26	1.91
--- Makefile.in	2001/07/11 00:06:36
*************** SUBDIR_MI_SRCS = \
*** 170,176 ****
  	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
  SUBDIR_MI_DEPS =
  SUBDIR_MI_INITS = \
! 	mi/mi-cmds.c mi/mi-parse.c mi/mi-main.c mi/mi-out.c
  SUBDIR_MI_LDFLAGS=
  SUBDIR_MI_CFLAGS= \
  	-DMI_OUT=1
--- 170,176 ----
  	mi/mi-main.c mi/mi-parse.c mi/mi-getopt.c
  SUBDIR_MI_DEPS =
  SUBDIR_MI_INITS = \
! 	$(srcdir)/mi/mi-cmds.c $(srcdir)/mi/mi-parse.c $(srcdir)/mi/mi-main.c $(srcdir)/mi/mi-out.c
  SUBDIR_MI_LDFLAGS=
  SUBDIR_MI_CFLAGS= \
  	-DMI_OUT=1
Index: gdb/i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.31
diff -c -p -r1.31 i386-tdep.c
*** i386-tdep.c	2001/05/09 16:16:33	1.31
--- i386-tdep.c	2001/07/11 00:06:36
*************** i386_store_return_value (struct type *ty
*** 861,871 ****
--- 861,885 ----
  
    if (TYPE_CODE (type) == TYPE_CODE_FLT)
      {
+       ULONGEST fstat;
+ 
        if (NUM_FREGS == 0)
  	{
  	  warning ("Cannot set floating-point return value.");
  	  return;
  	}
+ 
+       /* According to the SVR4 x86 ABI, a returned FP value must be at the top
+ 	 of the FP stack.  So we force the FP stack pointer to make it look
+ 	 like there is one item on the FP stack (at st(0)) which is where we
+ 	 will store the return value.  Failure to do this will result in great
+ 	 weirdness due to uncaught FP stack overflows.  */
+ 
+       fstat = read_register (FSTAT_REGNUM);
+       fstat |= 0x3800;
+       write_register (FSTAT_REGNUM, fstat);
+ 
+       write_register (FTAG_REGNUM, 0x3fff);
  
        /* Floating-point return values can be found in %st(0).  */
        if (len == TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT
Index: gdb/infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.41
diff -c -p -r1.41 infrun.c
*** infrun.c	2001/06/28 21:48:41	1.41
--- infrun.c	2001/07/11 00:06:39
*************** handle_inferior_event (struct execution_
*** 2265,2304 ****
  	/* Clear the signal if it should not be passed.  */
  	if (signal_program[stop_signal] == 0)
  	  stop_signal = TARGET_SIGNAL_0;
! 
! 	/* I'm not sure whether this needs to be check_sigtramp2 or
! 	   whether it could/should be keep_going.
! 
! 	   This used to jump to step_over_function if we are stepping,
! 	   which is wrong.
! 
! 	   Suppose the user does a `next' over a function call, and while
! 	   that call is in progress, the inferior receives a signal for
! 	   which GDB does not stop (i.e., signal_stop[SIG] is false).  In
! 	   that case, when we reach this point, there is already a
! 	   step-resume breakpoint established, right where it should be:
! 	   immediately after the function call the user is "next"-ing
! 	   over.  If we call step_over_function now, two bad things
! 	   happen:
! 
! 	   - we'll create a new breakpoint, at wherever the current
! 	     frame's return address happens to be.  That could be
! 	     anywhere, depending on what function call happens to be on
! 	     the top of the stack at that point.  Point is, it's probably
! 	     not where we need it.
! 
!            - the existing step-resume breakpoint (which is at the correct
! 	     address) will get orphaned: step_resume_breakpoint will point
! 	     to the new breakpoint, and the old step-resume breakpoint
! 	     will never be cleaned up.
! 
!            The old behavior was meant to help HP-UX single-step out of
!            sigtramps.  It would place the new breakpoint at prev_pc, which
!            was certainly wrong.  I don't know the details there, so fixing
!            this probably breaks that.  As with anything else, it's up to
!            the HP-UX maintainer to furnish a fix that doesn't break other
!            platforms.  --JimB, 20 May 1999 */
! 	check_sigtramp2 (ecs);
  	keep_going (ecs);
  	return;
        }
--- 2265,2294 ----
  	/* Clear the signal if it should not be passed.  */
  	if (signal_program[stop_signal] == 0)
  	  stop_signal = TARGET_SIGNAL_0;
! 	else
! 	  {
! 	    /* What is happening here is that the inferior is about to have a
! 	       signal delivered.  What we will do now is set a step_resume
! 	       breakpoint at the current PC to allow the signal handler to run,
! 	       and then keep on chugging along.  */
! 
! 	    if (currently_stepping (ecs))
! 	      {
! 		struct symtab_and_line sr_sal;
! 
! 		INIT_SAL (&sr_sal);	/* initialize to zeroes */
! 		sr_sal.pc = stop_pc;
! 		sr_sal.section = find_pc_overlay (sr_sal.pc);
! 		/* We perhaps could set the frame if we kept track of what the
! 		   frame corresponding to prev_pc was.  But we don't, so don't.  */
! 		through_sigtramp_breakpoint =
! 		  set_momentary_breakpoint (sr_sal, NULL, bp_through_sigtramp);
! 		insert_breakpoints ();
! 
! 		ecs->remove_breakpoints_on_following_step = 1;
! 		ecs->another_trap = 1;
! 	      }
! 	  }
  	keep_going (ecs);
  	return;
        }
Index: gdb/config/i386/fbsd.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/fbsd.mh,v
retrieving revision 1.7
diff -c -p -r1.7 fbsd.mh
*** fbsd.mh	2001/04/12 18:44:40	1.7
--- fbsd.mh	2001/07/11 00:06:41
***************
*** 1,6 ****
  # Host: Intel 386 running FreeBSD
  XDEPFILES=
  # NOTE: Do not spread NATDEPFILES over several lines - it hurts BSD make.
! NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i387-nat.o i386bsd-nat.o i386-nat.o
  XM_FILE= xm-fbsd.h
  NAT_FILE= nm-fbsd.h
--- 1,6 ----
  # Host: Intel 386 running FreeBSD
  XDEPFILES=
  # NOTE: Do not spread NATDEPFILES over several lines - it hurts BSD make.
! NATDEPFILES= fork-child.o infptrace.o inftarg.o solib.o solib-svr4.o solib-legacy.o corelow.o core-aout.o core-regset.o i387-nat.o i386bsd-nat.o i386-nat.o i386-freebsd-nat.o
  XM_FILE= xm-fbsd.h
  NAT_FILE= nm-fbsd.h
Index: gdb/config/i386/nm-fbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-fbsd.h,v
retrieving revision 1.4
diff -c -p -r1.4 nm-fbsd.h
*** nm-fbsd.h	2001/03/31 18:09:03	1.4
--- nm-fbsd.h	2001/07/11 00:06:42
***************
*** 28,33 ****
--- 28,36 ----
  
  #include "i386/nm-i386.h"
  
+ /* Must use child_resume in i386-freebsd-nat.c to work around OS bug */
+ #define CHILD_RESUME
+ 
  /* Provide access to the i386 hardware debugging registers.  */
  
  #define I386_DR_LOW_SET_CONTROL(control) \
Index: gdb/config/i386/tm-fbsd.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/tm-fbsd.h,v
retrieving revision 1.3
diff -c -p -r1.3 tm-fbsd.h
*** tm-fbsd.h	2001/03/06 08:21:28	1.3
--- tm-fbsd.h	2001/07/11 00:06:42
***************
*** 24,33 ****
--- 24,43 ----
  #define HAVE_I387_REGS
  #include "i386/tm-i386.h"
  
+ #undef FRAME_SAVED_PC
+ #define FRAME_SAVED_PC(FRAME) i386_freebsd_frame_saved_pc(FRAME)
+ CORE_ADDR i386_freebsd_frame_saved_pc(struct frame_info *frame);
+ 
+ /* Use the alternate method of determining valid frame chains. */
+ 
+ #define FRAME_CHAIN_VALID(fp,fi) func_frame_chain_valid (fp, fi)
+ 
  /* FreeBSD uses the old gcc convention for struct returns.  */
  
+ #if 0
  #define USE_STRUCT_CONVENTION(gcc_p, type) \
    generic_use_struct_convention (1, type)
+ #endif
  \f
  
  /* Support for longjmp.  */
*************** extern int get_longjmp_target (CORE_ADDR
*** 45,57 ****
  \f
  
  /* Support for signal handlers.  */
- 
- /* The sigtramp is above the user stack and immediately below
-    the user area.  Using constants here allows for cross debugging.
-    These are tested for FreeBSD 3.4.  */
  
! #define SIGTRAMP_START(pc)	0xbfbfdf20
! #define SIGTRAMP_END(pc)	0xbfbfdff0
  
  /* Offset to saved PC in sigcontext, from <sys/signal.h>.  */
  #define SIGCONTEXT_PC_OFFSET 20
--- 55,63 ----
  \f
  
  /* Support for signal handlers.  */
  
! extern int i386_freebsd_in_sigtramp (CORE_ADDR pc, char *name);
! #define IN_SIGTRAMP(PC, NAME) i386_freebsd_in_sigtramp (PC, NAME)
  
  /* Offset to saved PC in sigcontext, from <sys/signal.h>.  */
  #define SIGCONTEXT_PC_OFFSET 20
Index: gdb/testsuite/gdb.base/completion.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/completion.exp,v
retrieving revision 1.4
diff -c -p -r1.4 completion.exp
*** completion.exp	2001/05/30 02:54:41	1.4
--- completion.exp	2001/07/11 00:06:46
*************** gdb_expect  {
*** 349,368 ****
          }
  
  
! send_gdb "p \"a\t"
  sleep 1
  gdb_expect  {
!         -re "^p \"a\\\x07$"\
              { send_gdb "\n"
                gdb_expect {
                        -re "Unterminated string in expression\\..*$gdb_prompt $"\
!                                         { pass "complete 'p a'"}
!                       -re ".*$gdb_prompt $" { fail "complete 'p a'"}
!                       timeout           {fail "(timeout) complete 'p a'"}
                       }
              }
!         -re ".*$gdb_prompt $"       { fail "complete 'p \"a'" }
!         timeout         { fail "(timeout) complete 'p \"a'" }
          }
  
  send_gdb "p 'a\t"
--- 349,370 ----
          }
  
  
! set unlikely_word abracadubious
! 
! send_gdb "p \"$unlikely_word\t"
  sleep 1
  gdb_expect  {
!         -re "^p \"$unlikely_word\\\x07$"\
              { send_gdb "\n"
                gdb_expect {
                        -re "Unterminated string in expression\\..*$gdb_prompt $"\
!                                         { pass "complete 'p $unlikely_word'"}
!                       -re ".*$gdb_prompt $" { fail "complete 'p $unlikely_word'"}
!                       timeout           {fail "(timeout) complete 'p $unlikely_word'"}
                       }
              }
!         -re ".*$gdb_prompt $"       { fail "complete 'p \"$unlikely_word'" }
!         timeout         { fail "(timeout) complete 'p \"$unlikely_word'" }
          }
  
  send_gdb "p 'a\t"
*************** gdb_expect {
*** 387,393 ****
      -re "^p 'a\\\x07$" {
  	send_gdb "\t"
  	gdb_expect {
! 	    -re "a64l.*argv.*$gdb_prompt p .a$" {
  		send_gdb "\n"
  		gdb_expect {
  		    -re "Invalid character constant\\..*$gdb_prompt $" {
--- 389,395 ----
      -re "^p 'a\\\x07$" {
  	send_gdb "\t"
  	gdb_expect {
! 	    -re ".*argv.*$gdb_prompt p .a$" {
  		send_gdb "\n"
  		gdb_expect {
  		    -re "Invalid character constant\\..*$gdb_prompt $" {
*************** gdb_expect {
*** 425,487 ****
  }
  
  
! send_gdb "p b-a\t"
  sleep 1
  gdb_expect  {
!         -re "^p b-a\\\x07$"\
              { send_gdb "\n"
                gdb_expect {
                        -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
!                                         { pass "complete 'p b-a'"}
!                       -re ".*$gdb_prompt $" { fail "complete 'p b-a'"}
!                       timeout           {fail "(timeout) complete 'p b-a'"}
                       }
              }
!         -re ".*$gdb_prompt $"       { fail "complete 'p b-a'" }
!         timeout         { fail "(timeout) complete 'p b-a'" }
          }
  
! send_gdb "p b-a\t"
  sleep 1
  gdb_expect {
!     -re "^p b-a\\\x07$" {
  	send_gdb "\t"
  	gdb_expect {
! 	    -re "a64l.*argv.*$gdb_prompt p b-a$" {
  		send_gdb "\n"
  		gdb_expect {
  		    -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
! 			pass "complete (2) 'p b-a'"
  		    }
! 		    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
! 		    timeout { fail "(timeout) complete (2) 'p b-a'" }
  		}
  	    }
  	    -re "(There are $decimal possibilities\\.  Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
  		send_gdb "n"
  		gdb_expect {
! 		    -re "\\(gdb\\) p b-a$" {
  			send_gdb "\n"
  			gdb_expect {
  			    -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
! 				pass "complete (2) 'p b-a'"
  			    }
  			    -re ".*$gdb_prompt $" {
! 				fail "complete (2) 'p b-a'"
  			    }
! 			    timeout { fail "(timeout) complete (2) 'p b-a'" }
  			}
  		    }
! 		    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
! 		    timeout { fail "(timeout) complete (2) 'p b-a'" }
  		}
  	    }
! 	    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
! 	    timeout { fail "(timeout) complete (2) 'p b-a'" }
          }
      }
!     -re ".*$gdb_prompt $" { fail "complete (2) 'p b-a'" }
!     timeout { fail "(timeout) complete (2) 'p b-a'" }
  }
  
  send_gdb "p b-\t"
--- 427,489 ----
  }
  
  
! send_gdb "p b-marker\t"
  sleep 1
  gdb_expect  {
!         -re "^p b-marker\\\x07$"\
              { send_gdb "\n"
                gdb_expect {
                        -re "No symbol \"b\" in current context\\..*$gdb_prompt $"\
!                                         { pass "complete 'p b-marker'"}
!                       -re ".*$gdb_prompt $" { fail "complete 'p b-marker'"}
!                       timeout           {fail "(timeout) complete 'p b-marker'"}
                       }
              }
!         -re ".*$gdb_prompt $"       { fail "complete 'p b-marker'" }
!         timeout         { fail "(timeout) complete 'p b-marker'" }
          }
  
! send_gdb "p b-marker\t"
  sleep 1
  gdb_expect {
!     -re "^p b-marker\\\x07$" {
  	send_gdb "\t"
  	gdb_expect {
! 	    -re "marker1  *marker2  *marker3  *marker4 *.*$gdb_prompt p b-marker$" {
  		send_gdb "\n"
  		gdb_expect {
  		    -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
! 			pass "complete (2) 'p b-marker'"
  		    }
! 		    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-marker'" }
! 		    timeout { fail "(timeout) complete (2) 'p b-marker'" }
  		}
  	    }
  	    -re "(There are $decimal possibilities\\.  Do you really\r\nwish to see them all.|Display all $decimal possibilities.) \\(y or n\\)$" {
  		send_gdb "n"
  		gdb_expect {
! 		    -re "\\(gdb\\) p b-marker$" {
  			send_gdb "\n"
  			gdb_expect {
  			    -re "No symbol \"b\" in current context\\..*$gdb_prompt $" {
! 				pass "complete (2) 'p b-marker'"
  			    }
  			    -re ".*$gdb_prompt $" {
! 				fail "complete (2) 'p b-marker'"
  			    }
! 			    timeout { fail "(timeout) complete (2) 'p b-marker'" }
  			}
  		    }
! 		    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-marker'" }
! 		    timeout { fail "(timeout) complete (2) 'p b-marker'" }
  		}
  	    }
! 	    -re ".*$gdb_prompt $" { fail "complete (2) 'p b-marker'" }
! 	    timeout { fail "(timeout) complete (2) 'p b-marker'" }
          }
      }
!     -re ".*$gdb_prompt $" { fail "complete (2) 'p b-marker'" }
!     timeout { fail "(timeout) complete (2) 'p b-marker'" }
  }
  
  send_gdb "p b-\t"
Index: gdb/testsuite/gdb.base/selftest.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/selftest.exp,v
retrieving revision 1.2
diff -c -p -r1.2 selftest.exp
*** selftest.exp	2001/03/06 08:21:51	1.2
--- selftest.exp	2001/07/11 00:06:46
*************** GDB.*Copyright \[0-9\]+ Free Software Fo
*** 376,382 ****
      set description "backtrace through signal handler"
      send_gdb "backtrace\n"
      gdb_expect {
! 	-re "#0.*read.*in main \\(.*\\) at .*main\\.c.*$gdb_prompt $" {
  	    pass "$description"
  	}
  	-re ".*$gdb_prompt $" {
--- 376,382 ----
      set description "backtrace through signal handler"
      send_gdb "backtrace\n"
      gdb_expect {
! 	-re "#0.*cli_command_loop.*in main \\(.*\\) at .*main\\.c.*$gdb_prompt $" {
  	    pass "$description"
  	}
  	-re ".*$gdb_prompt $" {
Index: gdb/i386-freebsd-nat.c
===================================================================
diff -c -p empty i386-freebsd-nat.c 
*** 			Tue Jul 10 17:24:02 2001
--- i386-freebsd-nat.c	Tue Jul 10 13:40:10 2001
***************
*** 0 ****
--- 1,115 ----
+ /* Native-dependent code for FreeBSD Unix running on i386's, for GDB.
+    Copyright 2000 Free Software Foundation, Inc.
+ 
+    (This file is derived from i386b-nat.c.)
+ 
+    This file is part of GDB.
+ 
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+ 
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+ 
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.  */
+ 
+ #include "defs.h"
+ #include "gdbcore.h"
+ #include "frame.h"
+ #include "inferior.h"
+ #include <sys/param.h>
+ #include <sys/user.h>
+ #include <sys/exec.h>
+ #include <machine/sigframe.h>
+ #include <sys/ptrace.h>
+ 
+ /* Return the saved program counter for FRAME.  */
+ 
+ CORE_ADDR
+ i386_freebsd_frame_saved_pc (struct frame_info *frame)
+ {
+   CORE_ADDR pc;
+ 
+   if (!frame->signal_handler_caller)
+     return read_memory_unsigned_integer (frame->frame + 4, 4);
+ 
+   if (frame->next)
+     return read_memory_unsigned_integer ((CORE_ADDR)&((struct sigframe *)(frame->next->frame + 8))->sf_uc.uc_mcontext.mc_eip, 4);
+   else
+     return 0;
+ }
+ 
+ int
+ i386_freebsd_in_sigtramp (CORE_ADDR pc, char *name)
+ {
+   return ((pc >= (CORE_ADDR)PS_STRINGS - 100)
+ 	  && ((pc) < (CORE_ADDR)PS_STRINGS));
+ }
+ 
+ /* Resume execution of the inferior process.
+    If STEP is nonzero, single-step it.
+    If SIGNAL is nonzero, give it that signal.  */
+ 
+ void
+ child_resume (ptid_t ptid, int step, enum target_signal signal)
+ {
+   int pid = PIDGET (ptid);
+ 
+   errno = 0;
+ 
+   if (pid == -1)
+     /* Resume all threads.  */
+     /* I think this only gets used in the non-threaded case, where "resume
+        all threads" and "resume inferior_ptid" are the same.  */
+     pid = PIDGET (inferior_ptid);
+ 
+   /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
+      it was.  (If GDB wanted it to start some other way, we have already
+      written a new PC value to the child.)
+ 
+      If this system does not support PT_STEP, a higher level function will
+      have called single_step() to transmute the step request into a
+      continue request (by setting breakpoints on all possible successor
+      instructions), so we don't have to worry about that here.  */
+ 
+   if (step)
+     {
+       if (SOFTWARE_SINGLE_STEP_P ())
+ 	internal_error (__FILE__, __LINE__, "failed internal consistency check");		/* Make sure this doesn't happen. */
+       else
+ 	ptrace (PT_STEP, pid, (PTRACE_ARG3_TYPE) 1,
+ 		target_signal_to_host (signal));
+     }
+   else
+     {
+       unsigned int eflags;
+ 
+       /* Workaround for a bug in FreeBSD.  Make sure that the trace flag is off
+ 	 when doing a continue.  There is a code path through the kernel which
+ 	 can leaves the flag on by the time we get here.  If a process has a
+ 	 signal pending (such as SIGALRM) and we do a PT_STEP, the process
+ 	 never really has a chance to run because the kernel needs to notify
+ 	 the debugger that a signal is being sent.  Therefore, the process
+ 	 never goes through the kernel's trap() function which would normally
+ 	 clear it.  */
+ 
+       eflags = read_register (PS_REGNUM);
+       if (eflags & 0x100)
+ 	write_register (PS_REGNUM, eflags & ~0x100);
+ 
+       ptrace (PT_CONTINUE, pid, (PTRACE_ARG3_TYPE) 1,
+ 	      target_signal_to_host (signal));
+     }
+ 
+   if (errno)
+     {
+       perror_with_name ("ptrace");
+     }
+ }


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

* Re: Patches for FreeBSD 4.2
  2001-07-10 23:39 Patches for FreeBSD 4.2 Stu Grossman
@ 2001-07-11  8:46 ` Andrew Cagney
  2001-07-11  9:18   ` Stu Grossman
  2001-07-12 13:50 ` Mark Kettenis
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2001-07-11  8:46 UTC (permalink / raw)
  To: Stu Grossman, Jim Blandy; +Cc: gdb-patches

Stu, you know the drill.  Can you get an assignment in place?  I've cc'd 
our assignments clerk

With regard to the patches, once the assignment is done, can you please 
break them down as they each end up on a different persons plate.

	Andrew


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

* Re: Patches for FreeBSD 4.2
  2001-07-11  8:46 ` Andrew Cagney
@ 2001-07-11  9:18   ` Stu Grossman
  0 siblings, 0 replies; 7+ messages in thread
From: Stu Grossman @ 2001-07-11  9:18 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Jim Blandy, gdb-patches

Andrew Cagney writes:
 > Stu, you know the drill.  Can you get an assignment in place?  I've cc'd 
 > our assignments clerk

FYI, the following links in:

http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/src/gdb/CONTRIBUTE?content-type=text/x-cvsweb-markup&cvsroot=src

no longer work:

	http://gcc.gnu.org/fsf-forms/assignment-instructions.html
	http://gcc.gnu.org/fsf-forms/assign.future
	http://gcc.gnu.org/fsf-forms/disclaim.future
	http://gcc.gnu.org/fsf-forms/copyrights.html

So, if somebody could point me at copies of those files...


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

* Re: Patches for FreeBSD 4.2
  2001-07-10 23:39 Patches for FreeBSD 4.2 Stu Grossman
  2001-07-11  8:46 ` Andrew Cagney
@ 2001-07-12 13:50 ` Mark Kettenis
  2001-07-12 14:58   ` Stu Grossman
  2001-07-12 16:51   ` Stu Grossman
  1 sibling, 2 replies; 7+ messages in thread
From: Mark Kettenis @ 2001-07-12 13:50 UTC (permalink / raw)
  To: Stu Grossman; +Cc: gdb-patches

Stu Grossman <grossman@juniper.net> writes:

> Here is a set of patches that fixes a bunch of problems (and some testsuite
> failures) for FreeBSD 4.2.

Thanks.  A few comments about the things that fall on my turf:

> + 	* i386-tdep.c (i386_store_return_value):  Make sure that floats get
> + 	stored at the top of the FP stack.

Already fixed :-).

> + 	* i386-freebsd-nat.c:  New file to support FreeBSD specific stuff.

* I'd prefer the name i386fbsd-nat.c, since we already have
  alphafbsd-tdep.c.

* This file won't compile on FreeBSD 3.x, since <machine/sigframe.h>
  doesn't exist.  Besides, the implementation of a *_frame_saved_pc
  function belongs in a target-dependent file, and shouldn't depend on
  the target headers.  What's wrong with the old implementation?

  Hmm, `struct sigcontext' has been changed.  The CVS logs in the
  FreeBSD tree seems to imply that it is possible to distinguish
  between a new and an old signal handler frame.  So perhaps we can
  distinguish between the two.  Otherwise we have to provide different
  implementations for old and new FreeBSD versions.

* I think the SOFTWARE_SINGLE_STEP_P stuff can be removed from your
  version of child_resume.

> + 	* config/i386/tm-fbsd.h:  Define FRAME_SAVED_PC to use FreeBSD specific
> + 	code to extract return PC from signal frames.
> + 	* Define FRAME_CHAIN_VALID to use func_frame_chain_valid, since ELF
> + 	doesn't generate N_TEXT object file markers.
> + 	* Remove SIGTRAMP_START and SIGTRAMP_END.  Move all of that logic into
> + 	a FreeBSD specific function invoke via IN_SIGTRAMP.

Why did you comment out USE_STRUCT_CONVENTION here?  AFAIK FreeBSD
uses the old GCC 1 conventions for passing short structs.

Mark


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

* Re: Patches for FreeBSD 4.2
  2001-07-12 13:50 ` Mark Kettenis
@ 2001-07-12 14:58   ` Stu Grossman
  2001-07-13  8:16     ` Mark Kettenis
  2001-07-12 16:51   ` Stu Grossman
  1 sibling, 1 reply; 7+ messages in thread
From: Stu Grossman @ 2001-07-12 14:58 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

Mark Kettenis writes:
 > Stu Grossman <grossman@juniper.net> writes:
 > 
 > > Here is a set of patches that fixes a bunch of problems (and some testsuite
 > > failures) for FreeBSD 4.2.
 > 
 > Thanks.  A few comments about the things that fall on my turf:
 > 
 > > + 	* i386-tdep.c (i386_store_return_value):  Make sure that floats get
 > > + 	stored at the top of the FP stack.
 > 
 > Already fixed :-).

Ahh, cool!

 > 
 > > + 	* i386-freebsd-nat.c:  New file to support FreeBSD specific stuff.
 > 
 > * I'd prefer the name i386fbsd-nat.c, since we already have
 >   alphafbsd-tdep.c.

Actually, I was following the linux convention (xxx-linux-yyy.c).  But, I can
fix it.

As an aside, it would be nice to use a consistent file naming convention
throughout GDB.  So far, we have <mach><os>-nat/tdep, or <mach>-<os>-nat/tdep.
Mostly, files seem to use the latter convention unless it's one of the BSDs, in
which case they use the former.  Picking one convention and sticking to it
would make things cleaner.

 > * This file won't compile on FreeBSD 3.x, since <machine/sigframe.h>
 >   doesn't exist.

I'll try to clean that up for 3.x.  It looks like in 3.x and earlier, struct
sigframe was in <machine/frame.h>.

 > Besides, the implementation of a *_frame_saved_pc
 >   function belongs in a target-dependent file, and shouldn't depend on
 >   the target headers.  What's wrong with the old implementation?

I disagree.  *_frame_saved_pc is inherently native dependent for most OS's as
it involves looking at some kind of OS specific signal context structure.

 >   Hmm, `struct sigcontext' has been changed.  The CVS logs in the
 >   FreeBSD tree seems to imply that it is possible to distinguish
 >   between a new and an old signal handler frame.  So perhaps we can
 >   distinguish between the two.  Otherwise we have to provide different
 >   implementations for old and new FreeBSD versions.

I think you are stuck with different versions of GDB anyway.  3.4 seems to have
two versions of sigcontext (the old one is called `osigcontext').  Sigcontext
is pretty much the same as the 4.2 version.  In any case, I don't see a good
way to distinguish between the two versions of sigcontext.  In addition, I
doubt that core files are compatible between 3.4 and 4.2.  So, it really looks
like you want different builds of GDB for each OS version.

 > * I think the SOFTWARE_SINGLE_STEP_P stuff can be removed from your
 >   version of child_resume.

That is only used for an internal consistency check, which I think is valuable
here.

 > > + 	* config/i386/tm-fbsd.h:  Define FRAME_SAVED_PC to use FreeBSD specific
 > > + 	code to extract return PC from signal frames.
 > > + 	* Define FRAME_CHAIN_VALID to use func_frame_chain_valid, since ELF
 > > + 	doesn't generate N_TEXT object file markers.
 > > + 	* Remove SIGTRAMP_START and SIGTRAMP_END.  Move all of that logic into
 > > + 	a FreeBSD specific function invoke via IN_SIGTRAMP.
 > 
 > Why did you comment out USE_STRUCT_CONVENTION here?  AFAIK FreeBSD
 > uses the old GCC 1 conventions for passing short structs.

Brain fart.  You are right, that needs to be left in for FreeBSD.

			Stu


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

* Re: Patches for FreeBSD 4.2
  2001-07-12 13:50 ` Mark Kettenis
  2001-07-12 14:58   ` Stu Grossman
@ 2001-07-12 16:51   ` Stu Grossman
  1 sibling, 0 replies; 7+ messages in thread
From: Stu Grossman @ 2001-07-12 16:51 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

Mark Kettenis writes:
 > * This file won't compile on FreeBSD 3.x, since <machine/sigframe.h>
 >   doesn't exist.  Besides, the implementation of a *_frame_saved_pc
 >   function belongs in a target-dependent file, and shouldn't depend on
 >   the target headers.  What's wrong with the old implementation?

Let me clarify my previous message...  This needs to be fixed in order to make
backtraces through signal handlers work.  I think that without this fix, the
backtrace stops at the signal handler, or worse yet, it prints junk for the
caller or the interrupted code.

			Stu


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

* Re: Patches for FreeBSD 4.2
  2001-07-12 14:58   ` Stu Grossman
@ 2001-07-13  8:16     ` Mark Kettenis
  0 siblings, 0 replies; 7+ messages in thread
From: Mark Kettenis @ 2001-07-13  8:16 UTC (permalink / raw)
  To: grossman; +Cc: gdb-patches

   From: Stu Grossman <grossman@juniper.net>
   Date: Thu, 12 Jul 2001 14:58:03 -0700

   Actually, I was following the linux convention (xxx-linux-yyy.c).
   But, I can fix it.

   As an aside, it would be nice to use a consistent file naming
   convention throughout GDB.  So far, we have <mach><os>-nat/tdep, or
   <mach>-<os>-nat/tdep.  Mostly, files seem to use the latter
   convention unless it's one of the BSDs, in which case they use the
   former.  Picking one convention and sticking to it would make
   things cleaner.

New files tend to use the latter convention, but let's stick to
<mach><os>-nat/dep for the BSDs.

    > * This file won't compile on FreeBSD 3.x, since <machine/sigframe.h>
    >   doesn't exist.

   I'll try to clean that up for 3.x.  It looks like in 3.x and
   earlier, struct sigframe was in <machine/frame.h>.

Looks like it, but we may not need that.

    > Besides, the implementation of a *_frame_saved_pc
    >   function belongs in a target-dependent file, and shouldn't depend on
    >   the target headers.  What's wrong with the old implementation?

   I disagree.  *_frame_saved_pc is inherently native dependent for
   most OS's as it involves looking at some kind of OS specific signal
   context structure.

Well, it's true that it's OS specific, but that doesn't mean that it's
native dependent.  A cross debugger should be able to trace back
through signal frames just as well as a native debugger.  The only
thing that's needed is that instead of relying on target headers such
as <machine/sigframe.h> to provide the necessary offsets, we must
simply hardcode the values into GDB.  That's what I did when I updated
the FreeBSD support some time ago.

Now hardcoding has a drawback.  When the signal frame layout changes
(as it did between FreeBSD 3 and FreeBSD 4) things break.  That's too
bad, but it is a change in the ABI, and there's nothing we can do
about it if we don't have the target headers available (and even then
it is problematic since the location of the relevant details is often
changed between different releases of an OS).

The best we can do is somehow override these hardcoded values when
building a native debugger.  I have an idea to implement that makes
multi-arching the i386 target easier.  It would really help if you
could send me the numerical value of PS_STRINGS on FreeBSD 4.2.

I'll go and test my version of sigtramp code a bit.  If it works, that
part of your patch will not be necessary.

   I think you are stuck with different versions of GDB anyway.  3.4
   seems to have two versions of sigcontext (the old one is called
   `osigcontext').  Sigcontext is pretty much the same as the 4.2
   version.  In any case, I don't see a good way to distinguish
   between the two versions of sigcontext.  In addition, I doubt that
   core files are compatible between 3.4 and 4.2.  So, it really looks
   like you want different builds of GDB for each OS version.

The idea of a multi-arch GDB is that it contains support for multiple
targets in a single GDB.  It might be necessary for the user to
explicitly set the target if distinguishing between them isn't
possible, but that's no reason not to add support for different
versions of FreeBSD.

    > * I think the SOFTWARE_SINGLE_STEP_P stuff can be removed from your
    >   version of child_resume.

   That is only used for an internal consistency check, which I think
   is valuable here.

It's not as important as for the generic version to have this check,
but it doesn't hurt, so feel free to leave it in.

Mark


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

end of thread, other threads:[~2001-07-13  8:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-10 23:39 Patches for FreeBSD 4.2 Stu Grossman
2001-07-11  8:46 ` Andrew Cagney
2001-07-11  9:18   ` Stu Grossman
2001-07-12 13:50 ` Mark Kettenis
2001-07-12 14:58   ` Stu Grossman
2001-07-13  8:16     ` Mark Kettenis
2001-07-12 16:51   ` Stu Grossman

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