Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Marc Khouzam <marc.khouzam@ericsson.com>
To: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: [Patch] Broken multi-process detach
Date: Mon, 16 Jul 2012 13:54:00 -0000	[thread overview]
Message-ID: <F7CE05678329534C957159168FA70DEC5979611424@EUSAACMS0703.eamcs.ericsson.se> (raw)

Hi,

Detaching from an inferior in multi-process is broken.
The problem seems to be that in linux_nat.c:linux_nat_detach()
GDB first unregisters from the event loop by calling 
linux_nat_async (NULL, 0).  In multi-process, further
events received from running inferiors are missed; breakpoint
hits are not reported, interrupting a thread is not reported,
and so on.  See below for a broken session example.

We could remove the call to linux_nat_async (NULL, 0) but I didn't
know if that would have bad side-effects.  Here is the patch that
does that, if it is felt that is the correct solution.

The testsuite hangs on HEAD so I wasn't able to run it yet.
But I'll do so once it works again.

Thanks

Marc

2012-07-16  Marc Khouzam  <marc.khouzam@ericsson.com>

        * linux_nat.c (linux_nat_detach): Don't unregister from the event
        loop.

### Eclipse Workspace Patch 1.0
#P src
Index: gdb/linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.254
diff -u -r1.254 linux-nat.c
--- gdb/linux-nat.c     7 Jul 2012 12:13:56 -0000       1.254
+++ gdb/linux-nat.c     16 Jul 2012 12:44:38 -0000
@@ -1848,8 +1848,8 @@
 
   pid = GET_PID (inferior_ptid);
 
-  if (target_can_async_p ())
-    linux_nat_async (NULL, 0);
+  /* Don't unregister from the event loop, as there may be other
+     inferiors running. */
 
   /* Stop all threads before detaching.  ptrace requires that the
      thread is stopped to sucessfully detach.  */


Broken session:
==============
> gdb.7.5
GNU gdb (GDB) 7.4.50.20120714-cvs

==> set non-stop and start two inferiors
[...]

(gdb) inf thread
  Id   Target Id         Frame 
  2    process 23634     (running)
* 1    process 23629     main () at loopfirst.noprint.cc:5
(gdb) detach
Detaching from program: /home/lmckhou/testing/loopfirst.noprint, process 23629
(gdb) inf thread
  Id   Target Id         Frame 
  2    process 23634     (running)

No selected thread.  See `help thread'.
(gdb) thread 2
[Switching to thread 2 (process 23634)](running)

=> interrupt the running thread

(gdb) interrupt
(gdb) inf thread
  Id   Target Id         Frame 
* 2    process 23634     (running)

=> event not received, thread still marked running

(gdb) c
Continuing.
Cannot execute this command while the selected thread is running.


             reply	other threads:[~2012-07-16 13:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-16 13:54 Marc Khouzam [this message]
2012-07-16 17:49 ` Pedro Alves
2012-07-16 19:08   ` Marc Khouzam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F7CE05678329534C957159168FA70DEC5979611424@EUSAACMS0703.eamcs.ericsson.se \
    --to=marc.khouzam@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox