diff --git a/core/debuggercontroller.cpp b/core/debuggercontroller.cpp index 6577ff1..c50eb26 100644 --- a/core/debuggercontroller.cpp +++ b/core/debuggercontroller.cpp @@ -118,6 +118,7 @@ bool DebuggerController::Launch() if (!CreateDebugAdapter()) return false; + m_inputFileLoaded = false; m_state->MarkDirty(); bool result = Execute(); if (result) @@ -144,6 +145,7 @@ bool DebuggerController::Attach(int32_t pid) if (!CreateDebugAdapter()) return false; + m_inputFileLoaded = false; m_state->MarkDirty(); bool result = m_adapter->Attach(pid); if (result) @@ -640,7 +642,10 @@ void DebuggerController::DetectLoadedModule() { // Rebase the binary and create DebugView uint64_t remoteBase; - if (!m_state->GetRemoteBase(remoteBase)) + // Right now we only support applying the analysis info from one module into the debugger view, So we use a bool + // here. In the future, we would like to support loading multiple modules, and we will need a more + // robust mechanism. + if (m_inputFileLoaded || (!m_state->GetRemoteBase(remoteBase))) return; FileMetadataRef fileMetadata = m_data->GetFile(); @@ -663,6 +668,8 @@ void DebuggerController::DetectLoadedModule() }); if (!ok) LogWarn("create snapshoted view failed"); + + m_inputFileLoaded = true; } @@ -733,6 +740,7 @@ void DebuggerController::Connect() if (!CreateDebugAdapter()) return; + m_inputFileLoaded = false; m_state->MarkDirty(); m_state->SetConnectionStatus(DebugAdapterConnectingStatus); diff --git a/core/debuggercontroller.h b/core/debuggercontroller.h index 053eb9f..5785db3 100644 --- a/core/debuggercontroller.h +++ b/core/debuggercontroller.h @@ -90,6 +90,8 @@ namespace BinaryNinjaDebugger { bool m_lastAdapterStopEventConsumed = true; + bool m_inputFileLoaded = false; + void EventHandler(const DebuggerEvent& event); void UpdateStackVariables(); void AddRegisterValuesToExpressionParser(); diff --git a/core/debuggerstate.cpp b/core/debuggerstate.cpp index b531f74..ec813d5 100644 --- a/core/debuggerstate.cpp +++ b/core/debuggerstate.cpp @@ -320,6 +320,9 @@ bool DebuggerModules::GetModuleBase(const std::string& name, uint64_t& address) if (IsDirty()) Update(); + if (name.empty()) + return false; + for (const DebugModule& module : m_modules) { if (module.IsSameBaseModule(name))