1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

Temporary fix for bug 77279: The memory view address should not be cleared on project restart.

This commit is contained in:
Mikhail Khodjaiants 2005-06-13 20:19:58 +00:00
parent 5122fa3417
commit 953acd1eef
5 changed files with 134 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2005-06-13 Mikhail Khodjaiants
Temporary fix for bug 77279: The memory view address should not be cleared on project restart.
* ICDTLaunchConfigurationConstants.java
* CMemoryBlockRetrievalExtension.java
* InternalDebugCoreMessages.properties
* CDebugTarget.java
2005-06-12 Mikhail Khodjaiants
Temporary fix for bug 79872: Make instruction stepping default in disassembly view.
* ICDebugConstants.java

View file

@ -144,6 +144,11 @@ public interface ICDTLaunchConfigurationConstants {
*/
public static final String ATTR_DEBUGGER_GLOBAL_VARIABLES = CDT_LAUNCH_ID + ".GLOBAL_VARIABLES"; //$NON-NLS-1$
/**
* Launch configuration attribute key. The value is a memory blocks' memento.
*/
public static final String ATTR_DEBUGGER_MEMORY_BLOCKS = CDT_LAUNCH_ID + ".MEMORY_BLOCKS"; //$NON-NLS-1$
/**
* Launch configuration attribute value. The key is
* ATTR_DEBUGGER_STOP_AT_MAIN.

View file

@ -12,7 +12,11 @@ package org.eclipse.cdt.debug.internal.core;
import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.model.ICType;
@ -22,9 +26,13 @@ import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CMemoryBlockExtension;
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
import org.eclipse.cdt.debug.internal.core.model.CThread;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IMemoryBlock;
@ -32,12 +40,20 @@ import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IValue;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Implements the memory retrieval features based on the CDI model.
*/
public class CMemoryBlockRetrievalExtension implements IMemoryBlockRetrievalExtension {
private static final String MEMORY_BLOCK_EXPRESSION_LIST = "memoryBlockExpressionList"; //$NON-NLS-1$
private static final String MEMORY_BLOCK_EXPRESSION = "expression"; //$NON-NLS-1$
private static final String ATTR_MEMORY_BLOCK_EXPRESSION_TEXT = "text"; //$NON-NLS-1$
CDebugTarget fDebugTarget;
/**
@ -51,6 +67,72 @@ public class CMemoryBlockRetrievalExtension implements IMemoryBlockRetrievalExte
return fDebugTarget;
}
public void initialize() {
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
try {
String memento = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_MEMORY_BLOCKS, "" ); //$NON-NLS-1$
if ( memento != null && memento.trim().length() != 0 )
initializeFromMemento( memento );
}
catch( CoreException e ) {
CDebugCorePlugin.log( e );
}
}
private void initializeFromMemento( String memento ) throws CoreException {
Element root = DebugPlugin.parseDocument( memento );
if ( root.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION_LIST ) ) {
List expressions = new ArrayList();
NodeList list = root.getChildNodes();
int length = list.getLength();
for( int i = 0; i < length; ++i ) {
Node node = list.item( i );
short type = node.getNodeType();
if ( type == Node.ELEMENT_NODE ) {
Element entry = (Element)node;
if ( entry.getNodeName().equalsIgnoreCase( MEMORY_BLOCK_EXPRESSION ) ) {
String exp = entry.getAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT );
expressions.add( exp );
}
}
}
createMemoryBlocks( (String[])expressions.toArray( new String[expressions.size()] ) );
return;
}
abort( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.3" ), null ); //$NON-NLS-1$
}
private void createMemoryBlocks( String[] expressions ) {
ArrayList list = new ArrayList( expressions.length );
for ( int i = 0; i < expressions.length; ++i ) {
IAddress address = getDebugTarget().getAddressFactory().createAddress( expressions[i] );
if ( address != null ) {
list.add( new CMemoryBlockExtension( getDebugTarget(), address.toHexAddressString(), address.getValue() ) );
}
}
DebugPlugin.getDefault().getMemoryBlockManager().addMemoryBlocks( (IMemoryBlock[])list.toArray( new IMemoryBlock[list.size()] ) );
}
public String getMemento() throws CoreException {
IMemoryBlock[] blocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks( getDebugTarget() );
Document document = DebugPlugin.newDocument();
Element element = document.createElement( MEMORY_BLOCK_EXPRESSION_LIST );
for ( int i = 0; i < blocks.length; ++i ) {
if ( blocks[i] instanceof IMemoryBlockExtension ) {
Element child = document.createElement( MEMORY_BLOCK_EXPRESSION );
try {
child.setAttribute( ATTR_MEMORY_BLOCK_EXPRESSION_TEXT, ((IMemoryBlockExtension)blocks[i]).getBigBaseAddress().toString() );
element.appendChild( child );
}
catch( DebugException e ) {
CDebugCorePlugin.log( e.getStatus() );
}
}
}
document.appendChild( element );
return DebugPlugin.serializeDocument( document );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlockExtensionRetrieval#getExtendedMemoryBlock(java.lang.String, org.eclipse.debug.core.model.IDebugElement)
*/
@ -71,6 +153,7 @@ public class CMemoryBlockRetrievalExtension implements IMemoryBlockRetrievalExte
ICType type = ((ICValue)value).getType();
if ( type != null && (type.isPointer() || type.isIntegralType()) ) {
address = value.getValueString();
exp.dispose();
IDebugTarget target = debugElement.getDebugTarget();
if ( target instanceof CDebugTarget ) {
if ( address != null ) {
@ -127,4 +210,27 @@ public class CMemoryBlockRetrievalExtension implements IMemoryBlockRetrievalExte
}
return null;
}
public void save() {
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
try {
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_MEMORY_BLOCKS, getMemento() );
wc.doSave();
}
catch( CoreException e ) {
CDebugCorePlugin.log( e.getStatus() );
}
}
/**
* Throws an internal error exception
*/
private void abort( String message, Throwable e ) throws CoreException {
IStatus s = new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, message, e );
throw new CoreException( s );
}
public void dispose() {
}
}

View file

@ -16,6 +16,7 @@ CGlobalVariableManager.0=Invalid global variables data.
CMemoryBlockRetrievalExtension.0=Expression ''{0}'' evaluated to invalid address value: {1}.
CMemoryBlockRetrievalExtension.1=Invalid expression type: ''{0}''
CMemoryBlockRetrievalExtension.2=Invalid expression: ''{0}''
CMemoryBlockRetrievalExtension.3=Memory initialization: invalid memento.
DebugConfiguration.0=This debugger no longer supports this operation
CDebugAdapter.0=This debugger does not support debugging external files
CDebugAdapter.1=Debugger Process

View file

@ -256,6 +256,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
initializeRegisters();
initializeSourceManager();
initializeModuleManager();
initializeMemoryBlocks();
getLaunch().addDebugTarget( this );
fireEventSet( (DebugEvent[])debugEvents.toArray( new DebugEvent[debugEvents.size()] ) );
}
@ -352,6 +353,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
getModuleManager().addModules( new ICModule[] { CModule.createExecutable( this, getExecFile().getPath() ) } );
}
protected void initializeMemoryBlocks() {
getMemoryBlockRetrieval().initialize();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
*/
@ -989,6 +994,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
disposeSignalManager();
saveRegisterGroups();
disposeRegisterManager();
saveMemoryBlocks();
disposeMemoryBlockRetrieval();
disposeDisassembly();
disposeSourceManager();
disposeSourceLookupPath();
@ -1465,6 +1472,14 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
}
protected void saveMemoryBlocks() {
getMemoryBlockRetrieval().save();
}
protected void disposeMemoryBlockRetrieval() {
getMemoryBlockRetrieval().dispose();
}
public IFile getCurrentBreakpointFile() {
Object info = getCurrentStateInfo();
if ( info instanceof ICDIBreakpointHit ) {