Bug 285907 - [launch] Should GdbLaunchDelegate use AbstractCLaunchDelegate?
Summary: [launch] Should GdbLaunchDelegate use AbstractCLaunchDelegate?
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 normal (vote)
Target Milestone: 7.0   Edit
Assignee: Ken Ryall CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-06 12:26 EDT by Ken Ryall CLA
Modified: 2014-01-29 22:40 EST (History)
4 users (show)

See Also:
marc.khouzam: review+
ken.ryall: review+


Attachments
launch delegate refactoring (22.91 KB, patch)
2010-03-01 07:49 EST, Ken Ryall CLA
ken.ryall: iplog-
Details | Diff
main tab (61.45 KB, patch)
2010-03-08 21:34 EST, Ken Ryall CLA
cdtdoug: iplog-
Details | Diff
Small fixes for DSF-GDB (3.38 KB, patch)
2010-03-12 11:25 EST, 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 2009-08-06 12:26:14 EDT
There have been a couple improvements to AbstractCLaunchDelegate that GdbLaunchDelegate won't pick up for free: bug 178731 and bug 285904.

I couldn't recall why GdbLaunchDelegate doesn't use AbstractCLaunchDelegate. Should we do whatever work is required to make AbstractCLaunchDelegate sharable with GdbLaunchDelegate?
Comment 1 Pawel Piech CLA 2009-08-06 13:35:31 EDT
I also think it's a good idea.  There was a lot of confusion early on about dependencies between various launch components, so the functionality was likely duplicated needlessly.
Comment 2 Ken Ryall CLA 2009-08-29 01:34:48 EDT
Just ran into another related problem (bug 285907). I'll start working on better sharing of launch code.
Comment 3 Ken Ryall CLA 2009-10-30 17:27:24 EDT
I started working on this and then realized that GdbLaunchDelegate is public and API. I'll look at it again when we get to work on CDT 7.0.
Comment 4 Marc Khouzam CLA 2009-11-01 14:41:10 EST
(In reply to comment #3)
> I started working on this and then realized that GdbLaunchDelegate is public
> and API. I'll look at it again when we get to work on CDT 7.0.

What changes would break the API?
Making GdbLaunchDelegate extend AbstractCLaunchDelegate doesn't break the API, right?  Are there methods you need to remove to make this change worthwhile?
Comment 5 Ken Ryall CLA 2010-02-24 12:50:14 EST
I've been looking at this in more detail and I'm having second thoughts. AbstractCLaunchDelegate has some useful common things but also some things that are not CDI specific but don't add any value to a DSF launch. It should probably be broken up into AbstractCLaunchDelegate and a AbstractCDILaunchDelegate.

But given our attempts to deprecate CDI this may not be worth the effort. Perhaps we should instead create an AbstractDSFLaunchDelegate that DSF based debuggers can share and make sure it supports all the stuff in AbstractCLaunchDelegate (mostly the build before run settings).
Comment 6 Marc Khouzam CLA 2010-02-24 13:06:53 EST
(In reply to comment #5)
> I've been looking at this in more detail and I'm having second thoughts.
> AbstractCLaunchDelegate has some useful common things but also some things that
> are not CDI specific but don't add any value to a DSF launch. It should
> probably be broken up into AbstractCLaunchDelegate and a
> AbstractCDILaunchDelegate.
> 
> But given our attempts to deprecate CDI this may not be worth the effort.
> Perhaps we should instead create an AbstractDSFLaunchDelegate that DSF based
> debuggers can share and make sure it supports all the stuff in
> AbstractCLaunchDelegate (mostly the build before run settings).

Although it won't help getting new feature of AbstractCLaunchDelegate for free, it would help getting features for free between DSF-based debuggers, so +1 from me.
Comment 7 Ken Ryall CLA 2010-02-24 16:59:50 EST
Never mind, I thought about it over a burrito and now it looks easier than I thought thought to pull the CDI stuff out of AbstractCLaunchDelegate. I'll experiment with that.
Comment 8 Ken Ryall CLA 2010-02-25 12:42:22 EST
OK, I've come full circle: I've created an AbstractCLaunchDelegate2 that combines the common stuff from GdbLaunchDelegate and the new build integration support from AbstractCLaunchDelegate. AbstractCLaunchDelegate is left alone because it has loads of legacy stuff in it that may not make sense or be required any longer but could be relied upon by people building on CDT.

Now GdbLaunchDelegate and the EDC launch delegates extend AbstractCLaunchDelegate2 and pick up the new build integration features. These require the new UI in org.eclipse.cdt.launch.ui.CMainTab so the DSF Gdb launch now uses it instead org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab. They are identical except for the new work in org.eclipse.cdt.launch.ui.CMainTab.

org.eclipse.cdt.launch.ui.CMainTab has an option for "Connect process input & output to a terminal" that is not in org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab. Does anyone know if this is by design? If so we can hide it in the DSF-GDB launch.

My next move is to change the CDI launches to use AbstractCLaunchDelegate2 and see if I have left anything out.
Comment 9 Marc Khouzam CLA 2010-02-25 13:23:42 EST
(In reply to comment #8)

> org.eclipse.cdt.launch.ui.CMainTab has an option for "Connect process input &
> output to a terminal" that is not in
> org.eclipse.cdt.dsf.gdb.internal.ui.launching.CMainTab. Does anyone know if
> this is by design? If so we can hide it in the DSF-GDB launch.

Yep, that was by design.  CDI allows the user not to connect the process i/o to a terminal because it fails when using the Restart operation.  For DSF-GDB, the Restart action does not break in this case, so we always attach the process i/o to a terminal.
Comment 10 Ken Ryall CLA 2010-03-01 07:49:21 EST
Created attachment 160476 [details]
launch delegate refactoring

Here is the patch.
Comment 11 Ken Ryall CLA 2010-03-01 08:00:35 EST
Marc, how does this look?
Comment 12 Marc Khouzam CLA 2010-03-02 15:28:49 EST
(In reply to comment #11)
> Marc, how does this look?

Thanks Ken.  I'm going over the patch now, but here are some comments about sharing the CMainTab.  I think it is a great idea, (DSF-GDB having it's own copy only made us lose features, but this was done when we were not part of CDT).  I had made some modifications to the tab for DSF-GDB so we'll need to make the common one fit properly for both DSF-GDB and CDI-gDB.  Below is what is missing:

- I see that for CDI, the attach launch config type and the core launch config type have the new "Build before launching" UI.  I guess it should also be there for those launch config types for DSF-GDB; so dsf.gdb.internal.ui.launching.CMainCoreTAb should be replaced with the one in cdt.launch.ui, and the DSF-GDB one removed; as for dsf.gdb.internal.ui.launching.CMainAttachTab it should be replaced by the one in cdt.launch.ui, but it will need modification to allow to turn off 'checking for program'

- There is also a DSF-GDB remote launch that is one of the choices of the Local App launch config type.  Should it use the new launch.ui.CMainTab?  It still uses the DSF-GDB one in the plugin.xml file.

- To get rid of the "Connect process i/o to a terminal" option for DSF-GDB we will need a new class that will inherit from CMainTab but that will call CMainTab(false).  You could re-use the filename of gdb.ui.CMainTab if no one else is using it anymore.

- In the DSF-GDB main tab we had reversed the order of the input boxes 'binary' and 'project' to make 'project' the one on top.  I found it weird that CDI would ask for the 'binary' first but if you clicked on Search Project it would complain that you haven't selected a project yet.  But I'm not set on it as I might be missing something.

- DSF-GDB supports debugging binaries that are not in an Eclipse project.  Therefore, the fBrowseForBinaryButton selectionListener was modified not to require the user to enter a project.
Comment 13 Ken Ryall CLA 2010-03-02 16:07:35 EST
OK, that explains a lot, I'll start working on those changes.
Comment 14 Ken Ryall CLA 2010-03-05 13:54:09 EST
Looking at this again maybe the right thing to do is to have the DSF CMainTab extend the CDT Launch CMainTab. I'll experiment with that.
Comment 15 Marc Khouzam CLA 2010-03-05 14:26:10 EST
(In reply to comment #14)
> Looking at this again maybe the right thing to do is to have the DSF CMainTab
> extend the CDT Launch CMainTab. I'll experiment with that.

That sounds like a good idea.  We'll have more flexibility in DSF, while not risking breaking the CDI stuff.
Comment 16 Marc Khouzam CLA 2010-03-05 14:33:47 EST
One thing to pay attention to: in the plugin.xml, the tabs have a 'placement' field which tell them where to be placed.  The id of that field should be the TAB_ID defined _in the class_ and returned by getId().  Currently, it is wrong in dsf.gdb.ui/plugin.xml because the CMainTab used has changed.

Depending on what you decide, Ken, just make sure the placement field is properly updated.
Comment 17 Marc Khouzam CLA 2010-03-08 16:36:12 EST
The posted patch "launch delegate refactoring" looks good to me.  The one problem that I see is that we no longer accept an empty project/binary as required by Bug 244567.  But I see that Ken is currently in the process of adding that in.

One suggestion is that GdbLaunchDelegate should use verifyCProject() of the new AbstractCLaunchDelegate2 inside of checkBinaryDetails(), instead of the LaunchUtils one.
Comment 18 Ken Ryall CLA 2010-03-08 21:34:15 EST
Created attachment 161396 [details]
main tab

This patch takes most of the common bits of the two CMainTabs and puts them into a abstract base class. The goal was to leave the CDI CMainTab as unaltered as possible and bring the new build settings into the DSF CMainTab.
Comment 19 Ken Ryall CLA 2010-03-09 00:28:45 EST
(In reply to comment #17)
> One suggestion is that GdbLaunchDelegate should use verifyCProject() of the new
> AbstractCLaunchDelegate2 inside of checkBinaryDetails(), instead of the
> LaunchUtils one.

Committed this change as well as the "main tab" patch. There is probably a little more that could move into CAbstractMainTab but I think this will do for now.
Comment 20 Marc Khouzam CLA 2010-03-09 09:26:03 EST
(In reply to comment #19)
> (In reply to comment #17)
> > One suggestion is that GdbLaunchDelegate should use verifyCProject() of the new
> > AbstractCLaunchDelegate2 inside of checkBinaryDetails(), instead of the
> > LaunchUtils one.
> 
> Committed this change as well as the "main tab" patch. There is probably a
> little more that could move into CAbstractMainTab but I think this will do for
> now.

This looks great!  I think it was very important to show a very similar launch between CDI-GDB and DSF-GDB.  This was a great bug to have done.

One last thing that I think is needed is that the DSF-GDB CMainAttachTab and CMainCoreTab classes should specify the new flag INCLUDE_BUILD_SETTINGS.  CDI-GDB shows those settings for both Attach and Core launches.

Finally, from the user's perspective, should we have the same order of Project and Binary in the main tab between CDI and DSF?  As I said, I felt the order for CDI should have been reversed, but having the two tabs so subtly different may be confusing to the user.  Maybe an email to the list is in order?

Thanks Ken!
Comment 21 Marc Khouzam CLA 2010-03-12 11:25:26 EST
Created attachment 161894 [details]
Small fixes for DSF-GDB

(In reply to comment #20)

This small patch addresses the below issues.

> One last thing that I think is needed is that the DSF-GDB CMainAttachTab and
> CMainCoreTab classes should specify the new flag INCLUDE_BUILD_SETTINGS. 
> CDI-GDB shows those settings for both Attach and Core launches.

I think this was missing functionality.

> Finally, from the user's perspective, should we have the same order of Project
> and Binary in the main tab between CDI and DSF?  As I said, I felt the order
> for CDI should have been reversed, but having the two tabs so subtly different
> may be confusing to the user.  Maybe an email to the list is in order?

I thought it was better to have both launch tab look the same, for user friendliness.

I committed to HEAD.
Comment 22 Marc Khouzam CLA 2010-03-12 11:26:13 EST
Ken, can you review the minor changes I just made?
Comment 23 Marc Khouzam CLA 2010-03-16 09:56:09 EDT
I think we can mark this bug as fixed, no?
Comment 24 Ken Ryall CLA 2010-03-16 15:21:51 EDT
Done.