1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Added request interfaces for the virtual (disassembly) viewer.

This commit is contained in:
Mikhail Khodjaiants 2008-04-02 16:20:24 +00:00
parent 7fde922525
commit 231b11b8ab
10 changed files with 331 additions and 23 deletions

View file

@ -15,16 +15,16 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
import org.eclipse.cdt.debug.internal.core.DebugConfiguration;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
import org.eclipse.cdt.debug.internal.core.ListenerList;
import org.eclipse.cdt.debug.internal.core.SessionManager;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.cdt.debug.internal.core.disassembly.DisassemblyContextService;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CommonSourceLookupDirector;
import org.eclipse.cdt.debug.internal.core.sourcelookup.SourceUtils;
@ -38,9 +38,6 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.osgi.framework.BundleContext;
/**
@ -63,9 +60,9 @@ public class CDebugCorePlugin extends Plugin {
*/
private static CDebugCorePlugin plugin;
private HashMap fDebugConfigurations;
private HashMap<String, DebugConfiguration> fDebugConfigurations;
private HashSet fActiveDebugConfigurations;
private HashSet<String> fActiveDebugConfigurations;
/**
* Breakpoint listener list.
@ -77,6 +74,8 @@ public class CDebugCorePlugin extends Plugin {
*/
private BreakpointActionManager breakpointActionManager;
private DisassemblyContextService fDisassemblyContextService;
public static final String CDEBUGGER_EXTENSION_POINT_ID = "CDebugger"; //$NON-NLS-1$
public static final String DEBUGGER_ELEMENT = "debugger"; //$NON-NLS-1$
@ -169,7 +168,7 @@ public class CDebugCorePlugin extends Plugin {
private void initializeDebugConfiguration() {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( getUniqueIdentifier(), CDEBUGGER_EXTENSION_POINT_ID );
IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
fDebugConfigurations = new HashMap( infos.length );
fDebugConfigurations = new HashMap<String, DebugConfiguration>( infos.length );
for( int i = 0; i < infos.length; i++ ) {
IConfigurationElement configurationElement = infos[i];
if (configurationElement.getName().equals(DEBUGGER_ELEMENT)) {
@ -180,7 +179,7 @@ public class CDebugCorePlugin extends Plugin {
}
private void initializeActiveDebugConfigurations() {
fActiveDebugConfigurations = new HashSet( getDebugConfigurations().length );
fActiveDebugConfigurations = new HashSet<String>( getDebugConfigurations().length );
fActiveDebugConfigurations.addAll( fDebugConfigurations.keySet() );
String[] filteredTypes = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ); //$NON-NLS-1$
fActiveDebugConfigurations.removeAll( Arrays.asList( filteredTypes ) );
@ -190,7 +189,7 @@ public class CDebugCorePlugin extends Plugin {
if ( fDebugConfigurations == null ) {
initializeDebugConfiguration();
}
return (ICDebugConfiguration[])fDebugConfigurations.values().toArray( new ICDebugConfiguration[0] );
return fDebugConfigurations.values().toArray( new ICDebugConfiguration[fDebugConfigurations.size()] );
}
public ICDebugConfiguration[] getActiveDebugConfigurations() {
@ -200,21 +199,21 @@ public class CDebugCorePlugin extends Plugin {
if ( fActiveDebugConfigurations == null ) {
initializeActiveDebugConfigurations();
}
ArrayList list = new ArrayList( fActiveDebugConfigurations.size() );
Iterator it = fActiveDebugConfigurations.iterator();
while( it.hasNext() ) {
Object o = fDebugConfigurations.get( it.next() );
if ( o != null )
list.add( o );
ArrayList<DebugConfiguration> list = new ArrayList<DebugConfiguration>( fActiveDebugConfigurations.size() );
for ( String id : fActiveDebugConfigurations ) {
DebugConfiguration dc = fDebugConfigurations.get( id );
if ( dc != null )
list.add( dc );
}
return (ICDebugConfiguration[])list.toArray( new ICDebugConfiguration[list.size()] );
return list.toArray( new ICDebugConfiguration[list.size()] );
}
public ICDebugConfiguration[] getDefaultActiveDebugConfigurations() {
List filtered = Arrays.asList( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ) ); //$NON-NLS-1$
HashMap all = (HashMap)fDebugConfigurations.clone();
List<String> filtered = Arrays.asList( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ) ); //$NON-NLS-1$
HashMap<String, DebugConfiguration> all = new HashMap<String, DebugConfiguration>( fDebugConfigurations );
all.keySet().removeAll( filtered );
return (ICDebugConfiguration[])all.values().toArray( new ICDebugConfiguration[all.size()] );
return all.values().toArray( new ICDebugConfiguration[all.size()] );
}
public void saveFilteredDebugConfigurations( ICDebugConfiguration[] configurations ) {
@ -261,7 +260,7 @@ public class CDebugCorePlugin extends Plugin {
if ( fDebugConfigurations == null ) {
initializeDebugConfiguration();
}
ICDebugConfiguration dbgCfg = (ICDebugConfiguration)fDebugConfigurations.get( id );
ICDebugConfiguration dbgCfg = fDebugConfigurations.get( id );
if ( dbgCfg == null ) {
IStatus status = new Status( IStatus.ERROR, getUniqueIdentifier(), 100, DebugCoreMessages.getString( "CDebugCorePlugin.0" ), null ); //$NON-NLS-1$
throw new CoreException( status );
@ -328,18 +327,22 @@ public class CDebugCorePlugin extends Plugin {
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start( BundleContext context ) throws Exception {
@Override
public void start( BundleContext context ) throws Exception {
super.start( context );
initializeCommonSourceLookupDirector();
createBreakpointListenersList();
createDisassemblyContextService();
setSessionManager( new SessionManager() );
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop( BundleContext context ) throws Exception {
@Override
public void stop( BundleContext context ) throws Exception {
setSessionManager( null );
disposeDisassemblyContextService();
disposeBreakpointListenersList();
disposeCommonSourceLookupDirector();
disposeDebugConfigurations();
@ -399,4 +402,16 @@ public class CDebugCorePlugin extends Plugin {
return breakpointActionManager;
}
private void createDisassemblyContextService() {
fDisassemblyContextService = new DisassemblyContextService();
}
public IDisassemblyContextService getDisassemblyContextService() {
return fDisassemblyContextService;
}
private void disposeDisassemblyContextService() {
if ( fDisassemblyContextService != null )
fDisassemblyContextService.dispose();
}
}

View file

@ -21,6 +21,7 @@ package org.eclipse.cdt.debug.core.disassembly;
* <p>
* The clients may implement this interface.
* </p>
* This interface is experimental.
*/
public interface IDisassemblyContextListener {

View file

@ -17,6 +17,7 @@ package org.eclipse.cdt.debug.core.disassembly;
* Clients must implements this interface to plug into
* the diassembly framework.
* </p>
* This interface is experimental.
*/
public interface IDisassemblyContextProvider {

View file

@ -22,6 +22,8 @@ package org.eclipse.cdt.debug.core.disassembly;
* It can be accessed from <code>CDebugCorePlugin</code>.
* </p>
* @see org.eclipse.cdt.debug.core.IDisassemblyContextListener
*
* This interface is experimental.
*/
public interface IDisassemblyContextService {

View file

@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.disassembly;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService;
import org.eclipse.core.runtime.ListenerList;
public class DisassemblyContextService implements IDisassemblyContextService {
private ListenerList fListeners;
private Set<Object> fContexts;
public DisassemblyContextService() {
fContexts = new CopyOnWriteArraySet<Object>();
fListeners = new ListenerList();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#addDisassemblyContextListener(org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener)
*/
public void addDisassemblyContextListener( IDisassemblyContextListener listener ) {
fListeners.add( listener );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#removeDisassemblyContextListener(org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextListener)
*/
public void removeDisassemblyContextListener( IDisassemblyContextListener listener ) {
fListeners.remove( listener );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#register(java.lang.Object)
*/
public void register( Object context ) {
fContexts.add( context );
for( Object listener : fListeners.getListeners() ) {
((IDisassemblyContextListener)listener).contextAdded( context );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService#unregister(java.lang.Object)
*/
public void unregister( Object context ) {
fContexts.remove( context );
for( Object listener : fListeners.getListeners() ) {
((IDisassemblyContextListener)listener).contextRemoved( context );
}
}
public void dispose() {
for( Object context : fContexts ) {
for( Object listener : fListeners.getListeners() ) {
((IDisassemblyContextListener)listener).contextRemoved( context );
}
}
fListeners.clear();
fContexts.clear();
}
}

View file

@ -0,0 +1,44 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.disassembly;
/**
* Request to provide a base element for the given element and presentation context.
* <p>
* Clients are not intended to implement this interface.
* </p>
*
* This interface is experimental
*/
public interface IDocumentBaseChangeUpdate extends IDocumentUpdate {
/**
* Returns the offset of the old base element.
*
* @return the offset of the old base element
*/
public int getOriginalOffset();
/**
* Sets the base element to use with the given presentation context.
*
* @param base the base element to use with the given presentation context
*/
public void setBaseElement( Object base );
/**
* Sets the offset of the new base element.
*
* @param offset the offset of the new base element
*/
public void setOffset( int offset );
}

View file

@ -0,0 +1,32 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.disassembly;
import org.eclipse.jface.text.source.Annotation;
/**
* Request to provide annotations for the given element and presentation context.
* <p>
* Clients are not intended to implement this interface.
* </p>
*
* This interface is experimental
*/
public interface IDocumentElementAnnotationUpdate extends IDocumentUpdate {
/**
* Adds an annotation to this request.
*
* @param annotation the annotation to add
*/
public void addAnnotation( Annotation annotation );
}

View file

@ -0,0 +1,67 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.disassembly;
/**
* A content update request for a source viewer.
* <p>
* Clients are not intended to implement this interface.
* </p>
*
* This interface is experimental.
*/
public interface IDocumentElementContentUpdate extends IDocumentUpdate {
/**
* Returns the line number associated with the base element.
* Can be outside of the requested line interval.
*
* @return line number associated with the element
*/
public int getOriginalOffset();
/**
* Returns the number of lines requested.
*
* @return number of lines requested
*/
public int getRequestedLineCount();
/**
* Sets the offset of the base element
*
* @param offset offset of the base element
*/
public void setOffset( int offset );
/**
* Sets the number of lines in this update request
*
* @param lineCount number of lines
*/
public void setLineCount( int lineCount );
/**
* Adds a source element for the given line number
*
* @param line line number
* @param element element to add
*/
public void addElement( int line, Object element ) throws IndexOutOfBoundsException;
/**
* Indicates whether or not the element should be revealed
*
* @return whether or not the element should be revealed
*/
public boolean reveal();
}

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.disassembly;
/**
* A label update request for a source viewer element.
* <p>
* Clients are not intended to implement this interface.
* </p>
*
* This interface is experimental.
*/
public interface IDocumentElementLabelUpdate extends IDocumentUpdate {
/**
* Sets the text of the label of the specified attribute.
*
* @param attribute the attribute name
* @param text the label text to set
*/
public void setLabel( String attribute, String text );
}

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2008 ARM Limited and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* ARM Limited - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.disassembly;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
/**
* A context sensitive document update request.
* <p>
* Clients are not intended to implement this interface.
* </p>
*
* Use the element path instead of this interface?
*
* This interface is experimental
*/
public interface IDocumentUpdate extends IViewerUpdate {
/**
* Returns the root element associated with this request.
*
* @return the root element
*/
public Object getRootElement();
/**
* Returns the base element associated with this request.
*
* @return the base element
*/
public Object getBaseElement();
}