Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-debug-dev] use the Memory View programmatically?

Hi Elin -

Do you need to show a rendering in the Memory View? or are you looking at
creating your own action and creating a memory rendering when your action
is invoked?

To get the Hex rendering to show up in the Memory View, you need to do the
following:
   Your debug target must return true when #supportsStorageRetrieval is
   called.  If you are implementing IMemoryBlockExtension, you need to
   implement IMemoryBlockRetrievalExtension in your debug target.
   You need to implement your memory block and return that from your debug
   target when #getMemoryBlock is called.  If you are implementing
   IMemoryBlockExtension, return your memory block when
   #getExtendedMemoryBlock is called.
   You need to define a memory rendering binding in your plugin.xml.
   Here's an example:

<extension
      point="org.eclipse.debug.ui.memoryRenderings">
   <renderingBindings renderingIds=
"org.eclipse.debug.ui.rendering.raw_memory>
      <enablement>
         <instanceof value="example.package.YourMemoryBlock"/>
      </enablement>
   </renderingBindings>
</extension>

A rendering defines a list of valid memory renderings for your memory
block.  This is must be defined in order to allow the memory rendering
manager to figure out what memory rendering is valid for a certain type of
memory block.

You should be able to show the Hex rendering for your memory block with the
above steps.  (i.e. You should be able to add the memory block and see
renderings from the view.)
This is the minimum step to show memory block and the hex rendering in the
Memory View.

To show the hex rendering in the Memory View programatically, your code has
done most of it correctly.  I tried out your code.  I did not get null from
#getContainer.  But since the rendering is not initialized properly, I got
a null pointer exception when the rendering is added to the container.

IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  if (page != null)
  {
     try
     {
        IViewPart view = page.showView("org.eclipse.debug.ui.MemoryView");

        IMemoryRenderingSite memoryView = (IMemoryRenderingSite) view;
        MemoryBlockExtentsion mbe = new MemoryBlockExtentsion(new
DummyDebugTarget(), 0);
        DebugPlugin.getDefault().getMemoryBlockManager().
                    addMemoryBlocks(new IMemoryBlock[] {mbe});

        IMemoryRenderingType renderingType =
DebugUITools.getMemoryRenderingManager().

getRenderingType("org.eclipse.debug.ui.rendering.raw_memory");
        IMemoryRendering rendering = renderingType.createRendering();

        IMemoryRenderingContainer container = memoryView.getContainer(
                   DebugUIPlugin.getUniqueIdentifier() +
".MemoryView.RenderingViewPane.1");

//DO THIS BEFORE ADDING THE RENDERING TO THE CONTAINER
        rendering.init(container, mbe);


        container.addMemoryRendering(rendering); // <------------- null!!!
       }
       catch ...

I added the init call to the rendering and I was able to use your code to
add the hex rendering to the Memory View.

Let me know if you still have problems.  Thanks...

Samantha




                                                                           
             "Elin Karasalo"                                               
             <Elin.Karasalo@en                                             
             ea.se>                                                     To 
             Sent by:                  <platform-debug-dev@xxxxxxxxxxx>    
             platform-debug-de                                          cc 
             v-bounces@eclipse                                             
             .org                                                  Subject 
                                       [platform-debug-dev] use the Memory 
                                       View programmatically?              
             03/15/2006 10:02                                              
             AM                                                            
                                                                           
                                                                           
             Please respond to                                             
             "Eclipse Platform                                             
              Debug component                                              
             developers list."                                             
                                                                           
                                                                           




Hello,

I have a question about how to use the Memory View in Eclipse
programmatically.
I want to read/display memory for a given address using the Memory View.

So far I have been following the advice given in the Bugzilla Bug 87374:

>To programatically open the memory view:
>PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView
>("org.eclipse.debug.ui.MemoryView");
>
>To add memory blocks to the view, you need to add memory blocks to the
memory
>block manager:
>
>DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks(new
>IMemoryBlock[] {memoryBlocks});
>
>In addition to persisting the memory blocks, you may also want to persist
the
>renderings that are opened. You will need to persist the rendering id and
id
>of the containers in which a rendering is hosted.
>
>IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow>().
>getActivePage().showView("org.eclipse.debug.ui.memoryview");
>IMemoryRenderingSite memoryView = (IMemoryRenderingSite)part;
>IMemoryRenderingContainer container =
memoryView.getContainer("containerId");
>IMemoryRendering[] renderings = container.getRenderings[];
>
>When restoring the renderings, you will need to create the rendering, and
add
>the rendering to the appropriate container within the memory view.
>
>To create a rendering:
>IMemoryRenderingType renderingType =
DebugUITools.getMemoryRenderingManager().
>getRenderingType("rendeirng id");
>IMemoryRendering rendering = renderingType.createRendering();
>
>Then to add the rendering to the Memory View:
>IViewPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().
>getActivePage().showView("org.eclipse.debug.ui.memoryview");
>IMemoryRenderingSite memoryView = (IMemoryRenderingSite)part;
>IMemoryRenderingContainer container =
memoryView.getContainer("containerId");
>container.addMemoryRendering(rendering);
>
>Hope this helps...
>Samantha


If my IMemoryBlock implementation is correctly implemented and I have added
it with
DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks(),
wouldn't that be enough to render it with the default "raw" memory
renderer?

I could not get this to work, so I tried adding a memory renderer to a
memory rendering container,
but I can not get hold of a non-null container. What default memory
rendering containers are available?

My code so far looks like this (the container = null):


IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
  if (page != null)
  {
     try
     {
        IViewPart view = page.showView("org.eclipse.debug.ui.MemoryView");

        IMemoryRenderingSite memoryView = (IMemoryRenderingSite) view;
        MemoryBlockExtentsion mbe = new MemoryBlockExtentsion(new
DummyDebugTarget(), 0);
        DebugPlugin.getDefault().getMemoryBlockManager().
                    addMemoryBlocks(new IMemoryBlock[] {mbe});

        IMemoryRenderingType renderingType =
DebugUITools.getMemoryRenderingManager().

getRenderingType("org.eclipse.debug.ui.rendering.raw_memory");
        IMemoryRendering rendering = renderingType.createRendering();

        IMemoryRenderingContainer container = memoryView.getContainer(
                   DebugUIPlugin.getUniqueIdentifier() +
".MemoryView.RenderingViewPane.1");
        container.addMemoryRendering(rendering); // <------------- null!!!
       }
       catch ...


In summary, what are the minimal steps required in order to display a block
of memory
in the Memory View?


- Elin Karasalo


(I posted this message to the eclipse.tools.cdt newsgroup, and was told to
mail the
eclipse-debug-dev@xxxxxxxxxxx mailing list. I could not find this mailing
list and
am now trying this list.)_______________________________________________
platform-debug-dev mailing list
platform-debug-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-debug-dev




Back to the top