From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id AC9133854160 for ; Thu, 6 Jul 2023 16:18:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC9133854160 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1688660303; bh=NnQfLPKKqh8Nnc8AcgFOVqbrrukqMPjLbU5RW7wGK14=; h=Date:Subject:To:References:From:In-Reply-To:From; b=AivY3jpJodwYtEwd0ZBKdMv/a0rKpBa6VRQbOEN4t+71PiPOFTRbBvMdGu82V63My sXaaIrmdMErBXQxHMieafGmYWZ4vDOpqeawoVdomwfog5CcfcZAXrHoSXK+sqP7aGz XtZtLeQIeSA9aLpvWQ9DDroi47vNqbvvYfsAdBtk= Received: from [10.0.0.170] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7B1221E00F; Thu, 6 Jul 2023 12:18:23 -0400 (EDT) Message-ID: Date: Thu, 6 Jul 2023 12:18:23 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/4] *-fbsd-nat: Handle null inferior in read_description. To: John Baldwin , gdb-patches@sourceware.org References: <20230526175742.66885-1-jhb@FreeBSD.org> <20230526175742.66885-2-jhb@FreeBSD.org> Content-Language: fr From: Simon Marchi In-Reply-To: <20230526175742.66885-2-jhb@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 5/26/23 13:57, John Baldwin wrote: > Don't invoke ptrace in the target read_description method if there is > not an active inferior to query via ptrace. Instead, use the default > register set for the architecture. > > Previously the native target could report an error from a failed > ptrace operation when fetching a tdesc without an attached process. > For example on FreeBSD/amd64: > > (gdb) target native > Done. Use the "run" command to start a process. > (gdb) unset tdesc filename > Couldn't get registers: Operation not permitted. > --- > gdb/aarch64-fbsd-nat.c | 3 +++ > gdb/amd64-fbsd-nat.c | 3 +++ > gdb/arm-fbsd-nat.c | 3 +++ > gdb/i386-fbsd-nat.c | 3 +++ > 4 files changed, 12 insertions(+) > > diff --git a/gdb/aarch64-fbsd-nat.c b/gdb/aarch64-fbsd-nat.c > index 709f5162ce0..29b58e5ff4a 100644 > --- a/gdb/aarch64-fbsd-nat.c > +++ b/gdb/aarch64-fbsd-nat.c > @@ -120,6 +120,9 @@ aarch64_fbsd_nat_target::store_registers (struct regcache *regcache, > const struct target_desc * > aarch64_fbsd_nat_target::read_description () > { > + if (inferior_ptid == null_ptid) > + return nullptr; > + > aarch64_features features; > features.tls = have_regset (inferior_ptid, NT_ARM_TLS)? 1 : 0; > return aarch64_read_description (features); > diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c > index bae267f230f..adbd85571a5 100644 > --- a/gdb/amd64-fbsd-nat.c > +++ b/gdb/amd64-fbsd-nat.c > @@ -310,6 +310,9 @@ amd64_fbsd_nat_target::read_description () > struct reg regs; > int is64; > > + if (inferior_ptid == null_ptid) > + return nullptr; Why do you return nullptr here, instead of calling the beneath target, as done in arm-fbsd-nat.c? Calling the beneath target seems like the right thing to do. In practice, it will likely reach dummy_target::read_description, which returns nullptr. Simon