diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java index 06f628f1993..d0fd7b73d68 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java @@ -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 fDebugConfigurations; - private HashSet fActiveDebugConfigurations; + private HashSet 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( 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( 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 list = new ArrayList( 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 filtered = Arrays.asList( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_FILTERED_DEBUGGERS ).split( "\\," ) ); //$NON-NLS-1$ + HashMap all = new HashMap( 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(); + } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java index 37d5d5f47db..c719ca25792 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextListener.java @@ -21,6 +21,7 @@ package org.eclipse.cdt.debug.core.disassembly; *

* The clients may implement this interface. *

+ * This interface is experimental. */ public interface IDisassemblyContextListener { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java index 35a3b05da81..518ad9a0c9f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextProvider.java @@ -17,6 +17,7 @@ package org.eclipse.cdt.debug.core.disassembly; * Clients must implements this interface to plug into * the diassembly framework. *

+ * This interface is experimental. */ public interface IDisassemblyContextProvider { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java index 94f904607e2..3501f6146e3 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/disassembly/IDisassemblyContextService.java @@ -22,6 +22,8 @@ package org.eclipse.cdt.debug.core.disassembly; * It can be accessed from CDebugCorePlugin. *

* @see org.eclipse.cdt.debug.core.IDisassemblyContextListener + * + * This interface is experimental. */ public interface IDisassemblyContextService { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java new file mode 100644 index 00000000000..5681f6abf08 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/disassembly/DisassemblyContextService.java @@ -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 fContexts; + + public DisassemblyContextService() { + fContexts = new CopyOnWriteArraySet(); + 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(); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java new file mode 100644 index 00000000000..418eff0d3fb --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentBaseChangeUpdate.java @@ -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. + *

+ * Clients are not intended to implement this interface. + *

+ * + * 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 ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java new file mode 100644 index 00000000000..5cd3bea05c4 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementAnnotationUpdate.java @@ -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. + *

+ * Clients are not intended to implement this interface. + *

+ * + * 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 ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java new file mode 100644 index 00000000000..8ac88529853 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementContentUpdate.java @@ -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. + *

+ * Clients are not intended to implement this interface. + *

+ * + * 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(); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java new file mode 100644 index 00000000000..d8db82e660a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentElementLabelUpdate.java @@ -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. + *

+ * Clients are not intended to implement this interface. + *

+ * + * 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 ); +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java new file mode 100644 index 00000000000..1414f5ec581 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/IDocumentUpdate.java @@ -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. + *

+ * Clients are not intended to implement this interface. + *

+ * + * 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(); +}