Commit 820faa6e authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

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

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: I682f97afa30a8d9dc572fe5e9dd256eeebf79de9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2056468Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66284}
parent 831bce26
......@@ -293,7 +293,8 @@ void ArmDebugger::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;
......@@ -320,20 +321,23 @@ void ArmDebugger::Debug() {
}
end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%08" V8PRIxPTR ": 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++;
......@@ -486,6 +490,10 @@ void ArmDebugger::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("disasm [<instructions>]\n");
PrintF("disasm [<address/register>]\n");
PrintF("disasm [[<address/register>] <instructions>]\n");
......
......@@ -3411,7 +3411,8 @@ void Simulator::Debug() {
// stack / mem
// ----------------------------------------------------------
} 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;
......@@ -3443,20 +3444,23 @@ void Simulator::Debug() {
}
end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%016" PRIx64 ": 0x%016" PRIx64 " %10" PRId64,
reinterpret_cast<uint64_t>(cur), *cur, *cur);
Object obj(*cur);
Heap* current_heap = isolate_->heap();
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %" PRId32, Smi::ToInt(obj));
} else {
obj.ShortPrint();
if (!skip_obj_print) {
Object obj(*cur);
Heap* current_heap = isolate_->heap();
if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
if (obj.IsSmi()) {
PrintF("smi %" PRId32, Smi::ToInt(obj));
} else {
obj.ShortPrint();
}
PrintF(")");
}
PrintF(")");
}
PrintF("\n");
cur++;
......@@ -3533,6 +3537,10 @@ void Simulator::Debug() {
"mem\n"
" mem <address> [<words>]\n"
" Dump memory content, default dump 10 words\n"
"dump\n"
" dump <address> [<words>]\n"
" Dump memory content without pretty printing JS objects, "
"default dump 10 words\n"
"trace / t\n"
" Toggle disassembly and register tracing\n"
"break / b\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