From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.baldwin.cx (bigwig.baldwin.cx [66.216.25.90]) by sourceware.org (Postfix) with ESMTPS id 985E53858024 for ; Mon, 9 Oct 2023 18:36:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 985E53858024 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=FreeBSD.org Received: from ralph.baldwin.net (unknown [98.47.15.113]) by mail.baldwin.cx (Postfix) with ESMTPSA id 68FD51A84E4F; Mon, 9 Oct 2023 14:36:51 -0400 (EDT) From: John Baldwin To: gdb-patches@sourceware.org Cc: Willgerodt, Felix , George, Jini Susan , Simon Marchi Subject: [RFC 13/13] {amd64,i386}-linux-tdep: Include NT_X86_CPUID notes in core dumps from gcore Date: Mon, 9 Oct 2023 11:36:15 -0700 Message-ID: <20231009183617.24862-14-jhb@FreeBSD.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231009183617.24862-1-jhb@FreeBSD.org> References: <20231009183617.24862-1-jhb@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.6.4 (mail.baldwin.cx [0.0.0.0]); Mon, 09 Oct 2023 14:36:52 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.103.1 at mail.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_STATUS,KHOP_HELO_FCRDNS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Override the gdbarch make_corefile_notes method for the Linux x86 arches with a new function that calls linux_make_corefile_notes and x86_elf_make_cpuid_note to generate the core dump notes. --- gdb/amd64-linux-tdep.c | 1 + gdb/i386-linux-tdep.c | 15 +++++++++++++++ gdb/i386-linux-tdep.h | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index e2fdf5fb6c8..11291a606b6 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1838,6 +1838,7 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch, set_gdbarch_core_read_description (gdbarch, amd64_linux_core_read_description); + set_gdbarch_make_corefile_notes (gdbarch, i386_linux_make_corefile_notes); /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 57d00a424d9..6573fcd9ead 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -38,6 +38,7 @@ #include "xml-syscall.h" #include "infrun.h" +#include "x86-tdep.h" #include "i387-tdep.h" #include "gdbsupport/x86-xstate.h" @@ -827,6 +828,19 @@ i386_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, return closure_; } +/* See i386-linux-tdep.h. */ + +gdb::unique_xmalloc_ptr +i386_linux_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, + int *note_size) +{ + gdb::unique_xmalloc_ptr note_data = + linux_make_corefile_notes (gdbarch, obfd, note_size); + + x86_elf_make_cpuid_note (obfd, ¬e_data, note_size); + return note_data; +} + static void i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { @@ -1068,6 +1082,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) (gdbarch, i386_linux_iterate_over_regset_sections); set_gdbarch_core_read_description (gdbarch, i386_linux_core_read_description); + set_gdbarch_make_corefile_notes (gdbarch, i386_linux_make_corefile_notes); /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h index bd8e328b7fe..86ea96edd67 100644 --- a/gdb/i386-linux-tdep.h +++ b/gdb/i386-linux-tdep.h @@ -58,6 +58,13 @@ extern void i386_linux_report_signal_info (struct gdbarch *gdbarch, /* Return the target description according to XCR0. */ extern const struct target_desc *i386_linux_read_description (uint64_t xcr0); +/* Create appropriate note sections for a corefile, returning them in + allocated memory. Extends linux_make_corefile_notes to add a + NT_X86_CPUID note. */ + +extern gdb::unique_xmalloc_ptr i386_linux_make_corefile_notes +(struct gdbarch *gdbarch, bfd *obfd, int *note_size); + /* Format of XSAVE extended state is: struct { -- 2.41.0