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() { ...@@ -354,7 +354,8 @@ void PPCDebugger::Debug() {
continue; continue;
} }
sim_->set_pc(value); 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* cur = nullptr;
intptr_t* end = nullptr; intptr_t* end = nullptr;
int next_arg = 1; int next_arg = 1;
...@@ -381,11 +382,13 @@ void PPCDebugger::Debug() { ...@@ -381,11 +382,13 @@ void PPCDebugger::Debug() {
} }
end = cur + words; end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) { while (cur < end) {
PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR, PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR,
reinterpret_cast<intptr_t>(cur), *cur, *cur); reinterpret_cast<intptr_t>(cur), *cur, *cur);
Object obj(*cur); Object obj(*cur);
Heap* current_heap = sim_->isolate_->heap(); Heap* current_heap = sim_->isolate_->heap();
if (!skip_obj_print) {
if (obj.IsSmi() || if (obj.IsSmi() ||
IsValidHeapObject(current_heap, HeapObject::cast(obj))) { IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
PrintF(" ("); PrintF(" (");
...@@ -396,6 +399,7 @@ void PPCDebugger::Debug() { ...@@ -396,6 +399,7 @@ void PPCDebugger::Debug() {
} }
PrintF(")"); PrintF(")");
} }
}
PrintF("\n"); PrintF("\n");
cur++; cur++;
} }
...@@ -565,6 +569,10 @@ void PPCDebugger::Debug() { ...@@ -565,6 +569,10 @@ void PPCDebugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n"); PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<num words>]\n"); PrintF("mem <address> [<num words>]\n");
PrintF(" dump memory content, default dump 10 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 [<instructions>]\n");
PrintF("disasm [<address/register>]\n"); PrintF("disasm [<address/register>]\n");
PrintF("disasm [[<address/register>] <instructions>]\n"); PrintF("disasm [[<address/register>] <instructions>]\n");
......
...@@ -384,7 +384,8 @@ void S390Debugger::Debug() { ...@@ -384,7 +384,8 @@ void S390Debugger::Debug() {
continue; continue;
} }
sim_->set_pc(value); 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* cur = nullptr;
intptr_t* end = nullptr; intptr_t* end = nullptr;
int next_arg = 1; int next_arg = 1;
...@@ -411,11 +412,13 @@ void S390Debugger::Debug() { ...@@ -411,11 +412,13 @@ void S390Debugger::Debug() {
} }
end = cur + words; end = cur + words;
bool skip_obj_print = (strcmp(cmd, "dump") == 0);
while (cur < end) { while (cur < end) {
PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR, PrintF(" 0x%08" V8PRIxPTR ": 0x%08" V8PRIxPTR " %10" V8PRIdPTR,
reinterpret_cast<intptr_t>(cur), *cur, *cur); reinterpret_cast<intptr_t>(cur), *cur, *cur);
Object obj(*cur); Object obj(*cur);
Heap* current_heap = sim_->isolate_->heap(); Heap* current_heap = sim_->isolate_->heap();
if (!skip_obj_print) {
if (obj.IsSmi()) { if (obj.IsSmi()) {
PrintF(" (smi %d)", Smi::ToInt(obj)); PrintF(" (smi %d)", Smi::ToInt(obj));
} else if (IsValidHeapObject(current_heap, HeapObject::cast(obj))) { } else if (IsValidHeapObject(current_heap, HeapObject::cast(obj))) {
...@@ -424,6 +427,7 @@ void S390Debugger::Debug() { ...@@ -424,6 +427,7 @@ void S390Debugger::Debug() {
PrintF(")"); PrintF(")");
} }
PrintF("\n"); PrintF("\n");
}
cur++; cur++;
} }
} else if (strcmp(cmd, "disasm") == 0 || strcmp(cmd, "di") == 0) { } else if (strcmp(cmd, "disasm") == 0 || strcmp(cmd, "di") == 0) {
...@@ -579,6 +583,10 @@ void S390Debugger::Debug() { ...@@ -579,6 +583,10 @@ void S390Debugger::Debug() {
PrintF(" dump stack content, default dump 10 words)\n"); PrintF(" dump stack content, default dump 10 words)\n");
PrintF("mem <address> [<num words>]\n"); PrintF("mem <address> [<num words>]\n");
PrintF(" dump memory content, default dump 10 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 [<instructions>]\n");
PrintF("disasm [<address/register>]\n"); PrintF("disasm [<address/register>]\n");
PrintF("disasm [[<address/register>] <instructions>]\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