Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 303968 - Move GDB MoveToLine, ResumeAtLine, RunToLine to DSF
Summary: Move GDB MoveToLine, ResumeAtLine, RunToLine to DSF
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf (show other bugs)
Version: 7.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Ken Ryall CLA
QA Contact: Pawel Piech CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-25 15:41 EST by Ken Ryall CLA
Modified: 2010-05-26 15:25 EDT (History)
4 users (show)

See Also:
john.cortell: review+
ken.ryall: review?
pawel.1.piech: review+


Attachments
Move actions to DSF (124.93 KB, patch)
2010-03-01 00:48 EST, Ken Ryall CLA
ken.ryall: iplog-
ken.ryall: review?
Details | Diff
Fix for GDB 7.0 (2.89 KB, patch)
2010-03-04 13:41 EST, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff
Some missing things (19.41 KB, patch)
2010-03-05 11:53 EST, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff
move editor and disassembly actions (28.52 KB, patch)
2010-05-25 03:52 EDT, Ken Ryall CLA
ken.ryall: iplog-
Details | Diff
Simplified fix based on email discussion (27.49 KB, patch)
2010-05-25 10:15 EDT, Marc Khouzam CLA
marc.khouzam: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Ryall CLA 2010-02-25 15:41:06 EST
Currently the implementations for the MoveToLine, ResumeAtLine, RunToLine actions are in dsf-gdb. Move these to dsf for use by other debuggers and create an IRunControl2 interface to support these.
Comment 1 Ken Ryall CLA 2010-03-01 00:48:56 EST
Created attachment 160449 [details]
Move actions to DSF

Moves actions from gdb ui to dsf ui and introduces IRunControl2 and implementation in dsf-gdb.
Comment 2 John Cortell CLA 2010-03-01 11:58:56 EST
Ken, some of this may related to Marc's changes rather than your refacorting:

1. Why are the to-line adapters using the to-address interfaces instead of to-line ones?. E.g., why is DisassemblyMoveToLineAdapter getting and using the IMoveToAddress adapter instead of the IMoveToLine one? This is going on consistently in all three adapters. Perhaps there's something I'm not getting, but this looks odd to me.

2. Should we be using DebugPlugin.getAdapter() instead of calling IAdaptable.getAdapter() directly (e.g., in DisassemblyMoveToLineAdapter.moveToLine())

3. In IRunControl2, javadoc for line number paramters should be explicit that they are 1-based. I'm not sure that we are doing so everywhere else, but we should, in my opinion. We should avoid ambiguity in public interfaces.

4. We shouldn't duplicate the javadoc for an interface in its implementations (see GDBRunControl_7_0_NS.runToLine(), e.g.). This increases maintenance efforts, and creates an opportunity for conflicting documentation. E.g., each IRunControl2's lengthy documentation is repeated three times throughout the code. The implementations should instead have the
	
	/* (non-Javadoc)
	 * @see org.eclipse.cdt....
	 */
	 
as generated by Source > Generate Element Comment
Comment 3 Ken Ryall CLA 2010-03-01 12:52:35 EST
(In reply to comment #2)
> Ken, some of this may related to Marc's changes rather than your refacorting:
> 
> 1. Why are the to-line adapters using the to-address interfaces instead of
> to-line ones?. E.g., why is DisassemblyMoveToLineAdapter getting and using the
> IMoveToAddress adapter instead of the IMoveToLine one? This is going on
> consistently in all three adapters. Perhaps there's something I'm not getting,
> but this looks odd to me.
> 
> 2. Should we be using DebugPlugin.getAdapter() instead of calling
> IAdaptable.getAdapter() directly (e.g., in
> DisassemblyMoveToLineAdapter.moveToLine())

I just moved the stuff that Marc had already created and didn't look at this closely. I propose I commit my refactoring and then we look at these issues separately.

> 3. In IRunControl2, javadoc for line number paramters should be explicit that
> they are 1-based. I'm not sure that we are doing so everywhere else, but we
> should, in my opinion. We should avoid ambiguity in public interfaces.

Good point, I'll add that.
> 
> 4. We shouldn't duplicate the javadoc for an interface in its implementations
> (see GDBRunControl_7_0_NS.runToLine(), e.g.). This increases maintenance
> efforts, and creates an opportunity for conflicting documentation. E.g., each
> IRunControl2's lengthy documentation is repeated three times throughout the
> code. The implementations should instead have the
> 
>     /* (non-Javadoc)
>      * @see org.eclipse.cdt....
>      */
> 
> as generated by Source > Generate Element Comment

Thanks, I wasn't sure what to do there, I'll change the doc in the services.
Comment 4 John Cortell CLA 2010-03-01 14:10:45 EST
(In reply to comment #3)
> I just moved the stuff that Marc had already created and didn't look at this
> closely. I propose I commit my refactoring and then we look at these issues
> separately.

Sounds good. We'll see what Marc says.
Comment 5 Ken Ryall CLA 2010-03-02 08:29:51 EST
Committed to HEAD.
Comment 6 Marc Khouzam CLA 2010-03-02 10:58:41 EST
(In reply to comment #1)
> Created an attachment (id=160449) [details]
> Move actions to DSF

Nice work Ken.  I like the interface better the way you did it.
Below are some minor (except the first one) comments:

1- Both GDBRunControl_7_0 and GDBRunControl_7_0_NS must also register with the IRunControl2 name.

2- in RunToLine.java, the top @since should be 2.1 and you can remove the couple of @since 2.1 that is within the file

3- In MIRunControl.java and GDBRunControl_7_0_NS.java, how about making resumeAtLocation() and runToLocation() private, now that you added a better interface? 

4- In MIRunControl.moveToLine and moveToAdress, I would suggest only creating the breakpoint in the (!resume) case, instead of all the time.  Same comment for GDBRunControl_7_0_NS.java

5- do we need some @since 3.0 tag in IMIRunControl since it now needs to implement the new IRunControl2 methods?  I'm not sure about that...

6- maybe rename SuspendResumeAdapterFactory.GdbSuspendResume to remove the 'Gdb'

7- in MoveToLine.moveToLine I don't think you need the empty DataRequestMonitor<Object> when calling IRunControl2.moveToLine, I believe you can use 'rm' directly.  Same comment for moveToAddress.  Same comment for file ResumeAtLine.java and RunToLine.java

8- in RunToLine.java, MoveToLine.java and ResumeAtLine.java, there is a recurring typo (probably mine); 'Faild' instead of 'Failed'

9- In MIRunControl and GDBRunControl_7_0_NS.java, to convert an address to a string you used address.toHexAddressString().  This call keeps all the leading 0's, which I found annoying when looking at the gdb traces.  Everywhere else you use address.toString(16) anyway, which I found to be nicer for the traces.
Comment 7 Marc Khouzam CLA 2010-03-02 13:13:50 EST
(In reply to comment #2)
> 1. Why are the to-line adapters using the to-address interfaces instead of
> to-line ones?. E.g., why is DisassemblyMoveToLineAdapter getting and using the
> IMoveToAddress adapter instead of the IMoveToLine one? This is going on
> consistently in all three adapters. Perhaps there's something I'm not getting,
> but this looks odd to me.

This is only done when dealing with the DisassemblyView.  Although I got inspired from another piece of code, I believe the reason is that a location in Disassembly cannot always be sourceFile:line; in the DisassemblyView, if you select an assembly line, it does not correspond to a sourceFile:line, so we always use an address.

> 2. Should we be using DebugPlugin.getAdapter() instead of calling
> IAdaptable.getAdapter() directly (e.g., in
> DisassemblyMoveToLineAdapter.moveToLine())

I copied that code from MoveToLineAdapter, which was already there.  But I believe you are right that we should use DebugPlugin.getAdapter() instead, in all those cases.
Comment 8 Marc Khouzam CLA 2010-03-02 13:14:28 EST
Last thing is that Pawel should give his ok for the IRunControl2 interface.
Comment 9 Pawel Piech CLA 2010-03-02 18:34:53 EST
(In reply to comment #8)
> Last thing is that Pawel should give his ok for the IRunControl2 interface.

I would request one clarification though: I assume that the "sourceFile" parameter refers to a source path that has been mapped by the source lookup to a debugger path... if there is a source lookup path mapping configured.
Comment 10 Marc Khouzam CLA 2010-03-04 13:41:24 EST
Created attachment 160995 [details]
Fix for GDB 7.0

(In reply to comment #6)

> 1- Both GDBRunControl_7_0 and GDBRunControl_7_0_NS must also register with the
> IRunControl2 name.

I've fixed this with the attached patch.  Without this, RunToLine, MoveToLine and ResumeAtLine no longer worked for GDB 7.0.

Committed to HEAD.

I did not address the other comments on this bug.
Comment 11 Ken Ryall CLA 2010-03-04 15:17:38 EST
(In reply to comment #10)
> Created an attachment (id=160995) [details]
> Fix for GDB 7.0
> 
> (In reply to comment #6)
> 
> > 1- Both GDBRunControl_7_0 and GDBRunControl_7_0_NS must also register with the
> > IRunControl2 name.
> 
> I've fixed this with the attached patch.  Without this, RunToLine, MoveToLine
> and ResumeAtLine no longer worked for GDB 7.0.
> 
> Committed to HEAD.
> 
> I did not address the other comments on this bug.

Thanks, I've been in meetings a lot and am just now addressing the other comments.
Comment 12 Marc Khouzam CLA 2010-03-04 15:24:05 EST
(In reply to comment #11)

> Thanks, I've been in meetings a lot and am just now addressing the other
> comments.

No problem
Comment 13 Ken Ryall CLA 2010-03-04 17:17:36 EST
Just committed changes that I think will address all of the comments. Thanks for all the feedback.
Comment 14 Marc Khouzam CLA 2010-03-05 09:26:12 EST
(In reply to comment #13)
> Just committed changes that I think will address all of the comments. Thanks
> for all the feedback.

Thanks Ken.
As a favor, can you attach to the bug any patch you will commit?  They are often useful for reference.  Also, I sometimes like to review the updates to a previous review, as it often makes other points come out.

Thanks
Comment 15 Marc Khouzam CLA 2010-03-05 11:53:17 EST
Created attachment 161136 [details]
Some missing things

I committed this patch to HEAD.
It adds a couple of missing cleanups.

Importantly though, it puts back the overridden resumeAtLocation() and runToLocation() in GDBRunControl and GDBRunControl_7_0.  When I suggested making those methods private in MIRunControl, I didn't realize they were being overridden.  For ResumeAtLine, the GDBRunControl_7_0 uses the new -exec-jump which MIRunControl cannot use since it didn't exist.  For RunToLine, GDBRunControl does the real work; MIRunControl uses -exec-until which is very limited; GDBRunControl uses temporary breakpoints instead (I had left MIRunControl as it was from the start, but I don't think we should use the -exec-until solution).
Comment 16 Ken Ryall CLA 2010-05-25 03:52:05 EDT
Created attachment 169777 [details]
move editor and disassembly actions

I found a little more to do here: While the re-targetable actions were
moved to DSF UI, the actions themselves contributing to the editor and
disassembly view were left behind in the DSF GDB UI plugin.  It took a small
refactoring but the patch basically just moves those actions and the enablement
class from the GDB plugin to the generic DSF UI plug-in.
Comment 17 Ken Ryall CLA 2010-05-25 03:53:44 EDT
Marc, can you take a look at this last bit as well?
Comment 18 Marc Khouzam CLA 2010-05-25 10:15:24 EDT
Created attachment 169833 [details]
Simplified fix based on email discussion

(In reply to comment #17)
> Marc, can you take a look at this last bit as well?

Sorry, there was some confusion about who was going to do this 
(see bug 300096 comment #29)

Also, a discussion on the mailing list made me realize I over-complicated the solution.  See http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg18539.html

So here is a suggested simpler approach that should do what we need.

Suggested changes are:

- re-use the registration of the 4 actions for the editor that is already done by CDT by simply setting the same system property to make them visible.  We no longer need to add them to dsf.ui/plugin.xml

- make dsf.ui/EvaluationContextManager use the same system property as base CDT to re-use the same action registration.

- move the 2 icons from dsf.gdb.ui to dsf.ui for the Disassembly view and make the dsf.ui/plugin.xml point to these new icons

- delete the watch_exp icon from dsf.gdb.ui since we will re-use base CDT's one.

Ken, I'll let you check this in if you agree with it.
Comment 19 Ken Ryall CLA 2010-05-25 14:49:09 EDT
Applied Marc's patch. Tested with GDB and EDC. Thanks - Marc.
Comment 20 CDT Genie CLA 2010-05-26 15:25:16 EDT
[cdt cvs genie] kryall: added file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/icons/move_to_line.gif?root=Tools_Project&revision=1.1&view=markup
[cdt cvs genie] kryall: added file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/icons/resume_at_line.gif?root=Tools_Project&revision=1.1&view=markup

[cdt cvs genie] kryall: added file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/EvaluationContextManager.java?root=Tools_Project&revision=1.1&view=markup

[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/plugin.properties?root=Tools_Project&r1=1.11&r2=1.12
[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/plugin.xml?root=Tools_Project&r1=1.18&r2=1.19

[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/internal/ui/DsfUIPlugin.java?root=Tools_Project&r1=1.5&r2=1.6

[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties?root=Tools_Project&r1=1.16&r2=1.17
[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml?root=Tools_Project&r1=1.36&r2=1.37

[cdt cvs genie] kryall: deleted  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/watch_exp.gif?root=Tools_Project&view=markup
[cdt cvs genie] kryall: deleted  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/move_to_line.gif?root=Tools_Project&view=markup
[cdt cvs genie] kryall: deleted  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/icons/full/obj16/resume_at_line.gif?root=Tools_Project&view=markup

[cdt cvs genie] kryall: changed file  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java?root=Tools_Project&r1=1.4&r2=1.5
[cdt cvs genie] kryall: deleted  http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/EvaluationContextManager.java?root=Tools_Project&view=markup