Bug 400840 - Register values not properly updated in the 'Registers' tree viewer
Summary: Register values not properly updated in the 'Registers' tree viewer
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: 8.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.2   Edit
Assignee: Marc Khouzam CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-14 14:18 EST by Roland Grunberg CLA
Modified: 2014-01-28 21:00 EST (History)
4 users (show)

See Also:


Attachments
Patch (git-formatted) (1.43 KB, patch)
2013-05-22 16:41 EDT, Roland Grunberg CLA
cdtdoug: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Grunberg CLA 2013-02-14 14:18:37 EST
I'm not sure if I've filed this under the right component, but if I switch to using the gdb-mi debugger (by specifying a standard process launcher for the configuration) then the problem described below does not occur.

I'm seeing this behaviour in 8.1.0, 8.1.1 and the nightly kepler builds.

Steps to reproduce :

1) After having built a C project, attempt to debug the project using the GDB DSF launcher.
2) Open up the 'Registers' view and scroll through all registers (this is to ensure their values get loaded)
3) modify one of the accumulator registers (eg. set rax to 11)
4) scroll to eax/ax and note that the 'value' column in the tree viewer for those registers haven't been updated (they will not be 11)
5) either edit-click the values or view the values in the detail pane for eax/ax to see that it has in fact been updated correctly for those UI elements (they will be 11).
Comment 1 Roland Grunberg CLA 2013-05-22 16:41:52 EDT
Created attachment 231335 [details]
Patch (git-formatted)

Dispatching an IGroupsChangedDMEvent seems to solve this issue for me. This event is handled in RegisterGroupVMNode as a content change. I'm not sure if the upcoming changes to CDT 8.2.0 (Kepler) regarding synchronization of views include the Registers view, but if they don't, this small change should resolve the issue for now.
Comment 2 Alvaro Sanchez-Leon CLA 2013-05-23 11:15:45 EDT
I tried the solution and it works well,

The only suggestion I have is to use IRegistersChangedDMEvent instead of IGroupsChangedDMEvent, 
This will adjust the scope of the change accordingly and be ready when register groups are supported,

The change could look as shown below.

Would you push the change to Gerrit ?

        IRegistersChangedDMEvent event = new IRegistersChangedDMEvent() {
			@Override
			public IRegisterGroupDMContext getDMContext() {
		    	final MIRegisterGroupDMC groupDmc = DMContexts.getAncestorOfType(dmc, MIRegisterGroupDMC.class);
				return groupDmc;
			}
		};
		
        // Fix Bug 400840
        getSession().dispatchEvent(event, null);
Comment 3 Roland Grunberg CLA 2013-05-23 12:21:26 EDT
Thanks for the feedback. I've submitted this to Gerrit at https://git.eclipse.org/r/#/c/13084/ .
Comment 4 Alvaro Sanchez-Leon CLA 2013-05-23 15:07:17 EDT
I had a discussion with Mark Khouzam and he raised the concerned that raising the event for RegistersChanged will trigger a refresh on all registers as we scroll through the view.
  So the patch will fix the issue but will introduce an inefficiency that needs to be addressed.
  
Looking at the command sequence from the Standard debug (CDI), we can see that it uses a MI command to find out the indexes of the registers that changed i.e. 
   [1,369,334,325,939] 1605-data-list-changed-registers
   [1,369,334,325,940] 1605^done,changed-registers=["0","74","94","110"]

So it is possible to introduce a more robust solution where individual register updates triggers data-list-changed-regisers from the MI/GDB interface and then fire individual Register Changed events which will limit the number of updates.

Do we take this patch and create a new bug to track the missing part or do we modify the solution?
Comment 5 Marc Khouzam CLA 2013-05-23 15:11:54 EDT
(In reply to comment #4)

> Do we take this patch and create a new bug to track the missing part or do
> we modify the solution?

I think it is too late in the cycle to start using a new MI command that we may not understand fully right now.

Since being correct is more important than being efficient, we should take this fix for Kepler.  Once that is done, I'll open a new bug for the improvement.
Comment 6 Nobody - feel free to take it CLA 2013-05-23 15:23:21 EDT
(In reply to comment #5)
> (In reply to comment #4)
> 
> > Do we take this patch and create a new bug to track the missing part or do
> > we modify the solution?
> 
> I think it is too late in the cycle to start using a new MI command that we
> may not understand fully right now.
> 
> Since being correct is more important than being efficient, we should take
> this fix for Kepler.  Once that is done, I'll open a new bug for the
> improvement.

Marc, I am not familiar with the current implementation. We use var-object based registers in our product. In our case the var-object mechanism takes care of updates. I just haven't had a time to modify and submit the local patch upstream.
Comment 7 Marc Khouzam CLA 2013-05-23 15:41:18 EDT
(In reply to comment #6)

> Marc, I am not familiar with the current implementation. We use var-object
> based registers in our product. In our case the var-object mechanism takes
> care of updates. I just haven't had a time to modify and submit the local
> patch upstream.

Thanks Mikhail.
I was wondering if you knew about -data-list-changed-registers:
http://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Data-Manipulation.html#GDB_002fMI-Data-Manipulation

It seems to be a way to ask GDB what registers have changed.

The current bug is that when the user changes a register, other registers can change, e.g., rax changes => eax changes.  This would force us to update all registers as soon as one changes, which seems inefficient.  We'll have to do that for Kepler, but I has hoping that for Luna, we could use -data-list-changed-registers to limit the scope of what needs to be updated.  Since CDI uses it, I thought you may know about it.
Comment 8 Nobody - feel free to take it CLA 2013-05-23 16:05:30 EDT
(In reply to comment #7)
> (In reply to comment #6)
> 
> > Marc, I am not familiar with the current implementation. We use var-object
> > based registers in our product. In our case the var-object mechanism takes
> > care of updates. I just haven't had a time to modify and submit the local
> > patch upstream.
> 
> Thanks Mikhail.
> I was wondering if you knew about -data-list-changed-registers:
> http://sourceware.org/gdb/current/onlinedocs/gdb/GDB_002fMI-Data-
> Manipulation.html#GDB_002fMI-Data-Manipulation
> 
> It seems to be a way to ask GDB what registers have changed.
> 
> The current bug is that when the user changes a register, other registers
> can change, e.g., rax changes => eax changes.  This would force us to update
> all registers as soon as one changes, which seems inefficient.  We'll have
> to do that for Kepler, but I has hoping that for Luna, we could use
> -data-list-changed-registers to limit the scope of what needs to be updated.
> Since CDI uses it, I thought you may know about it.

That's how it is used in CDI but that's all I know.
Comment 9 Marc Khouzam CLA 2013-05-23 16:13:11 EDT
I've updated Roland's so it could be committed right away.  I've committed it to master from Gerrit.

I'm not thrilled with the fix, but I think it is the best we can so late in the cycle. We'll improve on it for the next release.

If someone has suggestions or comments, please voice them, and we'll do an update on the commit.

I've opened bug 408894 to improve this solution.

Thanks Roland for reporting and posting the patch!