Commit afc37ebd authored by Zhao Jiazhong's avatar Zhao Jiazhong Committed by Commit Bot

[mips][simulator] Add a new command to the debugger to dump memory.

Port 820faa6e
https://crrev.com/c/2056468

Original Commit Message:

  The arm/arm64 simulators debugger has a command "mem" that prints
  the content of the memory. It also prints a short summary for JS
  objects (SMI, Array, JSFunction, ...). That is very handy, but
  when trying to print incomplete initialized memory, it could raise
  an exception.

  It is useful to have a command that prints the content of the memory
  for non-initialized or bogus values without the risk of raising
  an exception. This CL adds the command "dump".

Change-Id: If8c96d7bac4a484c2a4fee9d192a29ea2696580a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2089224Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66615}
parent d29c68be
......@@ -465,7 +465,8 @@ void MipsDebugger::Debug() {
} else {
PrintF("printobject <value>\n");
}
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 ||
strcmp(cmd, "dump") == 0) {
int32_t* cur = nullptr;
int32_t* end = nullptr;
int next_arg = 1;
......@@ -505,20 +506,23 @@ void MipsDebugger::Debug() {
end = cur + words;
}
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%08" PRIxPTR ": 0x%08x %10d",
reinterpret_cast<intptr_t>(cur), *cur, *cur);
Object obj(*cur);
Heap* current_heap = sim_->isolate_->heap();
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %d", Smi::ToInt(obj));
} else {
obj.ShortPrint();
if (!skip_obj_print) {
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %d", Smi::ToInt(obj));
} else {
obj.ShortPrint();
}
PrintF(")");
}
PrintF(")");
}
PrintF("\n");
cur++;
......@@ -702,6 +706,10 @@ void MipsDebugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<words>]\n");
PrintF(" dump memory content, default dump 10 words)\n");
PrintF("dump [<words>]\n");
PrintF(
" dump memory content without pretty printing JS objects, default "
"dump 10 words)\n");
PrintF("flags\n");
PrintF(" print flags\n");
PrintF("disasm [<instructions>]\n");
......
......@@ -420,7 +420,8 @@ void MipsDebugger::Debug() {
} else {
PrintF("printobject <value>\n");
}
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 ||
strcmp(cmd, "dump") == 0) {
int64_t* cur = nullptr;
int64_t* end = nullptr;
int next_arg = 1;
......@@ -447,20 +448,23 @@ void MipsDebugger::Debug() {
}
end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%012" PRIxPTR " : 0x%016" PRIx64 " %14" PRId64 " ",
reinterpret_cast<intptr_t>(cur), *cur, *cur);
Object obj(*cur);
Heap* current_heap = sim_->isolate_->heap();
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %d", Smi::ToInt(obj));
} else {
obj.ShortPrint();
if (!skip_obj_print) {
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %d", Smi::ToInt(obj));
} else {
obj.ShortPrint();
}
PrintF(")");
}
PrintF(")");
}
PrintF("\n");
cur++;
......@@ -644,6 +648,10 @@ void MipsDebugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<words>]\n");
PrintF(" dump memory content, default dump 10 words)\n");
PrintF("dump [<words>]\n");
PrintF(
" dump memory content without pretty printing JS objects, default "
"dump 10 words)\n");
PrintF("flags\n");
PrintF(" print flags\n");
PrintF("disasm [<instructions>]\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment