Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FW: Update dump_xsave() to print the APX Extended GPRs #345

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions framework/sandstone_context_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "fp_vectors/Floats.h"

#include <algorithm>
#include <array>
#include <limits>

#ifdef __unix__
Expand All @@ -25,6 +26,8 @@
# include <cpuid.h>
#endif

using ApxState = std::array<int64_t, 16>;

union xmmreg
{
__m128 f;
Expand Down Expand Up @@ -296,6 +299,27 @@ void dump_gprs(FILE *f, const mcontext_t mc)
}
#endif

static void print_egprs(FILE *f, const Fxsave *state)
{
int offset = xsave_offset(XSave_ApxState);
if (offset + sizeof(ApxState) <= Fxsave::size)
return;

auto base = reinterpret_cast<const uint8_t *>(state);
auto egprs = reinterpret_cast<const ApxState *>(base + offset);
char regname[] = "r16";
for (int64_t value : *egprs) {
print_gpr(f, regname, value);

// increment the register name
if (regname[2]++ == '9') {
// NB: the AAA instruction would be useful for this!
++regname[1];
regname[2] = '0';
}
}
}

static void print_x87mmx_registers(FILE *f, const Fxsave *state)
{
int fptop = (state->fsw >> 11) & 7;
Expand Down Expand Up @@ -467,6 +491,9 @@ void dump_xsave(FILE *f, const void *xsave_area, size_t xsave_size, int xsave_du
return; // bit vector contains invalid bits
}

if (mask & XSave_ApxState)
print_egprs(f, state);

if (mask & XSave_X87)
print_x87mmx_registers(f, state);

Expand Down