public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: gdb-patches@sourceware.org
Cc: Willgerodt, Felix <felix.willgerodt@intel.com>,
	George, Jini Susan <JiniSusan.George@amd.com>,
	Simon Marchi <simon.marchi@polymtl.ca>
Subject: [RFC 10/13] {amd64,i386}-fbsd-tdep: Include NT_X86_CPUID notes in core dumps from gcore
Date: Mon,  9 Oct 2023 11:36:12 -0700	[thread overview]
Message-ID: <20231009183617.24862-11-jhb@FreeBSD.org> (raw)
In-Reply-To: <20231009183617.24862-1-jhb@FreeBSD.org>

Override the gdbarch make_corefile_notes method for the FreeBSD x86
arches with a new function that calls fbsd_make_corefile_notes and
x86_elf_make_cpuid_note to generate the core dump notes.
---
 gdb/amd64-fbsd-tdep.c |  1 +
 gdb/i386-fbsd-tdep.c  | 15 +++++++++++++++
 gdb/i386-fbsd-tdep.h  |  7 +++++++
 3 files changed, 23 insertions(+)

diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c
index 2b633cd479c..30cba8f6e6a 100644
--- a/gdb/amd64-fbsd-tdep.c
+++ b/gdb/amd64-fbsd-tdep.c
@@ -329,6 +329,7 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_core_read_description (gdbarch,
 				     amd64fbsd_core_read_description);
+  set_gdbarch_make_corefile_notes (gdbarch, i386_fbsd_make_corefile_notes);
 
   /* FreeBSD uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index 1789f3921fd..810ecc90df1 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -26,6 +26,7 @@
 #include "tramp-frame.h"
 #include "i386-fbsd-tdep.h"
 
+#include "x86-tdep.h"
 #include "i386-tdep.h"
 #include "i387-tdep.h"
 #include "fbsd-tdep.h"
@@ -370,6 +371,19 @@ i386fbsd_get_thread_local_address (struct gdbarch *gdbarch, ptid_t ptid,
   return fbsd_get_thread_local_address (gdbarch, dtv_addr, lm_addr, offset);
 }
 
+/* See i386-fbsd-tdep.h.  */
+
+gdb::unique_xmalloc_ptr<char>
+i386_fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd,
+			       int *note_size)
+{
+  gdb::unique_xmalloc_ptr<char> note_data =
+    fbsd_make_corefile_notes (gdbarch, obfd, note_size);
+
+  x86_elf_make_cpuid_note (obfd, &note_data, note_size);
+  return note_data;
+}
+
 static void
 i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
@@ -403,6 +417,7 @@ i386fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   set_gdbarch_core_read_description (gdbarch,
 				     i386fbsd_core_read_description);
+  set_gdbarch_make_corefile_notes (gdbarch, i386_fbsd_make_corefile_notes);
 
   /* FreeBSD uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index c49cb1eba68..fc7bb1c521d 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -40,6 +40,13 @@ bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
    matches the layout on Linux.  */
 #define I386_FBSD_XSAVE_XCR0_OFFSET 464
 
+/* Create appropriate note sections for a corefile, returning them in
+   allocated memory.  Extends fbsd_make_corefile_notes to add a
+   NT_X86_CPUID note.  */
+
+gdb::unique_xmalloc_ptr<char> i386_fbsd_make_corefile_notes
+(struct gdbarch *gdbarch, bfd *obfd, int *note_size);
+
 extern const struct regset i386_fbsd_gregset;
 
 #endif /* i386-fbsd-tdep.h */
-- 
2.41.0


  parent reply	other threads:[~2023-10-09 18:36 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 NT_X86_CPUID core dump note 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
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 ` John Baldwin [this message]
2023-10-16  9:31   ` [RFC 10/13] {amd64, i386}-fbsd-tdep: Include NT_X86_CPUID notes in core dumps from gcore 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=20231009183617.24862-11-jhb@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=JiniSusan.George@amd.com \
    --cc=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --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).