From 442f71a7d9240b994c8b22ea24443a7e84eb8fc9 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 22 Jun 2013 12:51:27 -0400 Subject: [PATCH] Extend FunctionSourceCodeRequested(). Now takes an optional boolean parameter to indicate that disassembly is explicitly being requested. Adjust TeamDebugger and LoadSourceCodeJob's implementations accordingly. --- src/apps/debugger/controllers/TeamDebugger.cpp | 13 +++++++++---- src/apps/debugger/controllers/TeamDebugger.h | 3 ++- src/apps/debugger/jobs/LoadSourceCodeJob.cpp | 12 ++++++++++++ src/apps/debugger/user_interface/UserInterface.h | 3 ++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index 25ab2314d0..7974368833 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -762,22 +762,27 @@ TeamDebugger::SourceEntryLocateRequested(const char* sourcePath, void -TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance) +TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance, + bool forceDisassembly) { Function* function = functionInstance->GetFunction(); // mark loading AutoLocker< ::Team> locker(fTeam); - if (functionInstance->SourceCodeState() != FUNCTION_SOURCE_NOT_LOADED) + if (forceDisassembly && functionInstance->SourceCodeState() + != FUNCTION_SOURCE_NOT_LOADED) { return; - if (function->SourceCodeState() == FUNCTION_SOURCE_LOADED) + } else if (!forceDisassembly && function->SourceCodeState() + == FUNCTION_SOURCE_LOADED) { return; + } functionInstance->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); bool loadForFunction = false; - if (function->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED) { + if (!forceDisassembly && function->SourceCodeState() + == FUNCTION_SOURCE_NOT_LOADED) { loadForFunction = true; function->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); } diff --git a/src/apps/debugger/controllers/TeamDebugger.h b/src/apps/debugger/controllers/TeamDebugger.h index f236f428a9..3aa5f1f90f 100644 --- a/src/apps/debugger/controllers/TeamDebugger.h +++ b/src/apps/debugger/controllers/TeamDebugger.h @@ -59,7 +59,8 @@ public: private: // UserInterfaceListener virtual void FunctionSourceCodeRequested( - FunctionInstance* function); + FunctionInstance* function, + bool forceDisassembly = false); virtual void SourceEntryLocateRequested( const char* sourcePath, const char* locatedPath); diff --git a/src/apps/debugger/jobs/LoadSourceCodeJob.cpp b/src/apps/debugger/jobs/LoadSourceCodeJob.cpp index 4cb60a0a31..402a9ab711 100644 --- a/src/apps/debugger/jobs/LoadSourceCodeJob.cpp +++ b/src/apps/debugger/jobs/LoadSourceCodeJob.cpp @@ -82,6 +82,18 @@ LoadSourceCodeJob::Do() locker.Lock(); if (error == B_OK) { if (fFunctionInstance->SourceCodeState() == FUNCTION_SOURCE_LOADING) { + // various parts of the debugger expect functions to have only + // one of source or disassembly available. As such, if the current + // function had source code previously active, unset it when + // explicitly asked for disassembly. This needs to be done first + // since Function will clear the disassembled code states of all + // its child instances. + if (function->SourceCodeState() == FUNCTION_SOURCE_LOADED) { + FileSourceCode* sourceCode = function->GetSourceCode(); + function->SetSourceCode(sourceCode, + FUNCTION_SOURCE_NOT_LOADED); + } + fFunctionInstance->SetSourceCode(sourceCode, FUNCTION_SOURCE_LOADED); sourceCode->ReleaseReference(); diff --git a/src/apps/debugger/user_interface/UserInterface.h b/src/apps/debugger/user_interface/UserInterface.h index fa95fe823c..20d9db09be 100644 --- a/src/apps/debugger/user_interface/UserInterface.h +++ b/src/apps/debugger/user_interface/UserInterface.h @@ -82,7 +82,8 @@ public: virtual ~UserInterfaceListener(); virtual void FunctionSourceCodeRequested( - FunctionInstance* function) = 0; + FunctionInstance* function, + bool forceDisassembly = false) = 0; virtual void SourceEntryLocateRequested( const char* sourcePath, const char* locatedPath) = 0;