Simulator* sim_;
- bool GetValue(char* desc, int32_t* value);
+ bool GetValue(const char* desc, int32_t* value);
// Set or delete a breakpoint. Returns true if successful.
bool SetBreakpoint(Instr* breakpc);
#endif
+// The order of these are important, see the handling of the 'print all'
+// debugger command.
static const char* reg_names[] = { "r0", "r1", "r2", "r3",
"r4", "r5", "r6", "r7",
"r8", "r9", "r10", "r11",
11, 10};
-static int RegNameToRegNum(char* name) {
+static int RegNameToRegNum(const char* name) {
int reg = 0;
while (*reg_names[reg] != 0) {
if (strcmp(reg_names[reg], name) == 0) {
}
-bool Debugger::GetValue(char* desc, int32_t* value) {
+bool Debugger::GetValue(const char* desc, int32_t* value) {
int regnum = RegNameToRegNum(desc);
if (regnum >= 0) {
if (regnum == 15) {
v8::internal::EmbeddedVector<char, 256> buffer;
dasm.InstructionDecode(buffer,
reinterpret_cast<byte*>(sim_->get_pc()));
- PrintF(" 0x%x %s\n", sim_->get_pc(), buffer.start());
+ PrintF(" 0x%08x %s\n", sim_->get_pc(), buffer.start());
last_pc = sim_->get_pc();
}
char* line = ReadLine("sim> ");
} else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) {
if (args == 2) {
int32_t value;
- if (GetValue(arg1, &value)) {
- PrintF("%s: %d 0x%x\n", arg1, value, value);
+ if (strcmp(arg1, "all") == 0) {
+ for (int i = 0; i <= 15; i++) {
+ if (GetValue(reg_names[i], &value)) {
+ if (i <= 10) {
+ PrintF("%3s: 0x%08x %d\n", reg_names[i], value, value);
+ } else {
+ PrintF("%3s: 0x%08x %d\n", reg_names[15 + 16 - i], value, value);
+ }
+ }
+ }
} else {
- PrintF("%s unrecognized\n", arg1);
+ if (GetValue(arg1, &value)) {
+ PrintF("%s: 0x%08x %d \n", arg1, value, value);
+ } else {
+ PrintF("%s unrecognized\n", arg1);
+ }
}
} else {
- PrintF("print value\n");
+ PrintF("print <register>\n");
}
} else if ((strcmp(cmd, "po") == 0)
|| (strcmp(cmd, "printobject") == 0)) {
Object* obj = reinterpret_cast<Object*>(value);
USE(obj);
PrintF("%s: \n", arg1);
-#if defined(DEBUG)
+#ifdef DEBUG
obj->PrintLn();
-#endif // defined(DEBUG)
+#else
+ obj->ShortPrint();
+ PrintF("\n");
+#endif
} else {
PrintF("%s unrecognized\n", arg1);
}
} else {
- PrintF("printobject value\n");
+ PrintF("printobject <value>\n");
}
} else if (strcmp(cmd, "disasm") == 0) {
disasm::NameConverter converter;
while (cur < end) {
dasm.InstructionDecode(buffer, cur);
- PrintF(" 0x%x %s\n", cur, buffer.start());
+ PrintF(" 0x%08x %s\n", cur, buffer.start());
cur += Instr::kInstrSize;
}
} else if (strcmp(cmd, "gdb") == 0) {
PrintF("%s unrecognized\n", arg1);
}
} else {
- PrintF("break addr\n");
+ PrintF("break <address>\n");
}
} else if (strcmp(cmd, "del") == 0) {
if (!DeleteBreakpoint(NULL)) {
} else {
PrintF("Not at debugger stop.");
}
+ } else if ((strcmp(cmd, "h") == 0) || (strcmp(cmd, "help") == 0)) {
+ PrintF("cont\n");
+ PrintF(" continue execution (alias 'c')\n");
+ PrintF("stepi\n");
+ PrintF(" step one instruction (alias 'si')\n");
+ PrintF("print <register>\n");
+ PrintF(" print register content (alias 'p')\n");
+ PrintF(" use register name 'all' to print all registers\n");
+ PrintF("printobject <register>\n");
+ PrintF(" print an object from a register (alias 'po')\n");
+ PrintF("flags\n");
+ PrintF(" print flags\n");
+ PrintF("disasm [<instructions>]\n");
+ PrintF("disasm [[<address>] <instructions>]\n");
+ PrintF(" disassemble code, default is 10 instructions from pc\n");
+ PrintF("gdb\n");
+ PrintF(" enter gdb\n");
+ PrintF("break <address>\n");
+ PrintF(" set a break point on the address\n");
+ PrintF("del\n");
+ PrintF(" delete the breakpoint\n");
+ PrintF("unstop\n");
+ PrintF(" ignore the stop instruction at the current location");
+ PrintF(" from now on\n");
} else {
PrintF("Unknown command: %s\n", cmd);
}
intptr_t* ptr = reinterpret_cast<intptr_t*>(addr);
return *ptr;
}
- PrintF("Unaligned read at %x\n", addr);
+ PrintF("Unaligned read at 0x%08x\n", addr);
UNIMPLEMENTED();
return 0;
}
*ptr = value;
return;
}
- PrintF("Unaligned write at %x, pc=%p\n", addr, instr);
+ PrintF("Unaligned write at 0x%08x, pc=%p\n", addr, instr);
UNIMPLEMENTED();
}
uint16_t* ptr = reinterpret_cast<uint16_t*>(addr);
return *ptr;
}
- PrintF("Unaligned unsigned halfword read at %x, pc=%p\n", addr, instr);
+ PrintF("Unaligned unsigned halfword read at 0x%08x, pc=%p\n", addr, instr);
UNIMPLEMENTED();
return 0;
}
int16_t* ptr = reinterpret_cast<int16_t*>(addr);
return *ptr;
}
- PrintF("Unaligned signed halfword read at %x\n", addr);
+ PrintF("Unaligned signed halfword read at 0x%08x\n", addr);
UNIMPLEMENTED();
return 0;
}
*ptr = value;
return;
}
- PrintF("Unaligned unsigned halfword write at %x, pc=%p\n", addr, instr);
+ PrintF("Unaligned unsigned halfword write at 0x%08x, pc=%p\n", addr, instr);
UNIMPLEMENTED();
}
*ptr = value;
return;
}
- PrintF("Unaligned halfword write at %x, pc=%p\n", addr, instr);
+ PrintF("Unaligned halfword write at 0x%08x, pc=%p\n", addr, instr);
UNIMPLEMENTED();
}
// Unsupported instructions use Format to print an error and stop execution.
void Simulator::Format(Instr* instr, const char* format) {
- PrintF("Simulator found unsupported instruction:\n 0x%x: %s\n",
+ PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n",
instr, format);
UNIMPLEMENTED();
}
uint16_t halfword = ReadH(addr, instr);
set_register(rd, halfword);
} else {
- UNIMPLEMENTED();
+ Debugger dbg(this);
+ dbg.Stop(instr);
}
}
v8::internal::EmbeddedVector<char, 256> buffer;
dasm.InstructionDecode(buffer,
reinterpret_cast<byte*>(instr));
- PrintF(" 0x%x %s\n", instr, buffer.start());
+ PrintF(" 0x%08x %s\n", instr, buffer.start());
}
if (instr->ConditionField() == special_condition) {
DecodeUnconditional(instr);