diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java index 812c77ee9e5..ad4837a0dea 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/provisional/IMemorySpaceAwareMemoryBlockRetrieval.java @@ -92,5 +92,12 @@ public interface IMemorySpaceAwareMemoryBlockRetrieval extends IMemoryBlockRetri * if unable to retrieve the specified memory */ public IMemorySpaceAwareMemoryBlock getMemoryBlock(String expression, Object context, String memorySpaceID) throws DebugException; - + + /** + * Return true if creating a memory block with a null memory space ID is NOT + * supported. Some debuggers may not have the ability to infer the memory + * space from an expression, in which case the user should be forced to + * select a memory space when being prompted for a memory location. + */ + public boolean creatingBlockRequiresMemorySpaceID(); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java index cd38ad9c30c..c0a64fc6127 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java @@ -473,4 +473,13 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM // Nope; use default decoding return decodeAddressDefault(str); } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#creatingBlockRequiresMemorySpaceID() + */ + public boolean creatingBlockRequiresMemorySpaceID() { + // A behavioral control we're not extending to CDI clients, but is being + // extended to DSF ones. + return false; + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java index bbcd45a6d1c..485cd0be2cb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java @@ -362,4 +362,15 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks( blocks.toArray(new IMemoryBlock[blocks.size()])); } } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#creatingBlockRequiresMemorySpaceID() + */ + public boolean creatingBlockRequiresMemorySpaceID() { + IMemorySpaces memoryPageService = (IMemorySpaces)fMemorySpaceServiceTracker.getService(); + if (memoryPageService != null) { + return memoryPageService.creatingBlockRequiresMemorySpaceID(); + } + return false; + } } diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMemorySpaces.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMemorySpaces.java index e5396f814ce..79794457d91 100644 --- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMemorySpaces.java +++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IMemorySpaces.java @@ -68,12 +68,23 @@ public interface IMemorySpaces extends IDsfService{ String getMemorySpaceId(); String getExpression(); } - + /** * Provides the memory spaces available in the given context. * - * @param ctx a DM context - * @param rm the asynchronous data request monitor + * @param ctx + * a DM context + * @param rm + * the asynchronous data request monitor. Returns a collection of + * memory space IDs. */ - void getMemorySpaces(IDMContext context, final DataRequestMonitor rm); + void getMemorySpaces(IDMContext context, final DataRequestMonitor rm); + + /** + * Return true if creating a memory block with a null memory space ID is NOT + * supported. Some debuggers may not have the ability to infer the memory + * space from an expression, in which case the user should be forced to + * select a memory space when being prompted for a memory location. + */ + public boolean creatingBlockRequiresMemorySpaceID(); } 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 7a6adf78d48..853890c3958 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 @@ -367,11 +367,15 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM } private void performGo(boolean inNewTab) { - // Index zero is the 'auto' (n/a) memory space entry + // Index zero is the 'auto' (n/a) memory space entry, unless the backend + // said we need to force a memory space selection String memorySpace = null; - if (fGotoMemorySpaceControl.isVisible() && (fGotoMemorySpaceControl.getSelectionIndex() != 0)) { + if (fGotoMemorySpaceControl.isVisible()) { memorySpace = fGotoMemorySpaceControl.getText(); - assert (memorySpace != null) && (memorySpace.length() > 0); + if (memorySpace.equals(NA_MEMORY_SPACE_ID)) { + memorySpace = null; + } + assert (memorySpace == null) || (memorySpace.length() > 0); } String expression = fGotoAddressBar.getExpressionText(); @@ -855,7 +859,16 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM // https://bugs.eclipse.org/bugs/show_bug.cgi?id=309032#c50 if (memorySpaces.length >= 2) { fGotoMemorySpaceControl.setItems(memorySpaces); - fGotoMemorySpaceControl.add(NA_MEMORY_SPACE_ID, 0); //$NON-NLS-1$ the n/a entry; don't think this needs to be translated + + // Add the '----' (N/A) entry unless the retrieval object + // says it requires a memory space ID in all cases + boolean addNA = true; + if (retrieval instanceof IMemorySpaceAwareMemoryBlockRetrieval) { + addNA = !((IMemorySpaceAwareMemoryBlockRetrieval)retrieval).creatingBlockRequiresMemorySpaceID(); + } + if (addNA) { + fGotoMemorySpaceControl.add(NA_MEMORY_SPACE_ID, 0); + } setMemorySpaceControlVisible(true); } else {