From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120743 invoked by alias); 11 Apr 2018 19:08:04 -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 120733 invoked by uid 89); 11 Apr 2018 19:08:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 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= 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:08:02 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59AD24023155 for ; Wed, 11 Apr 2018 19:08:01 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 147B7BDC58; Wed, 11 Apr 2018 19:07:59 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches , Jan Kratochvil Subject: Re: [PATCH v5] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages References: <20180124194714.26222-1-sergiodj@redhat.com> <20180411184644.719-1-sergiodj@redhat.com> Date: Wed, 11 Apr 2018 19:08:00 -0000 In-Reply-To: (Pedro Alves's message of "Wed, 11 Apr 2018 20:05:29 +0100") Message-ID: <87sh81h88h.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2018-04/txt/msg00224.txt.bz2 On Wednesday, April 11 2018, Pedro Alves wrote: > 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. That's true, wrong copy&paste. >> >> - Fix some wrong regexps when expecting for the inferior to be killed. > > Hmm, you didn't address the comments to the gdb code itself. Sigh. Sorry about that. I'll do that now. Thanks, > >> 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 -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/