public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v5 08/19] *-linux-nat: Handle null inferior in read_description.
Date: Thu, 27 Apr 2023 14:01:02 -0700	[thread overview]
Message-ID: <20230427210113.45380-9-jhb@FreeBSD.org> (raw)
In-Reply-To: <20230427210113.45380-1-jhb@FreeBSD.org>

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-linux-nat.c | 3 +++
 gdb/arm-linux-nat.c     | 3 +++
 gdb/mips-linux-nat.c    | 3 +++
 gdb/ppc-linux-nat.c     | 3 +++
 gdb/riscv-linux-nat.c   | 3 +++
 gdb/s390-linux-nat.c    | 3 +++
 gdb/x86-linux-nat.c     | 3 +++
 7 files changed, 21 insertions(+)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index ecb2eeb9540..62f8825b9c8 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -785,6 +785,9 @@ aarch64_linux_nat_target::read_description ()
   gdb_byte regbuf[ARM_VFP3_REGS_SIZE];
   struct iovec iovec;
 
+  if (inferior_ptid == null_ptid)
+    return nullptr;
+
   tid = inferior_ptid.pid ();
 
   iovec.iov_base = regbuf;
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index ef3fa008adf..70c6bc684fa 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -531,6 +531,9 @@ ps_get_thread_area (struct ps_prochandle *ph,
 const struct target_desc *
 arm_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return this->beneath ()->read_description ();
+
   CORE_ADDR arm_hwcap = linux_get_hwcap ();
 
   if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 972b5db8e76..1fa0e8c479c 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -454,6 +454,9 @@ mips_linux_nat_target::register_u_offset (struct gdbarch *gdbarch,
 const struct target_desc *
 mips_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return _MIPS_SIM == _ABIO32 ? tdesc_mips_linux : tdesc_mips64_linux;
+
   static int have_dsp = -1;
 
   if (have_dsp < 0)
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 42885deb45e..2f4799aa73a 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1941,6 +1941,9 @@ ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
 const struct target_desc *
 ppc_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return ppc_linux_match_description (ppc_linux_no_features);
+
   int tid = inferior_ptid.pid ();
 
   if (have_ptrace_getsetevrregs)
diff --git a/gdb/riscv-linux-nat.c b/gdb/riscv-linux-nat.c
index 8be4a5ac3e5..5d325e633da 100644
--- a/gdb/riscv-linux-nat.c
+++ b/gdb/riscv-linux-nat.c
@@ -201,6 +201,9 @@ fill_fpregset (const struct regcache *regcache, prfpregset_t *fpregs,
 const struct target_desc *
 riscv_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return nullptr;
+
   const struct riscv_gdbarch_features features
     = riscv_linux_read_features (inferior_ptid.pid ());
   return riscv_lookup_target_description (features);
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index fc3917d30be..7d3b3cfe78b 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -987,6 +987,9 @@ s390_linux_nat_target::auxv_parse (const gdb_byte **readptr,
 const struct target_desc *
 s390_linux_nat_target::read_description ()
 {
+  if (inferior_ptid == null_ptid)
+    return nullptr;
+
   int tid = inferior_ptid.pid ();
 
   have_regset_last_break
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index fd2145244cc..87862b89eab 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -115,6 +115,9 @@ x86_linux_nat_target::read_description ()
   static uint64_t xcr0;
   uint64_t xcr0_features_bits;
 
+  if (inferior_ptid == null_ptid)
+    return nullptr;
+
   tid = inferior_ptid.pid ();
 
 #ifdef __x86_64__
-- 
2.40.0


  parent reply	other threads:[~2023-04-27 21:01 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 21:00 [PATCH v5 00/19] Handle variable XSAVE layouts John Baldwin
2023-04-27 21:00 ` [PATCH v5 01/19] x86: Add an x86_xsave_layout structure to handle " John Baldwin
2023-04-27 21:00 ` [PATCH v5 02/19] gdb: Store an x86_xsave_layout in i386_gdbarch_tdep John Baldwin
2023-05-03 16:22   ` Simon Marchi
2023-05-08 16:51     ` John Baldwin
2023-04-27 21:00 ` [PATCH v5 03/19] core: Support fetching x86 XSAVE layout from architectures John Baldwin
2023-04-27 21:00 ` [PATCH v5 04/19] nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count John Baldwin
2023-04-27 21:00 ` [PATCH v5 05/19] x86 nat: Add helper functions to save the XSAVE layout for the host John Baldwin
2023-04-27 21:01 ` [PATCH v5 06/19] x86-fbsd-nat: Add missing public label John Baldwin
2023-04-27 21:01 ` [PATCH v5 07/19] *-fbsd-nat: Handle null inferior in read_description John Baldwin
2023-04-27 21:01 ` John Baldwin [this message]
2023-05-03 16:38   ` [PATCH v5 08/19] *-linux-nat: " Simon Marchi
2023-05-08 17:24     ` John Baldwin
2023-04-27 21:01 ` [PATCH v5 09/19] gdb: Update x86 FreeBSD architectures to support XSAVE layouts John Baldwin
2023-05-03 17:14   ` Simon Marchi
2023-05-03 17:20     ` Simon Marchi
2023-05-03 23:45     ` John Baldwin
2023-05-04 17:20       ` Simon Marchi
2023-05-08 17:33         ` John Baldwin
2023-04-27 21:01 ` [PATCH v5 10/19] gdb: Support XSAVE layouts for the current host in the FreeBSD x86 targets John Baldwin
2023-04-27 21:01 ` [PATCH v5 11/19] gdb: Update x86 Linux architectures to support XSAVE layouts John Baldwin
2023-04-27 21:01 ` [PATCH v5 12/19] gdb: Support XSAVE layouts for the current host in the Linux x86 targets John Baldwin
2023-04-27 21:01 ` [PATCH v5 13/19] gdb: Use x86_xstate_layout to parse the XSAVE extended state area John Baldwin
2023-04-27 21:01 ` [PATCH v5 14/19] gdbserver: Add a function to set the XSAVE mask and size John Baldwin
2023-04-27 21:01 ` [PATCH v5 15/19] gdbserver: Refactor the legacy region within the xsave struct John Baldwin
2023-04-27 21:01 ` [PATCH v5 16/19] gdbserver: Clear upper ZMM registers in the right location John Baldwin
2023-05-03 17:49   ` Simon Marchi
2023-05-03 23:47     ` John Baldwin
2023-04-27 21:01 ` [PATCH v5 17/19] gdbserver: Use x86_xstate_layout to parse the XSAVE extended state area John Baldwin
2023-04-27 21:01 ` [PATCH v5 18/19] x86: Remove X86_XSTATE_SIZE and related constants John Baldwin
2023-04-27 21:01 ` [PATCH v5 19/19] gdbserver: Simplify handling of ZMM registers John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230427210113.45380-9-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).