[haiku-commits] haiku: hrev50702 - src/kits/debugger/debug_info src/apps/debugger/user_interface/gui/team_window src/kits/debugger/controllers src/kits/debugger/jobs headers/private/debugger/debug_info

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Nov 2016 05:18:29 +0100 (CET)

hrev50702 adds 1 changeset to branch 'master'
old head: 2082b5d25f269acb1dee6e465806d72804fa2779
new head: a9d53d9e7e24ac82e150d792f05ea45bf8e497a1
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=a9d53d9e7e24+%5E2082b5d25f26

----------------------------------------------------------------------------

a9d53d9e7e24: 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!

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev50702
Commit:      a9d53d9e7e24ac82e150d792f05ea45bf8e497a1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a9d53d9e7e24
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Wed Nov 23 04:06:09 2016 UTC

----------------------------------------------------------------------------

6 files changed, 39 insertions(+), 12 deletions(-)
.../debugger/debug_info/FunctionInstance.h       |  4 +++-
.../gui/team_window/SourceView.cpp               |  7 ++++---
.../gui/team_window/TeamWindow.cpp               |  9 ++++++---
src/kits/debugger/controllers/TeamDebugger.cpp   |  5 +++--
src/kits/debugger/debug_info/TeamDebugInfo.cpp   | 20 ++++++++++++++++++++
src/kits/debugger/jobs/LoadSourceCodeJob.cpp     |  6 +++---

----------------------------------------------------------------------------

diff --git a/headers/private/debugger/debug_info/FunctionInstance.h 
b/headers/private/debugger/debug_info/FunctionInstance.h
index 6af6832..11d8f67 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@xxxxxx.
+ * Copyright 2016, Rene Gollent, rene@xxxxxxxxxxx.
  * 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 fdb9328..98e90e7 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@xxxxxx.
- * Copyright 2009-2014, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2009-2016, Rene Gollent, rene@xxxxxxxxxxx.
  * 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 7116614..f589869 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@xxxxxx.
- * Copyright 2010-2015, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2010-2016, Rene Gollent, rene@xxxxxxxxxxx.
  * 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 e475001..faf3944 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 1736a19..5ed9ba1 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 6265a03..517ee64 100644
--- a/src/kits/debugger/jobs/LoadSourceCodeJob.cpp
+++ b/src/kits/debugger/jobs/LoadSourceCodeJob.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012, Rene Gollent, rene@xxxxxxxxxxx.
+ * Copyright 2012-2016, Rene Gollent, rene@xxxxxxxxxxx.
  * Copyright 2009, Ingo Weinhold, ingo_weinhold@xxxxxx.
  * 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


Other related posts:

  • » [haiku-commits] haiku: hrev50702 - src/kits/debugger/debug_info src/apps/debugger/user_interface/gui/team_window src/kits/debugger/controllers src/kits/debugger/jobs headers/private/debugger/debug_info - anevilyak