Extend FunctionSourceCodeRequested().

Now takes an optional boolean parameter to indicate that disassembly is
explicitly being requested. Adjust TeamDebugger and LoadSourceCodeJob's
implementations accordingly.
This commit is contained in:
Rene Gollent 2013-06-22 12:51:27 -04:00
parent 26a4510e59
commit 442f71a7d9
4 changed files with 25 additions and 6 deletions

View File

@ -762,22 +762,27 @@ TeamDebugger::SourceEntryLocateRequested(const char* sourcePath,
void void
TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance) TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance,
bool forceDisassembly)
{ {
Function* function = functionInstance->GetFunction(); Function* function = functionInstance->GetFunction();
// mark loading // mark loading
AutoLocker< ::Team> locker(fTeam); AutoLocker< ::Team> locker(fTeam);
if (functionInstance->SourceCodeState() != FUNCTION_SOURCE_NOT_LOADED) if (forceDisassembly && functionInstance->SourceCodeState()
!= FUNCTION_SOURCE_NOT_LOADED) {
return; return;
if (function->SourceCodeState() == FUNCTION_SOURCE_LOADED) } else if (!forceDisassembly && function->SourceCodeState()
== FUNCTION_SOURCE_LOADED) {
return; return;
}
functionInstance->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); functionInstance->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING);
bool loadForFunction = false; bool loadForFunction = false;
if (function->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED) { if (!forceDisassembly && function->SourceCodeState()
== FUNCTION_SOURCE_NOT_LOADED) {
loadForFunction = true; loadForFunction = true;
function->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); function->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING);
} }

View File

@ -59,7 +59,8 @@ public:
private: private:
// UserInterfaceListener // UserInterfaceListener
virtual void FunctionSourceCodeRequested( virtual void FunctionSourceCodeRequested(
FunctionInstance* function); FunctionInstance* function,
bool forceDisassembly = false);
virtual void SourceEntryLocateRequested( virtual void SourceEntryLocateRequested(
const char* sourcePath, const char* sourcePath,
const char* locatedPath); const char* locatedPath);

View File

@ -82,6 +82,18 @@ LoadSourceCodeJob::Do()
locker.Lock(); locker.Lock();
if (error == B_OK) { if (error == B_OK) {
if (fFunctionInstance->SourceCodeState() == FUNCTION_SOURCE_LOADING) { 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, fFunctionInstance->SetSourceCode(sourceCode,
FUNCTION_SOURCE_LOADED); FUNCTION_SOURCE_LOADED);
sourceCode->ReleaseReference(); sourceCode->ReleaseReference();

View File

@ -82,7 +82,8 @@ public:
virtual ~UserInterfaceListener(); virtual ~UserInterfaceListener();
virtual void FunctionSourceCodeRequested( virtual void FunctionSourceCodeRequested(
FunctionInstance* function) = 0; FunctionInstance* function,
bool forceDisassembly = false) = 0;
virtual void SourceEntryLocateRequested( virtual void SourceEntryLocateRequested(
const char* sourcePath, const char* sourcePath,
const char* locatedPath) = 0; const char* locatedPath) = 0;