Fetch the CPUID data from the current target via a new
TARGET_OBJECT_X86_CPUID and write it to an output bfd for a core dump.
---
gdb/target.h | 2 ++
gdb/x86-tdep.c | 22 ++++++++++++++++++++++
gdb/x86-tdep.h | 9 +++++++++
3 files changed, 33 insertions(+)
@@ -210,6 +210,8 @@ enum target_object
TARGET_OBJECT_FREEBSD_VMMAP,
/* FreeBSD process strings. */
TARGET_OBJECT_FREEBSD_PS_STRINGS,
+ /* x86 CPUID leaves stored in NT_X86_CPUID core dump note. */
+ TARGET_OBJECT_X86_CPUID,
/* Possible future objects: TARGET_OBJECT_FILE, ... */
};
@@ -18,8 +18,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "elf-bfd.h"
+#include "inferior.h"
#include "x86-tdep.h"
#include "symtab.h"
+#include "target.h"
/* Check whether NAME is included in NAMES[LO] (inclusive) to NAMES[HI]
@@ -75,3 +78,22 @@ x86_in_indirect_branch_thunk (CORE_ADDR pc, const char * const *register_names,
return false;
}
+
+/* See x86-tdep.h. */
+
+void
+x86_elf_make_cpuid_note (bfd *obfd, gdb::unique_xmalloc_ptr<char> *note_data,
+ int *note_size)
+{
+ gdb::optional<gdb::byte_vector> buf =
+ target_read_alloc (current_inferior ()->top_target (),
+ TARGET_OBJECT_X86_CPUID, nullptr);
+ if (!buf || buf->empty ())
+ return;
+
+ note_data->reset (elfcore_write_register_note (obfd,
+ note_data->release (),
+ note_size,
+ ".reg-x86-cpuid",
+ buf->data (), buf->size ()));
+}
@@ -27,4 +27,13 @@ extern bool x86_in_indirect_branch_thunk (CORE_ADDR pc,
const char * const *register_names,
int lo, int hi);
+/* Add content to *NOTE_DATA (and update *NOTE_SIZE) to include a note
+ containing CPUID leaves for the current target. The core file is
+ being written to OBFD. If something goes wrong then *NOTE_DATA can
+ be set to nullptr. */
+
+extern void x86_elf_make_cpuid_note (bfd *obfd,
+ gdb::unique_xmalloc_ptr<char> *note_data,
+ int *note_size);
+
#endif /* x86-tdep.h */