13 static const char digit[] =
"0123456789abcdef";
20 "RAX: %016lx RSI: %016lx R11: %016lx\n" 21 "RBX: %016lx RDI: %016lx R12: %016lx\n" 22 "RCX: %016lx R8: %016lx R13: %016lx\n" 23 "RDX: %016lx R9: %016lx R14: %016lx\n" 24 "RBP: %016lx R10: %016lx R15: %016lx\n",
35 #define B(F) ((rflags & F) ? 1 : 0) 39 "CF=%u PF=%u AF=%u ZF=%u SF=%u " 40 "TF=%u IF=%u DF=%u OF=%u IOPL=%u\n",
50 dump_memory(
char *buf,
size_t bufsize,
const void *mem,
size_t memsize,
54 char *bt = buf + bufsize;
55 const uint8_t *m = (
const uint8_t *)mem;
56 const uint8_t *mt = (
const uint8_t *)mem + memsize;
58 while (b < bt && m < mt) {
63 uint64_t o = (uint64_t)(m - (
const uint8_t *)mem);
64 for (
int i = 7; i >= 0; i--) {
65 b[i] =
digit[o & 0xf];
77 uint64_t a = (uint64_t)m;
78 for (
int i = 16; i > 8; i--) {
79 b[i] =
digit[a & 0xf];
83 for (
int i = 7; i >= 0; i--) {
84 b[i] =
digit[a & 0xf];
94 for (
int j = 0; j < 16; j++) {
99 b[1] =
digit[v & 0xf];
108 if (((j + 1) & 3) == 0) {
123 for (
int j = 0; j < 16; j++) {
127 *b = (v < 32 || v > 126) ?
'.' : (
char)v;
157 else if (bufsize > 0) {
163 return (
int)(b - buf);
#define CPU_EFLAGS_PARITY
int dump_registers(char *buf, size_t bufsize, const registers_t *regs)
Dump the contents of a CPU registers structure to a string buffer.
static const char digit[]
A record describing all 64-bit general-purpose registers.
Include address offset in memory dump.
#define CPU_EFLAGS_INTERRUPT
int snprintf(char *buf, size_t n, const char *format,...)
Compose a printf-formatted string into the target buffer.
int dump_memory(char *buf, size_t bufsize, const void *mem, size_t memsize, enum dumpstyle style)
Dump the contents of memory.
dumpstyle
Memory dump output style.
int dump_cpuflags(char *buf, size_t bufsize, uint64_t rflags)
Dump the contents of the CPU flags register.
#define CPU_EFLAGS_ADJUST
Debugging memory and CPU state dump routines.
Include full address in memory dump.
#define CPU_EFLAGS_DIRECTION
#define CPU_EFLAGS_OVERFLOW