diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index d084e22f6e..d551bd0859 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -820,6 +820,15 @@ TeamDebugger::SourceEntryLocateRequested(const char* sourcePath, } +void +TeamDebugger::SourceEntryInvalidateRequested(LocatableFile* sourceFile) +{ + AutoLocker< ::Team> locker(fTeam); + + fTeam->DebugInfo()->ClearSourceCode(sourceFile); +} + + void TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance, bool forceDisassembly) diff --git a/src/apps/debugger/controllers/TeamDebugger.h b/src/apps/debugger/controllers/TeamDebugger.h index 46fa880378..d48c8487f6 100644 --- a/src/apps/debugger/controllers/TeamDebugger.h +++ b/src/apps/debugger/controllers/TeamDebugger.h @@ -66,6 +66,8 @@ private: virtual void SourceEntryLocateRequested( const char* sourcePath, const char* locatedPath); + virtual void SourceEntryInvalidateRequested( + LocatableFile* sourceFile); virtual void ImageDebugInfoRequested(Image* image); virtual void ValueNodeValueRequested(CpuState* cpuState, ValueNodeContainer* container, diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index 00b174e0fa..1cdb1934f0 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -546,6 +546,17 @@ TeamDebugInfo::LoadSourceCode(LocatableFile* file, FileSourceCode*& _sourceCode) } +void +TeamDebugInfo::ClearSourceCode(LocatableFile* sourceFile) +{ + AutoLocker locker(fLock); + + SourceFileEntry* entry = fSourceFiles->Lookup(sourceFile); + if (entry != NULL) + entry->SetSourceCode(NULL); +} + + status_t TeamDebugInfo::DisassembleFunction(FunctionInstance* functionInstance, DisassembledCode*& _sourceCode) diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.h b/src/apps/debugger/debug_info/TeamDebugInfo.h index 884a1a36c7..b3dff5ed38 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.h +++ b/src/apps/debugger/debug_info/TeamDebugInfo.h @@ -62,6 +62,8 @@ public: status_t LoadSourceCode(LocatableFile* file, FileSourceCode*& _sourceCode); // returns reference + void ClearSourceCode(LocatableFile* file); + status_t DisassembleFunction( FunctionInstance* functionInstance, DisassembledCode*& _sourceCode); diff --git a/src/apps/debugger/files/FileManager.cpp b/src/apps/debugger/files/FileManager.cpp index 797437e96a..33be50f06b 100644 --- a/src/apps/debugger/files/FileManager.cpp +++ b/src/apps/debugger/files/FileManager.cpp @@ -646,6 +646,14 @@ FileManager::SourceEntryLocated(const BString& path, const BString& locatedPath) { AutoLocker locker(this); + + // check if we already have this path mapped. If so, + // first clear the mapping, as the user may be attempting + // to correct an existing entry. + SourceFileEntry* entry = _LookupSourceFile(path); + if (entry != NULL) + _SourceFileUnused(entry); + fSourceDomain->EntryLocated(path, locatedPath); try { diff --git a/src/apps/debugger/user_interface/UserInterface.h b/src/apps/debugger/user_interface/UserInterface.h index 5eb9c2be49..50e293ef7b 100644 --- a/src/apps/debugger/user_interface/UserInterface.h +++ b/src/apps/debugger/user_interface/UserInterface.h @@ -20,6 +20,7 @@ class entry_ref; class CpuState; class FunctionInstance; class Image; +class LocatableFile; class StackFrame; class Team; class TeamUiSettings; @@ -92,6 +93,8 @@ public: virtual void SourceEntryLocateRequested( const char* sourcePath, const char* locatedPath) = 0; + virtual void SourceEntryInvalidateRequested( + LocatableFile* sourceFile) = 0; virtual void ImageDebugInfoRequested(Image* image) = 0; virtual void ValueNodeValueRequested(CpuState* cpuState, ValueNodeContainer* container, diff --git a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp index c10c6947d3..c554974326 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -1620,6 +1620,11 @@ TeamWindow::_HandleResolveMissingSourceFile(entry_ref& locatedPath) if (choice <= 0) return; } + + LocatableFile* foundSourceFile = fActiveSourceCode + ->GetSourceFile(); + if (foundSourceFile != NULL) + fListener->SourceEntryInvalidateRequested(foundSourceFile); fListener->SourceEntryLocateRequested(sourcePath, targetFilePath.Path()); fListener->FunctionSourceCodeRequested(fActiveFunction); @@ -1637,8 +1642,6 @@ TeamWindow::_HandleLocateSourceRequest(BStringList* entries) return; else if (fActiveSourceCode == NULL) return; - else if (fActiveSourceCode->GetSourceFile() != NULL) - return; else if (fActiveFunction->GetFunction()->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED) { return;