Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342141 - Executables view content goes stale in various scenarios
Summary: Executables view content goes stale in various scenarios
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 8.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: John Cortell CLA
QA Contact: Ken Ryall CLA
URL:
Whiteboard:
Keywords:
: 341542 341838 (view as bug list)
Depends on: 160728
Blocks:
  Show dependency tree
 
Reported: 2011-04-07 07:41 EDT by John Cortell CLA
Modified: 2011-05-19 20:40 EDT (History)
4 users (show)

See Also:
ken.ryall: review+


Attachments
Fix should pass this suite 100% (5.75 KB, text/plain)
2011-04-07 07:41 EDT, John Cortell CLA
no flags Details
Setup for test suite (556 bytes, application/x-zip-compressed)
2011-04-07 07:46 EDT, John Cortell CLA
no flags Details
Fix should pass this suite 100% (8.37 KB, text/plain)
2011-04-13 18:20 EDT, John Cortell CLA
no flags Details
Fix (94.42 KB, patch)
2011-04-13 18:47 EDT, John Cortell CLA
john.cortell: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Cortell CLA 2011-04-07 07:41:14 EDT
In looking at bug 341542, I found various other scenarios where the Executables view fails to update. I'm going to address all of these in bulk.

I've attached a manual test suite with the scenarios I could think of (some work, some don't). The solution or any tweaks in the future to this logic should be validated with the suite. Also, as more scenarios are found, the test suite shold be extended. Unfortunately, there are no automated tests for the Executables view in the CDT repository (I think Nokia may have some non-contributed ones). Unfortunately, I don't have the time to code up such an automated suite using pure junit; if SWTBot was part of the standard environment, I would. 

The test suite points out what scenarios are currently failing
Comment 1 John Cortell CLA 2011-04-07 07:41:56 EDT
Created attachment 192722 [details]
Fix should pass this suite 100%
Comment 2 John Cortell CLA 2011-04-07 07:46:59 EDT
Created attachment 192723 [details]
Setup for test suite

The test suite requires having the mingw toolchain and running a small script to compile some files into various programs. Instructions are in the test suite. The test suite and this setup is specific to a Windows environment, though the steps could easily be followed in other platforms with slight adjustments
Comment 3 John Cortell CLA 2011-04-13 18:20:42 EDT
Created attachment 193203 [details]
Fix should pass this suite 100%

Additional test cases
Comment 4 John Cortell CLA 2011-04-13 18:45:35 EDT
The attached fix makes extensive changes, as there are a lot of deficiencies and bugs in the current implementation. Below is a summary of those issues. I've attached a fairly extensive manual test. This fix passes 100% of the cases. Many of the cases fail with the current code.

* There's caching done at various levels and those caches are not being invalidated properly. The fact that adding a file to a project and rebuilding it doesn't cause the Executables view's right pane to update is the most obvious failure.

* ExecutablesManager should react to CDT model events, not platform resource events. The latter results in race condition failures, since the Executables view relies on getting state from the CDT model. Reacting to a platform resource change then asynchronously running code that queries the CDT model is problematic since the CDT model itself is reacting to platform resource changes. We need to let the CDT model update first and then react to its delta notifications. 

* Viewers should not themselves listen for model changes and force a refresh. They technically should know little to nothing about the model. A viewer’s content/label providers are responsible for keeping tabs on the model and asking the viewer to refresh as needed.

* There's a lot of state manipulation on arbitrary threads, involving multiple locks. This not only requires careful crafting of the code to avoid deadlocks, but the resulting logic is prone to inconsistencies. These states can and should be updated on the UI thread, as the code involved is lightweight. Heavy operations (looking for executables, parsing them, mapping source files) should be done in asynchronous jobs, and this fix keeps it that way. By doing the lightweight state manipulation strictly on the UI thread, no locks are needed and the code can ensure all related states are updated in consistent and predictable ways.

* Canceling an executable parse, though not yet supported by the dwarf reader, is not well supported by the viewer itself. The viewer should expect that the user may cancel the parse and the UI should react in an appropriate way. For starters, the canceling of a parse should leave the right pane with a cue that the parse was canceled and not show partial results. Secondly, the user should be able to restart the parse via the refresh button. The attached fix adds both of these behaviors.

Other issues and enhancements: 

* use of launch config reference  as key in CSourceFinder map is problematic and unnecessary. Use launch config name instead, as that is unique

* added new interface to allow executable listener to determine specifically when an executable has been added vs removed. Currently, they can only tell that the list has changed.

* WorkbenchJobs should be used instead of Display.asyncExec

* Improved tracing.
Comment 5 John Cortell CLA 2011-04-13 18:47:09 EDT
Created attachment 193208 [details]
Fix
Comment 6 John Cortell CLA 2011-04-14 10:08:55 EDT
*** Bug 341838 has been marked as a duplicate of this bug. ***
Comment 7 John Cortell CLA 2011-04-14 10:11:37 EDT
*** Bug 341542 has been marked as a duplicate of this bug. ***
Comment 8 Ken Ryall CLA 2011-04-14 15:34:23 EDT
Nice work and great conceptual overview and cleanup. I'm going to produce a build of Carbide with these changes and try it out, but I think this looks good to go.
Comment 9 John Cortell CLA 2011-04-14 16:31:37 EDT
Thanks for the review. Committed to HEAD.
Comment 10 CDT Genie CLA 2011-04-14 17:23:09 EDT
*** cdt cvs genie on behalf of jcortell ***
Bug 342141 - Executables view content goes stale in various scenarios

[*] Messages.properties 1.2 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/Messages.properties?root=Tools_Project&r1=1.1&r2=1.2
[*] ExecutablesViewer.java 1.9 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesViewer.java?root=Tools_Project&r1=1.8&r2=1.9
[*] Messages.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/Messages.java?root=Tools_Project&r1=1.7&r2=1.8
[*] SourceFilesViewer.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesViewer.java?root=Tools_Project&r1=1.7&r2=1.8
[*] ExecutablesContentProvider.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesContentProvider.java?root=Tools_Project&r1=1.7&r2=1.8
[*] ExecutablesView.java 1.10 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/ExecutablesView.java?root=Tools_Project&r1=1.9&r2=1.10
[*] SourceFilesContentProvider.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/executables/SourceFilesContentProvider.java?root=Tools_Project&r1=1.7&r2=1.8

[*] CSourceFinder.java 1.6 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/srcfinder/CSourceFinder.java?root=Tools_Project&r1=1.5&r2=1.6

[+] IExecutablesChangeListener2.java  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener2.java?root=Tools_Project&revision=1.1&view=markup
[*] IExecutablesChangeListener.java 1.4 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/IExecutablesChangeListener.java?root=Tools_Project&r1=1.3&r2=1.4
[*] Executable.java 1.15 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/Executable.java?root=Tools_Project&r1=1.14&r2=1.15
[*] ExecutablesManager.java 1.17 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java?root=Tools_Project&r1=1.16&r2=1.17

[*] StandardSourceFilesProvider.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardSourceFilesProvider.java?root=Tools_Project&r1=1.4&r2=1.5
[*] StandardExecutableImporter.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/executables/StandardExecutableImporter.java?root=Tools_Project&r1=1.4&r2=1.5
Comment 11 Teodor Madan CLA 2011-04-15 11:23:25 EDT
John, I have updated the source and have an API breakage that would force to upgrade "org.eclipse.cdt.debug.core" to version 8.0.0.

This is due to a public considered class ExecutablesManager no longer implementing IResourceChangeListener.
Comment 12 John Cortell CLA 2011-04-15 11:29:49 EDT
Strange. The API Tooling did not flag that. I'll reintroduce the method/interface and just no-op it (I won't be reintroducing the calls to register and deregister the listener).
Comment 13 John Cortell CLA 2011-04-15 11:51:17 EDT
(In reply to comment #12)
> Strange. The API Tooling did not flag that. I'll reintroduce the
> method/interface and just no-op it (I won't be reintroducing the calls to
> register and deregister the listener).

Well, I double checked and the tooling is working in my workspace. If I remove the resourceChanged() method, I get:

The major version should be incremented in version 7.1.0.qualifier, since API breakage occurred since version 7.0.0.201006141710

Yet, it does not complain about the loss of the interface. Clearly it should. Hmmm...
Comment 14 Teodor Madan CLA 2011-04-15 12:07:27 EDT
(In reply to comment #13)
> Yet, it does not complain about the loss of the interface. Clearly it should.
> Hmmm...

You should check in workspace setting that "API Errors/Warnings -> API Compatibility -> Class -> The superinterface hierarchy has been reduce" is set to error.
Comment 15 CDT Genie CLA 2011-04-15 12:23:09 EDT
*** cdt cvs genie on behalf of jcortell ***
Bug 342141 - Executables view content goes stale in various scenarios [corrected inadvertent API breakage]

[*] ExecutablesManager.java 1.18 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java?root=Tools_Project&r1=1.17&r2=1.18
Comment 16 CDT Genie CLA 2011-05-12 14:23:06 EDT
*** cdt cvs genie on behalf of jcortell ***
Bug 342141 - Executables view content goes stale in various scenarios [Discovered inefficiency in new code. There's no need to research a project for executables when we've been able to determine that one or more specific Executable objects were removed. Just update the model and notify listeners.]

[*] ExecutablesManager.java 1.19 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/ExecutablesManager.java?root=Tools_Project&r1=1.18&r2=1.19
Comment 17 John Cortell CLA 2011-05-12 14:56:49 EDT
(In reply to comment #16)
BTW, I exercised the relevant parts of the manual test suite (attached to this bugzilla) and had no failures.
Comment 18 John Cortell CLA 2011-05-12 15:15:54 EDT
The fix uses IResource.getModificationStamp(), and is dependent on the enhancement in 160728 (committed a while back)