From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id aKlWFefiSmQQGDgAWB0awg (envelope-from ) for ; Thu, 27 Apr 2023 17:02:31 -0400 Received: by simark.ca (Postfix, from userid 112) id 556B11E224; Thu, 27 Apr 2023 17:02:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 75EFA1E128 for ; Thu, 27 Apr 2023 17:02:30 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D18A5385694E for ; Thu, 27 Apr 2023 21:02:27 +0000 (GMT) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2607:f138:0:13::2]) by sourceware.org (Postfix) with ESMTPS id B8BAC3858C1F for ; Thu, 27 Apr 2023 21:01:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8BAC3858C1F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.baldwin.net (c-98-35-126-114.hsd1.ca.comcast.net [98.35.126.114]) by mail.baldwin.cx (Postfix) with ESMTPSA id 53DA51A84E2B for ; Thu, 27 Apr 2023 17:01:32 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Subject: [PATCH v5 07/19] *-fbsd-nat: Handle null inferior in read_description. Date: Thu, 27 Apr 2023 14:01:01 -0700 Message-Id: <20230427210113.45380-8-jhb@FreeBSD.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427210113.45380-1-jhb@FreeBSD.org> References: <20230427210113.45380-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Thu, 27 Apr 2023 17:01:32 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. --- 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; + if (ptrace (PT_GETREGS, inferior_ptid.pid (), (PTRACE_TYPE_ARG3) ®s, 0) == -1) perror_with_name (_("Couldn't get registers")); diff --git a/gdb/arm-fbsd-nat.c b/gdb/arm-fbsd-nat.c index 5181281b27d..cf22fc6cce9 100644 --- a/gdb/arm-fbsd-nat.c +++ b/gdb/arm-fbsd-nat.c @@ -93,6 +93,9 @@ arm_fbsd_nat_target::read_description () const struct target_desc *desc; bool tls = false; + if (inferior_ptid == null_ptid) + return this->beneath ()->read_description (); + #ifdef PT_GETREGSET tls = have_regset (inferior_ptid, NT_ARM_TLS) != 0; #endif diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c index 927771e8b20..26ae420949e 100644 --- a/gdb/i386-fbsd-nat.c +++ b/gdb/i386-fbsd-nat.c @@ -315,6 +315,9 @@ i386_fbsd_nat_target::read_description () #endif static int xmm_probed; + if (inferior_ptid == null_ptid) + return nullptr; + #ifdef PT_GETXSTATE_INFO if (!xsave_probed) { -- 2.40.0