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

Contributing new disassembly.

This commit is contained in:
Mikhail Khodjaiants 2008-04-07 17:31:51 +00:00
parent b20ba9eac9
commit 35dfb7a9a9
12 changed files with 215 additions and 13 deletions

View file

@ -116,6 +116,13 @@ OpenDisassembly.label = Open Disassembly
OpenDisassembly.tooltip = Open disassembly window
DisassemblyEditor.name = Disassembly
DisassemblyRendering.name = Disassembly
DisassemblyDisplayMode.name = Disassembly Display Mode
DisassemblyDisplayMode.description = Disassembly display mode
InstructionsDisplayMode.label = Show Instructions
InstructionsDisplayMode.tooltip = Show disassembly instructions
SourceDisplayMode.label = Show Source
SourceDisplayMode.tooltip = Show source code
# new disassembly (end)
DebugTextHover.label=Debugger

View file

@ -1560,6 +1560,19 @@
id="org.eclipse.cdt.debug.ui.command.openDisassembly"
name="%OpenDisassembly.name">
</command>
<command
categoryId="org.eclipse.cdt.debug.ui.category.disassembly"
defaultHandler="org.eclipse.cdt.debug.internal.ui.disassembly.commands.DisassemblyDisplayModeHandler"
description="%DisassemblyDisplayMode.description"
helpContextId="disassembly_display_mode_command_context"
id="org.eclipse.cdt.debug.command.disassemblyDisplayMode"
name="%DisassemblyDisplayMode.name">
<commandParameter
id="org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"
name="displayMode"
optional="false">
</commandParameter>
</command>
</extension>
<extension
point="org.eclipse.ui.menus">
@ -1584,6 +1597,33 @@
</visibleWhen>
</command>
</menuContribution>
<menuContribution
locationURI="popup:#DisassemblyEditorContext?after=additions">
<command
commandId="org.eclipse.cdt.debug.command.disassemblyDisplayMode"
helpContextId="instructions_display_mode_menu_context"
id="org.eclipse.cdt.debug.menu.command.disassemblyDisplayMode.instructions"
label="%InstructionsDisplayMode.label"
style="toggle"
tooltip="%InstructionsDisplayMode.tooltip">
<parameter
name="org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"
value="instructions">
</parameter>
</command>
<command
commandId="org.eclipse.cdt.debug.command.disassemblyDisplayMode"
helpContextId="source_display_mode_menu_context"
id="org.eclipse.cdt.debug.menu.command.disassemblyDisplayMode.source"
label="%SourceDisplayMode.label"
style="toggle"
tooltip="%SourceDisplayMode.tooltip">
<parameter
name="org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"
value="source">
</parameter>
</command>
</menuContribution>
</extension>
</plugin>

View file

@ -73,4 +73,11 @@ public interface IInternalCDebugUIConstants {
* Status code indicating an unexpected internal error.
*/
public static final int INTERNAL_ERROR = 150;
// new disassembly (start)
public static final String DISASM_DISPLAY_MODE_INSTRUCTIONS = "instructions"; //$NON-NLS-1$
public static final String DISASM_DISPLAY_MODE_SOURCE = "source"; //$NON-NLS-1$
// new disassembly (end)
}

View file

@ -0,0 +1,92 @@
/*******************************************************************************
* 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.ui.disassembly.commands;
import java.util.Map;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorInput;
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorPresentation;
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyDocumentProvider;
import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
import org.eclipse.ui.texteditor.IDocumentProvider;
public class DisassemblyDisplayModeHandler extends AbstractHandler implements IElementUpdater {
private static final String ID_PARAMETER_MODE = "org.eclipse.cdt.debug.command.disassemblyDisplayMode.parameterMode"; //$NON-NLS-1$
private boolean fShowInstructions = false;
private boolean fShowSource = false;
public DisassemblyDisplayModeHandler() {
super();
fShowInstructions = CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS );
fShowSource = CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE );
}
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute( ExecutionEvent event ) throws ExecutionException {
DisassemblyEditorPresentation presentation = getEditorPresentation( event );
if ( presentation != null ) {
String param = event.getParameter( ID_PARAMETER_MODE );
if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) {
fShowInstructions = !fShowInstructions;
presentation.setShowIntstructions( fShowInstructions );
}
else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) {
fShowSource = !fShowSource;
presentation.setShowSource( fShowSource );
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map)
*/
@SuppressWarnings("unchecked")
public void updateElement( UIElement element, Map parameters ) {
String param = (String)parameters.get( ID_PARAMETER_MODE );
if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) {
element.setChecked( fShowInstructions );
}
else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) {
element.setChecked( fShowSource );
}
}
private DisassemblyEditorPresentation getEditorPresentation( ExecutionEvent event ) throws ExecutionException {
ISelection s = HandlerUtil.getActiveMenuEditorInputChecked( event );
if ( s instanceof IStructuredSelection ) {
Object o = ((IStructuredSelection)s).getFirstElement();
if ( o instanceof DisassemblyEditorInput ) {
IDocumentProvider dp = CDebugUIPlugin.getDefault().getDisassemblyEditorManager().getDocumentProvider();
if ( dp instanceof DisassemblyDocumentProvider ) {
return (DisassemblyEditorPresentation)((DisassemblyDocumentProvider)dp).getDocumentPresentation( o );
}
}
}
return null;
}
}

View file

@ -49,7 +49,7 @@ public class DisassemblyEditor extends EditorPart implements ITextEditor, IReusa
public DisassemblyEditor() {
super();
fDisassemblyPane = new DisassemblyPane();
fDisassemblyPane = new DisassemblyPane( "#DisassemblyEditorContext", "#DisassemblyEditorRulerContext" ); //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyDocumentProvider;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -45,7 +46,6 @@ import org.eclipse.ui.progress.UIJob;
public class DisassemblyEditorManager implements IWindowListener, IDisassemblyContextListener, IPartListener2 {
private static final String DEFAULT_EDITOR_ID = "org.eclipse.cdt.debug.ui.disassemblyEditor"; //$NON-NLS-1$
private Map<Object, IEditorPart> fEditorParts;
private Map<Object, String> fOpenDisassemblyPolicy;
private Map<Object, ISteppingModeTarget> fSteppingModePolicy;
@ -278,7 +278,7 @@ public class DisassemblyEditorManager implements IWindowListener, IDisassemblyCo
private boolean isDisassemblyEditorPart( IWorkbenchPartReference partRef ) {
// TODO: check all editors contributed via the extension point
return ( partRef.getId().equals( DEFAULT_EDITOR_ID ) );
return ( partRef.getId().equals( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR ) );
}
private ISourcePresentation getSourcePresentation() {
@ -291,7 +291,7 @@ public class DisassemblyEditorManager implements IWindowListener, IDisassemblyCo
}
public String getEditorId( IEditorInput input, Object element ) {
return DEFAULT_EDITOR_ID;
return ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR;
}
};
}

View file

@ -0,0 +1,46 @@
/*******************************************************************************
* 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.ui.disassembly.editor;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
/**
* org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyEditorPresentation:
* //TODO Add description.
*/
public class DisassemblyEditorPresentation extends PresentationContext implements IDocumentPresentation {
private boolean fShowIntstructions = true;
private boolean fShowSource = false;
public DisassemblyEditorPresentation() {
super( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR );
}
public boolean showIntstructions() {
return fShowIntstructions;
}
public void setShowIntstructions( boolean showIntstructions ) {
fShowIntstructions = showIntstructions;
}
public boolean showSource() {
return fShowSource;
}
public void setShowSource( boolean showSource ) {
fShowSource = showSource;
}
}

View file

@ -34,7 +34,7 @@ public class DisassemblyMemoryRendering extends AbstractMemoryRendering {
public DisassemblyMemoryRendering( String renderingId ) {
super( renderingId );
fDisassemblyPane = new DisassemblyPane();
fDisassemblyPane = new DisassemblyPane( "#DisassemblyRenderingContext", "#DisassemblyRenderingRulerContext" ); //$NON-NLS-1$//$NON-NLS-2$
}
/* (non-Javadoc)

View file

@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorInput;
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorPresentation;
import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@ -214,6 +215,6 @@ public class DisassemblyDocumentProvider implements IDocumentProvider {
}
private IDocumentPresentation createDocumentPresentation( Object context ) {
return null;
return new DisassemblyEditorPresentation();
}
}

View file

@ -89,10 +89,10 @@ public class DisassemblyPane implements IPropertyChangeListener {
private Map<String, IAction> fActions = new HashMap<String, IAction>( 10 );
public DisassemblyPane() {
public DisassemblyPane( String contextMenuId, String rulerMenuId ) {
fAnnotationPreferences = new MarkerAnnotationPreferences();
setViewContextMenuId( "#DisassemblyViewContext" ); //$NON-NLS-1$
setRulerContextMenuId( "#DisassemblyEditorRulerContext" ); //$NON-NLS-1$
setViewContextMenuId( contextMenuId );
setRulerContextMenuId( rulerMenuId );
}
public void create( Composite parent ) {

View file

@ -35,4 +35,8 @@ public interface ICDebugPreferenceConstants {
* Boolean preference controlling whether primitive types types display char values.
*/
public static final String PREF_SHOW_CHAR_VALUES = ICDebugUIConstants.PLUGIN_ID + ".cDebug.showCharValues"; //$NON-NLS-1$
public static final String PREF_DISASM_SHOW_INSTRUCTIONS = ICDebugUIConstants.PLUGIN_ID + ".disassembly.showInstructions"; //$NON-NLS-1$
public static final String PREF_DISASM_SHOW_SOURCE = ICDebugUIConstants.PLUGIN_ID + ".disassembly.showSource"; //$NON-NLS-1$
}

View file

@ -27,10 +27,15 @@ public interface ICDebugUIConstants {
*/
public static final String ID_EXECUTABLES_VIEW = PREFIX + "executablesView"; //$NON-NLS-1$
/**
* Disassembly view identifier (value <code>"org.eclipse.cdt.debug.ui.DisassemblyView"</code>).
*/
public static final String ID_DISASSEMBLY_VIEW = PREFIX + "DisassemblyView"; //$NON-NLS-1$
/**
* Disassembly view identifier (value <code>"org.eclipse.cdt.debug.ui.DisassemblyView"</code>).
*/
public static final String ID_DISASSEMBLY_VIEW = PREFIX + "DisassemblyView"; //$NON-NLS-1$
/**
* Deafult disassembly editor identifier (value <code>"org.eclipse.cdt.debug.ui.disassemblyEditor"</code>).
*/
public static final String ID_DEFAULT_DISASSEMBLY_EDITOR = PREFIX + "disassemblyEditor"; //$NON-NLS-1$
/**
* Id for the popup menu associated with the detail (text viewer) part of the Modules view