From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95486 invoked by alias); 11 Apr 2018 19:05:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 95465 invoked by uid 89); 11 Apr 2018 19:05:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS autolearn=ham version=3.3.2 spammy=Anyway X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Apr 2018 19:05:32 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 437FA43362FB for ; Wed, 11 Apr 2018 19:05:31 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B012215CDC6; Wed, 11 Apr 2018 19:05:30 +0000 (UTC) Subject: Re: [PATCH v5] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages To: Sergio Durigan Junior , GDB Patches References: <20180124194714.26222-1-sergiodj@redhat.com> <20180411184644.719-1-sergiodj@redhat.com> Cc: Jan Kratochvil From: Pedro Alves Message-ID: Date: Wed, 11 Apr 2018 19:05:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180411184644.719-1-sergiodj@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-04/txt/msg00223.txt.bz2 On 04/11/2018 07:46 PM, Sergio Durigan Junior wrote: > Changes from v4: > > - Fix race on gdb.threads/process-dies-while-detaching-1-detach.exp. I don't think that testcase exists. :-) Anyway, just remember to remove the "Changes from" section before pushing that then it's moot. > > - Fix some wrong regexps when expecting for the inferior to be killed. Hmm, you didn't address the comments to the gdb code itself. > diff --git a/gdb/infcmd.c b/gdb/infcmd.c > index d43e7f202d..1f724fbf23 100644 > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -2595,8 +2595,16 @@ kill_command (const char *arg, int from_tty) > error (_("The program is not being run.")); > if (!query (_("Kill the program being debugged? "))) > error (_("Not confirmed.")); > + > + const char *pid_str = target_pid_to_str (inferior_ptid); > + int infnum = current_inferior ()->num; > + > target_kill (); > > + if (print_inferior_events) > + printf_unfiltered (_("[Inferior %d (%s) has been killed]\n"), > + infnum, pid_str); > + My previous comment still applies here: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This still seem risky -- Target backends use target_pid_to_str inside target_kill, e.g., when logging is enabled. E.g., linux_nat_kill -> -> stop_callback -> target_pid_to_str ISTM a deep copy like: std::string pid_str = target_pid_to_str (inferior_ptid); would be safer/better. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > @@ -123,7 +122,8 @@ add_inferior (int pid) > struct inferior *inf = add_inferior_silent (pid); > > if (print_inferior_events) > - printf_unfiltered (_("[New inferior %d]\n"), pid); > + printf_unfiltered (_("[New inferior %d (process %d)]\n"), > + inf->num, pid); Likewise. > @@ -266,7 +263,8 @@ detach_inferior (inferior *inf) > exit_inferior_1 (inf, 0); > > if (print_inferior_events) > - printf_unfiltered (_("[Inferior %d detached]\n"), pid); > + printf_unfiltered (_("[Inferior %d (process %d) detached]\n"), > + inf->num, pid); > } > Likewise? > - if (info_verbose || debug_infrun) > + if (print_inferior_events) > { > + gdb::unique_xmalloc_ptr > + parent_pid (xstrdup (target_pid_to_str (parent_ptid))); > + gdb::unique_xmalloc_ptr > + child_pid (xstrdup (target_pid_to_str (child_ptid))); > + Likewise? /me stops looking further. Looks like you missed handling the comments for the gdb code. Try again? :-) Thanks, Pedro Alves