Commit 45f1ec5d authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

PPC/s390: [simulator] Add a new command to the debugger to dump memory.

Port 820faa6e

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".

R=victorgomes@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ie3931af0cf34052706618774ba95bf0057cfcabf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2062159Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#66308}
parent eaaf5c8d
......@@ -354,7 +354,8 @@ void PPCDebugger::Debug() {
continue;
}
sim_->set_pc(value);
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 ||
strcmp(cmd, "dump") == 0) {
intptr_t* cur = nullptr;
intptr_t* end = nullptr;
int next_arg = 1;
......@@ -381,20 +382,23 @@ void PPCDebugger::Debug() {
}
end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR,
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++;
......@@ -565,6 +569,10 @@ void PPCDebugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<num 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");
......
......@@ -384,7 +384,8 @@ void S390Debugger::Debug() {
continue;
}
sim_->set_pc(value);
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0) {
} else if (strcmp(cmd, "stack") == 0 || strcmp(cmd, "mem") == 0 ||
strcmp(cmd, "dump") == 0) {
intptr_t* cur = nullptr;
intptr_t* end = nullptr;
int next_arg = 1;
......@@ -411,19 +412,22 @@ void S390Debugger::Debug() {
}
end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) {
PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR,
reinterpret_cast<intptr_t>(cur), *cur, *cur);
Object obj(*cur);
Heap* current_heap = sim_->isolate_->heap();
if (obj.IsSmi()) {
PrintF(" (smi %d)", Smi::ToInt(obj));
} else if (IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
obj.ShortPrint();
PrintF(")");
if (!skip_obj_print) {
if (obj.IsSmi()) {
PrintF(" (smi %d)", Smi::ToInt(obj));
} else if (IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" (");
obj.ShortPrint();
PrintF(")");
}
PrintF("\n");
}
PrintF("\n");
cur++;
}
} else if (strcmp(cmd, "disasm") == 0 || strcmp(cmd, "di") == 0) {
......@@ -579,6 +583,10 @@ void S390Debugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<num 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");
......
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