Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 339708 - [Memory Browser] Need a public method for getting selected memory space
Summary: [Memory Browser] Need a public method for getting selected memory space
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-memory (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: John Cortell CLA
QA Contact: Ted Williams CLA
URL:
Whiteboard:
Keywords:
: 355431 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-11 10:41 EST by Norman Yee CLA
Modified: 2013-09-11 21:53 EDT (History)
5 users (show)

See Also:


Attachments
Added a public getMemorySpace() method (1.73 KB, patch)
2011-03-11 10:52 EST, Norman Yee CLA
no flags Details | Diff
Fix (6.22 KB, patch)
2011-03-11 12:52 EST, John Cortell CLA
john.cortell: iplog-
Details | Diff
fix (7.24 KB, patch)
2011-03-11 14:47 EST, John Cortell CLA
john.cortell: iplog-
Details | Diff
fix (5.10 KB, patch)
2011-10-10 17:30 EDT, John Cortell CLA
no flags Details | Diff
fix (8.11 KB, patch)
2011-10-14 22:05 EDT, John Cortell CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Norman Yee CLA 2011-03-11 10:41:30 EST
Build Identifier: I20110127-2034

I need to call the memory browser's performGo() method from my debugger plugin.  The problem is that I need to get the selected memory space to pass to performGo() and there is no public method to get that information.

Reproducible: Always
Comment 1 Norman Yee CLA 2011-03-11 10:52:40 EST
Created attachment 190996 [details]
Added a public getMemorySpace() method
Comment 2 John Cortell CLA 2011-03-11 11:02:04 EST
Accessing that class from a non-CDT plugin is not ideal. That's an
implementation class, not a public interface. Unfortunately, there was no
attempt to distinguish between internal and public code when that plugin was
written. (In fact, I believe every method of every class in every plugin is
qualified as public, giving new meaning to the term "Open Source").

Let me look at providing an API for letting other features tell the browser to
go to a new address.
Comment 3 John Cortell CLA 2011-03-11 11:25:09 EST
(In reply to comment #2)
> (In fact, I believe every method of every class in every plugin is
> qualified as public, giving new meaning to the term "Open Source").

Scratch that. I need a mid morning cup of coffee.
Comment 4 John Cortell CLA 2011-03-11 12:52:59 EST
Created attachment 191009 [details]
Fix

I need to do some more testing, but this is what I've got. Norman, can you verify that this meets your needs and works in your environment? In addition to introducing a public interface, this allows the user to specify the memory space to be either (a) n/a or (b) whatever memory space is currently selected. There is a big difference between the two. Also, we want to update the UI controls (address bar and the memory selector) otherwise the view ends up in a misleading state. Programatically telling the browser to go to a location should have the same end result as if the user had done it from the GUI.

Unfortunately, API freeze has to happen by M6, and the M6 build is going to happen 10 minutes from now. So the timing of this request is unfortunate. This will have to go in post-Indigo.
Comment 5 Norman Yee CLA 2011-03-11 14:12:03 EST
John, thanks for looking into this problem.

I tried your patch and the go() method works great, but I still need a public API to get the selected memory space.  I guess I should have mentioned this earlier but we get the selected memory space first and then let the user pick from a list of symbols in the selected memory space.  After the user picks a symbol to go to, we call the go() method.

Also, since you're working on a public API, any chance you could add selectRendering() from bug #339289 to the API?  Our users want to be able to change the rendering of an existing tab, and would rather not have to create a new tab to see a new rendering.
Comment 6 John Cortell CLA 2011-03-11 14:21:50 EST
(In reply to comment #5)
> I tried your patch and the go() method works great, but I still need a public
> API to get the selected memory space.  I guess I should have mentioned this
> earlier but we get the selected memory space first and then let the user pick
> from a list of symbols in the selected memory space.  After the user picks a
> symbol to go to, we call the go() method.

Hm. Are you enhancing your copy of the Memory Browser or is this activity happening external to the view?

> Also, since you're working on a public API, any chance you could add
> selectRendering() from bug #339289 to the API?  Our users want to be able to
> change the rendering of an existing tab, and would rather not have to create a
> new tab to see a new rendering.

I'll take a look at the bug and comment there.
Comment 7 Norman Yee CLA 2011-03-11 14:28:55 EST
(In reply to comment #6)
> Hm. Are you enhancing your copy of the Memory Browser or is this activity
> happening external to the view?

The latter.  We're adding toolbar buttons and context menus from our debugger plugin.
Comment 8 John Cortell CLA 2011-03-11 14:47:53 EST
Created attachment 191023 [details]
fix
Comment 9 Norman Yee CLA 2011-03-11 15:56:34 EST
I tried the latest patch and it looks good.  Thanks!
Comment 10 Alain Lee CLA 2011-09-21 14:37:44 EDT
*** Bug 355431 has been marked as a duplicate of this bug. ***
Comment 11 Alain Lee CLA 2011-09-21 15:43:18 EDT
(In reply to comment #9)
> I tried the latest patch and it looks good.  Thanks!

Norman & John,

Did you test it when the Memory Browser is not yet opened? I invoked IWorkbenchWindow.getActivePage().showView to open Memory Browser and then call memoryBorwser.go() immediately. There is a chance that the updateTab() is not completely done when go() is running. When fStackLayout.topControl is still not a tabFolder, performGo() will not do anything. This is just a timing issue.

Also, do we allow people to call Go() from a non-UI thread?
Comment 12 Norman Yee CLA 2011-09-22 09:37:04 EDT
(In reply to comment #11)
> Norman & John,
> 
> Did you test it when the Memory Browser is not yet opened? I invoked
> IWorkbenchWindow.getActivePage().showView to open Memory Browser and then call
> memoryBorwser.go() immediately. There is a chance that the updateTab() is not
> completely done when go() is running. When fStackLayout.topControl is still not
> a tabFolder, performGo() will not do anything. This is just a timing issue.

In my patch for bug 317749, I call showView() to open the memory browser and then I call go() from the UI thread.  I didn't test the case in which you call showView() and then call go() immediately.  I assume you're doing both from the UI thread?

> Also, do we allow people to call Go() from a non-UI thread?

go() updates the memory browser UI so I think it should be called from the UI thread.
Comment 13 Alain Lee CLA 2011-09-22 10:05:02 EDT
(In reply to comment #12)
> (In reply to comment #11)
> > Norman & John,
> > 
> > Did you test it when the Memory Browser is not yet opened? I invoked
> > IWorkbenchWindow.getActivePage().showView to open Memory Browser and then call
> > memoryBorwser.go() immediately. There is a chance that the updateTab() is not
> > completely done when go() is running. When fStackLayout.topControl is still not
> > a tabFolder, performGo() will not do anything. This is just a timing issue.
> In my patch for bug 317749, I call showView() to open the memory browser and
> then I call go() from the UI thread.  I didn't test the case in which you call
> showView() and then call go() immediately.  I assume you're doing both from the
> UI thread?

This is what happened in my test:
1. Ensure that Memory Browser is not opened. Call showView() in the UI thread and then call go() immediately in the UI thread as well.
2. When Memory Browser starts, MemoryBrowser.createPartControl() calls handleDebugContextChanged() to get the IMemorySpaceAwareMemoryBlockRetrieval from another thread. When this thread is done, it calls updateTab to do a lot of things in the UI thread including setting fStackLayout.topControl to a tabFolder. If go() is invoked before all of these are done, it is possible that fStackLayout.topControl is set to null and then performGo() will exit without doing anything.

This is a timing issue.
Comment 14 Alain Lee CLA 2011-10-07 15:56:01 EDT
(In reply to comment #9)
> I tried the latest patch and it looks good.  Thanks!

John, will this be applied soon? Please also check the timing issue I mentioned.
Comment 15 John Cortell CLA 2011-10-07 16:15:16 EDT
Sorry. I've been out of pocket for a while, but am returning to the front line shortly. I'll return to this issue early next week.
Comment 16 John Cortell CLA 2011-10-10 17:30:44 EDT
Created attachment 204911 [details]
fix

Adds new method for getting the active memory retrieval object. Can be used to solve the timing issue noted in comment # 11
Comment 17 John Cortell CLA 2011-10-10 17:48:29 EDT
(In reply to comment #14)
> (In reply to comment #9)
> > I tried the latest patch and it looks good.  Thanks!
> 
> John, will this be applied soon? Please also check the timing issue I
> mentioned.

Lee, trying to do a go() immediately after opening the view programatically will indeed require some special logic. As you noted, the view cannot fully initialize itself synchronously during the creation of the part. We need to find out what memory spaces are available before we can populate the memory space selector; in a DSF session, that's an async operation.

However, I've done two things that will support your scenario. First, I've added a new method to the proposed IMemoryBrowser interface for getting the active memory retrieval object. Secondly, I've documented the go() method to reflect that it's a no-op if there is no active memory retrieval object. You thus can write logic that can spin until the browser has an active retrieval object (hopefully not in the GUI thread, and hopefully not without some minimal sleep to allow other threads to breath, and hopefully not without some timeout). I coded an example action that opens the view and sets the expression and its working well for me. It's non-trivial in that the IMemoryBrowser methods must be called on the GUI thread (this was documented in my first path, BTW), but you don't want to spin on the GUI thread. That said, it's not rocket science nor a ton of code.
Comment 18 Alain Lee CLA 2011-10-12 15:21:11 EDT
(In reply to comment #17)
> Lee, trying to do a go() immediately after opening the view programatically
> will indeed require some special logic. As you noted, the view cannot fully
> initialize itself synchronously during the creation of the part. We need to
> find out what memory spaces are available before we can populate the memory
> space selector; in a DSF session, that's an async operation.
> However, I've done two things that will support your scenario. First, I've
> added a new method to the proposed IMemoryBrowser interface for getting the
> active memory retrieval object. Secondly, I've documented the go() method to
> reflect that it's a no-op if there is no active memory retrieval object. You
> thus can write logic that can spin until the browser has an active retrieval
> object (hopefully not in the GUI thread, and hopefully not without some minimal
> sleep to allow other threads to breath, and hopefully not without some
> timeout). I coded an example action that opens the view and sets the expression
> and its working well for me. It's non-trivial in that the IMemoryBrowser
> methods must be called on the GUI thread (this was documented in my first path,
> BTW), but you don't want to spin on the GUI thread. That said, it's not rocket
> science nor a ton of code.
This looks good to me. Could you apply this to the head so it can be picked up in the next update?
Comment 19 John Cortell CLA 2011-10-13 21:17:50 EDT
(In reply to comment #18)
> This looks good to me. Could you apply this to the head so it can be picked up
> in the next update?

Will do very soon.
Comment 20 John Cortell CLA 2011-10-14 22:05:44 EDT
Created attachment 205240 [details]
fix

Last patch was missing new file
Comment 21 CDT Genie CLA 2011-10-14 22:23:05 EDT
*** cdt git genie on behalf of U-bobgato\cortell ***

    Bug 339708 - [Memory Browser] Need a public method for getting selected memory space

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e453c2257d80c878c00729d7f17aad0b7280ed1f
Comment 22 Randy Rohrbach CLA 2012-05-22 14:12:06 EDT
John

   It looks like you did all this work, but did not complete the bugzilla
   record keeping. Am I correct. If so I can take care of it.

Randy
Comment 23 Marc Khouzam CLA 2013-09-11 21:53:00 EDT
(In reply to Randy Rohrbach from comment #22)
> John
> 
>    It looks like you did all this work, but did not complete the bugzilla
>    record keeping. Am I correct. If so I can take care of it.
> 
> Randy

Looks like this was fixed a while back.