From patchwork Mon Jan 29 17:36:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 25672 Received: (qmail 104878 invoked by alias); 29 Jan 2018 17:36:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 104869 invoked by uid 89); 29 Jan 2018 17:36:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 29 Jan 2018 17:36:29 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24B1487630; Mon, 29 Jan 2018 17:36:28 +0000 (UTC) Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BE3E5C266; Mon, 29 Jan 2018 17:36:27 +0000 (UTC) From: Sergio Durigan Junior To: Simon Marchi Cc: Pedro Alves , gdb-patches@sourceware.org, Simon Marchi Subject: Re: [Regression] Segfault on native-extended-gdbserver + fork References: <20180119161628.21611-1-simon.marchi@polymtl.ca> <20180119161628.21611-3-simon.marchi@polymtl.ca> <87efmaebo3.fsf_-_@redhat.com> <931f8b594f7405649778f66ab2960a40@polymtl.ca> <669ec8c3-caa3-6901-b26c-00a7e20bc0d1@redhat.com> <1b82573ce66790c935eaff87b7565907@polymtl.ca> <87mv0w8tnr.fsf@redhat.com> Date: Mon, 29 Jan 2018 12:36:26 -0500 Message-ID: <87372o8t45.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes On Monday, January 29 2018, I wrote: > On Monday, January 29 2018, Simon Marchi wrote: > >> On 2018-01-29 11:00, Pedro Alves wrote: >>> On 01/28/2018 04:50 PM, Simon Marchi wrote: >>>> On 2018-01-28 01:32, Sergio Durigan Junior wrote: >>>> This means (I just tried it) that it won't show the "[Inferior %d >>>> detached]\n" message in that case.  So what I would suggest is >>>> putting >>>> >>>>   if (print_inferior_events) >>>>     printf_unfiltered (_("[Inferior %d detached]\n"), pid); >>>> >>>> in its own function, called by both versions of detach_inferior for >>>> now (bonus, it de-duplicates the printing of the message).  In the >>>> multi-target branch, remote_target::follow_fork (renamed from >>>> remote_follow_fork) can call this function in the case where we >>>> don't have an inferior object. >>> >>> But why would we want to print that? We will have already printed >>> >>> "Detaching after fork from child process PID." >>> >>> from the common code. When native debugging, in this scenario, >>> we don't call detach_inferior either, right? Can't see why >>> we'd want to call it for remote. >> >> It's true that it's a bit of a lie to say "[Inferior PID detached]" if >> there never actually was an inferior for that PID. Since we never >> print "[Inferior PID detached]" on native in that case, I am fine with >> removing the call from remote.c. Sergio, that would fix the crash you >> found I think? > > I was also unsure about printing the message in this case, because > there's no real detach happening. I'm fine with not printing it. And > yes, removing the call to "detach_inferior" also fixes the problem. > > I'll prepare a patch. Here's what I have. WDYT? I'll address Pedro's comment about changing the "[Inferior PID detached]" output in another patch. diff --git a/gdb/remote.c b/gdb/remote.c index 5ac84df0a0..74d18f7b17 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5206,7 +5206,6 @@ remote_follow_fork (struct target_ops *ops, int follow_child, child_pid = ptid_get_pid (child_ptid); remote_detach_pid (child_pid); - detach_inferior (child_pid); } } return 0;