mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 94139: User-defined register groups. Added API and group serialization.
This commit is contained in:
parent
ab0ae772ae
commit
1edec8debe
13 changed files with 540 additions and 113 deletions
|
@ -1,3 +1,19 @@
|
|||
2005-05-20 Mikhail Khodjaiants
|
||||
Bug 94139: User-defined register groups.
|
||||
Added API and group serialization.
|
||||
* ICDTLaunchConfigurationConstants.java
|
||||
- ICRegisterManager.java
|
||||
* ICDebugTarget.java
|
||||
+ IPersistableRegisterGroup.java
|
||||
+ IRegisterDescriptor.java
|
||||
* CRegisterManager.java
|
||||
* InternalDebugCoreMessages.properties
|
||||
* CDebugTarget.java
|
||||
* CoreModelMessages.properties
|
||||
* CRegister.java
|
||||
+ CRegisterDescriptor.java
|
||||
* CRegisterGroup.java
|
||||
|
||||
2005-05-12 Mikhail Khodjaiants
|
||||
Bug 94905: Error examining structure contents in debugger.
|
||||
The structure's elements should inherit the enablement flag from parents.
|
||||
|
|
|
@ -94,6 +94,12 @@ public interface ICDTLaunchConfigurationConstants {
|
|||
*/
|
||||
public static final String ATTR_DEBUGGER_STOP_AT_MAIN = CDT_LAUNCH_ID + ".DEBUGGER_STOP_AT_MAIN"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Launch configuration attribute key. The value is a String specifying
|
||||
* the register groups memento.
|
||||
*/
|
||||
public static final String ATTR_DEBUGGER_REGISTER_GROUPS = CDT_LAUNCH_ID + ".DEBUGGER_REGISTER_GROUPS"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Launch configuration attribute key. The value is an int specifying the
|
||||
* process id to attach to if the ATTR_DEBUGGER_START_MODE is
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.core;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
* Provides the access to the register groups' management functions.
|
||||
*/
|
||||
public interface ICRegisterManager extends IAdaptable {
|
||||
|
||||
void addRegisterGroup( IRegisterGroup group );
|
||||
|
||||
void removeRegisterGroup( IRegisterGroup group );
|
||||
|
||||
void removeAllRegisterGroups();
|
||||
}
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.core.model;
|
|||
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
* C/C++ extension of <code>IDebugTarget</code>.
|
||||
|
@ -90,4 +91,33 @@ public interface ICDebugTarget extends IDebugTarget,
|
|||
* @throws DebugException if this method fails. Reasons include:
|
||||
*/
|
||||
public void loadSymbolsForAllModules() throws DebugException;
|
||||
|
||||
/**
|
||||
* Returns the list of descriptors of the target registers
|
||||
*
|
||||
* @return the list register descriptors
|
||||
* @throws DebugException if this method fails. Reasons include:
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public IRegisterDescriptor[] getRegisterDescriptors() throws DebugException;
|
||||
|
||||
/**
|
||||
* Adds a new user-defined register group to this target
|
||||
*
|
||||
* @param name the group name
|
||||
* @param descriptors the list of registers to be grouped
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public void addUserDefinedRegisterGroup( String name, IRegisterDescriptor[] descriptors );
|
||||
|
||||
/**
|
||||
* Removes the given register group from the target
|
||||
*
|
||||
* @param group a group to be removed
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public void removeRegisterGroups( IRegisterGroup[] groups );
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
|
||||
/**
|
||||
* A register group to be persisted and restored.
|
||||
* To be used for the user-defined register groups.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IPersistableRegisterGroup extends IRegisterGroup {
|
||||
|
||||
/**
|
||||
* Returns a memento that can be used to reconstruct this group
|
||||
*
|
||||
* @return a memento that can be used to reconstruct this group
|
||||
* @exception CoreException if unable to construct a memento
|
||||
*/
|
||||
public String getMemento() throws CoreException;
|
||||
|
||||
/**
|
||||
* Initializes this group based on the given memento.
|
||||
*
|
||||
* @param memento a memento to initialize this group
|
||||
* @exception CoreException on failure to initialize
|
||||
*/
|
||||
public void initializeFromMemento( String memento ) throws CoreException;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.core.model;
|
||||
|
||||
/**
|
||||
* Describes a register.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IRegisterDescriptor {
|
||||
|
||||
/**
|
||||
* Returns the regiser's name
|
||||
*
|
||||
* @return the register's name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Returns the name of the hardware register group this register belongs to
|
||||
*
|
||||
* @return the name of the hardware register group
|
||||
*/
|
||||
public String getGroupName();
|
||||
}
|
|
@ -11,22 +11,41 @@
|
|||
package org.eclipse.cdt.debug.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICRegisterManager;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CRegisterGroup;
|
||||
import org.eclipse.cdt.debug.internal.core.model.CStackFrame;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
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.IRegisterGroup;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* Manages all register groups in a debug target.
|
||||
*/
|
||||
public class CRegisterManager implements ICRegisterManager {
|
||||
public class CRegisterManager {
|
||||
|
||||
private static final String ELEMENT_REGISTER_GROUP_LIST = "registerGroups"; //$NON-NLS-1$
|
||||
private static final String ELEMENT_REGISTER_GROUP = "group"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_GROUP_MEMENTO = "memento"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The debug target associated with this manager.
|
||||
|
@ -36,12 +55,12 @@ public class CRegisterManager implements ICRegisterManager {
|
|||
/**
|
||||
* Collection of register groups added to this target. Values are of type <code>CRegisterGroup</code>.
|
||||
*/
|
||||
private List fRegisterGroups;
|
||||
protected List fRegisterGroups;
|
||||
|
||||
/**
|
||||
* The last stack frame.
|
||||
* The list of all register descriptors.
|
||||
*/
|
||||
private CStackFrame fStackFrame;
|
||||
private IRegisterDescriptor[] fRegisterDescriptors;
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterManager.
|
||||
|
@ -54,68 +73,99 @@ public class CRegisterManager implements ICRegisterManager {
|
|||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter( Class adapter ) {
|
||||
if ( ICRegisterManager.class.equals( adapter ) )
|
||||
return this;
|
||||
if ( CRegisterManager.class.equals( adapter ) )
|
||||
return this;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
setStackFrame( null );
|
||||
removeAllRegisterGroups();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.ICRegisterManager#addRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup)
|
||||
*/
|
||||
public void addRegisterGroup( IRegisterGroup group ) {
|
||||
// TODO Auto-generated method stub
|
||||
public IRegisterDescriptor[] getAllRegisterDescriptors() throws DebugException {
|
||||
return fRegisterDescriptors;
|
||||
}
|
||||
|
||||
public IRegisterGroup[] getRegisterGroups( CStackFrame frame ) throws DebugException {
|
||||
setStackFrame( frame );
|
||||
return (IRegisterGroup[])fRegisterGroups.toArray( new IRegisterGroup[fRegisterGroups.size()] );
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
createRegisterGroups();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.ICRegisterManager#removeAllRegisterGroups()
|
||||
*/
|
||||
public void removeAllRegisterGroups() {
|
||||
Iterator it = fRegisterGroups.iterator();
|
||||
while( it.hasNext() ) {
|
||||
((CRegisterGroup)it.next()).dispose();
|
||||
}
|
||||
fRegisterGroups.clear();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.ICRegisterManager#removeRegisterGroup(org.eclipse.debug.core.model.IRegisterGroup)
|
||||
*/
|
||||
public void removeRegisterGroup( IRegisterGroup group ) {
|
||||
fRegisterGroups.remove( group );
|
||||
}
|
||||
|
||||
private void createRegisterGroups() {
|
||||
fRegisterGroups = new ArrayList( 20 );
|
||||
createMainRegisterGroup();
|
||||
}
|
||||
|
||||
private void createMainRegisterGroup() {
|
||||
ICDIRegisterGroup[] groups = null;
|
||||
ICDIRegisterGroup[] groups = new ICDIRegisterGroup[0];
|
||||
try {
|
||||
groups = getDebugTarget().getCDITarget().getRegisterGroups();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
for (int i = 0; i < groups.length; ++i) {
|
||||
fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), groups[i] ) ); //$NON-NLS-1$
|
||||
List list = new ArrayList();
|
||||
for( int i = 0; i < groups.length; ++i ) {
|
||||
try {
|
||||
ICDIRegisterDescriptor[] cdiDescriptors = groups[i].getRegisterDescriptors();
|
||||
for ( int j = 0; j < cdiDescriptors.length; ++j ) {
|
||||
list.add( new CRegisterDescriptor( groups[i], cdiDescriptors[j] ) );
|
||||
}
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
}
|
||||
fRegisterDescriptors = (IRegisterDescriptor[])list.toArray( new IRegisterDescriptor[list.size()] );
|
||||
createRegisterGroups();
|
||||
}
|
||||
|
||||
public void addRegisterGroup( final String name, final IRegisterDescriptor[] descriptors ) {
|
||||
DebugPlugin.getDefault().asyncExec(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), name, descriptors ) );
|
||||
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void removeAllRegisterGroups() {
|
||||
DebugPlugin.getDefault().asyncExec(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
synchronized( fRegisterGroups ) {
|
||||
Iterator it = fRegisterGroups.iterator();
|
||||
while( it.hasNext() ) {
|
||||
((CRegisterGroup)it.next()).dispose();
|
||||
}
|
||||
fRegisterGroups.clear();
|
||||
}
|
||||
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public void removeRegisterGroups( final IRegisterGroup[] groups ) {
|
||||
DebugPlugin.getDefault().asyncExec(
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
for ( int i = 0; i < groups.length; ++i ) {
|
||||
((CRegisterGroup)groups[i]).dispose();
|
||||
}
|
||||
fRegisterGroups.removeAll( Arrays.asList( groups ) );
|
||||
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void createRegisterGroups() {
|
||||
fRegisterGroups = Collections.synchronizedList( new ArrayList( 20 ) );
|
||||
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
|
||||
try {
|
||||
String memento = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS, "" ); //$NON-NLS-1$
|
||||
if ( memento != null && memento.length() > 0 ) {
|
||||
initializeFromMemento( memento );
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
initializeDefaults();
|
||||
}
|
||||
|
||||
public void targetSuspended() {
|
||||
|
@ -125,15 +175,102 @@ public class CRegisterManager implements ICRegisterManager {
|
|||
}
|
||||
}
|
||||
|
||||
public CStackFrame getStackFrame() {
|
||||
return fStackFrame;
|
||||
}
|
||||
|
||||
private void setStackFrame( CStackFrame stackFrame ) {
|
||||
fStackFrame = stackFrame;
|
||||
}
|
||||
|
||||
protected CDebugTarget getDebugTarget() {
|
||||
return fDebugTarget;
|
||||
}
|
||||
|
||||
private void initializeFromMemento( String memento ) throws CoreException {
|
||||
Node node = DebugPlugin.parseDocument( memento );
|
||||
if ( node.getNodeType() != Node.ELEMENT_NODE ) {
|
||||
abort( InternalDebugCoreMessages.getString( "CRegisterManager.0" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
Element element = (Element)node;
|
||||
if ( !ELEMENT_REGISTER_GROUP_LIST.equals( element.getNodeName() ) ) {
|
||||
abort( InternalDebugCoreMessages.getString( "CRegisterManager.1" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
Node childNode = element.getFirstChild();
|
||||
while( childNode != null ) {
|
||||
if ( childNode.getNodeType() == Node.ELEMENT_NODE ) {
|
||||
Element child = (Element)childNode;
|
||||
if ( ELEMENT_REGISTER_GROUP.equals( child.getNodeName() ) ) {
|
||||
String groupMemento = child.getAttribute( ATTR_REGISTER_GROUP_MEMENTO );
|
||||
CRegisterGroup group = new CRegisterGroup( getDebugTarget() );
|
||||
try {
|
||||
group.initializeFromMemento( groupMemento );
|
||||
doAddRegisterGroup( group );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
// skip this group
|
||||
}
|
||||
}
|
||||
}
|
||||
childNode = childNode.getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeDefaults() {
|
||||
String current = null;
|
||||
int startIndex = 0;
|
||||
for ( int i = 0; i < fRegisterDescriptors.length; ++i ) {
|
||||
CRegisterDescriptor d = (CRegisterDescriptor)fRegisterDescriptors[i];
|
||||
if ( current != null && d.getGroupName().compareTo( current ) != 0 ) {
|
||||
IRegisterDescriptor[] descriptors = new IRegisterDescriptor[i - startIndex];
|
||||
System.arraycopy( fRegisterDescriptors, startIndex, descriptors, 0, descriptors.length );
|
||||
fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), current, descriptors ) );
|
||||
startIndex = i;
|
||||
}
|
||||
current = d.getGroupName();
|
||||
}
|
||||
if ( startIndex < fRegisterDescriptors.length - 1 ) {
|
||||
IRegisterDescriptor[] descriptors = new IRegisterDescriptor[fRegisterDescriptors.length - startIndex];
|
||||
System.arraycopy( fRegisterDescriptors, startIndex, descriptors, 0, descriptors.length );
|
||||
fRegisterGroups.add( new CRegisterGroup( getDebugTarget(), current, descriptors ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected synchronized void doAddRegisterGroup( IRegisterGroup group ) {
|
||||
fRegisterGroups.add( group );
|
||||
}
|
||||
|
||||
public void save() {
|
||||
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
|
||||
try {
|
||||
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
||||
wc.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_REGISTER_GROUPS, getMemento() );
|
||||
wc.doSave();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
CDebugCorePlugin.log( e );
|
||||
}
|
||||
}
|
||||
|
||||
private String getMemento() throws CoreException {
|
||||
if ( fRegisterGroups == null )
|
||||
return ""; //$NON-NLS-1$
|
||||
Document document = DebugPlugin.newDocument();
|
||||
Element element = document.createElement( ELEMENT_REGISTER_GROUP_LIST );
|
||||
Iterator it = fRegisterGroups.iterator();
|
||||
while( it.hasNext() ) {
|
||||
CRegisterGroup group = (CRegisterGroup)it.next();
|
||||
Element child = document.createElement( ELEMENT_REGISTER_GROUP );
|
||||
child.setAttribute( ATTR_REGISTER_GROUP_MEMENTO, group.getMemento() );
|
||||
element.appendChild( child );
|
||||
}
|
||||
document.appendChild( element );
|
||||
return DebugPlugin.serializeDocument( document );
|
||||
}
|
||||
|
||||
private void abort( String message, Throwable exception ) throws CoreException {
|
||||
IStatus status = new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, message, exception );
|
||||
throw new CoreException( status );
|
||||
}
|
||||
|
||||
public IRegisterDescriptor findDescriptor( String groupName, String name ) {
|
||||
for ( int i = 0; i < fRegisterDescriptors.length; ++i ) {
|
||||
IRegisterDescriptor d = fRegisterDescriptors[i];
|
||||
if ( groupName.equals( d.getGroupName() ) && name.equals( d.getName() ) )
|
||||
return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,6 @@ CMemoryBlockExtensionRetrieval.2=Invalid expression: ''{0}''
|
|||
DebugConfiguration.0=This debugger no longer supports this operation
|
||||
CDebugAdapter.0=This debugger does not support debugging external files
|
||||
CDebugAdapter.1=Debugger Process
|
||||
CDebugAdapter.Program_file_not_specified=Program file not specified
|
||||
CDebugAdapter.Program_file_not_specified=Program file not specified
|
||||
CRegisterManager.0=Unable to restore register groups - invalid memento.
|
||||
CRegisterManager.1=Unable to restore register groups - expecting register group list element.
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.eclipse.cdt.debug.core.CDIDebugModel;
|
|||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
|
||||
import org.eclipse.cdt.debug.core.ICRegisterManager;
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
|
||||
|
@ -76,6 +75,7 @@ import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
|||
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
||||
import org.eclipse.cdt.debug.core.model.IJumpToAddress;
|
||||
import org.eclipse.cdt.debug.core.model.IJumpToLine;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.CDirectorySourceContainer;
|
||||
|
@ -827,7 +827,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
return getBreakpointManager();
|
||||
if ( adapter.equals( CSignalManager.class ) )
|
||||
return getSignalManager();
|
||||
if ( adapter.equals( ICRegisterManager.class ) )
|
||||
if ( adapter.equals( CRegisterManager.class ) )
|
||||
return getRegisterManager();
|
||||
if ( adapter.equals( ICGlobalVariableManager.class ) )
|
||||
return getGlobalVariableManager();
|
||||
|
@ -998,6 +998,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
disposeGlobalVariableManager();
|
||||
disposeModuleManager();
|
||||
disposeSignalManager();
|
||||
saveRegisterGroups();
|
||||
disposeRegisterManager();
|
||||
disposeDisassembly();
|
||||
disposeSourceManager();
|
||||
|
@ -1448,6 +1449,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
fSignalManager.dispose();
|
||||
}
|
||||
|
||||
protected void saveRegisterGroups() {
|
||||
fRegisterManager.save();
|
||||
}
|
||||
|
||||
protected void disposeRegisterManager() {
|
||||
fRegisterManager.dispose();
|
||||
}
|
||||
|
@ -1871,4 +1876,25 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#getRegisterDescriptors()
|
||||
*/
|
||||
public IRegisterDescriptor[] getRegisterDescriptors() throws DebugException {
|
||||
return getRegisterManager().getAllRegisterDescriptors();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#addUserDefinedRegisterGroup(java.lang.String, org.eclipse.cdt.debug.core.model.IRegisterDescriptor[])
|
||||
*/
|
||||
public void addUserDefinedRegisterGroup( String name, IRegisterDescriptor[] descriptors ) {
|
||||
getRegisterManager().addRegisterGroup( name, descriptors );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#removeRegisterGroups(org.eclipse.debug.core.model.IRegisterGroup[])
|
||||
*/
|
||||
public void removeRegisterGroups( IRegisterGroup[] groups ) {
|
||||
getRegisterManager().removeRegisterGroups( groups );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ package org.eclipse.cdt.debug.internal.core.model;
|
|||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||
import org.eclipse.cdt.debug.core.ICDebugConstants;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.model.CVariableFormat;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
|
@ -28,16 +28,16 @@ public class CRegister extends CGlobalVariable implements IRegister {
|
|||
/**
|
||||
* Constructor for CRegister.
|
||||
*/
|
||||
protected CRegister( CRegisterGroup parent, ICDIRegisterDescriptor cdiRegisterDescriptor ) {
|
||||
super( parent, null, cdiRegisterDescriptor );
|
||||
protected CRegister( CRegisterGroup parent, IRegisterDescriptor descriptor ) {
|
||||
super( parent, null, ((CRegisterDescriptor)descriptor).getCDIDescriptor() );
|
||||
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CRegister.
|
||||
*/
|
||||
protected CRegister( CRegisterGroup parent, ICDIRegisterDescriptor registerObject, String message ) {
|
||||
super( parent, null, registerObject, message );
|
||||
protected CRegister( CRegisterGroup parent, IRegisterDescriptor descriptor, String message ) {
|
||||
super( parent, null, ((CRegisterDescriptor)descriptor).getCDIDescriptor(), message );
|
||||
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
|
||||
/**
|
||||
* A register descriptor. Temporary, need to change the related CDI interfaces.
|
||||
*/
|
||||
public class CRegisterDescriptor implements IRegisterDescriptor {
|
||||
|
||||
private String fName;
|
||||
private String fGroupName;
|
||||
private ICDIRegisterDescriptor fCDIDescriptor = null;
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterDescriptor.
|
||||
*/
|
||||
public CRegisterDescriptor( String name, String groupName ) {
|
||||
fName = name;
|
||||
fGroupName = groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterDescriptor.
|
||||
*/
|
||||
public CRegisterDescriptor( ICDIRegisterGroup group, ICDIRegisterDescriptor desc ) {
|
||||
fName = desc.getName();
|
||||
fGroupName = group.getName();
|
||||
fCDIDescriptor = desc;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IRegisterDescriptor#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.model.IRegisterDescriptor#getGroupName()
|
||||
*/
|
||||
public String getGroupName() {
|
||||
return fGroupName;
|
||||
}
|
||||
|
||||
public ICDIRegisterDescriptor getCDIDescriptor() {
|
||||
return fCDIDescriptor;
|
||||
}
|
||||
|
||||
public void setCDIDescriptor( ICDIRegisterDescriptor descriptor ) {
|
||||
fCDIDescriptor = descriptor;
|
||||
}
|
||||
}
|
|
@ -10,59 +10,83 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterGroup;
|
||||
import java.util.ArrayList;
|
||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||
import org.eclipse.cdt.debug.core.model.IEnableDisableTarget;
|
||||
import org.eclipse.cdt.debug.core.model.IPersistableRegisterGroup;
|
||||
import org.eclipse.cdt.debug.core.model.IRegisterDescriptor;
|
||||
import org.eclipse.cdt.debug.internal.core.CRegisterManager;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.debug.core.DebugEvent;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IRegister;
|
||||
import org.eclipse.debug.core.model.IRegisterGroup;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* Represents a group of registers.
|
||||
*/
|
||||
public class CRegisterGroup extends CDebugElement implements IRegisterGroup, IEnableDisableTarget {
|
||||
public class CRegisterGroup extends CDebugElement implements IPersistableRegisterGroup, IEnableDisableTarget {
|
||||
|
||||
private ICDIRegisterGroup fCDIRegisterGroup;
|
||||
private static final String ELEMENT_REGISTER_GROUP = "registerGroup"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_GROUP_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_GROUP_ENABLED = "enabled"; //$NON-NLS-1$
|
||||
|
||||
private static final String ELEMENT_REGISTER = "register"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String ATTR_REGISTER_ORIGINAL_GROUP_NAME = "originalGroupName"; //$NON-NLS-1$
|
||||
|
||||
private String fName;
|
||||
|
||||
private IRegisterDescriptor[] fRegisterDescriptors;
|
||||
|
||||
private IRegister[] fRegisters;
|
||||
|
||||
private boolean fIsEnabled = true;
|
||||
|
||||
private boolean fDisposed = false;
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterGroup.
|
||||
*/
|
||||
public CRegisterGroup( CDebugTarget target, ICDIRegisterGroup regGroup ) {
|
||||
public CRegisterGroup( CDebugTarget target ) {
|
||||
super( target );
|
||||
fCDIRegisterGroup = regGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CRegisterGroup.
|
||||
*/
|
||||
public CRegisterGroup( CDebugTarget target, String name, IRegisterDescriptor[] descriptors ) {
|
||||
super( target );
|
||||
fName = name;
|
||||
fRegisterDescriptors = descriptors;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegisterGroup#getName()
|
||||
*/
|
||||
public String getName() throws DebugException {
|
||||
return fCDIRegisterGroup.getName();
|
||||
return fName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IRegisterGroup#getRegisters()
|
||||
*/
|
||||
public IRegister[] getRegisters() throws DebugException {
|
||||
if ( fDisposed )
|
||||
return new IRegister[0];
|
||||
if ( fRegisters == null ) {
|
||||
try {
|
||||
ICDIRegisterDescriptor[] regDescs = fCDIRegisterGroup.getRegisterDescriptors();
|
||||
fRegisters = new IRegister[regDescs.length];
|
||||
for( int i = 0; i < fRegisters.length; ++i ) {
|
||||
fRegisters[i] = new CRegister( this, regDescs[i] );
|
||||
if ( ((CRegister)fRegisters[i]).isEnabled() ) {
|
||||
((CRegister)fRegisters[i]).setEnabled( isEnabled() );
|
||||
}
|
||||
fRegisters = new IRegister[fRegisterDescriptors.length];
|
||||
for( int i = 0; i < fRegisters.length; ++i ) {
|
||||
fRegisters[i] = new CRegister( this, fRegisterDescriptors[i] );
|
||||
if ( ((CRegister)fRegisters[i]).isEnabled() ) {
|
||||
((CRegister)fRegisters[i]).setEnabled( isEnabled() );
|
||||
}
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
requestFailed( e.getMessage(), null );
|
||||
}
|
||||
}
|
||||
return fRegisters;
|
||||
}
|
||||
|
@ -71,24 +95,20 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup, IEn
|
|||
* @see org.eclipse.debug.core.model.IRegisterGroup#hasRegisters()
|
||||
*/
|
||||
public boolean hasRegisters() throws DebugException {
|
||||
try {
|
||||
return fCDIRegisterGroup.hasRegisters();
|
||||
} catch( CDIException e ) {
|
||||
requestFailed( e.getMessage(), null );
|
||||
}
|
||||
return false;
|
||||
return ( fRegisterDescriptors.length > 0 );
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
fDisposed = true;
|
||||
if (fRegisters == null) {
|
||||
return;
|
||||
}
|
||||
for ( int i = 0; i < fRegisters.length; ++i ) {
|
||||
if ( fRegisters[i] != null ) {
|
||||
((CRegister)fRegisters[i]).dispose();
|
||||
fRegisters[i] = null;
|
||||
}
|
||||
}
|
||||
fRegisters = null;
|
||||
}
|
||||
|
||||
public void targetSuspended() {
|
||||
|
@ -144,4 +164,79 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup, IEn
|
|||
fIsEnabled = enabled;
|
||||
fireChangeEvent( DebugEvent.CONTENT );
|
||||
}
|
||||
|
||||
public String getMemento() throws CoreException {
|
||||
Document document = DebugPlugin.newDocument();
|
||||
Element element = document.createElement( ELEMENT_REGISTER_GROUP );
|
||||
element.setAttribute( ATTR_REGISTER_GROUP_NAME, getName() );
|
||||
element.setAttribute( ATTR_REGISTER_GROUP_ENABLED, isEnabled() ? Boolean.TRUE.toString() : Boolean.FALSE.toString() );
|
||||
for ( int i = 0; i < fRegisterDescriptors.length; ++i ) {
|
||||
Element child = document.createElement( ELEMENT_REGISTER );
|
||||
child.setAttribute( ATTR_REGISTER_NAME, fRegisterDescriptors[i].getName() );
|
||||
child.setAttribute( ATTR_REGISTER_ORIGINAL_GROUP_NAME, fRegisterDescriptors[i].getGroupName() );
|
||||
element.appendChild( child );
|
||||
}
|
||||
document.appendChild( element );
|
||||
return DebugPlugin.serializeDocument( document );
|
||||
}
|
||||
|
||||
public void initializeFromMemento( String memento ) throws CoreException {
|
||||
Node node = DebugPlugin.parseDocument( memento );
|
||||
if ( node.getNodeType() != Node.ELEMENT_NODE ) {
|
||||
abort( CoreModelMessages.getString( "CRegisterGroup.0" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
Element element = (Element)node;
|
||||
if ( !ELEMENT_REGISTER_GROUP.equals( element.getNodeName() ) ) {
|
||||
abort( CoreModelMessages.getString( "CRegisterGroup.1" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
String groupName = element.getAttribute( ATTR_REGISTER_GROUP_NAME );
|
||||
if ( groupName == null || groupName.length() == 0 ) {
|
||||
abort( CoreModelMessages.getString( "CRegisterGroup.2" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
String e = element.getAttribute( ATTR_REGISTER_GROUP_ENABLED );
|
||||
boolean enabled = Boolean.valueOf( e ).booleanValue();
|
||||
CRegisterManager rm = getRegisterManager();
|
||||
ArrayList list = new ArrayList();
|
||||
Node childNode = element.getFirstChild();
|
||||
while( childNode != null ) {
|
||||
if ( childNode.getNodeType() == Node.ELEMENT_NODE ) {
|
||||
Element child = (Element)childNode;
|
||||
if ( ELEMENT_REGISTER.equals( child.getNodeName() ) ) {
|
||||
String name = child.getAttribute( ATTR_REGISTER_NAME );
|
||||
String originalGroupName = child.getAttribute( ATTR_REGISTER_ORIGINAL_GROUP_NAME );
|
||||
if ( name == null || name.length() == 0 || originalGroupName == null || originalGroupName.length() == 0 ) {
|
||||
abort( CoreModelMessages.getString( "CRegisterGroup.3" ), null ); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
IRegisterDescriptor d = rm.findDescriptor( originalGroupName, name );
|
||||
if ( d != null )
|
||||
list.add( d );
|
||||
else
|
||||
CDebugCorePlugin.log( CoreModelMessages.getString( "CRegisterGroup.4" ) ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
childNode = childNode.getNextSibling();
|
||||
}
|
||||
setName( groupName );
|
||||
setRegisterDescriptors( (IRegisterDescriptor[])list.toArray( new IRegisterDescriptor[list.size()] ) );
|
||||
setEnabled( enabled );
|
||||
}
|
||||
|
||||
private void abort( String message, Throwable exception ) throws CoreException {
|
||||
IStatus status = new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, message, exception );
|
||||
throw new CoreException( status );
|
||||
}
|
||||
|
||||
private void setName( String name ) {
|
||||
fName = name;
|
||||
}
|
||||
|
||||
private void setRegisterDescriptors( IRegisterDescriptor[] registerDescriptors ) {
|
||||
fRegisterDescriptors = registerDescriptors;
|
||||
}
|
||||
|
||||
private CRegisterManager getRegisterManager() {
|
||||
return (CRegisterManager)getDebugTarget().getAdapter( CRegisterManager.class );
|
||||
}
|
||||
}
|
|
@ -33,3 +33,8 @@ CModule.2=Invalid symbols file.
|
|||
CModule.4=Not supported
|
||||
CModuleManager.0=Error loading symbols.
|
||||
CModuleManager.1=Error loading symbols.
|
||||
CRegisterGroup.0=Unable to restore register group - invalid memento.
|
||||
CRegisterGroup.1=Unable to restore register group - expecting register group element.
|
||||
CRegisterGroup.2=Unable to restore register group - missing name attribute.
|
||||
CRegisterGroup.3=Unable to restore register - missing attributes.
|
||||
CRegisterGroup.4=Register doesn't exist on this target.
|
||||
|
|
Loading…
Add table
Reference in a new issue