Message ID | 1441229078-22073-1-git-send-email-simon.marchi@ericsson.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 115798 invoked by alias); 2 Sep 2015 21:24:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 115785 invoked by uid 89); 2 Sep 2015 21:24:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 02 Sep 2015 21:24:44 +0000 Received: from EUSAAHC003.ericsson.se (Unknown_Domain [147.117.188.81]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 67.93.26730.2EEF6E55; Wed, 2 Sep 2015 15:51:31 +0200 (CEST) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.81) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 2 Sep 2015 17:24:42 -0400 From: Simon Marchi <simon.marchi@ericsson.com> To: <gdb-patches@sourceware.org> CC: Simon Marchi <simon.marchi@ericsson.com> Subject: [PATCH] Fix mi-detach.exp on native-gdbserver Date: Wed, 2 Sep 2015 17:24:38 -0400 Message-ID: <1441229078-22073-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes |
Commit Message
Simon Marchi
Sept. 2, 2015, 9:24 p.m. UTC
The =thread-exited event did not appear when detaching from a process with "target remote". When mourning an inferior, target remote takes a different path than target extended_remote. target remote calls unpush_target first which calls remote_close in order to close the "remote" target. remote_close calls discard_all_inferiors, which exits all inferiors with exit_inferior_silent. Because it's the _silent version, we don't see the MI event. extended_remote_mourn calls generic_mourn_inferior, which calls exit_inferior. Since it's the non-silent version, we see the MI event. When changing discard_all_inferiors to call exit_inferior instead of exit_inferior_silent, the MI event appears. Since remote_mourn is the only place where discard_all_inferiors is used, it should be an otherwise harmless change. Regression-tested on Ubuntu 14.04, with native and native-gdbserver. gdb/ChangeLog: * inferior.c (discard_all_inferiors): Call exit_inferior instead of exit_inferior_silent. --- gdb/inferior.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 09/02/2015 10:24 PM, Simon Marchi wrote: > The =thread-exited event did not appear when detaching from a process > with "target remote". > > When mourning an inferior, target remote takes a different path than > target extended_remote. target remote calls unpush_target first which > calls remote_close in order to close the "remote" target. remote_close > calls discard_all_inferiors, which exits all inferiors with > exit_inferior_silent. Because it's the _silent version, we don't see > the MI event. > > extended_remote_mourn calls generic_mourn_inferior, which calls > exit_inferior. Since it's the non-silent version, we see the MI event. Please try enabling "set print inferior-events on". With native debugging, we currently get: (gdb) detach Detaching from program: /home/pedro/gdb/tests/main, process 15759 [Inferior 15759 detached] ^^^^^^^^ However, with target extended-remote, we get: (gdb) tar extended-remote :9999 (gdb) detach Detaching from program: /home/pedro/gdb/tests/main, process 15789 [Inferior 15789 exited] ^^^^^^ And with target remote, we get nothing: (gdb) tar remote :9999 0x0000003615a011f0 in _start () from target:/lib64/ld-linux-x86-64.so.2 (gdb) detach Detaching from program: /home/pedro/gdb/tests/main, process 15767 Ending remote debugging. (gdb) With your patch, we'll print "exited" in the remote case too, when it seems to me that in both extended-remote and remote we should be saying "detached" like in the native case. Also, if the user does "disconnect", after your patch gdb will say the inferiors we were debugging "exited" while they were left running on the target side. Is that confusing? Thanks, Pedro Alves
On 15-09-09 05:39 AM, Pedro Alves wrote: > Please try enabling "set print inferior-events on". With native > debugging, we currently get: > > (gdb) detach > Detaching from program: /home/pedro/gdb/tests/main, process 15759 > [Inferior 15759 detached] > ^^^^^^^^ > > However, with target extended-remote, we get: > > (gdb) tar extended-remote :9999 > (gdb) detach > Detaching from program: /home/pedro/gdb/tests/main, process 15789 > [Inferior 15789 exited] > ^^^^^^ > > And with target remote, we get nothing: > > (gdb) tar remote :9999 > 0x0000003615a011f0 in _start () from target:/lib64/ld-linux-x86-64.so.2 > (gdb) detach > Detaching from program: /home/pedro/gdb/tests/main, process 15767 > Ending remote debugging. > (gdb) > > With your patch, we'll print "exited" in the remote case too, > when it seems to me that in both extended-remote and remote > we should be saying "detached" like in the native case. > > Also, if the user does "disconnect", after your patch gdb will > say the inferiors we were debugging "exited" while they were > left running on the target side. Is that confusing? > > Thanks, > Pedro Alves The fact that different targets have different behaviors is certainly confusing and I think it should be improved. The problem seems to be that remote_mourn and extended_remote_mourn don't have enough information as to why they are mourning an inferior, so they just end up calling exit_inferior. In the native case, the message is right because inf_ptrace_detach calls directly detach_inferior (which is exactly like exit_inferior, except the message). By the way, it means that when detaching natively, we never mourn the inferior, is it normal?. According to these backtraces, it seems like it would be possible for the "mourn" functions to take a "why are we mourning" argument, so that the message printed there can be adjusted. #0 remote_mourn (target=0x2136200 <remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/remote.c:8502 #1 0x00000000007fb350 in delegate_mourn_inferior (self=0x2136200 <remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:1285 #2 0x0000000000808b3e in target_mourn_inferior () at /home/emaisin/src/binutils-gdb/gdb/target.c:2317 #3 0x000000000064b2f2 in remote_detach_1 (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4723 #4 0x000000000064b353 in remote_detach (ops=0x2136200 <remote_ops>, args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4734 #5 0x00000000007f747d in delegate_detach (self=0x2136200 <remote_ops>, arg1=0x0, arg2=1) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:34 #6 0x0000000000808888 in target_detach (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/target.c:2216 #7 0x00000000007a4677 in detach_command (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/infcmd.c:2908 #0 extended_remote_mourn (target=0x2136780 <extended_remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/remote.c:8511 #1 0x00000000007fb2a8 in delegate_mourn_inferior (self=0x2136780 <extended_remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:1285 #2 0x0000000000808a7f in target_mourn_inferior () at /home/emaisin/src/binutils-gdb/gdb/target.c:2317 #3 0x000000000064b27b in remote_detach_1 (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4723 #4 0x000000000064b302 in extended_remote_detach (ops=0x2136780 <extended_remote_ops>, args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4740 #5 0x00000000007f73dd in delegate_detach (self=0x2136780 <extended_remote_ops>, arg1=0x0, arg2=1) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:34 #6 0x00000000008087d8 in target_detach (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/target.c:2216 #7 0x00000000007a45e1 in detach_command (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/infcmd.c:2908 Does it make sense?
On 09/11/2015 07:11 PM, Simon Marchi wrote: > On 15-09-09 05:39 AM, Pedro Alves wrote: >> Please try enabling "set print inferior-events on". With native >> debugging, we currently get: >> >> (gdb) detach >> Detaching from program: /home/pedro/gdb/tests/main, process 15759 >> [Inferior 15759 detached] >> ^^^^^^^^ >> >> However, with target extended-remote, we get: >> >> (gdb) tar extended-remote :9999 >> (gdb) detach >> Detaching from program: /home/pedro/gdb/tests/main, process 15789 >> [Inferior 15789 exited] >> ^^^^^^ >> >> And with target remote, we get nothing: >> >> (gdb) tar remote :9999 >> 0x0000003615a011f0 in _start () from target:/lib64/ld-linux-x86-64.so.2 >> (gdb) detach >> Detaching from program: /home/pedro/gdb/tests/main, process 15767 >> Ending remote debugging. >> (gdb) >> >> With your patch, we'll print "exited" in the remote case too, >> when it seems to me that in both extended-remote and remote >> we should be saying "detached" like in the native case. >> >> Also, if the user does "disconnect", after your patch gdb will >> say the inferiors we were debugging "exited" while they were >> left running on the target side. Is that confusing? >> >> Thanks, >> Pedro Alves > > The fact that different targets have different behaviors is certainly confusing > and I think it should be improved. > > The problem seems to be that remote_mourn and extended_remote_mourn don't have > enough information as to why they are mourning an inferior, so they just end up > calling exit_inferior. In the native case, the message is right because > inf_ptrace_detach calls directly detach_inferior (which is exactly like > exit_inferior, except the message). remote_detach_1 also calls detach_inferior, though the condition there looks a bit confusing. > By the way, it means that when detaching > natively, we never mourn the inferior, is it normal?. I think most targets _don't_ mourn when detaching. Maybe we could/should make them all do so, not sure. E.g., looking at generic_mourn_inferior, we shouldn't need to mark breakpoints out when detaching, as we better have really removed breakpoints from the inferior before we detached it. Maybe we should instead have a generic_detach_inferior function. That also avoids the "why are we mourning the living?" question too. :-) Thanks, Pedro Alves > > According to these backtraces, it seems like it would be possible for the "mourn" > functions to take a "why are we mourning" argument, so that the message printed there > can be adjusted. > > #0 remote_mourn (target=0x2136200 <remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/remote.c:8502 > #1 0x00000000007fb350 in delegate_mourn_inferior (self=0x2136200 <remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:1285 > #2 0x0000000000808b3e in target_mourn_inferior () at /home/emaisin/src/binutils-gdb/gdb/target.c:2317 > #3 0x000000000064b2f2 in remote_detach_1 (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4723 > #4 0x000000000064b353 in remote_detach (ops=0x2136200 <remote_ops>, args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4734 > #5 0x00000000007f747d in delegate_detach (self=0x2136200 <remote_ops>, arg1=0x0, arg2=1) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:34 > #6 0x0000000000808888 in target_detach (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/target.c:2216 > #7 0x00000000007a4677 in detach_command (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/infcmd.c:2908 > > #0 extended_remote_mourn (target=0x2136780 <extended_remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/remote.c:8511 > #1 0x00000000007fb2a8 in delegate_mourn_inferior (self=0x2136780 <extended_remote_ops>) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:1285 > #2 0x0000000000808a7f in target_mourn_inferior () at /home/emaisin/src/binutils-gdb/gdb/target.c:2317 > #3 0x000000000064b27b in remote_detach_1 (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4723 > #4 0x000000000064b302 in extended_remote_detach (ops=0x2136780 <extended_remote_ops>, args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/remote.c:4740 > #5 0x00000000007f73dd in delegate_detach (self=0x2136780 <extended_remote_ops>, arg1=0x0, arg2=1) at /home/emaisin/src/binutils-gdb/gdb/target-delegates.c:34 > #6 0x00000000008087d8 in target_detach (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/target.c:2216 > #7 0x00000000007a45e1 in detach_command (args=0x0, from_tty=1) at /home/emaisin/src/binutils-gdb/gdb/infcmd.c:2908 > > Does it make sense? > Seems like one of those "have to try to tell" cases.
diff --git a/gdb/inferior.c b/gdb/inferior.c index 04e9a28..6ca18b8 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -315,7 +315,7 @@ discard_all_inferiors (void) for (inf = inferior_list; inf; inf = inf->next) { if (inf->pid != 0) - exit_inferior_silent (inf->pid); + exit_inferior (inf->pid); } }