summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/elf_machdep.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2014-11-21 20:53:17 +0000
committerjhb <jhb@FreeBSD.org>2014-11-21 20:53:17 +0000
commit1671ac9155f60e765c16e485d93ae02fe40656e3 (patch)
tree99aebdaca5d14d076e3c8d62e9c14bad62a4c56c /sys/amd64/amd64/elf_machdep.c
parentb532057d45360838a1a3c71ee77b32fec6d971ba (diff)
downloadFreeBSD-src-1671ac9155f60e765c16e485d93ae02fe40656e3.zip
FreeBSD-src-1671ac9155f60e765c16e485d93ae02fe40656e3.tar.gz
Improve support for XSAVE with debuggers.
- Dump an NT_X86_XSTATE note if XSAVE is in use. This note is designed to match what Linux does in that 1) it dumps the entire XSAVE area including the fxsave state, and 2) it stashes a copy of the current xsave mask in the unused padding between the fxsave state and the xstate header at the same location used by Linux. - Teach readelf() to recognize NT_X86_XSTATE notes. - Change PT_GET/SETXSTATE to take the entire XSAVE state instead of only the extra portion. This avoids having to always make two ptrace() calls to get or set the full XSAVE state. - Add a PT_GET_XSTATE_INFO which returns the length of the current XSTATE save area (so the size of the buffer needed for PT_GETXSTATE) and the current XSAVE mask (%xcr0). Differential Revision: https://reviews.freebsd.org/D1193 Reviewed by: kib MFC after: 2 weeks
Diffstat (limited to 'sys/amd64/amd64/elf_machdep.c')
-rw-r--r--sys/amd64/amd64/elf_machdep.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index fdc4d56..23fa39b 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_param.h>
#include <machine/elf.h>
+#include <machine/fpu.h>
#include <machine/md_var.h>
struct sysentvec elf64_freebsd_sysvec = {
@@ -133,12 +134,27 @@ SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY,
&kfreebsd_brand_info);
void
-elf64_dump_thread(struct thread *td __unused, void *dst __unused,
- size_t *off __unused)
+elf64_dump_thread(struct thread *td, void *dst, size_t *off)
{
+ void *buf;
+ size_t len;
+
+ len = 0;
+ if (use_xsave) {
+ if (dst != NULL) {
+ fpugetregs(td);
+ len += elf64_populate_note(NT_X86_XSTATE,
+ get_pcb_user_save_td(td), dst,
+ cpu_max_ext_state_size, &buf);
+ *(uint64_t *)((char *)buf + X86_XSTATE_XCR0_OFFSET) =
+ xsave_mask;
+ } else
+ len += elf64_populate_note(NT_X86_XSTATE, NULL, NULL,
+ cpu_max_ext_state_size, NULL);
+ }
+ *off = len;
}
-
/* Process one elf relocation with addend. */
static int
elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
OpenPOWER on IntegriCloud