| 31 | namespace chi { |
| 32 | |
| 33 | Debugger::Debugger(const char* pathToChig, GraphModule& mod) : mModule{&mod} { |
| 34 | // point it to lldb-server |
| 35 | #if __linux__ |
| 36 | auto lldbServerPath = fs::path(pathToChig).parent_path() / "lldb-server"; |
| 37 | setenv("LLDB_DEBUGSERVER_PATH", lldbServerPath.c_str(), 1); |
| 38 | #endif |
| 39 | |
| 40 | lldb::SBDebugger::Initialize(); |
| 41 | mDebugger = lldb::SBDebugger::Create(); |
| 42 | |
| 43 | // set the logger to stderr for testing |
| 44 | mDebugger.SetLoggingCallback( |
| 45 | [](const char* msg, void* dbg) { |
| 46 | std::cerr << msg; |
| 47 | std::cerr.flush(); |
| 48 | }, |
| 49 | this); |
| 50 | |
| 51 | const char* val[] = {"api", nullptr}; |
| 52 | mDebugger.EnableLog("lldb", val); |
| 53 | |
| 54 | // create target |
| 55 | mTarget = mDebugger.CreateTarget(pathToChig); |
| 56 | } |
| 57 | |
| 58 | Debugger::~Debugger() { lldb::SBDebugger::Terminate(); } |
| 59 | |