Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2008-04-17 17:23:35 +0000
committerMikhail Khodjaiants2008-04-17 17:23:35 +0000
commit501ebcad7f66871fa31a50b4cf240372a362179f (patch)
tree3ad9368a8644655396ea3bd76645fcaaf088b1b8 /debug
parent0a10b91cca34053ee7f6845619579f622a5260c9 (diff)
downloadorg.eclipse.cdt-501ebcad7f66871fa31a50b4cf240372a362179f.tar.gz
org.eclipse.cdt-501ebcad7f66871fa31a50b4cf240372a362179f.tar.xz
org.eclipse.cdt-501ebcad7f66871fa31a50b4cf240372a362179f.zip
Contributing new disassembly.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java61
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java15
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java49
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java3
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java22
7 files changed, 122 insertions, 32 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java
index 350bc755df0..7f9fa9a5ad0 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java
@@ -105,9 +105,11 @@ public class DisassemblyRetrieval extends CDebugElement implements ICDIEventList
BigInteger address = null;
if ( startAddress != null ) {
if ( getCurrentOffset() > offset ) {
+ // scrolling up
address = startAddress.subtract( BigInteger.valueOf( getMinInstructionSize() * (getCurrentOffset() - offset) ) );
}
else if ( getCurrentOffset() < offset ) {
+ // scrolling down
IDisassemblyInstruction next = getNextInstruction( startAddress, fLines );
if ( next != null )
address = next.getAdress().getValue();
@@ -157,10 +159,27 @@ public class DisassemblyRetrieval extends CDebugElement implements ICDIEventList
}
private IDisassemblyLine[] disassembleDown( BigInteger address, int lineCount, boolean mixed ) throws DebugException {
- BigInteger endAddress = address.add( BigInteger.valueOf( lineCount * getMaxInstructionSize() ) );
- if ( endAddress.compareTo( getGlobalEndAddress() ) > 0 )
- endAddress = getGlobalEndAddress();
- IDisassemblyLine[] lines = disassemble( address, endAddress, mixed );
+ BigInteger startAddress = address;
+ IDisassemblyLine[] lines = new IDisassemblyLine[0];
+ while( lines.length < lineCount ) {
+ BigInteger endAddress = address.add( BigInteger.valueOf( lineCount * getMaxInstructionSize() ) );
+ if ( endAddress.compareTo( getGlobalEndAddress() ) > 0 )
+ endAddress = getGlobalEndAddress();
+ lines = disassemble( address, endAddress, mixed );
+ IDisassemblyInstruction firstInstruction = getFirstInstruction( lines );
+ if ( firstInstruction == null )
+ break;
+ IDisassemblyInstruction lastInstruction = getLastInstruction( lines );
+ if ( lastInstruction == null )
+ break;
+ if ( startAddress.compareTo( firstInstruction.getAdress().getValue() ) < 0 ) {
+ lines = appendLines( disassemble( startAddress, firstInstruction.getAdress().getValue(), mixed ), lines );
+ }
+ startAddress = lastInstruction.getAdress().getValue();
+ if ( startAddress.compareTo( endAddress ) < 0 ) {
+ lines = appendLines( lines, disassemble( startAddress, endAddress, mixed ) );
+ }
+ }
int size = Math.min( lineCount, lines.length );
IDisassemblyLine[] result = new IDisassemblyLine[size];
int start = getIndexForAddress( address, lines );
@@ -189,10 +208,12 @@ public class DisassemblyRetrieval extends CDebugElement implements ICDIEventList
}
if ( mixedInstructions != null ) {
for ( ICDIMixedInstruction mi : mixedInstructions ) {
- list.add( new DisassemblySourceLine( (CDebugTarget)getDebugTarget(), fBaseElement, mi ) );
ICDIInstruction[] instructions = mi.getInstructions();
- for ( ICDIInstruction i : instructions ) {
- list.add( new DisassemblyInstruction( (CDebugTarget)getDebugTarget(), fBaseElement, i ) );
+ if ( instructions.length > 0 ) {
+ list.add( new DisassemblySourceLine( (CDebugTarget)getDebugTarget(), fBaseElement, mi ) );
+ for ( ICDIInstruction i : instructions ) {
+ list.add( new DisassemblyInstruction( (CDebugTarget)getDebugTarget(), fBaseElement, i ) );
+ }
}
}
}
@@ -240,6 +261,22 @@ public class DisassemblyRetrieval extends CDebugElement implements ICDIEventList
return ( index > 0 ) ? (IDisassemblyInstruction)lines[index - 1] : null;
}
+ private IDisassemblyInstruction getFirstInstruction( IDisassemblyLine[] lines ) {
+ for ( IDisassemblyLine l : lines ) {
+ if ( l instanceof IDisassemblyInstruction )
+ return (IDisassemblyInstruction)l;
+ }
+ return null;
+ }
+
+ private IDisassemblyInstruction getLastInstruction( IDisassemblyLine[] lines ) {
+ for ( int i = lines.length - 1; i >= 0; --i ) {
+ if ( lines[i] instanceof IDisassemblyInstruction )
+ return (IDisassemblyInstruction)lines[i];
+ }
+ return null;
+ }
+
private BigInteger getGlobalStartAddress() {
return getAddressFactory().getZero().getValue();
}
@@ -251,4 +288,14 @@ public class DisassemblyRetrieval extends CDebugElement implements ICDIEventList
private IAddressFactory getAddressFactory() {
return ((CDebugTarget)getDebugTarget()).getAddressFactory();
}
+
+ private IDisassemblyLine[] appendLines( IDisassemblyLine[] lines1, IDisassemblyLine[] lines2 ) {
+ List<IDisassemblyLine> list = new ArrayList<IDisassemblyLine>( lines1.length + lines2.length );
+ list.addAll( Arrays.asList( lines1 ) );
+ for ( IDisassemblyLine l : lines2 ) {
+ if ( !list.contains( l ) )
+ list.add( l );
+ }
+ return list.toArray( new IDisassemblyLine[list.size()] );
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java
index 3c18521b66a..f78fd8d7cab 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java
@@ -65,4 +65,19 @@ public class DisassemblySourceLine extends CDebugElement implements IDisassembly
public String toString() {
return fCDIMixedInstruction.getFileName() + ' ' + getLineNumber();
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if ( !(obj instanceof IDisassemblySourceLine) )
+ return false;
+ IDisassemblySourceLine other = (IDisassemblySourceLine)obj;
+ if ( !getFile().equals( other.getFile() ) )
+ return false;
+ if ( getLineNumber() != other.getLineNumber() )
+ return false;
+ return true;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java
index 96c54ec4d8c..3981bedbb8f 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java
@@ -38,6 +38,6 @@ public class CDebugUIPreferenceInitializer extends AbstractPreferenceInitializer
CDebugPreferencePage.initDefaults( pstore );
pstore.setDefault( ICDebugPreferenceConstants.PREF_OPEN_DISASSEMBLY_MODE, MessageDialogWithToggle.PROMPT );
pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS, true );
- pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, false );
+ pstore.setDefault( ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE, true );
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java
index c372cf0c121..14e73a0e774 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/commands/DisassemblyDisplayModeHandler.java
@@ -17,31 +17,26 @@ 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.cdt.debug.ui.disassembly.IDocumentPresentation;
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.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
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)
*/
@@ -51,12 +46,10 @@ public class DisassemblyDisplayModeHandler extends AbstractHandler implements IE
if ( presentation != null ) {
String param = event.getParameter( ID_PARAMETER_MODE );
if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) {
- fShowInstructions = !fShowInstructions;
- presentation.setShowIntstructions( fShowInstructions );
+ presentation.setShowIntstructions( !presentation.showIntstructions() );
}
else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) {
- fShowSource = !fShowSource;
- presentation.setShowSource( fShowSource );
+ presentation.setShowSource( !presentation.showSource() );
}
}
return null;
@@ -67,12 +60,28 @@ public class DisassemblyDisplayModeHandler extends AbstractHandler implements IE
*/
@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 );
+ IWorkbenchPartSite site = (IWorkbenchPartSite)element.getServiceLocator().getService( IWorkbenchPartSite.class );
+ if ( site != null ) {
+ IWorkbenchPart part = site.getPart();
+ if ( part instanceof ITextEditor ) {
+ IEditorInput input = ((ITextEditor)part).getEditorInput();
+ if ( input instanceof DisassemblyEditorInput ) {
+ IDocumentProvider dp = ((ITextEditor)part).getDocumentProvider();
+ if ( dp instanceof DisassemblyDocumentProvider ) {
+ IDocumentPresentation p = ((DisassemblyDocumentProvider)dp).getDocumentPresentation( input );
+ if ( p instanceof DisassemblyEditorPresentation ) {
+ DisassemblyEditorPresentation presentation = (DisassemblyEditorPresentation)p;
+ String param = (String)parameters.get( ID_PARAMETER_MODE );
+ if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_INSTRUCTIONS.equals( param ) ) {
+ element.setChecked( presentation.showIntstructions() );
+ }
+ else if ( IInternalCDebugUIConstants.DISASM_DISPLAY_MODE_SOURCE.equals( param ) ) {
+ element.setChecked( presentation.showSource() );
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java
index 5adcd4208c6..2695a38f023 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditorPresentation.java
@@ -29,9 +29,6 @@ public class DisassemblyEditorPresentation extends PresentationContext implement
public static final String PROPERTY_SHOW_ADDRESSES = "PROPERTY_SHOW_ADDRESSES"; //$NON-NLS-1$
public static final String PROPERTY_SHOW_LINE_NUMBERS = "PROPERTY_SHOW_LINE_NUMBERS"; //$NON-NLS-1$
- private boolean fShowInstructions = true;
- private boolean fShowSource = false;
-
private boolean fShowAddresses = true;
private boolean fShowLineNumbers = true;
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java
index 8939ec374a5..88e730b98be 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java
@@ -80,7 +80,7 @@ public class DisassemblyElementLabelProvider implements IDocumentElementLabelPro
sb.append( line.getLineNumber() );
sb.append( '\t' );
}
- sb.append( line.getFile().getAbsolutePath() );
+ sb.append( line.getFile().getPath() );
update.setLabel( DisassemblyEditorPresentation.ATTR_LINE_LABEL, sb.toString() );
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java
index 299af79ee23..5baa3d6686c 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java
@@ -12,10 +12,15 @@
package org.eclipse.cdt.debug.internal.ui.preferences;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -45,6 +50,23 @@ public class DisassemblyPreferencePage extends FieldEditorPreferencePage impleme
},
getFieldEditorParent(),
true ) );
+
+ Group group = ControlFactory.createGroup( getFieldEditorParent(), "Display settings", 1 );
+ Composite spacer = ControlFactory.createComposite( group, 1 );
+
+ FieldEditor edit = new BooleanFieldEditor(
+ ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS,
+ "Show instructions",
+ spacer );
+ edit.fillIntoGrid( spacer, 2 );
+ addField( edit );
+
+ edit = new BooleanFieldEditor(
+ ICDebugPreferenceConstants.PREF_DISASM_SHOW_SOURCE,
+ "Show source",
+ spacer );
+ edit.fillIntoGrid( spacer, 2 );
+ addField( edit );
}
/* (non-Javadoc)

Back to the top