]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
*-linux-nat: Handle null inferior in read_description.
authorJohn Baldwin <jhb@FreeBSD.org>
Fri, 14 Jul 2023 15:39:24 +0000 (08:39 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Fri, 14 Jul 2023 15:39:24 +0000 (08:39 -0700)
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 Linux x86-64:

(gdb) target native
Done.  Use the "run" command to start a process.
(gdb) unset tdesc filename
Couldn't get CS register: No such process.

gdb/aarch64-linux-nat.c
gdb/arm-linux-nat.c
gdb/mips-linux-nat.c
gdb/ppc-linux-nat.c
gdb/riscv-linux-nat.c
gdb/s390-linux-nat.c
gdb/x86-linux-nat.c

index ecb2eeb954010333b619bc5da2527f64020a57c3..eeb9761bfe5726dfa4b9a23680539452302b100e 100644 (file)
@@ -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 this->beneath ()->read_description ();
+
   tid = inferior_ptid.pid ();
 
   iovec.iov_base = regbuf;
index ef3fa008adf93de6ca218f3dd7352a072b46db7d..70c6bc684fa24122b31406a836980259f868a530 100644 (file)
@@ -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)
index 972b5db8e7682c0eecb217cbd6cbaeccc519ad54..8a7cc95f2a472fa8f9ddbabaaf7ac6ae61807fef 100644 (file)
@@ -458,6 +458,10 @@ mips_linux_nat_target::read_description ()
 
   if (have_dsp < 0)
     {
+      /* Assume no DSP if there is no inferior to inspect with ptrace.  */
+      if (inferior_ptid == null_ptid)
+       return _MIPS_SIM == _ABIO32 ? tdesc_mips_linux : tdesc_mips64_linux;
+
       int tid = get_ptrace_pid (inferior_ptid);
 
       errno = 0;
index 55dcda9f5259eb6bd33a01e85a48066ad89e01d3..d14aba694e539d182438207f1141ea799d8dc9b4 100644 (file)
@@ -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 this->beneath ()->read_description ();
+
   int tid = inferior_ptid.pid ();
 
   if (have_ptrace_getsetevrregs)
index 8be4a5ac3e5ee801744f84f27a17397fb2e6a2cf..9492cb680793cda3d5981f91be203f2fabc464e5 100644 (file)
@@ -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 this->beneath ()->read_description ();
+
   const struct riscv_gdbarch_features features
     = riscv_linux_read_features (inferior_ptid.pid ());
   return riscv_lookup_target_description (features);
index fc3917d30be18cf4f6959d97bb01800bdec4536e..8f54e9f63224e4d0ba477c814a10301adc1ec8ad 100644 (file)
@@ -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 this->beneath ()->read_description ();
+
   int tid = inferior_ptid.pid ();
 
   have_regset_last_break
index fd2145244cc16be1c17a1a1e4b9dad83a4bf316c..ca4eaf5b645146fc7d140923c0e382c0dfe4b75a 100644 (file)
@@ -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 this->beneath ()->read_description ();
+
   tid = inferior_ptid.pid ();
 
 #ifdef __x86_64__