![]() |
chigraph
master
Systems programming language written for beginners in LLVM
|
Helper class for using LLDB with chigraph. More...
#include <chi/Debugger/Debugger.hpp>
Public Member Functions | |
Debugger (const char *pathToChig, GraphModule &mod) | |
Default constructor. More... | |
Debugger (const Debugger &other)=delete | |
Debugger (Debugger &&other)=delete | |
~Debugger () | |
Destructor. | |
lldb::SBValue | inspectLocalVariable (boost::string_view name) |
Get the value of a local variable. More... | |
lldb::SBValue | inspectNodeOutput (const NodeInstance &inst, size_t id, lldb::SBFrame frame={}) |
Get the output of a node. More... | |
bool | isAttached () const |
Check if this debugger is attached to a process It's true if the process is stopped or if it's curretnly executing. More... | |
std::vector< const NodeInstance * > | listBreakpoints () const |
List the curretnly set breakpoints. More... | |
lldb::SBDebugger | lldbDebugger () const |
Get the debugger This should probably be valid...not sure why it wouldn't be. More... | |
lldb::SBProcess | lldbProcess () const |
Get the process This will only be valid if there's an attached process. More... | |
lldb::SBTarget | lldbTarget () const |
Get the target Keep in mind the return isn't necessarily valid, although it should be. More... | |
GraphModule & | module () const |
Get the module that's being debugged by this debugger. More... | |
NodeInstance * | nodeFromFrame (lldb::SBFrame frame={}) |
Get a NodeInstance from a frame. More... | |
Debugger & | operator= (const Debugger &)=delete |
Debugger & | operator= (Debugger &&)=delete |
Result | pause () |
Pause the execution state. More... | |
Result | processContinue () |
Continue the execution of the process. More... | |
bool | removeBreakpoint (NodeInstance &node) |
Remove a breakpoint from a node. More... | |
bool | running () const |
Check if the process is executing. More... | |
Result | setBreakpoint (NodeInstance &node, lldb::SBBreakpoint *bp=nullptr) |
Set a breakpoint on a given node. More... | |
Result | start (const char **argv=nullptr, const char **envp=nullptr, const boost::filesystem::path &workingDirectory=boost::filesystem::current_path()) |
Start debugging the process. More... | |
Result | terminate () |
Terminate the inferior process. More... | |
Helper class for using LLDB with chigraph.
Definition at line 20 of file Debugger.hpp.
chi::Debugger::Debugger | ( | const char * | pathToChig, |
GraphModule & | mod | ||
) |
Default constructor.
pathToChig | The path to the chig executable for JIT |
mod | The GraphModule to debug, should be a main module |
Definition at line 33 of file Debugger.cpp.
lldb::SBValue chi::Debugger::inspectLocalVariable | ( | boost::string_view | name | ) |
Get the value of a local variable.
name | The name ofthe local variable to get the value of |
SBValue
if the local variable wasn't found Referenced by running().
lldb::SBValue chi::Debugger::inspectNodeOutput | ( | const NodeInstance & | inst, |
size_t | id, | ||
lldb::SBFrame | frame = {} |
||
) |
Get the output of a node.
inst | The instance |
id | The ID of output to get |
id < inst.outputDataConnections.size()
frame | The frame. If this isn't a valid SBFrame (the default), then it uses lldbProcess().GetSelectedThread().GetSelectedFrame() |
Definition at line 223 of file Debugger.cpp.
References chi::NodeInstance::function(), lldbProcess(), nodeFromFrame(), chi::NodeInstance::outputDataConnections, and chi::NodeInstance::stringId().
Referenced by running().
|
inline |
Check if this debugger is attached to a process It's true if the process is stopped or if it's curretnly executing.
Definition at line 57 of file Debugger.hpp.
Referenced by pause(), processContinue(), running(), and terminate().
std::vector< const NodeInstance * > chi::Debugger::listBreakpoints | ( | ) | const |
List the curretnly set breakpoints.
Definition at line 216 of file Debugger.cpp.
Referenced by running().
|
inline |
Get the debugger This should probably be valid...not sure why it wouldn't be.
Definition at line 126 of file Debugger.hpp.
References chi::lineNumberFromNode().
|
inline |
Get the process This will only be valid if there's an attached process.
Definition at line 121 of file Debugger.hpp.
Referenced by inspectNodeOutput(), nodeFromFrame(), and running().
|
inline |
Get the target Keep in mind the return isn't necessarily valid, although it should be.
Definition at line 116 of file Debugger.hpp.
|
inline |
Get the module that's being debugged by this debugger.
Definition at line 111 of file Debugger.hpp.
Referenced by nodeFromFrame(), and start().
NodeInstance * chi::Debugger::nodeFromFrame | ( | lldb::SBFrame | frame = {} | ) |
Get a NodeInstance from a frame.
frame | The frame to get the function for. If this isn't a valid SBFrame (the default), then it uses lldbProcess().GetSelectedThread().GetSelectedFrame() |
Definition at line 244 of file Debugger.cpp.
References chi::ChiModule::context(), chi::GraphModule::createLineNumberAssoc(), chi::GraphModule::functionFromName(), lldbProcess(), module(), chi::GraphFunction::module(), chi::Context::moduleByFullName(), and chi::unmangleFunctionName().
Referenced by inspectNodeOutput(), and running().
Result chi::Debugger::pause | ( | ) |
Pause the execution state.
Definition at line 93 of file Debugger.cpp.
References chi::Result::addEntry(), and isAttached().
Referenced by running().
Result chi::Debugger::processContinue | ( | ) |
Continue the execution of the process.
Definition at line 77 of file Debugger.cpp.
References chi::Result::addEntry(), and isAttached().
Referenced by running().
bool chi::Debugger::removeBreakpoint | ( | NodeInstance & | node | ) |
Remove a breakpoint from a node.
[in] | node | The node to remove the breakpoint from |
Definition at line 138 of file Debugger.cpp.
Referenced by running().
|
inline |
Check if the process is executing.
Definition at line 61 of file Debugger.hpp.
References inspectLocalVariable(), inspectNodeOutput(), isAttached(), listBreakpoints(), lldbProcess(), nodeFromFrame(), pause(), processContinue(), removeBreakpoint(), and setBreakpoint().
Result chi::Debugger::setBreakpoint | ( | NodeInstance & | node, |
lldb::SBBreakpoint * | bp = nullptr |
||
) |
Set a breakpoint on a given node.
[in] | node | The node to set the breakpoint on |
[out] | bp | The (optional) SBBreakpoint object to fill |
Definition at line 110 of file Debugger.cpp.
References chi::Result::addEntry(), chi::lineNumberFromNode(), chi::NodeInstance::module(), chi::GraphModule::sourceFilePath(), and chi::NodeInstance::stringId().
Referenced by running().
Result chi::Debugger::start | ( | const char ** | argv = nullptr , |
const char ** | envp = nullptr , |
||
const boost::filesystem::path & | workingDirectory = boost::filesystem::current_path() |
||
) |
Start debugging the process.
[in] | argv | A null-terminated array of arguments. If it isn't null-terminated then this will probably crash |
[in] | envp | A null-terminated array of environment variables. If it isn't null-terminated then this will probably crash |
[in] | workingDirectory | The working directory to debug in, by default it's the current working directory of this process |
boost::filesystem::is_directory(workingDirectory)
Definition at line 145 of file Debugger.cpp.
References chi::Result::addEntry(), chi::Context::compileModule(), chi::ChiModule::context(), chi::Default, and module().
Result chi::Debugger::terminate | ( | ) |
Terminate the inferior process.
Definition at line 60 of file Debugger.cpp.
References chi::Result::addEntry(), and isAttached().