From f5439d09a45ffc4e2dd8afcf091056e6be378b54 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 12 Jul 2007 21:57:51 +0000 Subject: [PATCH] 196392 - calls to MemoryBlock on the UI dispatch thread --- .../META-INF/MANIFEST.MF | 2 +- .../renderings/traditional/AbstractPane.java | 2 +- .../renderings/traditional/Rendering.java | 128 ++++-------------- .../traditional/TraditionalRendering.java | 126 +++++++++++++++-- .../TraditionalRendering_messages.properties | 1 + 5 files changed, 147 insertions(+), 112 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index 091efcb421b..ee4f0610be2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Traditional Memory Rendering Bundle-SymbolicName: org.eclipse.dd.debug.memory.renderings.traditional;singleton:=true -Bundle-Version: 0.9.0.qualifier +Bundle-Version: 1.0.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.debug.core, org.eclipse.debug.ui, diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 628f8e45b5c..b8c399f3086 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -68,7 +68,7 @@ public abstract class AbstractPane extends Canvas try { - fCaretAddress = rendering.getMemoryBlock().getBigBaseAddress(); + fCaretAddress = rendering.getBigBaseAddress(); } catch(Exception e) { diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index bf5da6bead7..b2fdf416399 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -183,27 +183,15 @@ public class Rendering extends Composite implements IDebugEventSetListener this.fAddressBarControl.setVisible(false); // initialize the viewport start - IMemoryBlockExtension memoryBlock = getMemoryBlock(); - if(memoryBlock != null) + if(fParent.getMemoryBlock() != null) { - try - { - fViewportAddress = memoryBlock.getMemoryBlockStartAddress(); - // this will be null if memory may be retrieved at any address less than - // this memory block's base. if so use the base address. - if (fViewportAddress == null) - fViewportAddress = memoryBlock.getBigBaseAddress(); - fBaseAddress = fViewportAddress; - } - catch(DebugException e) - { - fViewportAddress = null; - if(isDebug()) - Rendering.this - .logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), e); //$NON-NLS-1$ - } + fViewportAddress = fParent.getMemoryBlockStartAddress(); + + // this will be null if memory may be retrieved at any address less than + // this memory block's base. if so use the base address. + if (fViewportAddress == null) + fViewportAddress = fParent.getBigBaseAddress(); + fBaseAddress = fViewportAddress; } getHorizontalBar().addSelectionListener(new SelectionListener() @@ -520,7 +508,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return false; } - protected IMemoryBlockExtension getMemoryBlock() + private IMemoryBlockExtension getMemoryBlock() { IMemoryBlock block = fParent.getMemoryBlock(); if(block != null) @@ -529,17 +517,15 @@ public class Rendering extends Composite implements IDebugEventSetListener return null; } + + protected BigInteger getBigBaseAddress() + { + return fParent.getBigBaseAddress(); + } protected int getAddressableSize() { - try - { - return getMemoryBlock().getAddressableSize(); - } - catch(DebugException e) - { - return 1; - } + return fParent.getAddressableSize(); } protected ViewportCache getViewportCache() @@ -925,7 +911,7 @@ public class Rendering extends Composite implements IDebugEventSetListener try { - getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); + getMemoryBlock().setValue(address.subtract(fParent.getBigBaseAddress()), byteValue); } catch(Exception e) { @@ -1334,27 +1320,9 @@ public class Rendering extends Composite implements IDebugEventSetListener return addressString.toString(); } - private int fAddressBytes = -1; // called often, cache - protected int getAddressBytes() { - if(fAddressBytes == -1) - { - try - { - IMemoryBlockExtension block = getMemoryBlock(); - fAddressBytes = block.getAddressSize(); - } - catch(DebugException e) - { - fAddressBytes = 0; - logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE"), e); //$NON-NLS-1$ - } - } - - return fAddressBytes; + return fParent.getAddressSize(); } protected int getColumnCount() @@ -1439,25 +1407,12 @@ public class Rendering extends Composite implements IDebugEventSetListener */ protected BigInteger getMemoryBlockStartAddress() { - if (fMemoryBlockStartAddress == null) - { - try { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); - if (startAddress != null) - fMemoryBlockStartAddress = startAddress; - } - } catch (DebugException e) { - fMemoryBlockStartAddress = null; - } - - // default to 0 if we have trouble getting the start address - if (fMemoryBlockStartAddress == null) - fMemoryBlockStartAddress = BigInteger.valueOf(0); - } - return fMemoryBlockStartAddress; + if(fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = fParent.getMemoryBlockStartAddress(); + if(fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = BigInteger.ZERO; + + return fMemoryBlockStartAddress; } /** @@ -1465,40 +1420,9 @@ public class Rendering extends Composite implements IDebugEventSetListener */ protected BigInteger getMemoryBlockEndAddress() { - if (fMemoryBlockEndAddress == null) - { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger endAddress; - try { - endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); - if (endAddress != null) - fMemoryBlockEndAddress = endAddress; - } catch (DebugException e) { - fMemoryBlockEndAddress = null; - } - - if (fMemoryBlockEndAddress == null) - { - int addressSize; - try { - addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); - } catch (DebugException e) { - addressSize = 4; - } - - endAddress = BigInteger.valueOf(2); - endAddress = endAddress.pow(addressSize*8); - endAddress = endAddress.subtract(BigInteger.valueOf(1)); - fMemoryBlockEndAddress = endAddress; - } - } - - // default to MAX_VALUE if we have trouble getting the end address - if (fMemoryBlockEndAddress == null) - fMemoryBlockEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); - } + if(fMemoryBlockEndAddress == null) + fMemoryBlockEndAddress = fParent.getMemoryBlockEndAddress(); + return fMemoryBlockEndAddress; } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index aae549716d4..48f47b3bb87 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -21,14 +21,18 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; @@ -50,22 +54,15 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.progress.UIJob; @@ -155,7 +152,121 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe }); } + + protected void logError(String message, Exception e) + { + Status status = new Status(IStatus.ERROR, getRenderingId(), + DebugException.INTERNAL_ERROR, message, e); + DebugUIPlugin.getDefault().getLog().log(status); + } + + private BigInteger fBigBaseAddress; + private BigInteger fStartAddress; + private BigInteger fEndAddress; + private int fAddressableSize; + private int fAddressSize; + + public void init(IMemoryRenderingContainer container, IMemoryBlock block) + { + super.init(container, block); + + try + { + fBigBaseAddress = ((IMemoryBlockExtension) block).getBigBaseAddress(); + } + catch(DebugException de) + { + logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_BASE_ADDRESS"), de); //$NON-NLS-1$ // FIXME + } + + try + { + fAddressableSize = ((IMemoryBlockExtension) block).getAddressableSize(); + } + catch(DebugException de) + { + fAddressableSize = 1; + } + + try + { + fStartAddress = ((IMemoryBlockExtension)block).getMemoryBlockStartAddress(); + } + catch (DebugException de) { + fStartAddress = null; + logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), de); //$NON-NLS-1$ + } + + + try + { + fAddressSize = ((IMemoryBlockExtension) block).getAddressSize(); + } + catch(DebugException e) + { + fAddressSize = 0; + } + + BigInteger endAddress; + try + { + endAddress = ((IMemoryBlockExtension) block).getMemoryBlockEndAddress(); + if (endAddress != null) + fEndAddress = endAddress; + } + catch (DebugException e) + { + fEndAddress = null; + } + + if (fEndAddress == null) + { + int addressSize; + try { + addressSize = ((IMemoryBlockExtension) block).getAddressSize(); + } catch (DebugException e) { + addressSize = 4; + } + + endAddress = BigInteger.valueOf(2); + endAddress = endAddress.pow(addressSize*8); + endAddress = endAddress.subtract(BigInteger.valueOf(1)); + fEndAddress = endAddress; + } + + // default to MAX_VALUE if we have trouble getting the end address + if (fEndAddress == null) + fEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); + } + + public BigInteger getBigBaseAddress() + { + return fBigBaseAddress; + } + + public BigInteger getMemoryBlockStartAddress() + { + return fStartAddress; + } + + public BigInteger getMemoryBlockEndAddress() + { + return fEndAddress; + } + + public int getAddressableSize() + { + return fAddressableSize; + } + + public int getAddressSize() + { + return fAddressSize; + } + public Control createControl(Composite parent) { allocateColors(); @@ -901,7 +1012,6 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe return super.getAdapter(adapter); } - } class TraditionalMemoryByte extends MemoryByte diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties index 04ddb74484c..a1f4ec4c951 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -24,6 +24,7 @@ TraditionalRendering.CELL_SIZE=Cell Size TraditionalRendering.RADIX=Radix TraditionalRendering.RENDERING_NAME=Traditional TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS=Failure in retrieving start address. +TraditionalRendering.FAILURE_RETRIEVE_BASE_ADDRESS=Failure in retrieving base address. TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD=Called on non-dispatch thread TraditionalRendering.FAILURE_READ_MEMORY=Failed reading memory. TraditionalRendering.FAILURE_WRITE_MEMORY=Error writing memory.