Bug 462988 - Register grouping should work with different implementations of IRegisters service
Summary: Register grouping should work with different implementations of IRegisters se...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.6.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-24 12:09 EDT by Nobody - feel free to take it CLA
Modified: 2020-09-04 15:23 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 Nobody - feel free to take it CLA 2015-03-24 12:09:43 EDT
Current implementation of the register grouping feature (see http://eclip.se/235747) works only with the MIRegisters service. It should be made more generic to support other implementations of IRegisters.
Comment 1 Eclipse Genie CLA 2015-03-24 16:01:39 EDT
New Gerrit change created: https://git.eclipse.org/r/44533

WARNING: this patchset contains 1363 new lines of code and may require a Contribution Questionnaire (CQ) if the author is not a committer on the project. Please see:https://wiki.eclipse.org/Project_Management_Infrastructure/Creating_A_Contribution_Questionnaire
Comment 2 Nobody - feel free to take it CLA 2015-03-24 16:20:45 EDT
Pushed a draft patch to Gerrit: https://git.eclipse.org/r/44533.

The patch adds a new interface IMIRegisters and a new implementation of the IRegisters2 service - GDBManagedRegisterGroups which is a modification of GDBRegisters. We should probably come up with a better name than GDBManagedRegisterGroups. Unfortunately, because of API reasons, I can't use or modify GDBRegisters directly because it extends MIRegisters and the new service doesn't.
I will update the tests if the patch is approved.
Comment 3 Marc Khouzam CLA 2015-04-02 12:00:06 EDT
(In reply to Mikhail Khodjaiants from comment #2)
> Unfortunately, because of API reasons, I can't use
> or modify GDBRegisters directly because it extends MIRegisters and the new
> service doesn't.

I tried and replaced the entire content of GDBRegisters with the content of GDBManagedRegisterGroups I got no compilation errors i.e., keeping the declarations as before:

public class GDBRegisters extends MIRegisters implements IRegisters2 {

but the rest is what was in GDBManagedRegisterGroups.

I haven't tested though.

This would allow to modify GDBRegisters to do what Mikhail wants and still use the delegate pattern.  The extending of MIRegisters would not be necessary but we'd keep it for API compatibility.

This may also fit well with the suggestion I made in the review to use a single register-service and a delegate (like GDBPatternMatchingExpressions) instead of two register services.
Comment 4 Nobody - feel free to take it CLA 2015-04-02 12:45:54 EDT
(In reply to Marc Khouzam from comment #3)
> (In reply to Mikhail Khodjaiants from comment #2)
> > Unfortunately, because of API reasons, I can't use
> > or modify GDBRegisters directly because it extends MIRegisters and the new
> > service doesn't.
> 
> I tried and replaced the entire content of GDBRegisters with the content of
> GDBManagedRegisterGroups I got no compilation errors i.e., keeping the
> declarations as before:
> 
> public class GDBRegisters extends MIRegisters implements IRegisters2 {
> 
> but the rest is what was in GDBManagedRegisterGroups.
> 
> I haven't tested though.
> 

I just realized that extending MIRegisters would work. I thought it would cause problems when initializing the delegate. GDBManagedRegisterGroups is not registered at the moment when the delegate is initialized and the services tracker will return the proper service.

> This would allow to modify GDBRegisters to do what Mikhail wants and still
> use the delegate pattern.  The extending of MIRegisters would not be
> necessary but we'd keep it for API compatibility.
> 
> This may also fit well with the suggestion I made in the review to use a
> single register-service and a delegate (like GDBPatternMatchingExpressions)
> instead of two register services.

Thanks, I'll take a look at the way GDBPatternMatchingExpressions is implemented.
Comment 5 Marc Khouzam CLA 2015-04-02 12:54:50 EDT
(In reply to Mikhail Khodjaiants from comment #4)

> I just realized that extending MIRegisters would work. I thought it would
> cause problems when initializing the delegate. GDBManagedRegisterGroups is
> not registered at the moment when the delegate is initialized and the
> services tracker will return the proper service.

I had to play around a little bit to make this work for GDBPatternMatchingExpressions.  The important points are:

- GDBPatternMatchingExpressions gets MIExpressions as a parameter not through a tracker (because there is not way to unregister a service easily)
- MIExpressions.initialize() is called by GDBPatternMatchingExpressions _after_ GDBPatternMatchingExpressions is registered, and MIExpressions won't register if there is already a service registered for IExpressions.
Comment 6 Nobody - feel free to take it CLA 2015-04-02 13:21:59 EDT
(In reply to Marc Khouzam from comment #5)
> I had to play around a little bit to make this work for
> GDBPatternMatchingExpressions.  The important points are:
> 
> - GDBPatternMatchingExpressions gets MIExpressions as a parameter not
> through a tracker (because there is not way to unregister a service easily)
> - MIExpressions.initialize() is called by GDBPatternMatchingExpressions
> _after_ GDBPatternMatchingExpressions is registered, and MIExpressions won't
> register if there is already a service registered for IExpressions.

Thanks Marc, hopefully I'll have time to work on it.