diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java index eac3d58ab16..be9c1198ac5 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2009-2010 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Ted R Williams (Wind River Systems, Inc.) - initial implementation + * Ted R Williams (Mentor Graphics, Inc.) - address space enhancements *******************************************************************************/ package org.eclipse.cdt.debug.ui.memory.memorybrowser; @@ -81,6 +82,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -117,6 +119,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM private HashMap fContextFolders = new HashMap (); private GoToAddressBarWidget fGotoAddressBar; private Control fGotoAddressBarControl; + private Combo fGotoAddressSpaceControl; private Label fUnsupportedLabel; private Composite fMainComposite; private String defaultRenderingTypeId = null; @@ -128,6 +131,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM private final static String KEY_MEMORY_BLOCK = "MEMORY"; //$NON-NLS-1$ private final static String KEY_RETRIEVAL = "RETRIEVAL"; //$NON-NLS-1$ private final static String KEY_CONTAINER = "CONTAINER"; //$NON-NLS-1$ + private final static String KEY_ADDRESS_SPACE_PREFIXES = "ADDRESSSPACEPREFIXES"; //$NON-NLS-1$ public static final String PREF_DEFAULT_RENDERING = "org.eclipse.cdt.debug.ui.memory.memorybrowser.defaultRendering"; //$NON-NLS-1$ @@ -173,6 +177,8 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM layout.spacing = 0; fMainComposite.setLayout(layout); + fGotoAddressSpaceControl = new Combo(fMainComposite, SWT.DROP_DOWN | SWT.READ_ONLY); + fGotoAddressBar = new GoToAddressBarWidget(); fGotoAddressBarControl = fGotoAddressBar.createControl(fMainComposite); @@ -197,9 +203,10 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM } }); + FormData data = new FormData(); data.top = new FormAttachment(0); - data.left = new FormAttachment(0); + data.left = new FormAttachment(fGotoAddressSpaceControl); data.right = new FormAttachment(100); fGotoAddressBarControl.setLayoutData(data); @@ -312,6 +319,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM { fStackLayout.topControl = fUnsupportedLabel; fGotoAddressBarControl.setVisible(false); + fGotoAddressSpaceControl.setVisible(false); } private void performGo(boolean inNewTab) @@ -337,7 +345,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM } final IRepositionableMemoryRendering rendering = (IRepositionableMemoryRendering) activeFolder.getSelection().getData(KEY_RENDERING); - final String gotoExpression = expression; + final String gotoExpression = getAddressSpacePrefix() + expression; if(retrieval instanceof IMemoryBlockRetrievalExtension) { @@ -365,6 +373,16 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM } } + private String getAddressSpacePrefix() + { + String prefixes[] = (String[]) fGotoAddressSpaceControl.getData(KEY_ADDRESS_SPACE_PREFIXES); + if(prefixes.length > 0) + { + return prefixes[fGotoAddressSpaceControl.getSelectionIndex()]; + } + return ""; + } + // MemoryBrowser.FailedToGoToAddressTitle=Unable to Go To specified address // MemoryBrowser.UnableToEvaluateAddress @@ -387,6 +405,28 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM tab.setText(label); } + /** + * fetch memory spaces for a given IMemoryBlockRetrieval + * @param retrieval memory block retrieval. + * @return two arrays, the first containing memory space mnemonics, the second containing associated expression prefixes + */ + + private String[][] getAddressSpaces(IMemoryBlockRetrieval retrieval) + { + // would like to avoid using reflection, but necessary interface additions should live in platform to avoid introducing dependencies. + + String[][] addressSpaceTitles = new String[0][0]; + try { + Method m = retrieval.getClass().getMethod("getAddressSpaces", new Class[0]); //$NON-NLS-1$ + if(m != null) + addressSpaceTitles = (String[][]) m.invoke(retrieval, new Object[0]); + } + catch (Exception e) + { + } + return addressSpaceTitles; + } + private CTabFolder createTabFolder(Composite parent) { final CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT); @@ -560,6 +600,15 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM if(retrieval != null && launch != null && !launch.isTerminated()) { fGotoAddressBarControl.setVisible(true); + String addressSpaces[][] = getAddressSpaces(retrieval); + if(addressSpaces[0].length > 0) + { + fGotoAddressSpaceControl.setVisible(true); + fGotoAddressSpaceControl.setItems(addressSpaces[0]); + fGotoAddressSpaceControl.setData(KEY_ADDRESS_SPACE_PREFIXES, addressSpaces[1]); + } + else + fGotoAddressSpaceControl.setVisible(false); CTabFolder tabFolder = getTabFolder(retrieval); if(tabFolder != null) { @@ -591,6 +640,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM { handleUnsupportedSelection(); } + fGotoAddressSpaceControl.pack(true); fStackLayout.topControl.getParent().layout(true); } }