1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

196392 - calls to MemoryBlock on the UI dispatch thread

This commit is contained in:
Ted Williams 2007-07-12 21:57:51 +00:00
parent 876cf49ed7
commit f5439d09a4
5 changed files with 147 additions and 112 deletions

View file

@ -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,

View file

@ -68,7 +68,7 @@ public abstract class AbstractPane extends Canvas
try
{
fCaretAddress = rendering.getMemoryBlock().getBigBaseAddress();
fCaretAddress = rendering.getBigBaseAddress();
}
catch(Exception e)
{

View file

@ -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;
}

View file

@ -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

View file

@ -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.