| chigraph master Systems programming language written for beginners in LLVM

Public Member Functions | List of all members
chi::Debugger Class Reference

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

## Detailed Description

Helper class for using LLDB with chigraph.

Definition at line 20 of file Debugger.hpp.

## Constructor & Destructor Documentation

## ◆ Debugger()

chi::Debugger::Debugger | ( | const char * | pathToChig,
|  | GraphModule & | mod
| ) |  |

Default constructor.

Parameters

  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.

## Member Function Documentation

## ◆ inspectLocalVariable()

lldb::SBValue chi::Debugger::inspectLocalVariable | ( | boost::string_view | name | ) |

Get the value of a local variable.

Parameters

  name | The name ofthe local variable to get the value of

Returns
  The value, or an invalid `SBValue` if the local variable wasn't found

Referenced by running().

Here is the caller graph for this function:

## ◆ inspectNodeOutput()

lldb::SBValue chi::Debugger::inspectNodeOutput | ( | const NodeInstance & | inst,
|  | size_t | id,
|  | lldb::SBFrame | frame = `{}`
| ) |  |

Get the output of a node.

Parameters

  inst | The instance
  id | The ID of output to get

Precondition
  `id < inst.outputDataConnections.size()`

Parameters

  frame | The frame. If this isn't a valid `SBFrame` (the default), then it uses `lldbProcess().GetSelectedThread().GetSelectedFrame()`

Returns
  The LLDB value object, or invalid if it failed.

Definition at line 223 of file Debugger.cpp.

References chi::NodeInstance::function(), lldbProcess(), nodeFromFrame(), chi::NodeInstance::outputDataConnections, and chi::NodeInstance::stringId().

Referenced by running().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ isAttached()

bool chi::Debugger::isAttached | ( |  | ) | const
| inline

Check if this debugger is attached to a process It's true if the process is stopped or if it's curretnly executing.

Returns
  True if it's attached

Definition at line 57 of file Debugger.hpp.

Referenced by pause(), processContinue(), running(), and terminate().

Here is the caller graph for this function:

## ◆ listBreakpoints()

std::vector< const NodeInstance * > chi::Debugger::listBreakpoints | ( |  | ) | const

List the curretnly set breakpoints.

Returns
  The breakpoints

Definition at line 216 of file Debugger.cpp.

Referenced by running().

Here is the caller graph for this function:

## ◆ lldbDebugger()

lldb::SBDebugger chi::Debugger::lldbDebugger | ( |  | ) | const
| inline

Get the debugger This should probably be valid...not sure why it wouldn't be.

Returns
  The LLDB debugger object

Definition at line 126 of file Debugger.hpp.

References chi::lineNumberFromNode().

Here is the call graph for this function:

## ◆ lldbProcess()

lldb::SBProcess chi::Debugger::lldbProcess | ( |  | ) | const
| inline

Get the process This will only be valid if there's an attached process.

Returns
  The LLDB process object

Definition at line 121 of file Debugger.hpp.

Referenced by inspectNodeOutput(), nodeFromFrame(), and running().

Here is the caller graph for this function:

## ◆ lldbTarget()

lldb::SBTarget chi::Debugger::lldbTarget | ( |  | ) | const
| inline

Get the target Keep in mind the return isn't necessarily valid, although it should be.

Returns
  The LLDB target object

Definition at line 116 of file Debugger.hpp.

## ◆ module()

GraphModule& chi::Debugger::module | ( |  | ) | const
| inline

Get the module that's being debugged by this debugger.

Returns
  The module

Definition at line 111 of file Debugger.hpp.

Referenced by nodeFromFrame(), and start().

Here is the caller graph for this function:

## ◆ nodeFromFrame()

NodeInstance * chi::Debugger::nodeFromFrame | ( | lldb::SBFrame | frame = `{}` | ) |

Get a NodeInstance from a frame.

Parameters

  frame | The frame to get the function for. If this isn't a valid `SBFrame` (the default), then it uses `lldbProcess().GetSelectedThread().GetSelectedFrame()`

Returns
  The NodeInstance, or nullptr if one wasn't found

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().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ pause()

Result chi::Debugger::pause | ( |  | ) |

Pause the execution state.

Returns
  The Result

Definition at line 93 of file Debugger.cpp.

References chi::Result::addEntry(), and isAttached().

Referenced by running().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ processContinue()

Result chi::Debugger::processContinue | ( |  | ) |

Continue the execution of the process.

Returns
  The Result

Definition at line 77 of file Debugger.cpp.

References chi::Result::addEntry(), and isAttached().

Referenced by running().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ removeBreakpoint()

bool chi::Debugger::removeBreakpoint | ( | NodeInstance & | node | ) |

Remove a breakpoint from a node.

Parameters

  [in] | node | The node to remove the breakpoint from

Returns
  True if a breakpoint was removed, false otherwise

Definition at line 138 of file Debugger.cpp.

Referenced by running().

Here is the caller graph for this function:

## ◆ running()

bool chi::Debugger::running | ( |  | ) | const
| inline

Check if the process is executing.

Returns
  If it's running

Definition at line 61 of file Debugger.hpp.

References inspectLocalVariable(), inspectNodeOutput(), isAttached(), listBreakpoints(), lldbProcess(), nodeFromFrame(), pause(), processContinue(), removeBreakpoint(), and setBreakpoint().

Here is the call graph for this function:

## ◆ setBreakpoint()

Result chi::Debugger::setBreakpoint | ( | NodeInstance & | node,
|  | lldb::SBBreakpoint * | bp = `nullptr`
| ) |  |

Set a breakpoint on a given node.

Parameters

  [in] | node | The node to set the breakpoint on
  [out] | bp | The (optional) `SBBreakpoint` object to fill

Returns
  The result

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().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ start()

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.

Parameters

  [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

Precondition
  `boost::filesystem::is_directory(workingDirectory)`

Returns
  The result

Definition at line 145 of file Debugger.cpp.

References chi::Result::addEntry(), chi::Context::compileModule(), chi::ChiModule::context(), chi::Default, and module().

Here is the call graph for this function:

## ◆ terminate()

Result chi::Debugger::terminate | ( |  | ) |

Terminate the inferior process.

Returns
  The result

Definition at line 60 of file Debugger.cpp.

References chi::Result::addEntry(), and isAttached().

Here is the call graph for this function:

The documentation for this class was generated from the following files:

- lib/debugger/include/chi/Debugger/Debugger.hpp
- lib/debugger/src/Debugger.cpp