Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318304 - Improve GDBBackend interface for derived classes
Summary: Improve GDBBackend interface for derived classes
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 7.0   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-29 08:31 EDT by Vladimir Prus CLA
Modified: 2010-07-06 05:40 EDT (History)
2 users (show)

See Also:
ling.5.wang: review+


Attachments
Fix (1013 bytes, patch)
2010-07-01 06:21 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 Vladimir Prus CLA 2010-06-29 08:31:21 EDT
Build Identifier: 

At present, GDBBackend.getGDBPath is private, so a custom class derived from GDBBackend cannot easily override just the logic for determining the gdb name.

Also, there's fLaunchConfiguration field, but it's not exposed to derived classes. I would recommend adding an accessor method. I can provide patches for both if so desired -- but it seems that sending patches for such trivial changes is not gonna help anybody ;-)

Reproducible: Always
Comment 1 Marc Khouzam CLA 2010-07-01 06:21:16 EDT
Created attachment 173194 [details]
Fix

(In reply to comment #0)
> At present, GDBBackend.getGDBPath is private, so a custom class derived from
> GDBBackend cannot easily override just the logic for determining the gdb name.

I made it protected in the attached patch.
Committed to HEAD.

> Also, there's fLaunchConfiguration field, but it's not exposed to derived
> classes.

I've made fLaunchConfiguration final in this patch.  Since it is set to a value that is be passed to the constructor, then an overriding class must also have that parameter and can create it's own fLaunchConfiguration.

Is that ok for you?
Comment 2 Marc Khouzam CLA 2010-07-01 06:22:05 EDT
Ling, can you review this two-line change?
Comment 3 Marc Khouzam CLA 2010-07-01 06:23:26 EDT
If the solution is not sufficient for some reason, please re-open.
Comment 4 Vladimir Prus CLA 2010-07-01 06:55:20 EDT
Thanks for looking into this.

I am not sure about fLaunchConfiguration. Yes, derived class must accept a config in its constructor. However, forcing it to have another member to hold a configuration, and assign to that member, seems unnecessary, given that FinalLaunchDelegate already has this information and will always have it.
Comment 5 Marc Khouzam CLA 2010-07-01 07:13:54 EDT
(In reply to comment #4)
> Thanks for looking into this.
> 
> I am not sure about fLaunchConfiguration. Yes, derived class must accept a
> config in its constructor. However, forcing it to have another member to hold a
> configuration, and assign to that member, seems unnecessary, given that
> FinalLaunchDelegate already has this information and will always have it.

It may seem overly careful, but I prefer not to add APIs unless really necessary.  Having a local member does not seem like such a big deal.
Comment 6 CDT Genie CLA 2010-07-01 07:23:02 EDT
*** cdt cvs genie on behalf of mkhouzam ***
Bug 318304: Allow for better overriding of the class.

[*] GDBBackend.java 1.18 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java?root=Tools_Project&r1=1.17&r2=1.18
Comment 7 Ling Wang CLA 2010-07-01 12:06:16 EDT
(In reply to comment #2)
> Ling, can you review this two-line change?

Looks good to me.
Comment 8 Vladimir Prus CLA 2010-07-06 05:40:12 EDT
Could you imagine a situation where GDBBackend does not need to store launch configuration, and access it from various methods? It seems that it's only possible if GDBBackend is completely redesigned, in which case an extra method is the least of the problems.

Anyway, I've hacked my code around this. Thanks for the other fixes!