![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
#include <Debugger.hpp>
Public Member Functions | |
| Debugger (const ExecutionContext &context, const std::vector< std::filesystem::path > &libenv, const std::vector< std::string > &symbols, const std::vector< Value > &constants) | |
| Create a new Debugger object. | |
| Debugger (const std::vector< std::filesystem::path > &libenv, const std::string &path_to_prompt_file, std::ostream &os, const std::vector< std::string > &symbols, const std::vector< Value > &constants) | |
| Create a new Debugger object that will use lines from a file as prompts, instead of waiting for user inputs. | |
| void | saveState (const ExecutionContext &context) |
| Save the current VM state, to get back to it once the debugger is done running. | |
| void | resetContextToSavedState (ExecutionContext &context) |
| Reset a VM context to the last state saved by the debugger. | |
| void | run (VM &vm, ExecutionContext &context, bool from_breakpoint) |
| Start the debugger shell. | |
| bool | isRunning () const noexcept |
| bool | shouldQuitVM () const noexcept |
Private Member Functions | |
| void | showContext (const VM &vm, const ExecutionContext &context) const |
| void | showStack (VM &vm, const ExecutionContext &context, std::size_t count) const |
| void | showLocals (VM &vm, ExecutionContext &context, std::size_t count) const |
| std::optional< std::size_t > | getArgAndParseOrError (const std::string &command, const std::string &line, std::size_t default_value) const |
| std::optional< std::string > | prompt (std::size_t ip, std::size_t pp, VM &vm, ExecutionContext &context) |
| std::optional< CompiledPrompt > | compile (const std::string &code, std::size_t start_page_at_offset) const |
| Take care of compiling new code using the existing data tables. | |
Static Private Member Functions | |
| static std::optional< std::string > | getCommandArg (const std::string &command, const std::string &line) |
| static std::optional< std::size_t > | parseStringAsInt (const std::string &str) |
Private Attributes | |
| std::vector< std::unique_ptr< SavedState > > | m_states |
| std::vector< std::filesystem::path > | m_libenv |
| std::vector< std::string > | m_symbols |
| std::vector< Value > | m_constants |
| bool | m_running { false } |
| bool | m_quit_vm { false } |
| std::ostream & | m_os |
| bool | m_colorize |
| std::unique_ptr< std::istream > | m_prompt_stream |
| std::string | m_code |
| Code added while inside the debugger. | |
| std::size_t | m_line_count { 0 } |
Definition at line 48 of file Debugger.hpp.
| Ark::internal::Debugger::Debugger | ( | const ExecutionContext & | context, |
| const std::vector< std::filesystem::path > & | libenv, | ||
| const std::vector< std::string > & | symbols, | ||
| const std::vector< Value > & | constants ) |
Create a new Debugger object.
| context | context from the VM before displaying a backtrace |
| libenv | |
| symbols | symbols table of the VM |
| constants | constants table of the VM |
Definition at line 19 of file Debugger.cpp.
References saveState().
| Ark::internal::Debugger::Debugger | ( | const std::vector< std::filesystem::path > & | libenv, |
| const std::string & | path_to_prompt_file, | ||
| std::ostream & | os, | ||
| const std::vector< std::string > & | symbols, | ||
| const std::vector< Value > & | constants ) |
Create a new Debugger object that will use lines from a file as prompts, instead of waiting for user inputs.
| libenv | |
| path_to_prompt_file | |
| os | output stream |
| symbols | symbols table of the VM |
| constants | constants table of the VM |
Definition at line 29 of file Debugger.cpp.
|
nodiscardprivate |
Take care of compiling new code using the existing data tables.
| code | |
| start_page_at_offset | offset to start the new pages at |
Definition at line 329 of file Debugger.cpp.
References Ark::Welder::bytecode(), Ark::BytecodeReader::code(), Ark::Welder::computeASTFromStringWithKnownSymbols(), Ark::DefaultFeatures, Ark::BytecodeReader::feed(), Ark::BytecodeReader::filenames(), Ark::Welder::generateBytecodeUsingTables(), Ark::BytecodeReader::instLocations(), m_constants, m_libenv, m_symbols, Ark::BytecodeReader::symbols(), and Ark::BytecodeReader::values().
Referenced by run().
|
nodiscardprivate |
Definition at line 233 of file Debugger.cpp.
References getCommandArg(), m_os, and parseStringAsInt().
Referenced by prompt().
|
staticprivate |
Definition at line 213 of file Debugger.cpp.
References Ark::Utils::trimWhitespace().
Referenced by getArgAndParseOrError().
|
inlinenodiscardnoexcept |
Definition at line 95 of file Debugger.hpp.
References m_running.
|
staticprivate |
Definition at line 223 of file Debugger.cpp.
Referenced by getArgAndParseOrError().
|
private |
Definition at line 251 of file Debugger.cpp.
References Ark::Utils::countOpenEnclosures(), getArgAndParseOrError(), m_colorize, m_line_count, m_os, m_prompt_stream, m_quit_vm, showLocals(), showStack(), and Ark::Utils::trimWhitespace().
Referenced by run().
| void Ark::internal::Debugger::resetContextToSavedState | ( | ExecutionContext & | context | ) |
Reset a VM context to the last state saved by the debugger.
| context | context to reset |
Definition at line 50 of file Debugger.cpp.
References Ark::internal::ExecutionContext::fc, Ark::internal::ExecutionContext::ip, Ark::internal::ExecutionContext::locals, m_states, Ark::internal::ExecutionContext::pp, Ark::internal::ExecutionContext::sp, and Ark::internal::ExecutionContext::stacked_closure_scopes.
| void Ark::internal::Debugger::run | ( | VM & | vm, |
| ExecutionContext & | context, | ||
| bool | from_breakpoint ) |
Start the debugger shell.
| vm | |
| context | |
| from_breakpoint | true if the debugger is being invoked from a breakpoint |
Definition at line 63 of file Debugger.cpp.
References compile(), Ark::State::extendBytecode(), Ark::Garbage, Ark::InstPtr, Ark::internal::ExecutionContext::ip, Ark::internal::ExecutionContext::locals, m_code, m_colorize, m_line_count, m_os, Ark::State::m_pages, m_running, Ark::VM::m_running, Ark::VM::m_state, Ark::VM::peekAndResolveAsPtr(), Ark::internal::ExecutionContext::pp, prompt(), Ark::VM::safeRun(), Ark::internal::ExecutionContext::scopes_storage, showContext(), Ark::Value::toString(), Ark::Undefined, and Ark::Value::valueType().
| void Ark::internal::Debugger::saveState | ( | const ExecutionContext & | context | ) |
Save the current VM state, to get back to it once the debugger is done running.
| context |
Definition at line 38 of file Debugger.cpp.
References Ark::internal::ExecutionContext::fc, Ark::internal::ExecutionContext::ip, Ark::internal::ExecutionContext::locals, m_states, Ark::internal::ExecutionContext::pp, Ark::internal::ExecutionContext::sp, and Ark::internal::ExecutionContext::stacked_closure_scopes.
Referenced by Debugger().
|
inlinenodiscardnoexcept |
Definition at line 100 of file Debugger.hpp.
References m_quit_vm.
|
private |
Definition at line 131 of file Debugger.cpp.
References Ark::Utils::fileExists(), Ark::VM::findSourceLocation(), Ark::internal::ExecutionContext::ip, m_colorize, Ark::State::m_filenames, m_os, Ark::VM::m_state, Ark::Diagnostics::makeContext(), and Ark::internal::ExecutionContext::pp.
Referenced by run().
|
private |
Definition at line 179 of file Debugger.cpp.
References Ark::internal::ExecutionContext::locals, m_colorize, m_os, Ark::VM::m_state, Ark::State::m_symbols, and std::to_string().
Referenced by prompt().
|
private |
Definition at line 156 of file Debugger.cpp.
References m_colorize, m_os, Ark::internal::ExecutionContext::sp, and Ark::internal::ExecutionContext::stack.
Referenced by prompt().
|
private |
Code added while inside the debugger.
Definition at line 116 of file Debugger.hpp.
Referenced by run().
|
private |
Definition at line 114 of file Debugger.hpp.
Referenced by prompt(), run(), showContext(), showLocals(), and showStack().
|
private |
Definition at line 109 of file Debugger.hpp.
Referenced by compile().
|
private |
Definition at line 107 of file Debugger.hpp.
Referenced by compile().
|
private |
Definition at line 117 of file Debugger.hpp.
|
private |
Definition at line 113 of file Debugger.hpp.
Referenced by getArgAndParseOrError(), prompt(), run(), showContext(), showLocals(), and showStack().
|
private |
Definition at line 115 of file Debugger.hpp.
Referenced by prompt().
|
private |
Definition at line 111 of file Debugger.hpp.
Referenced by prompt(), and shouldQuitVM().
|
private |
Definition at line 110 of file Debugger.hpp.
Referenced by isRunning(), and run().
|
private |
Definition at line 106 of file Debugger.hpp.
Referenced by resetContextToSavedState(), and saveState().
|
private |
Definition at line 108 of file Debugger.hpp.
Referenced by compile().