MCPcopy Create free account
hub / github.com/Vector35/debugger / CreateDebugAdapter

Method CreateDebugAdapter

core/debuggercontroller.cpp:265–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263
264
265bool DebuggerController::CreateDebugAdapter()
266{
267 // The current adapter type is the same as the last one, and the last adapter is still valid
268 if (m_state->GetAdapterType() == m_lastAdapterName && m_adapter != nullptr)
269 {
270 ApplyBreakpoints();
271 return true;
272 }
273
274 DebugAdapterType* type = DebugAdapterType::GetByName(m_state->GetAdapterType());
275 if (!type)
276 {
277 LogWarn("Failed to get an debug adapter of type %s", m_state->GetAdapterType().c_str());
278 return false;
279 }
280 m_adapter = type->Create(GetData());
281 if (!m_adapter)
282 {
283 LogWarn("Failed to create an adapter of type %s", m_state->GetAdapterType().c_str());
284 return false;
285 }
286
287 if (!m_adapter->Init())
288 {
289 LogWarn("Failed to init an adapter of type %s", m_state->GetAdapterType().c_str());
290 return false;
291 }
292
293 m_lastAdapterName = m_state->GetAdapterType();
294 m_state->SetAdapter(m_adapter);
295
296 ApplyBreakpoints();
297
298 // Forward the DebuggerEvent from the adapters to the controller
299 m_adapter->SetEventCallback([this](const DebuggerEvent& event) { PostDebuggerEvent(event); });
300 return true;
301}
302
303
304// Apply all breakpoints that are added before the adapter is created

Callers

nothing calls this directly

Calls 5

SetEventCallbackMethod · 0.80
GetAdapterTypeMethod · 0.45
CreateMethod · 0.45
InitMethod · 0.45
SetAdapterMethod · 0.45

Tested by

no test coverage detected