| 56 | |
| 57 | |
| 58 | bool DbgEngTTDAdapter::ExecuteWithArgsInternal(const std::string& path, const std::string& args, |
| 59 | const std::string& workingDir, const LaunchConfigurations& configs) { |
| 60 | m_aboutToBeKilled = false; |
| 61 | |
| 62 | if (this->m_debugActive) { |
| 63 | this->Reset(); |
| 64 | } |
| 65 | |
| 66 | if (!Start()) { |
| 67 | this->Reset(); |
| 68 | DebuggerEvent event; |
| 69 | event.type = LaunchFailureEventType; |
| 70 | event.data.errorData.error = fmt::format("Failed to initialize DbgEng"); |
| 71 | event.data.errorData.shortError = fmt::format("Failed to initialize DbgEng"); |
| 72 | PostDebuggerEvent(event); |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | if (const auto result = this->m_debugControl->SetEngineOptions(DEBUG_ENGOPT_INITIAL_BREAK); result != S_OK) { |
| 77 | this->Reset(); |
| 78 | DebuggerEvent event; |
| 79 | event.type = LaunchFailureEventType; |
| 80 | event.data.errorData.error = fmt::format("Failed to engine option DEBUG_ENGOPT_INITIAL_BREAK"); |
| 81 | event.data.errorData.shortError = fmt::format("Failed to engine option"); |
| 82 | PostDebuggerEvent(event); |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | if (const auto result = this->m_debugClient->OpenDumpFile(const_cast<char *>(path.c_str())); |
| 87 | result != S_OK) { |
| 88 | this->Reset(); |
| 89 | DebuggerEvent event; |
| 90 | event.type = LaunchFailureEventType; |
| 91 | event.data.errorData.error = fmt::format("OpenDumpFile failed: 0x{:x}", result); |
| 92 | event.data.errorData.shortError = fmt::format("OpenDumpFile failed: 0x{:x}", result); |
| 93 | PostDebuggerEvent(event); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | // The WaitForEvent() must be called once before the engine fully attaches to the target. |
| 98 | if (!Wait()) { |
| 99 | DebuggerEvent event; |
| 100 | event.type = LaunchFailureEventType; |
| 101 | event.data.errorData.error = fmt::format("WaitForEvent failed"); |
| 102 | event.data.errorData.shortError = fmt::format("WaitForEvent failed"); |
| 103 | PostDebuggerEvent(event); |
| 104 | } |
| 105 | |
| 106 | // Apply the breakpoints added before the m_debugClient is created |
| 107 | ApplyBreakpoints(); |
| 108 | |
| 109 | auto settings = Settings::Instance(); |
| 110 | if (settings->Get<bool>("debugger.stopAtEntryPoint") && m_hasEntryFunction) { |
| 111 | AddBreakpoint(ModuleNameAndOffset(configs.inputFile, m_entryPoint - m_start)); |
| 112 | } |
| 113 | |
| 114 | if (!settings->Get<bool>("debugger.stopAtSystemEntryPoint")) { |
| 115 | if (this->m_debugControl->SetExecutionStatus(DEBUG_STATUS_GO) != S_OK) { |
nothing calls this directly
no test coverage detected