Debugger: Fix regression introduced in hrev50534.
FunctionInstance: - Add new state FUNCTION_SOURCE_SUPPRESSED. This signals that the user explicitly forced disassembly to be loaded despite source code being available. LoadSourceCodeJob: - When forced to disassembly, use the above suppressed state accordingly. SourceView/TeamWindow/TeamDebugger: - Adjust to take new state into account as needed. TeamDebugInfo::GetActiveSourceCode: - When looking at a function to decide whether to return line information based on source or disassembly, first examine the source code state. If the source has never been loaded for that function, but we have it available, set it on the function at that point. This lazily addresses the fact that LoadSourceCodeJob is called on behalf of a specific function, and consequently only sets the source code onto that function, and not all others present in the same file. This allows us to differentiate between the case where a function doesn't have source code available at all, versus a function that has simply been forced to disassembly view at this point in time. The primary symptom of the above issue was that attempting to set a breakpoint outside of the currently active function, but within the same file would result in the breakpoints view indicating that the breakpoint was at line 0 rather than the appropriate line, and breakpoints would also not be drawn in the source view for such locations. Thanks to Humdinger for the heads up!
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2016, Rene Gollent, [email protected].
|
||||
* 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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009-2012, Ingo Weinhold, [email protected].
|
||||
* Copyright 2009-2014, Rene Gollent, [email protected].
|
||||
* Copyright 2009-2016, Rene Gollent, [email protected].
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -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 '");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user