35#include <sys/kassert.h>
36#include <sys/kdebug.h>
123#define op2(x,y) ((x)|((y)<<8))
124#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
458 "fnop",
"",
"",
"",
"",
"",
"",
""
461 "fchs",
"fabs",
"",
"",
"ftst",
"fxam",
"",
""
464 "fld1",
"fldl2t",
"fldl2e",
"fldpi",
"fldlg2",
"fldln2",
"fldz",
""
467 "f2xm1",
"fyl2x",
"fptan",
"fpatan",
"fxtract",
"fprem1",
"fdecstp",
471 "fprem",
"fyl2xp1",
"fsqrt",
"fsincos",
"frndint",
"fscale",
"fsin",
"fcos"
475 "",
"fucompp",
"",
"",
"",
"",
"",
""
479 "fneni",
"fndisi",
"fnclex",
"fninit",
"fsetpm",
"",
"",
""
483 "",
"fcompp",
"",
"",
"",
"",
"",
""
487 "fnstsw",
"",
"",
"",
"",
"",
"",
""
505 {
"fstp",
SNGL, 0, 0 },
513 {
"fiadd",
LONG, 0, 0 },
514 {
"fimul",
LONG, 0, 0 },
515 {
"ficom",
LONG, 0, 0 },
516 {
"ficomp",
LONG, 0, 0 },
517 {
"fisub",
LONG, 0, 0 },
519 {
"fidiv",
LONG, 0, 0 },
520 {
"fidivr",
LONG, 0, 0 }
524 {
"fild",
LONG, 0, 0 },
526 {
"fist",
LONG, 0, 0 },
527 {
"fistp",
LONG, 0, 0 },
529 {
"fld",
EXTR, 0, 0 },
531 {
"fstp",
EXTR, 0, 0 },
537 {
"fcom",
DBLR, 0, 0 },
538 {
"fcomp",
DBLR, 0, 0 },
552 {
"fnsave",
NONE, 0, 0 },
553 {
"fnstsw",
NONE, 0, 0 },
559 {
"ficom",
WORD, 0, 0 },
568 {
"fild",
WORD, 0, 0 },
570 {
"fist",
WORD, 0, 0 },
571 {
"fistp",
WORD, 0, 0 },
573 {
"fild",
QUAD, 0, 0 },
574 {
"fbstp",
NONE, 0, 0 },
575 {
"fistp",
QUAD, 0, 0 },
933#define f_mod(rex, byte) ((byte)>>6)
934#define f_reg(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
935#define f_rm(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
937#define sib_ss(rex, byte) ((byte)>>6)
938#define sib_index(rex, byte) ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
939#define sib_base(rex, byte) (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
949static const char *
const db_reg[2][4][16] = {
951 {{
"%al",
"%cl",
"%dl",
"%bl",
"%ah",
"%ch",
"%dh",
"%bh",
952 "%r8b",
"%r9b",
"%r10b",
"%r11b",
"%r12b",
"%r13b",
"%r14b",
"%r15b" },
953 {
"%ax",
"%cx",
"%dx",
"%bx",
"%sp",
"%bp",
"%si",
"%di",
954 "%r8w",
"%r9w",
"%r10w",
"%r11w",
"%r12w",
"%r13w",
"%r14w",
"%r15w" },
955 {
"%eax",
"%ecx",
"%edx",
"%ebx",
"%esp",
"%ebp",
"%esi",
"%edi",
956 "%r8d",
"%r9d",
"%r10d",
"%r11d",
"%r12d",
"%r13d",
"%r14d",
"%r15d" },
957 {
"%rax",
"%rcx",
"%rdx",
"%rbx",
"%rsp",
"%rbp",
"%rsi",
"%rdi",
958 "%r8",
"%r9",
"%r10",
"%r11",
"%r12",
"%r13",
"%r14",
"%r15" }},
960 {{
"%al",
"%cl",
"%dl",
"%bl",
"%spl",
"%bpl",
"%sil",
"%dil",
961 "%r8b",
"%r9b",
"%r10b",
"%r11b",
"%r12b",
"%r13b",
"%r14b",
"%r15b" },
962 {
"%ax",
"%cx",
"%dx",
"%bx",
"%sp",
"%bp",
"%si",
"%di",
963 "%r8w",
"%r9w",
"%r10w",
"%r11w",
"%r12w",
"%r13w",
"%r14w",
"%r15w" },
964 {
"%eax",
"%ecx",
"%edx",
"%ebx",
"%esp",
"%ebp",
"%esi",
"%edi",
965 "%r8d",
"%r9d",
"%r10d",
"%r11d",
"%r12d",
"%r13d",
"%r14d",
"%r15d" },
966 {
"%rax",
"%rcx",
"%rdx",
"%rbx",
"%rsp",
"%rbp",
"%rsi",
"%rdi",
967 "%r8",
"%r9",
"%r10",
"%r11",
"%r12",
"%r13",
"%r14",
"%r15" }}
971 "%es",
"%cs",
"%ss",
"%ds",
"%fs",
"%gs",
"",
""
987#define get_value_inc(result, loc, size, is_signed) \
988 result = Debug_GetValue((loc), (size), (is_signed)); \
993 int size,
const char *seg);
1006 int mod, rm, sib, index, disp,
size, have_sib;
1008 mod =
f_mod(rex, regmodrm);
1009 rm =
f_rm(rex, regmodrm);
1024 if ((rm & 0x7) == 4) {
1041 else if (short_addr)
1042 addrp->
base =
"%eip";
1044 addrp->
base =
"%rip";
1078 if (addrp->
disp != 0 || (addrp->
base == 0 && addrp->
index == 0))
1080 if (addrp->
base != 0 || addrp->
index != 0) {
1098 const struct finst * fp;
1105 mod =
f_mod(rex, regmodrm);
1107 if (*fp->
f_name ==
'\0') {
1148 kprintf(
"%s\t%%st,%%st(%d)",name,
f_rm(rex, regmodrm));
1152 kprintf(
"%s\t%%st(%d),%%st",name,
f_rm(rex, regmodrm));
1156 kprintf(
"%s\t%%st(%d)",name,
f_rm(rex, regmodrm));
1159 name = ((
const char *
const *)fp->
f_rrname)[
f_rm(rex, regmodrm)];
1165 name = ((
const char *
const *)fp->
f_rrname)[
f_rm(rex, regmodrm)];
1192 const struct inst * ip;
1266 if (
inst >= 0xd8 &&
inst <= 0xdf) {
1301 ip = &ip[
f_reg(rex, regmodrm)];
1307 ip = &ip[
f_reg(rex, regmodrm)];
1382 f_reg(rex, regmodrm) == 0x6) {
1389 f_reg(rex, regmodrm) == 0x6) {
1409 if (short_addr ==
FALSE)
1509 kprintf(
"(%s)", short_addr ?
"%bx" :
"%ebx");
1523 kprintf(
"(%s)", short_addr ?
"%si" :
"%rsi");
1527 kprintf(
"%%es:(%s)", short_addr ?
"%di" :
"%rdi");
1584 len = (short_addr ? 2 : 4);
static const struct inst db_inst_0f3x[]
static const struct finst db_Escc[]
uintptr_t db_disasm(uintptr_t loc, bool altfmt)
static const struct inst *const db_inst_0f[]
#define sib_ss(rex, byte)
static const struct finst db_Esc8[]
static const char *const db_Esc97[]
static const char *const db_Grp1[]
static const char *const db_reg[2][4][16]
#define sib_index(rex, byte)
static const char *const db_Escb4[]
static const struct inst db_Grp4[]
static const struct inst db_inst_0f7x[]
static void db_print_address(const char *seg, int size, int rex, struct i_addr *addrp)
static const char *const db_Esc95[]
static uintptr_t db_disasm_esc(uintptr_t loc, int inst, int rex, int short_addr, int size, const char *seg)
static const char *const db_Grp15[]
static const struct finst db_Esca[]
static const struct inst db_inst_table[256]
static const char *const db_Grp7[]
static const struct inst db_Grp5[]
static const char *const db_Grp15b[]
static const struct inst db_inst_0f0x[]
static const char *const db_Esce3[]
static const char *const db_Grp2[]
static const struct inst db_inst_0f9x[]
static const struct finst db_Esce[]
static const char *const db_Grp8[]
static const struct inst db_inst_0f4x[]
static const char *const db_Esc94[]
static const struct inst db_inst_0fbx[]
#define get_value_inc(result, loc, size, is_signed)
static const struct finst db_Escb[]
static const struct finst db_Escf[]
static uintptr_t db_read_address(uintptr_t loc, int short_addr, int rex, int regmodrm, struct i_addr *addrp)
static const int db_lengths[]
static const struct inst db_inst_0f388x[]
static const char *const db_Esca5[]
static const struct inst db_inst_0f8x[]
static const struct finst *const db_Esc_inst[]
static const struct finst db_Esc9[]
static const struct inst db_inst_0fax[]
static const char *const db_seg_reg[8]
static const struct inst db_Grp3[]
#define sib_base(rex, byte)
static const char *const db_Grp6[]
static const struct inst db_inst_0f2x[]
static const struct finst db_Escd[]
static const char *const db_Grp9[]
static const char *const db_Esc92[]
static const struct inst db_inst_0fcx[]
static const char *const db_Esc96[]
static const struct inst *const db_inst_0f38[]
static const struct inst db_bad_inst
static const char *const db_Escf4[]
int kprintf(const char *fmt,...)
void Debug_PrintSymbol(uintptr_t off, int strategy)
int strcmp(const char *s1, const char *s2)