From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24122 invoked by alias); 3 Apr 2018 00:15:36 -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 20277 invoked by uid 89); 3 Apr 2018 00:15:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1343 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; Tue, 03 Apr 2018 00:15:26 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFE61406E97C for ; Tue, 3 Apr 2018 00:15:24 +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 727B710FFE72; Tue, 3 Apr 2018 00:15:22 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches , Jan Kratochvil Subject: Re: [PATCH v3] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages References: <20180124194714.26222-1-sergiodj@redhat.com> <20180309215548.29639-1-sergiodj@redhat.com> <14a839e8-5fa9-ce85-2ffa-98833a7f29ba@redhat.com> Date: Tue, 03 Apr 2018 00:15:00 -0000 In-Reply-To: <14a839e8-5fa9-ce85-2ffa-98833a7f29ba@redhat.com> (Pedro Alves's message of "Mon, 26 Mar 2018 12:43:52 +0100") Message-ID: <87k1tp5en9.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/msg00048.txt.bz2 On Monday, March 26 2018, Pedro Alves wrote: > On 03/26/2018 11:58 AM, Pedro Alves wrote: >> On 03/09/2018 09:55 PM, Sergio Durigan Junior wrote: >> >>> But if we use 'add_thread_silent' (with the same configuration as >>> before): >>> >>> (gdb) run >>> Starting program: a.out >>> [Attaching after process 26807 fork to child process 26807.] > > BTW, those two PIDs being the same looks suspicious. Is that > another instance of a parent vs child mixup? Or is that the case > that is fixed by the patch? Ah, good catch. After some time investigating, I found that the problem occurs because the code is now calling target_pid_to_str twice in the same statement, but target_pid_to_str actually returns a static string, which means that this string is overwritten when the second call happens: fprintf_filtered (gdb_stdlog, _("[Attaching after %s %s to child %s]\n"), target_pid_to_str (parent_ptid), <-- HERE has_vforked ? "vfork" : "fork", target_pid_to_str (child_ptid)); <-- AND HERE I fixed this by saving a copy of both strings before calling fprintf_filtered. I'll send an updated patch soon. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/