This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.


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

Patch for Hurd gdb bug


Hi,

The 19990412 snapshot compiles fine for the Hurd.  Thanks for
integrating my patches!  I'll try to track gdb development from now
on, on behalf of the Hurd developers.

Here is a patch for a nasty bug that makes it impossible to attach to
a crashed program. (The Hurd has this nice feature that it is possible
to suspend programs that crashed.  You can then attach the debugger to
investigate why the program crashed.  Very useful, especially since we
do not have core dumps yet.)

The problem is that inf_set_traced() ultimately calls
inf_validate_task_sc(), which under certain circumstances calls
target_terminal_inferior() to restore the terminal state.  However
since the terminal state has not yet been saved (this happens after
gnu_attach() returns) this results in a segmentation fault.

I think calling target_terminal_init() in gnu_attach() is the most
effective and noninvasive way to solve the problem.  At this point all
initializations that target_terminal_init() depends on have been
performed and calling target_terminal_init() twice seems to be no
problem.

Mark


1999-04-25  Mark Kettenis  <kettenis@gnu.org>

	* gnu-nat.c (gnu_attach): Call target_terminal_init before calling
	inf_set_traced, since that function calls code that might try to
	restore the terminal settings.


--- /home/kettenis/tmp/gdb-19990412/gdb/gnu-nat.c	Sat Apr  3 01:11:56 1999
+++ gdb-19990412/gdb/gnu-nat.c	Sun Apr 25 15:54:22 1999
@@ -2004,6 +2004,10 @@
   attach_flag = 1;
   push_target (&gnu_ops);
 
+  /* We have to initialize the terminal settings now, since the code
+     below might try to restore them.  */
+  target_terminal_init ();
+  
   inf_update_signal_thread (inf);
   inf_set_traced (inf, inf->want_signals);