From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id C2F563898383 for ; Thu, 6 Oct 2022 16:31:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C2F563898383 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4MjxlC2thFz3mYY; Thu, 6 Oct 2022 16:31:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MjxlC27szz3VqQ; Thu, 6 Oct 2022 16:31:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665073863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Iv81Otn883OFaUMROjb7i+kiX3UdPqhCYuLgBUdABY=; b=P01wrKtuTPFAxoY8hcEnO0hhWtk2h8XLyWlgfUXb1DePyb4EFcYDlGG5PpTEN4+0CpatnI IKL9pW4GpRW0L10KYS5hcoOyfeTMZlnWQj6oa5N9n8AjVOFBEYxVaTBdFpYBBAJ/pLrfTn D/q4pg/6In8cLRutHkw59j6Qx0eWLyxGsinCc12BRtqotmOV00mXLS8U/P8J3LtUYgLRYD 1RDXx29uuJQFTTR8Rbk7xqxqhJ41zRcadwGPCGSncC3TM4rV9ds6cNl48rbpT49nbg2WeU Qf4drS2vI3wRnpWpQcB8zSAKziUzfaWsmOeVq9E23bSzBG3H0wm4/Du/YLW0Ag== Received: from [IPV6:2601:648:8684:ad0:10a9:d003:d0ca:8481] (unknown [IPv6:2601:648:8684:ad0:10a9:d003:d0ca:8481]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4MjxlB5q6HzYP0; Thu, 6 Oct 2022 16:31:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <3ded5295-14e2-2426-a758-ca98084228bd@FreeBSD.org> Date: Thu, 6 Oct 2022 09:31:01 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH] gdb/gcore: interrupt all threads before generating the corefile Content-Language: en-US To: Lancelot SIX , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20221006095035.2857747-1-lancelot.six@amd.com> From: John Baldwin In-Reply-To: <20221006095035.2857747-1-lancelot.six@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665073863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8Iv81Otn883OFaUMROjb7i+kiX3UdPqhCYuLgBUdABY=; b=DUwkxEAURIYYrkpVDIxFTBo8QRNUDr9AZRO4UvtxuZbQ1xjKOfTylqp0EAEBTiCHNt7eRF LGGXQOLVvjN+jQJ2ycvK+0FfT2Igs6FNjW1DT6epBSjvwVA7HsRtFvadHBqyeyQNmCR1ga dDZX1h0sJnL41ea6qmEtYoc8ofsF8wr0ewio8mnkBXJKbjxZ7Mqz+m/EXa3ukJH8ia382T r79gTcQU+aspKaIhzUvF/+aZZO8lQIm/3EKyKj4QFE6npDGQf9fJR/nWJwm33qHk9EaQli Mm+8nbnmD6f+FhxoWgRt3TB0SZ6QW6TG5nf8oeq3Bz9NHH2Yg6+xCm1vnHBSHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665073863; a=rsa-sha256; cv=none; b=yr3LpfsvMowlI/Zf1e37i47NTn2WMwINPnHnEJSsdu+P1wJZpPp+Bd2sco1bbG4ZiM7D5h zmoK5j3gf8NuP8RbtMygGj+JZ7ViuxOx8Jy0WOXRos0l/2buAdeIlp4gT8ltkoBAHt89vb koLyo/qRPRS8g1A29BaX57Vi/S9Q6atCUKd7bwF/mg4e2TqWjrw+8ELc9cdv71nbqenL0n w4b5zHVJCi1O2pezmkSt8pjraXiUKiT4Z6Rwftx3e/7wHwVpGpBhxXQWcveX8lcWVdRDbY eG4+N7aJ+2G/FBCwavxVrdEccyaUqDil3C7CRviFTueRW91qD1FIQ3fFNgJuRw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2022 16:31:06 -0000 On 10/6/22 2:50 AM, Lancelot SIX via Gdb-patches wrote: > In non-stop mode, if the user tries to generate a core dump (using the > gcore command) while some threads are running, a non-helpful error > message is shown. > > Lets consider the following session as an example (debugging the test > program included in this patch): > > (gdb) set non-stop on > (gdb) b 37 > (gdb) r > Thread 1 "gcore-nonstop" hit Breakpoint 1, main () at gcore-nonstop.c:39 > (gdb) info thread > Id Target Id Frame > * 1 Thread 0x7ffff7d7a740 (LWP 431838) "gcore-nonstop" main () * at gcore-nonstop.c:39 > 2 Thread 0x7ffff7d79640 (LWP 431841) "gcore-nonstop" (running) > (gdb) gcore > Couldn't get registers: No such process. > > The reported error ("No such process") does not help the user understand > what happens. This is due to the fact that we cannot access the > registers of a running thread. Even if we ignore this error, generating > a core dump while any thread might update memory would most likely > result in a core file with an inconsistent view of the process' memory. > > To solve this, this patch proposes to change the gcore command so it > first stops all running threads before generating the corefile, and then > resumes them in their previous state. > > The patch proposes to stop all threads across all the inferiors (not > just the current one) just in case the memory space is shared between > inferiors. I agree with the idea in concept (gcore should stop all threads so it can write out a consistent snapshot). -- John Baldwin