Revision: 4388
Author: [email protected]
Date: Mon Apr 12 05:24:14 2010
Log: Add commands stack and mem to ARM simulator debugger
The command "stack" will dump the stack and "mem" will dump memory from a
address given either as a register or as a literal. Both commands dump 10
words unless an additional argument with the number of words to dump is
given.
sim> stack
sim> mem fp
sim> mem 0xe612a450 100
Also parse address literals in simulator debugger command as unsigned.
Review URL: http://codereview.chromium.org/1596022
http://code.google.com/p/v8/source/detail?r=4388
Modified:
/branches/bleeding_edge/src/arm/simulator-arm.cc
=======================================
--- /branches/bleeding_edge/src/arm/simulator-arm.cc Fri Apr 9 11:25:51
2010
+++ /branches/bleeding_edge/src/arm/simulator-arm.cc Mon Apr 12 05:24:14
2010
@@ -150,7 +150,11 @@
*value = GetRegisterValue(regnum);
return true;
} else {
- return SScanF(desc, "%i", value) == 1;
+ if (strncmp(desc, "0x", 2) == 0) {
+ return SScanF(desc + 2, "%x", reinterpret_cast<uint32_t*>(value)) ==
1;
+ } else {
+ return SScanF(desc, "%u", reinterpret_cast<uint32_t*>(value)) == 1;
+ }
}
return false;
}
@@ -231,6 +235,7 @@
char cmd[COMMAND_SIZE + 1];
char arg1[ARG_SIZE + 1];
char arg2[ARG_SIZE + 1];
+ char* argv[3] = { cmd, arg1, arg2 };
// make sure to have a proper terminating character if reaching the limit
cmd[COMMAND_SIZE] = 0;
@@ -258,7 +263,7 @@
} else {
// Use sscanf to parse the individual parts of the command line. At
the
// moment no command expects more than two parameters.
- int args = SScanF(line,
+ int argc = SScanF(line,
"%" XSTR(COMMAND_SIZE) "s "
"%" XSTR(ARG_SIZE) "s "
"%" XSTR(ARG_SIZE) "s",
@@ -271,7 +276,7 @@
// Leave the debugger shell.
done = true;
} else if ((strcmp(cmd, "p") == 0) || (strcmp(cmd, "print") == 0)) {
- if (args == 2) {
+ if (argc == 2) {
int32_t value;
float svalue;
double dvalue;
@@ -296,7 +301,7 @@
}
} else if ((strcmp(cmd, "po") == 0)
|| (strcmp(cmd, "printobject") == 0)) {
- if (args == 2) {
+ if (argc == 2) {
int32_t value;
if (GetValue(arg1, &value)) {
Object* obj = reinterpret_cast<Object*>(value);
@@ -313,6 +318,38 @@
} else {
PrintF("printobject <value>\n");
}
+ } else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
+
+ int32_t* cur = NULL;
+ int32_t* end = NULL;
+ int next_arg = 1;
+
+ if (strcmp(cmd, "stack") == 0) {
+ cur =
reinterpret_cast<int32_t*>(sim_->get_register(Simulator::sp));
+ } else { // "mem"
+ int32_t value;
+ if (!GetValue(arg1, &value)) {
+ PrintF("%s unrecognized\n", arg1);
+ continue;
+ }
+ cur = reinterpret_cast<int32_t*>(value);
+ next_arg++;
+ }
+
+ int32_t words;
+ if (argc == next_arg) {
+ words = 10;
+ } else if (argc == next_arg + 1) {
+ if (!GetValue(argv[next_arg], &words)) {
+ words = 10;
+ }
+ }
+ end = cur + words;
+
+ while (cur < end) {
+ PrintF(" 0x%08x: 0x%08x %10d\n", cur, *cur, *cur);
+ cur++;
+ }
} else if (strcmp(cmd, "disasm") == 0) {
disasm::NameConverter converter;
disasm::Disassembler dasm(converter);
@@ -322,10 +359,10 @@
byte* cur = NULL;
byte* end = NULL;
- if (args == 1) {
+ if (argc == 1) {
cur = reinterpret_cast<byte*>(sim_->get_pc());
end = cur + (10 * Instr::kInstrSize);
- } else if (args == 2) {
+ } else if (argc == 2) {
int32_t value;
if (GetValue(arg1, &value)) {
cur = reinterpret_cast<byte*>(value);
@@ -351,7 +388,7 @@
v8::internal::OS::DebugBreak();
PrintF("regaining control from gdb\n");
} else if (strcmp(cmd, "break") == 0) {
- if (args == 2) {
+ if (argc == 2) {
int32_t value;
if (GetValue(arg1, &value)) {
if (!SetBreakpoint(reinterpret_cast<Instr*>(value))) {
@@ -401,6 +438,10 @@
PrintF(" print an object from a register (alias 'po')\n");
PrintF("flags\n");
PrintF(" print flags\n");
+ PrintF("stack [<words>]\n");
+ PrintF(" dump stack content, default dump 10 words)\n");
+ PrintF("mem <address> [<words>]\n");
+ PrintF(" dump memory content, default dump 10 words)\n");
PrintF("disasm [<instructions>]\n");
PrintF("disasm [[<address>] <instructions>]\n");
PrintF(" disassemble code, default is 10 instructions from pc\n");
@@ -414,7 +455,7 @@
PrintF(" ignore the stop instruction at the current location");
PrintF(" from now on\n");
PrintF("trace (alias 't')\n");
- PrintF(" toogle the tracing of all executed statements");
+ PrintF(" toogle the tracing of all executed statements\n");
} else {
PrintF("Unknown command: %s\n", cmd);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe, reply using "remove me" as the subject.