Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 274951 - [menu][cdi] Add Watch action to C/C++ Editor
Summary: [menu][cdi] Add Watch action to C/C++ Editor
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 6.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 7.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-05 04:13 EDT by Anton Leherbauer CLA
Modified: 2010-05-28 12:20 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leherbauer CLA 2009-05-05 04:13:05 EDT
The Watch action in the editor is only visible when the system property
"org.eclipse.cdt.debug.ui.debuggerActive" is set to true.
The CDI debugger sets this property when a session is active.
The action implementation is actually pretty much agnostic of the debugger,
so I think it could be reused for DSF-GDB, provided there is a test
whether a DFS-GDB session is active.
Comment 1 Marc Khouzam CLA 2009-05-05 08:45:04 EDT
Nice find!
Comment 2 Pawel Piech CLA 2009-05-05 12:56:56 EDT
Toni, should the org.eclipse.cdt.debug.ui.debuggerActive system property be a count instead of the boolean, so that DSF-GDB as well as other debuggers be able to use it?  
Comment 3 Anton Leherbauer CLA 2009-05-06 02:37:13 EDT
(In reply to comment #2)
> Toni, should the org.eclipse.cdt.debug.ui.debuggerActive system property be a
> count instead of the boolean, so that DSF-GDB as well as other debuggers be
> able to use it?  

I don't think DSF-GDB should use it at all, because it also triggers the visibility of other actions and at least some of them are not (yet) supported by / compatible with DSF-GDB.

DSF-GDB could use a different system property or better use a different method of controlling the visibility of the action (e.g. using org.eclipse.ui.menus).
Comment 4 Marc-André Laperle CLA 2010-02-07 02:53:32 EST
(In reply to comment #0)
> The Watch action in the editor is only visible when the system property
> "org.eclipse.cdt.debug.ui.debuggerActive" is set to true.

Is there a reason it's not always visible? The action could be moved in a new view contribution that does not require an active debug session. It seems natural to me to leave the action visible since there is nothing preventing the user from adding an expression through the Expressions view when there is no debug session active.
Comment 5 Anton Leherbauer CLA 2010-02-08 03:17:09 EST
(In reply to comment #4)
> Is there a reason it's not always visible?

I can think of two reasons:
1. This is how the JDT Debugger works
2. The editor context menu is already very cluttered

I think we should continue to hide debug actions in the editor context menu unless a debug session is active.
Comment 6 Marc-André Laperle CLA 2010-02-08 09:46:18 EST
(In reply to comment #5)
> (In reply to comment #4)
> > Is there a reason it's not always visible?
> 
> I can think of two reasons:
> 1. This is how the JDT Debugger works
> 2. The editor context menu is already very cluttered
> 
> I think we should continue to hide debug actions in the editor context menu
> unless a debug session is active.

Ok, thanks.
Comment 7 Marc Khouzam CLA 2010-02-12 22:07:54 EST
I have fixed this bug as part of bug 300096.

However, I was not able to use the existing org.eclipse.cdt.debug.ui.debuggerActive but instead I had to copy the code that set/unset it and create a new system property org.eclipse.cdt.dsf.gdb.ui.debuggerActive.

The reason I couldn't re-use it is that the class that sets/unsets it (EvaluationContextManager) needs the selection to be adaptable to ICDebugTarget.  I wanted to also check for the selection to be an IDMVMNode, but of course, I can't do that in cdt.debug.ui, so I had to copy that code to cdt.dsf.gdb.ui.

If you guys have a way to re-use the class for both debugger integration, that would be great.  If not, then it may be worth moving the new EvaluationContextManager to DSF itself, so as to all others to use that visibility trick.