diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java index 931e85728ce..64c4783f289 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java @@ -234,6 +234,25 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, public void setChildCountLimit(int newLimit) { this.childCountLimit = newLimit; } + + /** + * @return if this expression is part of the memory space or not. + * If it not part of the memory space, it won't have an address. + * @since 4.2 + */ + public boolean inMemory() { + // Registers and convenience variables which both start with $ + // are not part of memory. We care about the top-most parent + // as it is the only one that can be a register or convenience var. + if (getParent() == null) { + if (getRelExpr().startsWith("$")) { //$NON-NLS-1$ + return false; + } + return true; + } + + return getParent().inMemory(); + } } /** @@ -1066,9 +1085,12 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, if (dmc instanceof MIExpressionDMC) { MIExpressionDMC miDMC = (MIExpressionDMC) dmc; - if (miDMC.getExpressionInfo().hasDynamicAncestor()) { + if (miDMC.getExpressionInfo().hasDynamicAncestor() || + !miDMC.getExpressionInfo().inMemory()) { // For children of dynamic varobjs, there is no full expression that gdb - // could evaluate in order to provide address and size. + // could evaluate in order to provide address and size. + // Also, if an expression is not in memory, such as a register + // or a GDB convenience variable, there is no address to return rm.setData(new InvalidDMAddress()); rm.done(); return; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java index 67cc4f3da5f..be7fa3dc801 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java @@ -518,18 +518,20 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer protected void handleSuccess() { // Figure out which memory area was modified IExpressionDMAddress expression = getData(); - final int count = expression.getSize(); IAddress expAddress = expression.getAddress(); - final Addr64 address; - if (expAddress instanceof Addr64) - address = (Addr64) expAddress; - else - address = new Addr64(expAddress.getValue()); + if (expAddress != IExpressions.IExpressionDMLocation.INVALID_ADDRESS) { + final int count = expression.getSize(); + final Addr64 address; + if (expAddress instanceof Addr64) + address = (Addr64) expAddress; + else + address = new Addr64(expAddress.getValue()); - final IMemoryDMContext memoryDMC = DMContexts.getAncestorOfType(context, IMemoryDMContext.class); - getMemoryCache(memoryDMC).refreshMemory(memoryDMC, address, 0, 1, count, true, - new RequestMonitor(getExecutor(), null)); + final IMemoryDMContext memoryDMC = DMContexts.getAncestorOfType(context, IMemoryDMContext.class); + getMemoryCache(memoryDMC).refreshMemory(memoryDMC, address, 0, 1, count, true, + new RequestMonitor(getExecutor(), null)); } + } }); } }