public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] *-fbsd-nat: Handle null inferior in read_description.
Date: Thu, 6 Jul 2023 09:56:36 -0700	[thread overview]
Message-ID: <cd638df3-bbea-5214-24ac-5bf295dae6a8@FreeBSD.org> (raw)
In-Reply-To: <a4107819-ada4-c881-71b2-c29e292ba176@simark.ca>

On 7/6/23 9:18 AM, Simon Marchi wrote:
> 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.

I think you are right, and I will change both this and patch 2 for the
Linux targets to call the beneath one.  My thinking was that in general
returning nullptr causes the caller code to pick a "default" tdesc, but
that for arm-fbsd-nat.c I was trying to match the existing code
(copied from arm-linux-nat.c) which calls the beneath target for its fallback
instead of returning nullptr.

-- 
John Baldwin


  reply	other threads:[~2023-07-06 16:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26 17:57 [PATCH 0/4] Handle null inferiors in target::read_description John Baldwin
2023-05-26 17:57 ` [PATCH 1/4] *-fbsd-nat: Handle null inferior in read_description John Baldwin
2023-07-06 16:18   ` Simon Marchi
2023-07-06 16:56     ` John Baldwin [this message]
2023-05-26 17:57 ` [PATCH 2/4] *-linux-nat: " John Baldwin
2023-06-12  8:56   ` Luis Machado
2023-06-12 17:43     ` John Baldwin
2023-05-26 17:57 ` [PATCH 3/4] Add a have_native_target helper function for use with require John Baldwin
2023-07-06 16:24   ` Simon Marchi
2023-07-06 17:18     ` John Baldwin
2023-05-26 17:57 ` [PATCH 4/4] Test that native targets can read a tdesc without a process attached John Baldwin
2023-06-09 16:55 ` [PING] [PATCH 0/4] Handle null inferiors in target::read_description John Baldwin
2023-06-30 14:22   ` 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=cd638df3-bbea-5214-24ac-5bf295dae6a8@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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).