diff --git a/headers/private/debugger/debug_info/FunctionInstance.h b/headers/private/debugger/debug_info/FunctionInstance.h index 6af6832b21..11d8f67cd9 100644 --- a/headers/private/debugger/debug_info/FunctionInstance.h +++ b/headers/private/debugger/debug_info/FunctionInstance.h @@ -1,5 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef FUNCTION_INSTANCE_H @@ -14,7 +15,8 @@ enum function_source_state { FUNCTION_SOURCE_NOT_LOADED, FUNCTION_SOURCE_LOADING, FUNCTION_SOURCE_LOADED, - FUNCTION_SOURCE_UNAVAILABLE + FUNCTION_SOURCE_UNAVAILABLE, + FUNCTION_SOURCE_SUPPRESSED }; diff --git a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp index fdb93281f5..98e90e73a6 100644 --- a/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/SourceView.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2009-2014, Rene Gollent, rene@gollent.com. + * Copyright 2009-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -2140,8 +2140,9 @@ SourceView::MessageReceived(BMessage* message) code = instance->GetSourceCode(); } else { Function* function = instance->GetFunction(); - if (function->SourceCodeState() - == FUNCTION_SOURCE_NOT_LOADED) { + if (function->SourceCodeState() == FUNCTION_SOURCE_NOT_LOADED + || function->SourceCodeState() + == FUNCTION_SOURCE_SUPPRESSED) { fListener->FunctionSourceCodeRequested(instance, false); break; } 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 7116614860..f5898698b7 100644 --- a/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/TeamWindow.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2010-2015, Rene Gollent, rene@gollent.com. + * Copyright 2010-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -1535,8 +1535,11 @@ TeamWindow::_UpdateSourcePathState() if (sourceFile != NULL && !sourceFile->GetLocatedPath(sourceText)) sourceFile->GetPath(sourceText); - if (fActiveFunction->GetFunction()->SourceCodeState() - != FUNCTION_SOURCE_NOT_LOADED + function_source_state state = fActiveFunction->GetFunction() + ->SourceCodeState(); + if (state == FUNCTION_SOURCE_SUPPRESSED) + sourceText.Prepend("Disassembly for: "); + else if (state != FUNCTION_SOURCE_NOT_LOADED && fActiveSourceCode->GetSourceFile() == NULL && sourceFile != NULL) { sourceText.Prepend("Click to locate source file '"); diff --git a/src/kits/debugger/controllers/TeamDebugger.cpp b/src/kits/debugger/controllers/TeamDebugger.cpp index e47500185e..faf3944573 100644 --- a/src/kits/debugger/controllers/TeamDebugger.cpp +++ b/src/kits/debugger/controllers/TeamDebugger.cpp @@ -1008,8 +1008,9 @@ TeamDebugger::FunctionSourceCodeRequested(FunctionInstance* functionInstance, functionInstance->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); bool loadForFunction = false; - if (!forceDisassembly && function->SourceCodeState() - == FUNCTION_SOURCE_NOT_LOADED) { + if (!forceDisassembly && (function->SourceCodeState() + == FUNCTION_SOURCE_NOT_LOADED + || function->SourceCodeState() == FUNCTION_SOURCE_SUPPRESSED)) { loadForFunction = true; function->SetSourceCode(NULL, FUNCTION_SOURCE_LOADING); } diff --git a/src/kits/debugger/debug_info/TeamDebugInfo.cpp b/src/kits/debugger/debug_info/TeamDebugInfo.cpp index 1736a19713..5ed9ba1e88 100644 --- a/src/kits/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/kits/debugger/debug_info/TeamDebugInfo.cpp @@ -487,10 +487,30 @@ TeamDebugInfo::GetActiveSourceCode(FunctionDebugInfo* info, SourceCode*& _code) Function* function = FunctionAtSourceLocation(file, info->SourceStartLocation()); if (function != NULL) { + function_source_state state = function->SourceCodeState(); if (function->SourceCodeState() == FUNCTION_SOURCE_LOADED) { _code = function->GetSourceCode(); _code->AcquireReference(); return B_OK; + } else if (state == FUNCTION_SOURCE_NOT_LOADED) { + // if the function's source state is not loaded, check + // if we already know the file anyways. Currently, when + // a source code job runs, it does so on behalf of a specific + // function, and consequently only sets the loaded source code + // on that particular function at that point in time, rather + // than all others sharing that same file. Consequently, + // set it lazily here. + SourceFileEntry* entry = fSourceFiles->Lookup(file); + if (entry != NULL) { + FileSourceCode* sourceCode = entry->GetSourceCode(); + if (sourceCode != NULL) { + function->SetSourceCode(sourceCode, + FUNCTION_SOURCE_LOADED); + _code = sourceCode; + _code->AcquireReference(); + return B_OK; + } + } } } } diff --git a/src/kits/debugger/jobs/LoadSourceCodeJob.cpp b/src/kits/debugger/jobs/LoadSourceCodeJob.cpp index 6265a03ff3..517ee64e0f 100644 --- a/src/kits/debugger/jobs/LoadSourceCodeJob.cpp +++ b/src/kits/debugger/jobs/LoadSourceCodeJob.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012, Rene Gollent, rene@gollent.com. + * Copyright 2012-2016, Rene Gollent, rene@gollent.com. * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -94,11 +94,11 @@ LoadSourceCodeJob::Do() if (function->SourceCodeState() == FUNCTION_SOURCE_LOADED) { FileSourceCode* sourceCode = function->GetSourceCode(); function->SetSourceCode(sourceCode, - FUNCTION_SOURCE_NOT_LOADED); + FUNCTION_SOURCE_SUPPRESSED); } fFunctionInstance->SetSourceCode(sourceCode, - FUNCTION_SOURCE_LOADED); + FUNCTION_SOURCE_SUPPRESSED); sourceCode->ReleaseReference(); } } else