Commit 1f72df06 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[arm64/sim] Add a 'sim' gdb command

Extract out the command processing from Simulator::Debug(), and expose
it to gdb as a new 'sim' command. Example usage:

    (gdb) sim p x15
    (gdb) sim stack

The sim command will execute that one command, and will return to gdb.

For a list of all commands, you can call

    (gdb) sim help

Note that sim won't resume simulator execution until gdb continues
execution; for example, `sim next` will set a breakpoint on the next
instruction, and will return to gdb. The user then has to continue
execution in gdb, at which point the simulator will break. The user can
then re-enter gdb with the gdb command. This will look like this:

    (gdb) sim next
    (gdb) continue
    ...
    sim> gdb
    (gdb) ...

Change-Id: I678e71e2642d8427950b5f7ed65890ceae69e18d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2664448
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72479}
parent 1f85cb19
...@@ -2744,12 +2744,12 @@ V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) { ...@@ -2744,12 +2744,12 @@ V8_EXPORT_PRIVATE extern void _v8_internal_Print_Code(void* object) {
} }
if (!isolate->heap()->InSpaceSlow(address, i::CODE_SPACE) && if (!isolate->heap()->InSpaceSlow(address, i::CODE_SPACE) &&
!isolate->heap()->InSpaceSlow(address, i::LO_SPACE) && !isolate->heap()->InSpaceSlow(address, i::CODE_LO_SPACE) &&
!i::InstructionStream::PcIsOffHeap(isolate, address) && !i::InstructionStream::PcIsOffHeap(isolate, address) &&
!i::ReadOnlyHeap::Contains(address)) { !i::ReadOnlyHeap::Contains(address)) {
i::PrintF( i::PrintF(
"%p is not within the current isolate's large object, code, read_only " "%p is not within the current isolate's code, read_only or embedded "
"or embedded spaces\n", "spaces\n",
object); object);
return; return;
} }
......
This diff is collapsed.
...@@ -731,6 +731,11 @@ class Simulator : public DecoderVisitor, public SimulatorBase { ...@@ -731,6 +731,11 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
// Start the debugging command line. // Start the debugging command line.
void Debug(); void Debug();
// Executes a single debug command. Takes ownership of the command (so that it
// can store it for repeat executions), and returns true if the debugger
// should resume execution after this command completes.
bool ExecDebugCommand(ArrayUniquePtr<char> command);
bool GetValue(const char* desc, int64_t* value); bool GetValue(const char* desc, int64_t* value);
bool PrintValue(const char* desc); bool PrintValue(const char* desc);
...@@ -2327,12 +2332,11 @@ class Simulator : public DecoderVisitor, public SimulatorBase { ...@@ -2327,12 +2332,11 @@ class Simulator : public DecoderVisitor, public SimulatorBase {
static const char* vreg_names[]; static const char* vreg_names[];
// Debugger input. // Debugger input.
void set_last_debugger_input(char* input) { void set_last_debugger_input(ArrayUniquePtr<char> input) {
DeleteArray(last_debugger_input_); last_debugger_input_ = std::move(input);
last_debugger_input_ = input;
} }
char* last_debugger_input() { return last_debugger_input_; } const char* last_debugger_input() { return last_debugger_input_.get(); }
char* last_debugger_input_; ArrayUniquePtr<char> last_debugger_input_;
// Synchronization primitives. See ARM DDI 0487A.a, B2.10. Pair types not // Synchronization primitives. See ARM DDI 0487A.a, B2.10. Pair types not
// implemented. // implemented.
......
...@@ -57,6 +57,14 @@ void DeleteArray(T* array) { ...@@ -57,6 +57,14 @@ void DeleteArray(T* array) {
delete[] array; delete[] array;
} }
template <typename T>
struct ArrayDeleter {
void operator()(T* array) { DeleteArray(array); }
};
template <typename T>
using ArrayUniquePtr = std::unique_ptr<T, ArrayDeleter<T>>;
// The normal strdup functions use malloc. These versions of StrDup // The normal strdup functions use malloc. These versions of StrDup
// and StrNDup uses new and calls the FatalProcessOutOfMemory handler // and StrNDup uses new and calls the FatalProcessOutOfMemory handler
// if allocation fails. // if allocation fails.
......
...@@ -86,6 +86,24 @@ Skip the jitted stack on x64 to where we entered JS last. ...@@ -86,6 +86,24 @@ Skip the jitted stack on x64 to where we entered JS last.
Usage: jss Usage: jss
end end
# Execute a simulator command.
python
import gdb
class SimCommand(gdb.Command):
"""Sim the current program."""
def __init__ (self):
super (SimCommand, self).__init__ ("sim", gdb.COMMAND_SUPPORT)
def invoke (self, arg, from_tty):
arg_c_string = gdb.Value(arg)
cmd_func = gdb.selected_frame().read_var("_v8_internal_Simulator_ExecDebugCommand")
cmd_func(arg_c_string)
SimCommand()
end
# Print stack trace with assertion scopes. # Print stack trace with assertion scopes.
define bta define bta
python python
......
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