public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH] i386: Use a fallback XSAVE layout for remote targets
Date: Mon, 27 Nov 2023 16:41:33 -0500	[thread overview]
Message-ID: <519c45e4-9902-489e-81e5-b10e7c5afae9@simark.ca> (raw)
In-Reply-To: <e9478c5e-0289-4934-9811-a07549472a9c@FreeBSD.org>

On 11/27/23 16:04, John Baldwin wrote:
> On 11/27/23 12:47 PM, John Baldwin wrote:
>> On 11/27/23 11:30 AM, Simon Marchi wrote:
>>> On 11/21/23 17:22, John Baldwin wrote:
>>>> On 11/21/23 2:09 PM, John Baldwin wrote:
>>>>> If a target provides a target description including registers from the
>>>>> XSAVE extended region, but does not provide an XSAVE layout, use a
>>>>> fallback XSAVE layout based on the included registers.  This fallback
>>>>> layout matches GDB's behavior in earlier releases which assumes the
>>>>> layout from Intel CPUs.
>>>>>
>>>>> This fallback layout is currently only used for remote targets since
>>>>> native targets which support XSAVE provide an explicit layout derived
>>>>> from CPUID.
>>>>>
>>>>> PR gdb/30912
>>>>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30912
>>>>
>>>> This fixes the regression for me locally.  It would perhaps be cleaner
>>>> to isolate the regression to the remote target by moving the new logic
>>>> in i386_gdbarch_init into remote::fetch_x86_xsave_layout.  The one
>>>> caveat of that is getting access to the right tdesc.  I could perhaps
>>>> change target::fetch_x86_xsave_layout to pass down the tdesc pointer
>>>> (or maybe the gdbarch_info?).  Alternatively it might be sufficient to
>>>> just use target_current_description() as the tdesc in remote.c?  It
>>>> wasn't clear to me if the relevant tdesc in this case was always the
>>>> same as target_current_description() (though I suspect it probably is).
>>>
>>> My understanding is that the fallback is used for targets that can debug
>>> x86, where xcr0 may claim that the inferior has extended state
>>> registers, but where the target is unable to provide an xsave layout.
>>> There probably won't ever be another target than the remote target
>>> in this situation, so if you can make the fix local to the remote
>>> target that would be nice.  But really I would also be fine with what
>>> you have.
> 
> I took at stab at moving this into the remote target, but ran into an
> ugly bit which is that this requires calling these new functions
> from i38[67]-tdep.c from remote.c.  This means remote::fetch_x86_xsave_layout
> would need a suitable #define so it could be conditional on the the i386
> target being enabled.  The posted patch does avoid this problem by keeping
> the logic internal to i38[67]-tdep.c.

Ack, thanks for trying.

Simon

  reply	other threads:[~2023-11-27 21:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21 22:09 John Baldwin
2023-11-21 22:22 ` John Baldwin
2023-11-27  4:39   ` Joel Brobecker
2023-11-27 18:18     ` John Baldwin
2023-11-27 19:30   ` Simon Marchi
2023-11-27 20:47     ` John Baldwin
2023-11-27 21:04       ` John Baldwin
2023-11-27 21:41         ` Simon Marchi [this message]
2023-11-27 21:09       ` Simon Marchi
2023-11-27  4:36 ` Joel Brobecker
2023-11-27 17:59   ` 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=519c45e4-9902-489e-81e5-b10e7c5afae9@simark.ca \
    --to=simark@simark.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).