public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: nat/x86-dregs.c: add and use x86_dr_low_can_get_status
Date: Mon, 19 Jul 2021 10:44:32 -0400	[thread overview]
Message-ID: <0abc8226-64d7-641f-3743-526496963359@polymtl.ca> (raw)
In-Reply-To: <417b1713-9e0e-f1db-e8be-0d8167652333@FreeBSD.org>

On 2021-07-18 6:39 p.m., John Baldwin wrote:
> On 7/16/21 1:38 PM, John Baldwin wrote:
>> On 7/15/21 12:53 PM, Simon Marchi via Gdb-patches wrote:
>>> I built and tried gdb on OpenBSD, and it immediately segfaults when
>>> running a program.  I tracked down the problem to x86_dr_low.get_status
>>> being nullptr at this point:
>>
>> I've looked, and another way to possibly fix this is to make the x86_bsd_nat_target
>> class not inherit from x86_nat_target<> when x86 debug registers aren't supported.
>> Something like this in x86-bsd-nat.h:
>>
>> /* A prototype *BSD/x86 target.  */
>>
>> #ifdef HAVE_PT_GETDBREGS
>> template<typename BaseTarget>
>> class x86bsd_nat_target : public x86_nat_target<BaseTarget>
>> {
>>     using base_class = x86_nat_target<BaseTarget>
>> public:
>>     void mourn_inferior () override
>>     {
>>       x86_cleanup_dregs ();
>>       base_class::mourn_inferior ();
>>     }
>> };
>> #else /* !HAVE_PT_GETDBREGS */
>> template<typename BaseTarget>
>> class x86bsd_nat_target : public BaseTarget
>> {
>> };
>> #endif /* HAVE_PT_GETDBREGS */
> 
> I think this change is ok (but have only tested it on FreeBSD so far).
> 
>> I would be further tempted to then remove x86-bsd-nat.o from OpenBSD's configure.nat
>> lines entirely sine it shouldn't be needed at that point, and maybe adjust x86-bsd-nat.c
>> to start with something like:
>>
>> #ifndef HAVE_PT_GETDBREGS
>> #error "x86-bsd-nat.c requires PT_GETDBREGS"
>> #endif
> 
> These changes are probably premature (though might be realistic after my
> other series lands that pulls x86bsd_xsave_len into the FreeBSD-specific
> targets such that x86-bsd-nat.c is purely about debug registers).  It
> should still be possible to remove x86-nat.c from OpenBSD in configure.nat
> with the x86-bsd-nat.h change.  I can try to test it once I get an
> OpenBSD VM spun up.

All you said sounds good to me.  If you want to do it while you do the
changes to FreeBSD, please go ahead, because this is pretty far down on
my todo list (I just happened to give a try on OpenBSD and wanted to
minimally unbreak it).

Simon

  reply	other threads:[~2021-07-19 14:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15 19:53 Simon Marchi
2021-07-16 20:38 ` John Baldwin
2021-07-18 22:39   ` John Baldwin
2021-07-19 14:44     ` Simon Marchi [this message]
2021-07-27  0:26       ` 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=0abc8226-64d7-641f-3743-526496963359@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.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).