[v5,08/19] *-linux-nat: Handle null inferior in read_description.
Commit Message
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(+)
Comments
On 4/27/23 17:01, 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.
Since this fixes a user-visible problem, can you please update the
commit message to indicate what this is fixing? If I remember
correctly:
(gdb) target native
Done. Use the "run" command to start a process.
(gdb) unset tdesc filename
Couldn't get CS register: No such process.
And you could include the equivalent in the previous commit (the one
that fixes it for fbsd), I guess you get a slightly different error
there?
It would also be nice to have a test for this, which would ensure that
the "unset tdesc filename" command outputs nothing.
Simon
On 5/3/23 9:38 AM, Simon Marchi wrote:
> On 4/27/23 17:01, 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.
>
> Since this fixes a user-visible problem, can you please update the
> commit message to indicate what this is fixing? If I remember
> correctly:
>
> (gdb) target native
> Done. Use the "run" command to start a process.
> (gdb) unset tdesc filename
> Couldn't get CS register: No such process.
>
> And you could include the equivalent in the previous commit (the one
> that fixes it for fbsd), I guess you get a slightly different error
> there?
Yep, fixed.
> It would also be nice to have a test for this, which would ensure that
> the "unset tdesc filename" command outputs nothing.
I've added one in a followup commit locally.
@@ -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;
@@ -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)
@@ -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)
@@ -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)
@@ -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);
@@ -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
@@ -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__