Re: [PATCH v6 06/15] gdb: Update x86 FreeBSD architectures to support XSAVE layouts.

John Baldwin
2023-07-26T21:43:38Z

On 7/26/23 1:04 PM, Simon Marchi wrote:
>> @@ -241,43 +241,49 @@ static const struct tramp_frame i386_fbsd64_sigframe =
>> i386_fbsd_sigframe_init
>> };
>>
>> -/* Get XSAVE extended state xcr0 from core dump. */
>> +/* See i386-fbsd-tdep.h. */
>>
>> uint64_t
>> -i386fbsd_core_read_xcr0 (bfd *abfd)
>> +i386_fbsd_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout)
>> {
>> asection *xstate = bfd_get_section_by_name (abfd, ".reg-xstate");
>> - uint64_t xcr0;
>> + if (xstate == nullptr)
>> + return X86_XSTATE_SSE_MASK;
>>
>> - if (xstate)
>> + /* Check extended state size. */
>> + size_t size = bfd_section_size (xstate);
>> + if (size < X86_XSTATE_AVX_SIZE)
>> + return X86_XSTATE_SSE_MASK;
>> +
>> + char contents[8];
>> + if (! bfd_get_section_contents (abfd, xstate, contents,
>> + I386_FBSD_XSAVE_XCR0_OFFSET, 8))
>> {
>> - size_t size = bfd_section_size (xstate);
>> -
>> - /* Check extended state size. */
>> - if (size < X86_XSTATE_AVX_SIZE)
>> - xcr0 = X86_XSTATE_SSE_MASK;
>> - else
>> - {
>> - char contents[8];
>> -
>> - if (! bfd_get_section_contents (abfd, xstate, contents,
>> - I386_FBSD_XSAVE_XCR0_OFFSET,
>> - 8))
>> - {
>> - warning (_("Couldn't read `xcr0' bytes from "
>> - "`.reg-xstate' section in core file."));
>> - return X86_XSTATE_SSE_MASK;
>> - }
>> -
>> - xcr0 = bfd_get_64 (abfd, contents);
>> - }
>> + warning (_("Couldn't read `xcr0' bytes from "
>> + "`.reg-xstate' section in core file."));
>> + return X86_XSTATE_SSE_MASK;
>> }
>> - else
>> - xcr0 = X86_XSTATE_SSE_MASK;
>> +
>> + uint64_t xcr0 = bfd_get_64 (abfd, contents);
>> +
>> + if (!i387_set_xsave_layout (xcr0, size, layout))
>> + return X86_XSTATE_SSE_MASK;
>>
>> return xcr0;
>> }
>>
>> +/* Implement the core_read_x86_xsave_layout gdbarch method. */
> Should be:
>
> /* See i386-fbsd-tdep.h. */

Fixed.

>> +
>> +bool
>> +i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
>> + x86_xsave_layout &layout)
>> +{
>> + if (i386_fbsd_core_read_xsave_info (core_bfd, layout) == X86_XSTATE_SSE_MASK)
>> + return false;
>> +
>> + return true;
>> +}
>
> Rewrite as
>
> return i386_fbsd_core_read_xsave_info (core_bfd, layout) != X86_XSTATE_SSE_MASK;
>
> ?

Yes, and I'll fix it in i386-linux-tdep.c as well.

> Otherwise:
>
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
>
> Simon
>

--
John Baldwin