public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org, Felix <felix.willgerodt@intel.com>,
	Jini Susan <JiniSusan.George@amd.com>,
	Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [RFC 01/13] binutils: Support for the NT_X86_CPUID core dump note
Date: Mon, 16 Oct 2023 16:23:14 -0700	[thread overview]
Message-ID: <4fcf4c8b-a6f8-0864-e45c-81823b7bf03b@FreeBSD.org> (raw)
In-Reply-To: <20231016092315.a2dc3h3rfwb2xhq4@octopus>

On 10/16/23 2:23 AM, Lancelot SIX wrote:
> Hi John
> 
> I am aware this is a RFC series where you are mostly looking for
> feedback on the overall direction, but I have an implemenation question
> below (feel free to discard as part of the RFC process).t
> 
> On Mon, Oct 09, 2023 at 11:36:03AM -0700, John Baldwin wrote:
>> This core dump note contains an array of CPUID leaf values.  Each
>> entry in the array contains six 32-bit integers describing the inputs
>> to the CPUID instruction (%eax and %ecx) and the outputs of the
>> instruction (%eax, %ebx, %ecx, and %edx) similar to the C structure:
>>
>> struct cpuid_leaf
>> {
>>      uint32_t leaf;
>>      uint32_t subleaf;
>>      uint32_t eax;
>>      uint32_t ebx;
>>      uint32_t ecx;
>>      uint32_t edx;
>> };
>>
>> Current implementations of this note contain leaves associated with
>> the XSAVE state area (major leaf 0xd), but future implementations may
>> add other leaf values in the future.
>> ---
>>   bfd/elf-bfd.h        |  2 ++
>>   bfd/elf.c            | 35 +++++++++++++++++++++++++++++++++++
>>   binutils/readelf.c   |  2 ++
>>   include/elf/common.h |  2 ++
>>   4 files changed, 41 insertions(+)
>>
>> @@ -12640,6 +12660,19 @@ elfcore_write_xstatereg (bfd *abfd, char *buf, int *bufsiz,
>>   			     note_name, NT_X86_XSTATE, xfpregs, size);
>>   }
>>   
>> +char *
>> +elfcore_write_x86_cpuid (bfd *abfd, char *buf, int *bufsiz,
>> +			 const void *cpuid, int size)
>> +{
>> +  char *note_name;
>> +  if (get_elf_backend_data (abfd)->elf_osabi == ELFOSABI_FREEBSD)
>> +    note_name = "FreeBSD";
> 
> The code above (in elfcore_grok_note) only accept "LINUX", and the
> comment in "include/elf/common.h" says "note name must be "LINUX".
> 
> Is this something you intend to adjust later when adding full FreeBSD
> support?

I really just kept that to match what is there for NT_X86_XSTATE, but
this patch already includes FreeBSD support (FreeBSD notes use
elfcore_grok_freebsd_note rather than elfcore_grok_note).  I almost
left that comment about the note name out, and probably I should just
do that.  (Arguably I should also remove that comment from NT_X86_XSTATE
and possibly some others that both FreeBSD and Linux generate.)

On a related note, abusing elf_osabi to determine the note name is a
bit of a hack.  It would be nice if elfcore_write_register_note
accepted the note name as an argument, but I'm not sure how much
that would break (e.g. if that's a public binutils API used by
other things than gdb).

-- 
John Baldwin


  reply	other threads:[~2023-10-16 23:23 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 18:36 [RFC 00/13] Proposal for a new " John Baldwin
2023-10-09 18:36 ` [RFC 01/13] binutils: Support for the " John Baldwin
2023-10-16  9:23   ` Lancelot SIX
2023-10-16 23:23     ` John Baldwin [this message]
2023-10-09 18:36 ` [RFC 02/13] i387-tdep: Add function to read XSAVE layout from NT_X86_CPUID John Baldwin
2023-10-12  4:27   ` Simon Marchi
2023-10-16 23:52     ` John Baldwin
2023-10-16  9:17   ` Lancelot SIX
2023-10-17  0:04     ` John Baldwin
2023-10-09 18:36 ` [RFC 03/13] gdb: Use NT_X86_CPUID in x86 FreeBSD architectures to read XSAVE layouts John Baldwin
2023-10-09 18:36 ` [RFC 04/13] " John Baldwin
2023-10-12  4:28   ` Simon Marchi
2023-10-17  0:07     ` John Baldwin
2023-10-09 18:36 ` [RFC 05/13] nat/x86-cpuid.h: Remove non-x86 fallbacks John Baldwin
2023-10-12  4:29   ` Simon Marchi
2023-10-09 18:36 ` [RFC 06/13] nat/x86-cpuid: Add a function to build the contents of a NT_X86_CPUID note John Baldwin
2023-10-12  4:41   ` Simon Marchi
2023-10-17  0:22     ` John Baldwin
2023-10-09 18:36 ` [RFC 07/13] x86_elf_make_cpuid_note: Helper routine to build NT_X86_CPUID ELF note John Baldwin
2023-10-09 18:36 ` [RFC 08/13] x86-fbsd-nat: Support fetching TARGET_OBJECT_X86_CPUID objects John Baldwin
2023-10-09 18:36 ` [RFC 09/13] fbsd-tdep: Export fbsd_make_corefile_notes John Baldwin
2023-10-09 18:36 ` [RFC 10/13] {amd64,i386}-fbsd-tdep: Include NT_X86_CPUID notes in core dumps from gcore John Baldwin
2023-10-16  9:31   ` [RFC 10/13] {amd64, i386}-fbsd-tdep: " Lancelot SIX
2023-10-17  0:26     ` John Baldwin
2023-10-09 18:36 ` [RFC 11/13] x86-linux-nat: Support fetching TARGET_OBJECT_X86_CPUID objects John Baldwin
2023-10-09 18:36 ` [RFC 12/13] linux-tdep: Export linux_make_corefile_notes John Baldwin
2023-10-09 18:36 ` [RFC 13/13] {amd64,i386}-linux-tdep: Include NT_X86_CPUID notes in core dumps from gcore John Baldwin
2023-10-10 16:30 ` [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note George, Jini Susan
2023-10-12  4:01 ` Simon Marchi
2023-10-12 14:33 ` Simon Marchi
2023-10-12 17:18   ` John Baldwin
2023-10-13  9:38     ` George, Jini Susan
2023-10-17  0:36       ` John Baldwin
2023-10-26 16:18         ` George, Jini Susan
2023-10-27  2:53           ` John Baldwin
2023-10-27 11:11             ` George, Jini Susan
2023-10-31 16:41               ` 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=4fcf4c8b-a6f8-0864-e45c-81823b7bf03b@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=JiniSusan.George@amd.com \
    --cc=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=simon.marchi@polymtl.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).