This is the mail archive of the gdb-patches@sourceware.org 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]

Re: [Cygwin] Fix for: detaching crashes the inferior.


Pedro Alves wrote:
Pedro Alves wrote:
Hi all,

Detaching on Cygwin often crashes the inferior, either
when gdb attaches to the inferior, or when gdb launches
the inferior as a child.


Here is a new version.


The real reason for the crashes is that we should be setting
the context back to the inferior, as gdb's copy contains
an adjusted PC.  With win32_continue we would resume the
inferior at the wrong address.  win32_resume takes care of
that, so the simple fix is to use it when detaching.

The current code uses delete_command to remove breakpoints, but
that leaves the internal breakpoints behind - not something
we want.  Is there a case where we can get to to_detach
without remove_breakpoints being called?  I don't think there
is - we always get here through normal_stop, right?
If there isn't, I'll just remove the call to it I'm
introducing in the patch.

Cheers,
Pedro Alves



2007-04-09  Pedro Alves  <pedro_alves@portugalmail.pt>

	* win32-nat.c (win32_detach): Remove breakpoints with
	remove_breakpoints instead of delete_command.  Resume inferior
	with win32_resume instead of win32_continue.

---
 gdb/win32-nat.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Index: src/gdb/win32-nat.c
===================================================================
--- src.orig/gdb/win32-nat.c	2007-04-08 12:11:22.000000000 +0100
+++ src/gdb/win32-nat.c	2007-04-09 02:48:50.000000000 +0100
@@ -1775,8 +1775,13 @@ win32_detach (char *args, int from_tty)
 
   if (has_detach_ability ())
     {
-      delete_command (NULL, 0);
-      win32_continue (DBG_CONTINUE, -1);
+      ptid_t ptid = {-1};
+
+      /* Don't leave breakpoints in the inferior.  */
+      remove_breakpoints ();
+
+      win32_resume (ptid, 0, TARGET_SIGNAL_0);
+
       if (!DebugActiveProcessStop (current_event.dwProcessId))
 	{
 	  error (_("Can't detach process %lu (error %lu)"),




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