Merge set of debugger improvements by Doug Gale <doug16k>
Here is his original comment: I have made several improvements in the debugger. I have fixed several issues with proper handling of 64-bit addresses, and added support for 64 bit symbols. I also have added several symbol lookups.
This commit is contained in:
parent
f490b00beb
commit
2a55ba0a39
@ -284,8 +284,10 @@ int bx_dbg_main(void)
|
||||
|
||||
bx_dbg_user_input_loop();
|
||||
|
||||
if(debugger_log != NULL)
|
||||
if(debugger_log != NULL) {
|
||||
fclose(debugger_log);
|
||||
debugger_log = NULL;
|
||||
}
|
||||
|
||||
bx_dbg_exit(0);
|
||||
return(0); // keep compiler happy
|
||||
@ -1160,7 +1162,7 @@ void bx_dbg_info_registers_command(int which_regs_mask)
|
||||
dbg_printf("r14: %08x_%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = BX_CPU(dbg_cpu)->get_reg64(BX_64BIT_REG_R15);
|
||||
dbg_printf("r15: %08x_%08x\n", GET32H(reg), GET32L(reg));
|
||||
reg = bx_dbg_get_instruction_pointer();
|
||||
reg = bx_dbg_get_rip();
|
||||
dbg_printf("rip: %08x_%08x\n", GET32H(reg), GET32L(reg));
|
||||
#endif
|
||||
reg = BX_CPU(dbg_cpu)->read_eflags();
|
||||
@ -1290,6 +1292,15 @@ inserted:
|
||||
dbg_printf("Time breakpoint inserted. Delta = " FMT_LL "u\n", diff);
|
||||
}
|
||||
|
||||
Bit64u conv_8xBit8u_to_Bit64u(const Bit8u* buf)
|
||||
{
|
||||
Bit64u ret = 0;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
ret |= (buf[i] << (8 * i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bit32u conv_4xBit8u_to_Bit32u(const Bit8u* buf)
|
||||
{
|
||||
Bit32u ret = 0;
|
||||
@ -1701,21 +1712,30 @@ void bx_dbg_print_stack_command(unsigned nwords)
|
||||
if (! bx_dbg_read_linear(dbg_cpu, linear_sp, len, buf)) break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (len == 8) {
|
||||
dbg_printf(" | STACK 0x%08x%08x [0x%08x:0x%08x]\n",
|
||||
Bit64u addr_on_stack = conv_8xBit8u_to_Bit64u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf(" | STACK 0x%08x%08x [0x%08x:0x%08x] (%s)\n",
|
||||
GET32H(linear_sp), GET32L(linear_sp),
|
||||
(unsigned) conv_4xBit8u_to_Bit32u(buf+4),
|
||||
(unsigned) conv_4xBit8u_to_Bit32u(buf));
|
||||
(unsigned) conv_4xBit8u_to_Bit32u(buf),
|
||||
Sym ? Sym : "<unknown>");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (len == 4) {
|
||||
dbg_printf(" | STACK 0x%08x [0x%08x]\n",
|
||||
(unsigned) linear_sp, (unsigned) conv_4xBit8u_to_Bit32u(buf));
|
||||
Bit32u addr_on_stack = conv_4xBit8u_to_Bit32u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf(" | STACK 0x%08x [0x%08x] (%s)\n",
|
||||
(unsigned) linear_sp, (unsigned) conv_4xBit8u_to_Bit32u(buf),
|
||||
Sym ? Sym : "<unknown>");
|
||||
}
|
||||
else {
|
||||
dbg_printf(" | STACK 0x%04x [0x%04x]\n",
|
||||
(unsigned) linear_sp, (unsigned) conv_2xBit8u_to_Bit16u(buf));
|
||||
Bit32u addr_on_stack = conv_2xBit8u_to_Bit16u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf(" | STACK 0x%04x [0x%04x] (%s)\n",
|
||||
(unsigned) linear_sp, (unsigned) conv_2xBit8u_to_Bit16u(buf),
|
||||
Sym ? Sym : "<unknown>");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1723,6 +1743,98 @@ void bx_dbg_print_stack_command(unsigned nwords)
|
||||
}
|
||||
}
|
||||
|
||||
void bx_dbg_bt_command(unsigned dist)
|
||||
{
|
||||
bx_address linear_bp;
|
||||
bx_address linear_sp;
|
||||
unsigned len;
|
||||
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (BX_CPU(dbg_cpu)->get_cpu_mode() == BX_MODE_LONG_64) {
|
||||
linear_bp = BX_CPU(dbg_cpu)->get_reg64(BX_64BIT_REG_RBP);
|
||||
linear_sp = BX_CPU(dbg_cpu)->get_reg64(BX_64BIT_REG_RSP);
|
||||
bx_address rip = BX_CPU(dbg_cpu)->get_instruction_pointer();
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(rip, 0);
|
||||
dbg_printf("%012" FMT_64 "x -> %012" FMT_64 "x (%s)\n",
|
||||
(Bit64u)linear_sp, (Bit64u)rip, Sym);
|
||||
len = 8;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (BX_CPU(dbg_cpu)->sregs[BX_SEG_REG_SS].cache.u.segment.d_b) {
|
||||
linear_bp = BX_CPU(dbg_cpu)->get_reg32(BX_32BIT_REG_EBP);
|
||||
linear_sp = BX_CPU(dbg_cpu)->get_reg32(BX_32BIT_REG_ESP);
|
||||
bx_address eip = BX_CPU(dbg_cpu)->get_instruction_pointer();
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(eip, 0);
|
||||
dbg_printf("%08x -> %08x (%s)\n",
|
||||
(Bit32u)linear_sp, (Bit32u)eip, Sym);
|
||||
len = 4;
|
||||
} else {
|
||||
linear_bp = BX_CPU(dbg_cpu)->get_reg16(BX_16BIT_REG_BP);
|
||||
linear_sp = BX_CPU(dbg_cpu)->get_reg16(BX_16BIT_REG_BP);
|
||||
bx_address ip = BX_CPU(dbg_cpu)->get_instruction_pointer();
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(ip, 0);
|
||||
dbg_printf("%04x -> %04x (%s)\n",
|
||||
(Bit16u)linear_sp, (Bit16u)ip, Sym);
|
||||
len = 2;
|
||||
}
|
||||
}
|
||||
|
||||
Bit8u buf[8];
|
||||
Bit64u addr_on_stack;
|
||||
bx_address addr;
|
||||
|
||||
for (unsigned i = 0; i < dist; ++i) {
|
||||
// Read return address right above frame pointer
|
||||
addr = BX_CPU(dbg_cpu)->get_laddr(BX_SEG_REG_SS, linear_bp);
|
||||
if (!bx_dbg_read_linear(dbg_cpu, addr + len, len, buf))
|
||||
break;
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (len == 8) {
|
||||
addr_on_stack = conv_8xBit8u_to_Bit64u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf("%012" FMT_64 "x -> %012" FMT_64 "x (%s)\n",
|
||||
(Bit64u)addr,
|
||||
(Bit64u)addr_on_stack,
|
||||
Sym ? Sym : "<unknown>");
|
||||
|
||||
// Get next frame pointer
|
||||
if (!bx_dbg_read_linear(dbg_cpu, addr, len, buf))
|
||||
break;
|
||||
linear_bp = conv_8xBit8u_to_Bit64u(buf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (len == 4) {
|
||||
addr_on_stack = conv_4xBit8u_to_Bit32u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf(FMT_ADDRX32 " -> " FMT_ADDRX32 " (%s)\n",
|
||||
(Bit32u)addr,
|
||||
(Bit32u)addr_on_stack,
|
||||
Sym ? Sym : "<unknown>");
|
||||
|
||||
// Get next frame pointer
|
||||
if (!bx_dbg_read_linear(dbg_cpu, addr, len, buf))
|
||||
break;
|
||||
linear_bp = conv_4xBit8u_to_Bit32u(buf);
|
||||
} else {
|
||||
addr_on_stack = conv_2xBit8u_to_Bit16u(buf);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr_on_stack, 0);
|
||||
dbg_printf(FMT_ADDRX16 " -> " FMT_ADDRX16 " (%s)\n",
|
||||
(Bit16u)addr,
|
||||
(Bit16u)addr_on_stack,
|
||||
Sym ? Sym : "<unknown>");
|
||||
|
||||
// Get next frame pointer
|
||||
if (!bx_dbg_read_linear(dbg_cpu, addr, len, buf))
|
||||
break;
|
||||
linear_bp = conv_2xBit8u_to_Bit16u(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bx_dbg_print_watchpoints(void)
|
||||
{
|
||||
Bit8u buf[2];
|
||||
@ -2188,6 +2300,7 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
Bit8u data8;
|
||||
Bit16u data16;
|
||||
Bit32u data32;
|
||||
Bit64u data64;
|
||||
unsigned columns, per_line, offset;
|
||||
bx_bool is_linear;
|
||||
Bit8u databuf[8];
|
||||
@ -2290,11 +2403,6 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
return;
|
||||
}
|
||||
|
||||
if (unit_size == 'g') {
|
||||
dbg_printf("error: dbg_examine: 'g' (8-byte) unit size not supported.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (format_passed) {
|
||||
// store current options as default
|
||||
bx_debugger.default_display_format = display_format;
|
||||
@ -2317,7 +2425,7 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
case 'b': data_size = 1; per_line = 16; break;
|
||||
case 'h': data_size = 2; per_line = 8; break;
|
||||
case 'w': data_size = 4; per_line = 4; break;
|
||||
//case 'g': data_size = 8; per_line = 2; break;
|
||||
case 'g': data_size = 8; per_line = 2; break;
|
||||
}
|
||||
// binary format is quite large
|
||||
if (display_format == 't')
|
||||
@ -2329,7 +2437,7 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
case 'b': data_size = 1; per_line = 8; break;
|
||||
case 'h': data_size = 2; per_line = 8; break;
|
||||
case 'w': data_size = 4; per_line = 4; break;
|
||||
//case 'g': data_size = 8; per_line = 2; break;
|
||||
case 'g': data_size = 8; per_line = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2342,8 +2450,13 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
dbg_printf("\n");
|
||||
if (memory_dump)
|
||||
dbg_printf("0x" FMT_ADDRX ":", addr);
|
||||
else {
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(addr + offset, 0);
|
||||
if (Sym)
|
||||
dbg_printf("0x" FMT_ADDRX " <%s>:", addr, Sym);
|
||||
else
|
||||
dbg_printf("0x" FMT_ADDRX " <bogus+%8u>:", addr, offset);
|
||||
}
|
||||
columns = 1;
|
||||
}
|
||||
|
||||
@ -2425,10 +2538,10 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
}
|
||||
else
|
||||
switch (display_format) {
|
||||
case 'x': dbg_printf("\t0x%08x", (unsigned) data32); break;
|
||||
case 'd': dbg_printf("\t%d", (int) (Bit32s) data32); break;
|
||||
case 'u': dbg_printf("\t%u", (unsigned) data32); break;
|
||||
case 'o': dbg_printf("\t%o", (unsigned) data32); break;
|
||||
case 'x': dbg_printf("\t0x%08x", data32); break;
|
||||
case 'd': dbg_printf("\t%d", (Bit32s) data32); break;
|
||||
case 'u': dbg_printf("\t%u", data32); break;
|
||||
case 'o': dbg_printf("\t%o", data32); break;
|
||||
case 't': dbg_printf_binary("\t%s", data32, 32); break;
|
||||
case 'c':
|
||||
bx_print_char(0xff & (data32>>24));
|
||||
@ -2438,6 +2551,37 @@ void bx_dbg_examine_command(const char *command, const char *format, bx_bool for
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
ReadHostQWordFromLittleEndian(databuf, data64);
|
||||
|
||||
if (memory_dump)
|
||||
switch (display_format) {
|
||||
case 'd': dbg_printf("%10" FMT_64 "d ", data64); break;
|
||||
case 'u': dbg_printf("%10" FMT_64 "u ", data64); break;
|
||||
case 'o': dbg_printf("%12" FMT_64 "o ", data64); break;
|
||||
case 't': dbg_printf_binary("%s ", data64, 64); break;
|
||||
default : dbg_printf("%08" FMT_64 "X ", data64); break;
|
||||
}
|
||||
else
|
||||
switch (display_format) {
|
||||
case 'x': dbg_printf("\t0x%08" FMT_64 "x", data64); break;
|
||||
case 'd': dbg_printf("\t%" FMT_64 "d", (Bit64s) data64); break;
|
||||
case 'u': dbg_printf("\t%" FMT_64 "u", data64); break;
|
||||
case 'o': dbg_printf("\t%" FMT_64 "o", data64); break;
|
||||
case 't': dbg_printf_binary("\t%s", data64, 64); break;
|
||||
case 'c':
|
||||
bx_print_char(0xff & (data64>>56));
|
||||
bx_print_char(0xff & (data64>>48));
|
||||
bx_print_char(0xff & (data64>>40));
|
||||
bx_print_char(0xff & (data64>>32));
|
||||
bx_print_char(0xff & (data64>>24));
|
||||
bx_print_char(0xff & (data64>>16));
|
||||
bx_print_char(0xff & (data64>> 8));
|
||||
bx_print_char(0xff & (data64>> 0));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
addr += data_size;
|
||||
@ -2561,7 +2705,7 @@ void bx_dbg_set_symbol_command(const char *symbol, bx_address val)
|
||||
return;
|
||||
}
|
||||
char cpu_param_name[10];
|
||||
sprintf(cpu_param_name, "cpu%d", val);
|
||||
sprintf(cpu_param_name, "cpu%d", (int)val);
|
||||
dbg_cpu_list = (bx_list_c*) SIM->get_param(cpu_param_name, SIM->get_bochs_root());
|
||||
dbg_cpu = val;
|
||||
return;
|
||||
@ -2671,11 +2815,11 @@ void bx_dbg_disassemble_command(const char *format, Bit64u from, Bit64u to)
|
||||
if (! bx_dbg_read_linear(dbg_cpu, from, 16, bx_disasm_ibuf)) break;
|
||||
|
||||
unsigned ilen = bx_disassemble.disasm(dis_size==32, dis_size==64,
|
||||
(bx_address)(-1), (bx_address)(-1), bx_disasm_ibuf, bx_disasm_tbuf);
|
||||
0/*(bx_address)(-1)*/, from/*(bx_address)(-1)*/, bx_disasm_ibuf, bx_disasm_tbuf);
|
||||
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address((Bit32u)from, 0);
|
||||
const char *Sym=bx_dbg_disasm_symbolic_address(from, 0);
|
||||
|
||||
dbg_printf("%08x: ", (unsigned) from);
|
||||
dbg_printf(FMT_ADDRX ": ", from);
|
||||
dbg_printf("(%20s): ", Sym?Sym:"");
|
||||
dbg_printf("%-25s ; ", bx_disasm_tbuf);
|
||||
|
||||
@ -2870,6 +3014,11 @@ void bx_dbg_print_descriptor64(Bit32u lo1, Bit32u hi1, Bit32u lo2, Bit32u hi2)
|
||||
default:
|
||||
// task, int, trap, or call gate.
|
||||
dbg_printf("target=0x%04x:" FMT_ADDRX ", DPL=%d", segment, offset, dpl);
|
||||
|
||||
const char *Sym = bx_dbg_disasm_symbolic_address(offset, 0);
|
||||
if (Sym)
|
||||
dbg_printf(" (%s)", Sym);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2969,7 +3118,7 @@ void bx_dbg_info_gdt_command(unsigned from, unsigned to)
|
||||
Bit8u entry[8];
|
||||
if (8*n + 7 > gdtr.limit) break;
|
||||
if (bx_dbg_read_linear(dbg_cpu, gdtr.base + 8*n, 8, entry)) {
|
||||
dbg_printf("GDT[0x%02x]=", n);
|
||||
dbg_printf("GDT[0x%04x]=", n << 3);
|
||||
|
||||
Bit32u lo = (entry[3] << 24) | (entry[2] << 16) | (entry[1] << 8) | (entry[0]);
|
||||
Bit32u hi = (entry[7] << 24) | (entry[6] << 16) | (entry[5] << 8) | (entry[4]);
|
||||
@ -3582,7 +3731,7 @@ Bit32u bx_dbg_get_eip(void)
|
||||
return BX_CPU(dbg_cpu)->get_eip();
|
||||
}
|
||||
|
||||
bx_address bx_dbg_get_instruction_pointer(void)
|
||||
bx_address bx_dbg_get_rip(void)
|
||||
{
|
||||
return BX_CPU(dbg_cpu)->get_instruction_pointer();
|
||||
}
|
||||
@ -3712,7 +3861,8 @@ bx_address bx_dbg_get_laddr(Bit16u sel, bx_address ofs)
|
||||
highaddr = descriptor.u.segment.limit_scaled;
|
||||
}
|
||||
|
||||
if (ofs < lowaddr || ofs > highaddr) {
|
||||
if ((ofs < lowaddr || ofs > highaddr) &&
|
||||
BX_CPU(dbg_cpu)->get_cpu_mode() != BX_MODE_LONG_64) {
|
||||
dbg_printf("WARNING: Offset %08X is out of selector %04x limit (%08x...%08x)!\n",
|
||||
ofs, sel, lowaddr, highaddr);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ bx_bool bx_dbg_read_linear(unsigned which_cpu, bx_address laddr, unsigned len, B
|
||||
Bit16u bx_dbg_get_selector_value(unsigned int seg_no);
|
||||
Bit16u bx_dbg_get_ip (void);
|
||||
Bit32u bx_dbg_get_eip(void);
|
||||
bx_address bx_dbg_get_instruction_pointer(void);
|
||||
bx_address bx_dbg_get_rip(void);
|
||||
Bit8u bx_dbg_get_reg8l_value(unsigned reg);
|
||||
Bit8u bx_dbg_get_reg8h_value(unsigned reg);
|
||||
Bit16u bx_dbg_get_reg16_value(unsigned reg);
|
||||
@ -110,6 +110,7 @@ void bx_dbg_xlate_address(bx_lin_address laddr);
|
||||
void bx_dbg_tlb_lookup(bx_lin_address laddr);
|
||||
void bx_dbg_show_command(const char*);
|
||||
void bx_dbg_print_stack_command(unsigned nwords);
|
||||
void bx_dbg_bt_command(unsigned dist);
|
||||
void bx_dbg_print_watchpoints(void);
|
||||
void bx_dbg_watchpoint_continue(bx_bool watch_continue);
|
||||
void bx_dbg_watch(int type, bx_phy_address address, Bit32u len);
|
||||
@ -189,12 +190,12 @@ void bx_dbg_show_param_command(const char *param, bx_bool xml);
|
||||
|
||||
int bx_dbg_show_symbolic(void);
|
||||
void bx_dbg_set_symbol_command(const char *symbol, bx_address val);
|
||||
const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base);
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset);
|
||||
const char* bx_dbg_symbolic_address(bx_address context, bx_address eip, bx_address base);
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, bx_address offset);
|
||||
void bx_dbg_info_symbols_command(const char *Symbol);
|
||||
int bx_dbg_lbreakpoint_symbol_command(const char *Symbol, const char *condition);
|
||||
Bit32u bx_dbg_get_symbol_value(const char *Symbol);
|
||||
const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base);
|
||||
bx_address bx_dbg_get_symbol_value(const char *Symbol);
|
||||
const char* bx_dbg_disasm_symbolic_address(bx_address eip, bx_address base);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -136,6 +136,7 @@ sba { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TIMEBP_ABSOLUTE)
|
||||
modebp { bxlval.sval = strdup(bxtext); return(BX_TOKEN_MODEBP); }
|
||||
vmexitbp { bxlval.sval = strdup(bxtext); return(BX_TOKEN_VMEXITBP); }
|
||||
print-stack { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PRINT_STACK); }
|
||||
bt { bxlval.sval = strdup(bxtext); return(BX_TOKEN_BT); }
|
||||
watch { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WATCH); }
|
||||
unwatch { bxlval.sval = strdup(bxtext); return(BX_TOKEN_UNWATCH); }
|
||||
read { bxlval.sval = strdup(bxtext); return(BX_TOKEN_READ); }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -126,36 +126,37 @@ extern int bxdebug;
|
||||
BX_TOKEN_MODEBP = 336,
|
||||
BX_TOKEN_VMEXITBP = 337,
|
||||
BX_TOKEN_PRINT_STACK = 338,
|
||||
BX_TOKEN_WATCH = 339,
|
||||
BX_TOKEN_UNWATCH = 340,
|
||||
BX_TOKEN_READ = 341,
|
||||
BX_TOKEN_WRITE = 342,
|
||||
BX_TOKEN_SHOW = 343,
|
||||
BX_TOKEN_LOAD_SYMBOLS = 344,
|
||||
BX_TOKEN_SYMBOLS = 345,
|
||||
BX_TOKEN_LIST_SYMBOLS = 346,
|
||||
BX_TOKEN_GLOBAL = 347,
|
||||
BX_TOKEN_WHERE = 348,
|
||||
BX_TOKEN_PRINT_STRING = 349,
|
||||
BX_TOKEN_NUMERIC = 350,
|
||||
BX_TOKEN_PAGE = 351,
|
||||
BX_TOKEN_HELP = 352,
|
||||
BX_TOKEN_XML = 353,
|
||||
BX_TOKEN_CALC = 354,
|
||||
BX_TOKEN_DEVICE = 355,
|
||||
BX_TOKEN_GENERIC = 356,
|
||||
BX_TOKEN_RSHIFT = 357,
|
||||
BX_TOKEN_LSHIFT = 358,
|
||||
BX_TOKEN_EQ = 359,
|
||||
BX_TOKEN_NE = 360,
|
||||
BX_TOKEN_LE = 361,
|
||||
BX_TOKEN_GE = 362,
|
||||
BX_TOKEN_REG_IP = 363,
|
||||
BX_TOKEN_REG_EIP = 364,
|
||||
BX_TOKEN_REG_RIP = 365,
|
||||
NOT = 366,
|
||||
NEG = 367,
|
||||
INDIRECT = 368
|
||||
BX_TOKEN_BT = 339,
|
||||
BX_TOKEN_WATCH = 340,
|
||||
BX_TOKEN_UNWATCH = 341,
|
||||
BX_TOKEN_READ = 342,
|
||||
BX_TOKEN_WRITE = 343,
|
||||
BX_TOKEN_SHOW = 344,
|
||||
BX_TOKEN_LOAD_SYMBOLS = 345,
|
||||
BX_TOKEN_SYMBOLS = 346,
|
||||
BX_TOKEN_LIST_SYMBOLS = 347,
|
||||
BX_TOKEN_GLOBAL = 348,
|
||||
BX_TOKEN_WHERE = 349,
|
||||
BX_TOKEN_PRINT_STRING = 350,
|
||||
BX_TOKEN_NUMERIC = 351,
|
||||
BX_TOKEN_PAGE = 352,
|
||||
BX_TOKEN_HELP = 353,
|
||||
BX_TOKEN_XML = 354,
|
||||
BX_TOKEN_CALC = 355,
|
||||
BX_TOKEN_DEVICE = 356,
|
||||
BX_TOKEN_GENERIC = 357,
|
||||
BX_TOKEN_RSHIFT = 358,
|
||||
BX_TOKEN_LSHIFT = 359,
|
||||
BX_TOKEN_EQ = 360,
|
||||
BX_TOKEN_NE = 361,
|
||||
BX_TOKEN_LE = 362,
|
||||
BX_TOKEN_GE = 363,
|
||||
BX_TOKEN_REG_IP = 364,
|
||||
BX_TOKEN_REG_EIP = 365,
|
||||
BX_TOKEN_REG_RIP = 366,
|
||||
NOT = 367,
|
||||
NEG = 368,
|
||||
INDIRECT = 369
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
@ -240,36 +241,37 @@ extern int bxdebug;
|
||||
#define BX_TOKEN_MODEBP 336
|
||||
#define BX_TOKEN_VMEXITBP 337
|
||||
#define BX_TOKEN_PRINT_STACK 338
|
||||
#define BX_TOKEN_WATCH 339
|
||||
#define BX_TOKEN_UNWATCH 340
|
||||
#define BX_TOKEN_READ 341
|
||||
#define BX_TOKEN_WRITE 342
|
||||
#define BX_TOKEN_SHOW 343
|
||||
#define BX_TOKEN_LOAD_SYMBOLS 344
|
||||
#define BX_TOKEN_SYMBOLS 345
|
||||
#define BX_TOKEN_LIST_SYMBOLS 346
|
||||
#define BX_TOKEN_GLOBAL 347
|
||||
#define BX_TOKEN_WHERE 348
|
||||
#define BX_TOKEN_PRINT_STRING 349
|
||||
#define BX_TOKEN_NUMERIC 350
|
||||
#define BX_TOKEN_PAGE 351
|
||||
#define BX_TOKEN_HELP 352
|
||||
#define BX_TOKEN_XML 353
|
||||
#define BX_TOKEN_CALC 354
|
||||
#define BX_TOKEN_DEVICE 355
|
||||
#define BX_TOKEN_GENERIC 356
|
||||
#define BX_TOKEN_RSHIFT 357
|
||||
#define BX_TOKEN_LSHIFT 358
|
||||
#define BX_TOKEN_EQ 359
|
||||
#define BX_TOKEN_NE 360
|
||||
#define BX_TOKEN_LE 361
|
||||
#define BX_TOKEN_GE 362
|
||||
#define BX_TOKEN_REG_IP 363
|
||||
#define BX_TOKEN_REG_EIP 364
|
||||
#define BX_TOKEN_REG_RIP 365
|
||||
#define NOT 366
|
||||
#define NEG 367
|
||||
#define INDIRECT 368
|
||||
#define BX_TOKEN_BT 339
|
||||
#define BX_TOKEN_WATCH 340
|
||||
#define BX_TOKEN_UNWATCH 341
|
||||
#define BX_TOKEN_READ 342
|
||||
#define BX_TOKEN_WRITE 343
|
||||
#define BX_TOKEN_SHOW 344
|
||||
#define BX_TOKEN_LOAD_SYMBOLS 345
|
||||
#define BX_TOKEN_SYMBOLS 346
|
||||
#define BX_TOKEN_LIST_SYMBOLS 347
|
||||
#define BX_TOKEN_GLOBAL 348
|
||||
#define BX_TOKEN_WHERE 349
|
||||
#define BX_TOKEN_PRINT_STRING 350
|
||||
#define BX_TOKEN_NUMERIC 351
|
||||
#define BX_TOKEN_PAGE 352
|
||||
#define BX_TOKEN_HELP 353
|
||||
#define BX_TOKEN_XML 354
|
||||
#define BX_TOKEN_CALC 355
|
||||
#define BX_TOKEN_DEVICE 356
|
||||
#define BX_TOKEN_GENERIC 357
|
||||
#define BX_TOKEN_RSHIFT 358
|
||||
#define BX_TOKEN_LSHIFT 359
|
||||
#define BX_TOKEN_EQ 360
|
||||
#define BX_TOKEN_NE 361
|
||||
#define BX_TOKEN_LE 362
|
||||
#define BX_TOKEN_GE 363
|
||||
#define BX_TOKEN_REG_IP 364
|
||||
#define BX_TOKEN_REG_EIP 365
|
||||
#define BX_TOKEN_REG_RIP 366
|
||||
#define NOT 367
|
||||
#define NEG 368
|
||||
#define INDIRECT 369
|
||||
|
||||
/* Value type. */
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
@ -282,7 +284,7 @@ union YYSTYPE
|
||||
Bit64u uval;
|
||||
bx_bool bval;
|
||||
|
||||
#line 286 "y.tab.h" /* yacc.c:1909 */
|
||||
#line 288 "y.tab.h" /* yacc.c:1909 */
|
||||
};
|
||||
|
||||
typedef union YYSTYPE YYSTYPE;
|
||||
|
@ -103,6 +103,7 @@ Bit64u eval_value;
|
||||
%token <sval> BX_TOKEN_MODEBP
|
||||
%token <sval> BX_TOKEN_VMEXITBP
|
||||
%token <sval> BX_TOKEN_PRINT_STACK
|
||||
%token <sval> BX_TOKEN_BT
|
||||
%token <sval> BX_TOKEN_WATCH
|
||||
%token <sval> BX_TOKEN_UNWATCH
|
||||
%token <sval> BX_TOKEN_READ
|
||||
@ -187,6 +188,7 @@ command:
|
||||
| modebp_command
|
||||
| vmexitbp_command
|
||||
| print_stack_command
|
||||
| backtrace_command
|
||||
| watch_point_command
|
||||
| page_command
|
||||
| tlb_command
|
||||
@ -349,6 +351,19 @@ print_stack_command:
|
||||
}
|
||||
;
|
||||
|
||||
backtrace_command:
|
||||
BX_TOKEN_BT '\n'
|
||||
{
|
||||
bx_dbg_bt_command(16);
|
||||
free($1);
|
||||
}
|
||||
| BX_TOKEN_BT BX_TOKEN_NUMERIC '\n'
|
||||
{
|
||||
bx_dbg_bt_command($2);
|
||||
free($1);
|
||||
}
|
||||
;
|
||||
|
||||
watch_point_command:
|
||||
BX_TOKEN_WATCH BX_TOKEN_STOP '\n'
|
||||
{
|
||||
@ -1303,7 +1318,7 @@ vexpression:
|
||||
| BX_TOKEN_SEGREG { $$ = bx_dbg_get_selector_value($1); }
|
||||
| BX_TOKEN_REG_IP { $$ = bx_dbg_get_ip (); }
|
||||
| BX_TOKEN_REG_EIP { $$ = bx_dbg_get_eip(); }
|
||||
| BX_TOKEN_REG_RIP { $$ = bx_dbg_get_instruction_pointer(); }
|
||||
| BX_TOKEN_REG_RIP { $$ = bx_dbg_get_rip(); }
|
||||
| vexpression '+' vexpression { $$ = $1 + $3; }
|
||||
| vexpression '-' vexpression { $$ = $1 - $3; }
|
||||
| vexpression '*' vexpression { $$ = $1 * $3; }
|
||||
@ -1332,7 +1347,7 @@ expression:
|
||||
| BX_TOKEN_SEGREG { $$ = bx_dbg_get_selector_value($1); }
|
||||
| BX_TOKEN_REG_IP { $$ = bx_dbg_get_ip (); }
|
||||
| BX_TOKEN_REG_EIP { $$ = bx_dbg_get_eip(); }
|
||||
| BX_TOKEN_REG_RIP { $$ = bx_dbg_get_instruction_pointer(); }
|
||||
| BX_TOKEN_REG_RIP { $$ = bx_dbg_get_rip(); }
|
||||
| expression ':' expression { $$ = bx_dbg_get_laddr ($1, $3); }
|
||||
| expression '+' expression { $$ = $1 + $3; }
|
||||
| expression '-' expression { $$ = $1 - $3; }
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
static const char BX_HAVE_MAP_ERR[] = "context not implemented because BX_HAVE_MAP=0\n";
|
||||
|
||||
const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base)
|
||||
const char* bx_dbg_symbolic_address(bx_address context, bx_address eip, bx_address base)
|
||||
{
|
||||
static bx_bool first = true;
|
||||
if (first) {
|
||||
@ -37,7 +37,7 @@ const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base)
|
||||
return "unk. ctxt";
|
||||
}
|
||||
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, bx_address offset)
|
||||
{
|
||||
dbg_printf(BX_HAVE_MAP_ERR);
|
||||
return -1;
|
||||
@ -54,12 +54,12 @@ int bx_dbg_lbreakpoint_symbol_command(const char *symbol, const char *condition)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Bit32u bx_dbg_get_symbol_value(const char *symbol)
|
||||
bx_address bx_dbg_get_symbol_value(const char *symbol)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base)
|
||||
const char* bx_dbg_disasm_symbolic_address(bx_address eip, bx_address base)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -80,7 +80,7 @@ const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base)
|
||||
|
||||
struct symbol_entry_t
|
||||
{
|
||||
symbol_entry_t (Bit32u _start = 0, const char* _name = 0)
|
||||
symbol_entry_t (bx_address _start = 0, const char* _name = 0)
|
||||
{
|
||||
start = _start;
|
||||
name = _name ? strdup(_name) : 0;
|
||||
@ -94,7 +94,7 @@ struct symbol_entry_t
|
||||
void trim_quotes(void);
|
||||
|
||||
char* name;
|
||||
Bit32u start;
|
||||
bx_address start;
|
||||
|
||||
private:
|
||||
symbol_entry_t(const symbol_entry_t&); // No definition
|
||||
@ -121,13 +121,13 @@ struct context_t
|
||||
{
|
||||
typedef std::set<symbol_entry_t*,lt_symbol_entry_t> sym_set_t;
|
||||
typedef std::set<symbol_entry_t*,lt_rsymbol_entry_t> rsym_set_t;
|
||||
typedef std::map<Bit32u,context_t*> map_t;
|
||||
typedef std::map<bx_address,context_t*> map_t;
|
||||
|
||||
context_t (Bit32u);
|
||||
context_t (bx_address);
|
||||
~context_t();
|
||||
|
||||
static context_t* get_context(Bit32u);
|
||||
symbol_entry_t* get_symbol_entry(Bit32u);
|
||||
static context_t* get_context(bx_address);
|
||||
symbol_entry_t* get_symbol_entry(bx_address);
|
||||
symbol_entry_t* get_symbol_entry(const char *symbol) const;
|
||||
void add_symbol(symbol_entry_t*);
|
||||
const sym_set_t* get_all_symbols() const {return &m_syms;}
|
||||
@ -140,12 +140,12 @@ protected:
|
||||
sym_set_t m_syms;
|
||||
// Reverse references (find address by name)
|
||||
rsym_set_t m_rsyms;
|
||||
Bit32u m_id;
|
||||
bx_address m_id;
|
||||
};
|
||||
|
||||
context_t::map_t context_t::s_map;
|
||||
|
||||
context_t::context_t (Bit32u id)
|
||||
context_t::context_t (bx_address id)
|
||||
{
|
||||
m_id = id;
|
||||
s_map[m_id] = this;
|
||||
@ -162,12 +162,12 @@ context_t::~context_t()
|
||||
}
|
||||
}
|
||||
|
||||
context_t* context_t::get_context(Bit32u i)
|
||||
context_t* context_t::get_context(bx_address i)
|
||||
{
|
||||
return s_map[i];
|
||||
}
|
||||
|
||||
symbol_entry_t* context_t::get_symbol_entry(Bit32u ip)
|
||||
symbol_entry_t* context_t::get_symbol_entry(bx_address ip)
|
||||
{
|
||||
symbol_entry_t probe(ip, 0);
|
||||
// find the first symbol whose address is greater than ip.
|
||||
@ -214,7 +214,7 @@ void symbol_entry_t::trim_quotes(void)
|
||||
}
|
||||
}
|
||||
|
||||
Bit32u bx_dbg_get_symbol_value(const char *symbol)
|
||||
bx_address bx_dbg_get_symbol_value(const char *symbol)
|
||||
{
|
||||
context_t* cntx = context_t::get_context(0);
|
||||
if(!cntx) // Context not found
|
||||
@ -230,7 +230,7 @@ Bit32u bx_dbg_get_symbol_value(const char *symbol)
|
||||
return sym->start;
|
||||
}
|
||||
|
||||
const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base)
|
||||
const char* bx_dbg_symbolic_address(bx_address context, bx_address xip, bx_address base)
|
||||
{
|
||||
static char buf[80];
|
||||
|
||||
@ -244,17 +244,17 @@ const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
// full linear address not only eip (for nonzero based segments)
|
||||
symbol_entry_t* entr = cntx->get_symbol_entry(base+eip);
|
||||
// full linear address not only xip (for nonzero based segments)
|
||||
symbol_entry_t* entr = cntx->get_symbol_entry(base+xip);
|
||||
if (!entr) {
|
||||
snprintf (buf, 80, "no symbol");
|
||||
return buf;
|
||||
}
|
||||
snprintf (buf, 80, "%s+%x", entr->name, (base+eip) - entr->start);
|
||||
snprintf (buf, 80, "%s+%x", entr->name, (base+xip) - entr->start);
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base)
|
||||
const char* bx_dbg_disasm_symbolic_address(bx_address xip, bx_address base)
|
||||
{
|
||||
static char buf[80];
|
||||
|
||||
@ -264,16 +264,16 @@ const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// full linear address not only eip (for nonzero based segments)
|
||||
symbol_entry_t* entr = cntx->get_symbol_entry(base+eip);
|
||||
// full linear address not only xip (for nonzero based segments)
|
||||
symbol_entry_t* entr = cntx->get_symbol_entry(base+xip);
|
||||
if (!entr) {
|
||||
return 0;
|
||||
}
|
||||
snprintf (buf, 80, "%s+%x", entr->name, (base+eip) - entr->start);
|
||||
snprintf (buf, 80, "%s+%" FMT_64 "x", entr->name, (base+xip) - entr->start);
|
||||
return buf;
|
||||
}
|
||||
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
int bx_dbg_symbol_command(const char* filename, bx_bool global, bx_address offset)
|
||||
{
|
||||
symbol_entry_t file(0, filename);
|
||||
file.trim_quotes();
|
||||
@ -282,7 +282,7 @@ int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
// The file format should be
|
||||
// address symbol (example '00002afe _StartLoseNT')
|
||||
|
||||
Bit32u context_id = (global) ? 0 : ((Bit32u)BX_CPU(dbg_cpu)->cr3) >> 12;
|
||||
bx_address context_id = (global) ? 0 : ((bx_address)BX_CPU(dbg_cpu)->cr3) >> 12;
|
||||
|
||||
context_t* cntx = context_t::get_context(context_id);
|
||||
|
||||
@ -309,8 +309,13 @@ int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
|
||||
// parse
|
||||
char* sym_name;
|
||||
Bit32u addr = strtoul(buf, &sym_name, 16);
|
||||
|
||||
#if BX_SUPPORT_X86_64 && BX_HAVE_STRTOUQ
|
||||
bx_address addr = strtouq(buf, &sym_name, 16);
|
||||
#elif BX_SUPPORT_X86_64 && BX_HAVE_STRTOULL
|
||||
bx_address addr = strtoull(buf, &sym_name, 16);
|
||||
#else
|
||||
bx_address addr = strtoul(buf, &sym_name, 16);
|
||||
#endif
|
||||
if (!isspace(*sym_name)) {
|
||||
if (*sym_name == 0)
|
||||
dbg_printf("%s:%d: missing symbol name\n", file.name, line_num);
|
||||
@ -379,7 +384,11 @@ void bx_dbg_info_symbols_command(const char *symbol)
|
||||
dbg_printf ("No symbols found\n");
|
||||
else {
|
||||
for(;iter!=rsyms->end() && bx_dbg_strprefix(probe.name, (*iter)->name);++iter) {
|
||||
#if BX_SUPPORT_X86_64 && (BX_HAVE_STRTOULL || BX_HAVE_STRTOUQ)
|
||||
dbg_printf (FMT_ADDRX64 ": %s\n", (*iter)->start, (*iter)->name);
|
||||
#else
|
||||
dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -394,7 +403,14 @@ void bx_dbg_info_symbols_command(const char *symbol)
|
||||
|
||||
context_t::sym_set_t::const_iterator iter;
|
||||
for(iter = syms->begin();iter!=syms->end();++iter) {
|
||||
#if BX_SUPPORT_X86_64 && (BX_HAVE_STRTOULL || BX_HAVE_STRTOUQ)
|
||||
if (sizeof(long) == 8)
|
||||
dbg_printf ("%16lx: %s\n", (*iter)->start, (*iter)->name);
|
||||
else
|
||||
dbg_printf ("%16llx: %s\n", (*iter)->start, (*iter)->name);
|
||||
#else
|
||||
dbg_printf ("%08x: %s\n", (*iter)->start, (*iter)->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,30 +125,14 @@ void BX_CPU_C::debug(bx_address offset)
|
||||
#endif
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (long_mode()) {
|
||||
BX_INFO(("| RAX=%08x%08x RBX=%08x%08x",
|
||||
(unsigned) (RAX >> 32), (unsigned) EAX,
|
||||
(unsigned) (RBX >> 32), (unsigned) EBX));
|
||||
BX_INFO(("| RCX=%08x%08x RDX=%08x%08x",
|
||||
(unsigned) (RCX >> 32), (unsigned) ECX,
|
||||
(unsigned) (RDX >> 32), (unsigned) EDX));
|
||||
BX_INFO(("| RSP=%08x%08x RBP=%08x%08x",
|
||||
(unsigned) (RSP >> 32), (unsigned) ESP,
|
||||
(unsigned) (RBP >> 32), (unsigned) EBP));
|
||||
BX_INFO(("| RSI=%08x%08x RDI=%08x%08x",
|
||||
(unsigned) (RSI >> 32), (unsigned) ESI,
|
||||
(unsigned) (RDI >> 32), (unsigned) EDI));
|
||||
BX_INFO(("| R8=%08x%08x R9=%08x%08x",
|
||||
(unsigned) (R8 >> 32), (unsigned) (R8 & 0xFFFFFFFF),
|
||||
(unsigned) (R9 >> 32), (unsigned) (R9 & 0xFFFFFFFF)));
|
||||
BX_INFO(("| R10=%08x%08x R11=%08x%08x",
|
||||
(unsigned) (R10 >> 32), (unsigned) (R10 & 0xFFFFFFFF),
|
||||
(unsigned) (R11 >> 32), (unsigned) (R11 & 0xFFFFFFFF)));
|
||||
BX_INFO(("| R12=%08x%08x R13=%08x%08x",
|
||||
(unsigned) (R12 >> 32), (unsigned) (R12 & 0xFFFFFFFF),
|
||||
(unsigned) (R13 >> 32), (unsigned) (R13 & 0xFFFFFFFF)));
|
||||
BX_INFO(("| R14=%08x%08x R15=%08x%08x",
|
||||
(unsigned) (R14 >> 32), (unsigned) (R14 & 0xFFFFFFFF),
|
||||
(unsigned) (R15 >> 32), (unsigned) (R15 & 0xFFFFFFFF)));
|
||||
BX_INFO(("| RAX=" FMT_ADDRX64 " RBX=" FMT_ADDRX64 "", RAX, RBX));
|
||||
BX_INFO(("| RCX=" FMT_ADDRX64 " RDX=" FMT_ADDRX64 "", RCX, RDX));
|
||||
BX_INFO(("| RSP=" FMT_ADDRX64 " RBP=" FMT_ADDRX64 "", RSP, RBP));
|
||||
BX_INFO(("| RSI=" FMT_ADDRX64 " RDI=" FMT_ADDRX64 "", RSI, RDI));
|
||||
BX_INFO(("| R8=" FMT_ADDRX64 " R9=" FMT_ADDRX64 "", R8, R9));
|
||||
BX_INFO(("| R10=" FMT_ADDRX64 " R11=" FMT_ADDRX64 "", R10, R11));
|
||||
BX_INFO(("| R12=" FMT_ADDRX64 " R13=" FMT_ADDRX64 "", R12, R13));
|
||||
BX_INFO(("| R14=" FMT_ADDRX64 " R15=" FMT_ADDRX64 "", R14, R15));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -232,22 +216,19 @@ void BX_CPU_C::debug(bx_address offset)
|
||||
(unsigned) BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].cache.u.segment.d_b));
|
||||
#if BX_SUPPORT_X86_64
|
||||
if (long_mode()) {
|
||||
BX_INFO(("| MSR_FS_BASE:%08x%08x",
|
||||
(unsigned) (MSR_FSBASE >> 32), (unsigned) (MSR_FSBASE & 0xFFFFFFFF)));
|
||||
BX_INFO(("| MSR_GS_BASE:%08x%08x",
|
||||
(unsigned) (MSR_GSBASE >> 32), (unsigned) (MSR_GSBASE & 0xFFFFFFFF)));
|
||||
BX_INFO(("| MSR_FS_BASE:" FMT_ADDRX64,
|
||||
MSR_FSBASE));
|
||||
BX_INFO(("| MSR_GS_BASE:" FMT_ADDRX64,
|
||||
MSR_GSBASE));
|
||||
|
||||
BX_INFO(("| RIP=%08x%08x (%08x%08x)",
|
||||
(unsigned) (BX_CPU_THIS_PTR gen_reg[BX_64BIT_REG_RIP].dword.hrx),
|
||||
(unsigned) EIP,
|
||||
(unsigned) (BX_CPU_THIS_PTR prev_rip >> 32),
|
||||
(unsigned) (BX_CPU_THIS_PTR prev_rip & 0xffffffff)));
|
||||
BX_INFO(("| CR0=0x%08x CR2=0x%08x%08x",
|
||||
(unsigned) (BX_CPU_THIS_PTR cr0.get32()),
|
||||
(unsigned) (BX_CPU_THIS_PTR cr2 >> 32),
|
||||
(unsigned) (BX_CPU_THIS_PTR cr2 & 0xffffffff)));
|
||||
BX_INFO(("| CR3=0x%08x CR4=0x%08x",
|
||||
(unsigned) BX_CPU_THIS_PTR cr3, (unsigned) BX_CPU_THIS_PTR cr4.get32()));
|
||||
BX_INFO(("| RIP=" FMT_ADDRX64 " (" FMT_ADDRX64 ")",
|
||||
BX_CPU_THIS_PTR gen_reg[BX_64BIT_REG_RIP].rrx,
|
||||
BX_CPU_THIS_PTR prev_rip));
|
||||
BX_INFO(("| CR0=0x%08x CR2=0x" FMT_ADDRX64,
|
||||
(BX_CPU_THIS_PTR cr0.get32()),
|
||||
(BX_CPU_THIS_PTR cr2)));
|
||||
BX_INFO(("| CR3=0x" FMT_ADDRX64 " CR4=0x%08x",
|
||||
BX_CPU_THIS_PTR cr3, BX_CPU_THIS_PTR cr4.get32()));
|
||||
}
|
||||
else
|
||||
#endif // BX_SUPPORT_X86_64
|
||||
@ -260,7 +241,7 @@ void BX_CPU_C::debug(bx_address offset)
|
||||
(unsigned) BX_CPU_THIS_PTR cr0.get32(),
|
||||
(unsigned) BX_CPU_THIS_PTR cr2, (unsigned) BX_CPU_THIS_PTR cr3));
|
||||
#else
|
||||
BX_INFO(("| CR0=0x%08x CR2=0x%08x",
|
||||
BX_INFO(("| CR0=0x%08x CR2=0x" FMT_ADDRX64,
|
||||
BX_CPU_THIS_PTR cr0.get32(), BX_CPU_THIS_PTR cr2));
|
||||
BX_INFO(("| CR3=0x%08x CR4=0x%08x",
|
||||
(unsigned) BX_CPU_THIS_PTR cr3,
|
||||
|
@ -22,12 +22,16 @@
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "disasm.h"
|
||||
#include "osdep.h"
|
||||
|
||||
/*
|
||||
#if BX_DEBUGGER
|
||||
#include "../bx_debug/debug.h"
|
||||
#define SYMBOLIC_JUMP(fmt) fmt " (%s)"
|
||||
#define GET_SYMBOL(addr) bx_dbg_disasm_symbolic_address((addr), 0)
|
||||
#else
|
||||
#define SYMBOLIC_JUMP(fmt) fmt "%s"
|
||||
#define GET_SYMBOL(addr) ""
|
||||
#endif
|
||||
*/
|
||||
|
||||
#if BX_SUPPORT_X86_64 == 0
|
||||
#define BX_64BIT_REG_RAX BX_32BIT_REG_EAX
|
||||
@ -654,21 +658,23 @@ void disassembler::sYdq(const x86_insn *insn) { OP_sY(insn, XMM_SIZE + insn->vex
|
||||
void disassembler::Jb(const x86_insn *insn)
|
||||
{
|
||||
Bit8s imm8 = (Bit8s) fetch_byte();
|
||||
const char *sym;
|
||||
|
||||
if (insn->is_64) {
|
||||
Bit64u imm64 = (Bit8s) imm8;
|
||||
Bit64u target = db_eip + imm64;
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x" FMT_ADDRX64), imm64, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm8);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm8, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit64u target = db_eip + imm64;
|
||||
target += db_cs_base;
|
||||
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
||||
dis_sprintf(" (0x" FMT_ADDRX64 ")", target);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -676,31 +682,35 @@ void disassembler::Jb(const x86_insn *insn)
|
||||
|
||||
if (insn->os_32) {
|
||||
Bit32u imm32 = (Bit8s) imm8;
|
||||
Bit32u target = (Bit32u)(db_cs_base + db_eip + (Bit32s) imm32);
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%08x", (unsigned) imm32);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x%08x"), (unsigned) imm32, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm8);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm8, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit32u target = (Bit32u)(db_cs_base + db_eip + (Bit32s) imm32);
|
||||
dis_sprintf(" (0x%08x)", target);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Bit16u imm16 = (Bit8s) imm8;
|
||||
Bit16u target = (Bit16u)((db_eip + (Bit16s) imm16) & 0xffff);
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%04x", (unsigned) imm16);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x%04x"), (unsigned) imm16, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm8);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm8, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit16u target = (Bit16u)((db_eip + (Bit16s) imm16) & 0xffff);
|
||||
dis_sprintf(" (0x%08x)", target + db_cs_base);
|
||||
}
|
||||
}
|
||||
@ -712,16 +722,20 @@ void disassembler::Jw(const x86_insn *insn)
|
||||
assert(! insn->is_64);
|
||||
|
||||
Bit16s imm16 = (Bit16s) fetch_word();
|
||||
const char *sym;
|
||||
|
||||
Bit16u target = (db_eip + imm16) & 0xffff;
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%04x", (unsigned) (Bit16u) imm16);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x%04x"),
|
||||
(unsigned) (Bit16u) imm16, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm16);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm16, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit16u target = (db_eip + imm16) & 0xffff;
|
||||
dis_sprintf(" (0x%08x)", target + db_cs_base);
|
||||
}
|
||||
}
|
||||
@ -729,34 +743,40 @@ void disassembler::Jw(const x86_insn *insn)
|
||||
void disassembler::Jd(const x86_insn *insn)
|
||||
{
|
||||
Bit32s imm32 = (Bit32s) fetch_dword();
|
||||
const char *sym;
|
||||
|
||||
if (insn->is_64) {
|
||||
Bit64u imm64 = (Bit32s) imm32;
|
||||
Bit64u target = db_eip + (Bit64s) imm64;
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%08x%08x", GET32H(imm64), GET32L(imm64));
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x" FMT_ADDRX64),
|
||||
imm64, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm32);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm32, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit64u target = db_cs_base + db_eip + (Bit64s) imm64;
|
||||
dis_sprintf(" (0x%08x%08x)", GET32H(target), GET32L(target));
|
||||
dis_sprintf(" (0x" FMT_ADDRX64 ")", target);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bit32u target = (Bit32u)(db_cs_base + db_eip + (Bit32s) imm32);
|
||||
sym = GET_SYMBOL(target);
|
||||
sym = sym ? sym : "<unknown>";
|
||||
if (offset_mode_hex) {
|
||||
dis_sprintf(".+0x%08x", (unsigned) imm32);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".+0x%08x"), (unsigned) imm32, sym);
|
||||
}
|
||||
else {
|
||||
dis_sprintf(".%+d", (int) imm32);
|
||||
dis_sprintf(SYMBOLIC_JUMP(".%+d"), (int) imm32, sym);
|
||||
}
|
||||
|
||||
if (db_cs_base != BX_JUMP_TARGET_NOT_REQ) {
|
||||
Bit32u target = (Bit32u)(db_cs_base + db_eip + (Bit32s) imm32);
|
||||
dis_sprintf(" (0x%08x)", target);
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +266,15 @@ void disassembler::resolve32_mod1or2_rm4(const x86_insn *insn, unsigned datasize
|
||||
general_32bit_regname[insn->base], index, insn->scale, insn->displacement.displ32);
|
||||
}
|
||||
|
||||
#if BX_DEBUGGER
|
||||
#include "../bx_debug/debug.h"
|
||||
#define SYMBOLIC_ADDR(fmt) fmt " (%s)"
|
||||
#define GET_SYMBOL(addr) bx_dbg_disasm_symbolic_address((addr), 0)
|
||||
#else
|
||||
#define SYMBOLIC_ADDR(fmt) fmt "%s"
|
||||
#define GET_SYMBOL(addr) ""
|
||||
#endif
|
||||
|
||||
void disassembler::resolve64_mod0(const x86_insn *insn, unsigned datasize)
|
||||
{
|
||||
const char *seg, *rip_regname;
|
||||
@ -282,6 +291,10 @@ void disassembler::resolve64_mod0(const x86_insn *insn, unsigned datasize)
|
||||
print_memory_access64(datasize, seg, rip_regname, NULL, 0, (Bit32s) insn->displacement.displ32);
|
||||
else
|
||||
print_memory_access64(datasize, seg, general_64bit_regname[insn->rm], NULL, 0, 0);
|
||||
|
||||
const char *sym = GET_SYMBOL(db_eip + insn->displacement.displ32);
|
||||
if (sym)
|
||||
dis_sprintf(SYMBOLIC_ADDR(""), sym);
|
||||
}
|
||||
|
||||
void disassembler::resolve64_mod1or2(const x86_insn *insn, unsigned datasize)
|
||||
|
@ -7797,14 +7797,25 @@ From here, you may use the following commands:
|
||||
vbreak seg:off Set a virtual address instruction breakpoint
|
||||
vb seg:off
|
||||
|
||||
vbreak seg:off if "expr" Set a conditional virtual address instruction breakpoint
|
||||
vb seg:off if "expr"
|
||||
|
||||
lbreak addr Set a linear address instruction breakpoint
|
||||
lb addr
|
||||
|
||||
lbreak addr if "expr" Set a conditional linear address instruction breakpoint
|
||||
lb addr if "expr"
|
||||
|
||||
pbreak [*] addr Set a physical address instruction breakpoint
|
||||
pb [*] addr (the '*' is optional for GDB compatibility)
|
||||
break [*] addr
|
||||
b [*] addr
|
||||
|
||||
pbreak [*] addr if "expr" Set a conditional physical address instruction breakpoint
|
||||
pb [*] addr if "expr" (the '*' is optional for GDB compatibility)
|
||||
break [*] addr if "expr"
|
||||
b [*] addr if "expr"
|
||||
|
||||
info break Display state of all current breakpoints
|
||||
bpe n Enable a breakpoint
|
||||
bpd n Disable a breakpoint
|
||||
|
@ -49,11 +49,13 @@ extern "C" {
|
||||
// cygwin compiling with -mno-cygwin. e.g. VC++.
|
||||
|
||||
#if !defined(_MSC_VER) // gcc without -mno-cygwin
|
||||
#define FMT_64 "ll"
|
||||
#define FMT_LL "%ll"
|
||||
#define FMT_TICK "%011llu"
|
||||
#define FMT_ADDRX64 "%016llx"
|
||||
#define FMT_PHY_ADDRX64 "%012llx"
|
||||
#else
|
||||
#define FMT_64 "I64"
|
||||
#define FMT_LL "%I64"
|
||||
#define FMT_TICK "%011I64u"
|
||||
#define FMT_ADDRX64 "%016I64x"
|
||||
@ -102,6 +104,7 @@ extern "C" {
|
||||
|
||||
#else /* __MINGW32__ defined */
|
||||
// Definitions for cygwin compiled with -mno-cygwin
|
||||
#define FMT_64 "I64"
|
||||
#define FMT_LL "%I64"
|
||||
#define FMT_TICK "%011I64u"
|
||||
#define FMT_ADDRX64 "%016I64x"
|
||||
@ -116,11 +119,13 @@ extern "C" {
|
||||
|
||||
#else /* not WIN32 definitions */
|
||||
#if SIZEOF_UNSIGNED_LONG == 8
|
||||
#define FMT_64 "l"
|
||||
#define FMT_LL "%l"
|
||||
#define FMT_TICK "%011lu"
|
||||
#define FMT_ADDRX64 "%016lx"
|
||||
#define FMT_PHY_ADDRX64 "%012lx"
|
||||
#else
|
||||
#define FMT_64 "ll"
|
||||
#define FMT_LL "%ll"
|
||||
#define FMT_TICK "%011llu"
|
||||
#define FMT_ADDRX64 "%016llx"
|
||||
@ -129,6 +134,8 @@ extern "C" {
|
||||
#endif /* not WIN32 definitions */
|
||||
|
||||
#define FMT_ADDRX32 "%08x"
|
||||
#define FMT_ADDRX16 "%04x"
|
||||
|
||||
|
||||
// Missing defines for open
|
||||
#ifndef S_IRUSR
|
||||
|
Loading…
Reference in New Issue
Block a user