Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Khodjaiants2008-04-16 13:10:57 -0400
committerMikhail Khodjaiants2008-04-16 13:10:57 -0400
commit5b528871c9902959ce996933b7f66a4d771ba880 (patch)
tree6eb2e7ebb10730884a6c2a952d3bfef20857b63c
parentb3256c51da19a7f46a8fb13bc913cf5c10e8679a (diff)
downloadorg.eclipse.cdt-5b528871c9902959ce996933b7f66a4d771ba880.tar.gz
org.eclipse.cdt-5b528871c9902959ce996933b7f66a4d771ba880.tar.xz
org.eclipse.cdt-5b528871c9902959ce996933b7f66a4d771ba880.zip
Contributing new disassembly.
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyInstruction.java19
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java20
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java22
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDisassemblyContextProvider.java15
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java33
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java1
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java99
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java254
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java68
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr.gifbin83 -> 105 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr_top.gifbin82 -> 138 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml23
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIPreferenceInitializer.java8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java25
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementAnnotationProvider.java120
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementContentProvider.java124
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java88
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java55
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java5
20 files changed, 960 insertions, 21 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyInstruction.java
new file mode 100644
index 00000000000..71610d46dc2
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyInstruction.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.core.model;
+
+/**
+ * Represents an instruction in disassembly.
+ */
+public interface IDisassemblyInstruction extends IAsmInstruction, IDisassemblyLine {
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java
new file mode 100644
index 00000000000..1d899d4f3ac
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblyLine.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.core.model;
+
+/**
+ * org.eclipse.cdt.debug.core.model.IDisassemblyLine:
+ * //TODO Add description.
+ */
+public interface IDisassemblyLine {
+
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java
new file mode 100644
index 00000000000..8dc96433188
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/IDisassemblySourceLine.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.core.model;
+
+import java.io.File;
+
+/**
+ * Represents a source line in disassembly.
+ */
+public interface IDisassemblySourceLine extends IAsmSourceLine, IDisassemblyLine {
+
+ public File getFile();
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDisassemblyContextProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDisassemblyContextProvider.java
index 43735b8634c..52e844847b9 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDisassemblyContextProvider.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDisassemblyContextProvider.java
@@ -12,6 +12,9 @@
package org.eclipse.cdt.debug.internal.core;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextProvider;
+import org.eclipse.cdt.debug.core.model.ICDebugElement;
+import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
+import org.eclipse.debug.core.model.IDebugTarget;
/**
* org.eclipse.cdt.debug.internal.core.CDisassemblyContextProvider:
@@ -23,14 +26,10 @@ public class CDisassemblyContextProvider implements IDisassemblyContextProvider
* @see org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextProvider#getDisassemblyContext(java.lang.Object)
*/
public Object getDisassemblyContext( Object element ) {
-// if ( element instanceof ICDebugElement ) {
-// IDebugTarget target = ((ICDebugElement)element).getDebugTarget();
-// try {
-// return ((ICDebugTarget)target).getDisassembly();
-// }
-// catch( DebugException e ) {
-// }
-// }
+ if ( element instanceof ICDebugElement ) {
+ IDebugTarget target = ((ICDebugElement)element).getDebugTarget();
+ return ((CDebugTarget)target).getDisassemblyRetrieval();
+ }
return null;
}
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index 7241fc8a7e6..b657a2b586f 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -170,10 +170,15 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
private ICDITargetConfiguration fConfig;
- /**
- * The disassembly manager for this target.
- */
- private Disassembly fDisassembly;
+ /**
+ * The disassembly manager for this target.
+ */
+ private Disassembly fDisassembly;
+
+ /**
+ * The new disassembly manager for this target.
+ */
+ private DisassemblyRetrieval fDisassemblyRetrieval;
/**
* The module manager for this target.
@@ -1556,9 +1561,13 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#getDisassembly()
*/
- public IDisassembly getDisassembly() throws DebugException {
- return fDisassembly;
- }
+ public IDisassembly getDisassembly() throws DebugException {
+ return fDisassembly;
+ }
+
+ public DisassemblyRetrieval getDisassemblyRetrieval() {
+ return fDisassemblyRetrieval;
+ }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICDebugTarget#getSignals()
@@ -1584,12 +1593,16 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void createDisassembly() {
this.fDisassembly = new Disassembly( this );
+ this.fDisassemblyRetrieval = new DisassemblyRetrieval( this );
}
private void disposeDisassembly() {
- if ( fDisassembly != null )
- fDisassembly.dispose();
- fDisassembly = null;
+ if ( fDisassembly != null )
+ fDisassembly.dispose();
+ fDisassembly = null;
+ if ( fDisassemblyRetrieval != null )
+ fDisassemblyRetrieval.dispose();
+ fDisassemblyRetrieval = null;
}
/* (non-Javadoc)
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java
index 956e78f4e56..c90d569eb5b 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/Disassembly.java
@@ -122,6 +122,7 @@ public class Disassembly extends CDebugElement implements IDisassembly, ICDIEven
public void dispose() {
getCDISession().getEventManager().removeEventListener( this );
+ CDebugCorePlugin.getDefault().getDisassemblyContextService().unregister( this );
for ( int i = 0; i < fBlocks.length; ++i )
if ( fBlocks[i] != null ) {
fBlocks[i].dispose();
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java
new file mode 100644
index 00000000000..7473d9ae706
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyInstruction.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.math.BigInteger;
+
+import org.eclipse.cdt.core.IAddress;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
+import org.eclipse.cdt.debug.core.model.IDisassemblyInstruction;
+
+public class DisassemblyInstruction extends CDebugElement implements IDisassemblyInstruction {
+
+ private BigInteger fBaseElement;
+ private ICDIInstruction fCDIInstruction;
+ private IAddress fAddress;
+
+ public DisassemblyInstruction( CDebugTarget target, BigInteger baseElement, ICDIInstruction instruction ) {
+ super( target );
+ fBaseElement = baseElement;
+ fCDIInstruction = instruction;
+ fAddress = target.getAddressFactory().createAddress( fCDIInstruction.getAdress() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getAdress()
+ */
+ public IAddress getAdress() {
+ return fAddress;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getArguments()
+ */
+ public String getArguments() {
+ return fCDIInstruction.getArgs();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getFunctionName()
+ */
+ public String getFunctionName() {
+ return fCDIInstruction.getFuntionName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getInstructionText()
+ */
+ public String getInstructionText() {
+ return fCDIInstruction.getInstruction();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getOffset()
+ */
+ public long getOffset() {
+ return fCDIInstruction.getOffset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmInstruction#getOpcode()
+ */
+ public String getOpcode() {
+ return fCDIInstruction.getOpcode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if ( obj == this )
+ return true;
+ if ( !(obj instanceof IDisassemblyInstruction) )
+ return false;
+ IDisassemblyInstruction instr = (IDisassemblyInstruction)obj;
+ if ( !instr.getAdress().equals( getAdress() ) )
+ return false;
+ if ( instr.getOffset() != getOffset() )
+ return false;
+ if ( instr.getFunctionName().compareTo( getFunctionName() ) != 0 )
+ return false;
+ if ( instr.getOpcode().compareTo( getOpcode() ) != 0 )
+ return false;
+ if ( instr.getArguments().compareTo( getArguments() ) != 0 )
+ return false;
+ if ( instr.getInstructionText().compareTo( getInstructionText() ) != 0 )
+ return false;
+ return true;
+ }
+}
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
new file mode 100644
index 00000000000..350bc755df0
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblyRetrieval.java
@@ -0,0 +1,254 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.IAddressFactory;
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
+import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
+import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.core.model.ICStackFrame;
+import org.eclipse.cdt.debug.core.model.IDisassemblyInstruction;
+import org.eclipse.cdt.debug.core.model.IDisassemblyLine;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+
+public class DisassemblyRetrieval extends CDebugElement implements ICDIEventListener {
+
+ public static final int FLAGS_SHOW_INSTRUCTIONS = 0x1;
+ public static final int FLAGS_SHOW_SOURCE = 0x2;
+
+ private Object fInput = null;
+ private BigInteger fBaseElement = null;
+ private int fCurrentOffset = 0;
+ private int fFlags = 0;
+ private IDisassemblyLine[] fLines;
+
+ public DisassemblyRetrieval( CDebugTarget target ) {
+ super( target );
+ fLines = new IDisassemblyLine[0];
+ CDebugCorePlugin.getDefault().getDisassemblyContextService().register( this );
+ getCDISession().getEventManager().addEventListener( this );
+ }
+
+ public void dispose() {
+ getCDISession().getEventManager().removeEventListener( this );
+ CDebugCorePlugin.getDefault().getDisassemblyContextService().unregister( this );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(org.eclipse.cdt.debug.core.cdi.event.ICDIEvent[])
+ */
+ public void handleDebugEvents( ICDIEvent[] event ) {
+ // TODO Auto-generated method stub
+ }
+
+ public Object getInput() {
+ return fInput;
+ }
+
+ public BigInteger getBaseElement() {
+ return fBaseElement;
+ }
+
+ public int getCurrentOffset() {
+ return fCurrentOffset;
+ }
+
+ public IDisassemblyLine[] getLines() {
+ return fLines;
+ }
+
+ public void changeBase( Object input, int offset, int flags ) throws DebugException {
+ if ( input instanceof ICStackFrame ) {
+ fInput = input;
+ ICStackFrame frame = (ICStackFrame)input;
+ BigInteger address = frame.getAddress().getValue();
+ if ( !containsAddress( address, fLines ) ) {
+ fCurrentOffset = 0;
+ reset();
+ }
+ else if ( flags != fFlags ) {
+ reset();
+ }
+ else {
+ fCurrentOffset += getDistance( fBaseElement, address );
+ }
+ fBaseElement = address;
+ }
+ }
+
+ public void retrieveDisassembly( Object input, Object base, int offset, int lineCount, boolean reveal, int flags ) throws DebugException {
+ boolean showInstructions = ( (flags & FLAGS_SHOW_INSTRUCTIONS) != 0 );
+ boolean showSource = ( (flags & FLAGS_SHOW_SOURCE) != 0 );
+ List<IDisassemblyLine> lines = new ArrayList<IDisassemblyLine>( lineCount );
+ BigInteger startAddress = getCurrentStartAddress();
+ BigInteger address = null;
+ if ( startAddress != null ) {
+ if ( getCurrentOffset() > offset ) {
+ address = startAddress.subtract( BigInteger.valueOf( getMinInstructionSize() * (getCurrentOffset() - offset) ) );
+ }
+ else if ( getCurrentOffset() < offset ) {
+ IDisassemblyInstruction next = getNextInstruction( startAddress, fLines );
+ if ( next != null )
+ address = next.getAdress().getValue();
+ }
+ else {
+ address = startAddress;
+ }
+ }
+ if ( address == null )
+ address = fBaseElement;
+ lines.addAll( Arrays.asList( disassembleDown( address, lineCount, showSource ) ) );
+ fLines = lines.toArray( new IDisassemblyLine[lines.size()] );
+ fCurrentOffset = offset;
+ }
+
+ private boolean containsAddress( BigInteger address, IDisassemblyLine[] lines ) {
+ return ( getIndexForAddress( address, lines ) >= 0 );
+ }
+
+ public void reset() {
+ fLines = new IDisassemblyLine[0];
+ }
+
+ private int getDistance( BigInteger address1, BigInteger address2 ) {
+ int index1 = getIndexForAddress( address1, fLines );
+ Assert.isTrue( index1 >=0 );
+ int index2 = getIndexForAddress( address2, fLines );
+ Assert.isTrue( index2 >=0 );
+ return index2 - index1;
+ }
+
+ private int getIndexForAddress( BigInteger address, IDisassemblyLine[] lines ) {
+ for ( int i = 0; i < lines.length; ++i ) {
+ if ( lines[i] instanceof IDisassemblyInstruction &&
+ address.compareTo( ((IDisassemblyInstruction)lines[i]).getAdress().getValue() ) == 0 )
+ return i;
+ }
+ return -1;
+ }
+
+ private BigInteger getCurrentStartAddress() {
+ for ( IDisassemblyLine l : fLines ) {
+ if ( l instanceof IDisassemblyInstruction )
+ return ((IDisassemblyInstruction)l).getAdress().getValue();
+ }
+ return null;
+ }
+
+ 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 );
+ int size = Math.min( lineCount, lines.length );
+ IDisassemblyLine[] result = new IDisassemblyLine[size];
+ int start = getIndexForAddress( address, lines );
+ if ( start != -1 ) {
+ System.arraycopy( lines, start, result, 0, size );
+ }
+ return result;
+ }
+
+ private IDisassemblyLine[] disassemble( BigInteger startAddress, BigInteger endAddress, boolean mixed ) throws DebugException {
+ List<IDisassemblyLine> list = new ArrayList<IDisassemblyLine>();
+ ICDITarget cdiTarget = (ICDITarget)getDebugTarget().getAdapter( ICDITarget.class );
+ try {
+ ICDIMixedInstruction[] mixedInstructions = null;
+ ICDIInstruction[] asmInstructions = null;
+ if ( mixed ) {
+ mixedInstructions = cdiTarget.getMixedInstructions( startAddress, endAddress );
+ if ( mixedInstructions.length == 0
+ || mixedInstructions.length == 1
+ && mixedInstructions[0].getInstructions().length == 0 ) {
+ mixedInstructions = null;
+ }
+ }
+ if ( mixedInstructions == null ) {
+ asmInstructions = cdiTarget.getInstructions( startAddress, endAddress );
+ }
+ 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 ) );
+ }
+ }
+ }
+ else if ( asmInstructions != null ) {
+ for ( ICDIInstruction i : asmInstructions ) {
+ list.add( new DisassemblyInstruction( (CDebugTarget)getDebugTarget(), fBaseElement, i ) );
+ }
+ }
+ }
+ catch( CDIException exc ) {
+ throw new DebugException( new Status( IStatus.ERROR, "dummy", exc.getDetailMessage(), exc ) ); //$NON-NLS-1$
+ }
+ return list.toArray( new IDisassemblyLine[list.size()] );
+ }
+
+ private int getMaxInstructionSize() {
+ return 4;
+ }
+
+ private int getMinInstructionSize() {
+ return 1;
+ }
+
+ private IDisassemblyInstruction getNextInstruction( BigInteger address, IDisassemblyLine[] lines ) {
+ int index = getIndexForAddress( address, lines );
+ if ( index == -1 || index == lines.length - 1 )
+ return null;
+ for ( int i = index + 1; i < lines.length; ++i ) {
+ if ( lines[i] instanceof IDisassemblyInstruction )
+ return (IDisassemblyInstruction)lines[i];
+ }
+ return null;
+ }
+
+ private IDisassemblyInstruction getPreviousInstruction( BigInteger baseAddress ) throws DebugException {
+ BigInteger endAddress = baseAddress.add( BigInteger.valueOf( 1 ) );
+ BigInteger startAddress = baseAddress;
+ IDisassemblyLine[] lines = new IDisassemblyLine[0];
+ int index = -1;
+ while( index == -1 && startAddress.compareTo( getGlobalStartAddress() ) > 0 ) {
+ startAddress = startAddress.subtract( BigInteger.valueOf( 1 ) );
+ lines = disassemble( startAddress, endAddress, false );
+ index = getIndexForAddress( baseAddress, lines );
+ }
+ return ( index > 0 ) ? (IDisassemblyInstruction)lines[index - 1] : null;
+ }
+
+ private BigInteger getGlobalStartAddress() {
+ return getAddressFactory().getZero().getValue();
+ }
+
+ private BigInteger getGlobalEndAddress() {
+ return getAddressFactory().getMax().getValue();
+ }
+
+ private IAddressFactory getAddressFactory() {
+ return ((CDebugTarget)getDebugTarget()).getAddressFactory();
+ }
+}
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
new file mode 100644
index 00000000000..3c18521b66a
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/DisassemblySourceLine.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.model;
+
+import java.io.File;
+import java.math.BigInteger;
+
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
+import org.eclipse.cdt.debug.core.model.IAsmInstruction;
+import org.eclipse.cdt.debug.core.model.IDisassemblySourceLine;
+
+public class DisassemblySourceLine extends CDebugElement implements IDisassemblySourceLine {
+
+ private BigInteger fBaseElement;
+ private ICDIMixedInstruction fCDIMixedInstruction;
+
+ public DisassemblySourceLine( CDebugTarget target, BigInteger baseElement, ICDIMixedInstruction mixedInstruction ) {
+ super( target );
+ fBaseElement = baseElement;
+ fCDIMixedInstruction = mixedInstruction;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IDisassemblySourceLine#getFile()
+ */
+ public File getFile() {
+ String name = fCDIMixedInstruction.getFileName();
+ if ( name != null && name.length() > 0 ) {
+ return new File( name );
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmSourceLine#getInstructions()
+ */
+ public IAsmInstruction[] getInstructions() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.IAsmSourceLine#getLineNumber()
+ */
+ public int getLineNumber() {
+ return fCDIMixedInstruction.getLineNumber();
+ }
+
+ public BigInteger getBaseAddress() {
+ return fBaseElement;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return fCDIMixedInstruction.getFileName() + ' ' + getLineNumber();
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr.gif
index 9831329e711..d58bf895650 100644
--- a/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr.gif
+++ b/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr_top.gif b/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr_top.gif
index 961873ea99c..34ac8ac69dc 100644
--- a/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr_top.gif
+++ b/debug/org.eclipse.cdt.debug.ui/icons/obj16/inst_ptr_top.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index 54b66e6c789..9c0ca2eed9b 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -123,6 +123,8 @@ InstructionsDisplayMode.label = Show Instructions
InstructionsDisplayMode.tooltip = Show disassembly instructions
SourceDisplayMode.label = Show Source
SourceDisplayMode.tooltip = Show source code
+
+DisassemblyPreferencePage.name = Disassembly
# new disassembly (end)
DebugTextHover.label=Debugger
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 2659851eb03..5257168a3b9 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -1156,7 +1156,7 @@
verticalRulerPreferenceValue="true">
</specification>
<specification
- colorPreferenceValue="217,255,226"
+ colorPreferenceValue="198,219,174"
annotationType="org.eclipse.cdt.debug.ui.currentDisassemblyIP"
verticalRulerPreferenceValue="true"
colorPreferenceKey="currentDisassemblyIPColor"
@@ -1172,7 +1172,7 @@
overviewRulerPreferenceKey="currentDisassemblyIPOverviewRuler">
</specification>
<specification
- colorPreferenceValue="217,255,226"
+ colorPreferenceValue="219,235,204"
annotationType="org.eclipse.cdt.debug.ui.secondaryDisassemblyIP"
verticalRulerPreferenceValue="true"
colorPreferenceKey="secondaryDisassemblyIPColor"
@@ -1277,6 +1277,9 @@
<adapter
type="org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextProvider">
</adapter>
+ <adapter
+ type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider">
+ </adapter>
</factory>
<factory
adaptableType="org.eclipse.cdt.debug.core.model.ICModule"
@@ -1342,6 +1345,16 @@
type="org.eclipse.jface.viewers.ILabelDecorator">
</adapter>
</factory>
+ <factory
+ adaptableType="org.eclipse.cdt.debug.core.model.IDisassemblyLine"
+ class="org.eclipse.cdt.debug.internal.ui.elements.adapters.CDebugElementAdapterFactory">
+ <adapter
+ type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelProvider">
+ </adapter>
+ <adapter
+ type="org.eclipse.cdt.debug.ui.disassembly.IDocumentElementAnnotationProvider">
+ </adapter>
+ </factory>
</extension>
<extension
point="org.eclipse.ui.themes">
@@ -1459,6 +1472,12 @@
id="org.eclipse.cdt.debug.ui.breakpointactions.ActionsPreferencePage"
category="org.eclipse.cdt.debug.ui.CDebugPreferencePage">
</page>
+ <page
+ category="org.eclipse.debug.ui.DebugPreferencePage"
+ class="org.eclipse.cdt.debug.internal.ui.preferences.DisassemblyPreferencePage"
+ id="org.eclipse.cdt.debug.ui.disassemblyPreferencePge"
+ name="%DisassemblyPreferencePage.name">
+ </page>
</extension>
<extension
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 cdb33283422..96c54ec4d8c 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
@@ -11,8 +11,10 @@
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage;
+import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
/**
@@ -30,8 +32,12 @@ public class CDebugUIPreferenceInitializer extends AbstractPreferenceInitializer
/* (non-Javadoc)
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/
- public void initializeDefaultPreferences() {
+ @Override
+ public void initializeDefaultPreferences() {
IPreferenceStore pstore = CDebugUIPlugin.getDefault().getPreferenceStore();
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 );
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
index 92246dfaa58..99156291155 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/CDebugElementAdapterFactory.java
@@ -19,10 +19,14 @@ import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICThread;
+import org.eclipse.cdt.debug.core.model.IDisassemblyLine;
import org.eclipse.cdt.debug.core.model.IModuleRetrieval;
import org.eclipse.cdt.debug.internal.core.CDisassemblyContextProvider;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleContentProvider;
import org.eclipse.cdt.debug.internal.ui.views.modules.ModuleMementoProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementAnnotationProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelProvider;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
@@ -41,6 +45,9 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
private static IElementMementoProvider fgModuleMementoProvider = new ModuleMementoProvider();
private static IDisassemblyContextProvider fgDisassemblyContextProvider = new CDisassemblyContextProvider();
+ private static IDocumentElementContentProvider fgDisassemblyContentProvider = new DisassemblyElementContentProvider();
+ private static IDocumentElementLabelProvider fgDisassemblyLabelProvider = new DisassemblyElementLabelProvider();
+ private static IDocumentElementAnnotationProvider fgDisassemblyAnnotationProvider = new DisassemblyElementAnnotationProvider();
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
@@ -97,6 +104,21 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
return fgDisassemblyContextProvider;
}
}
+ if ( adapterType.equals( IDocumentElementContentProvider.class ) ) {
+ if ( adaptableObject instanceof ICStackFrame ) {
+ return fgDisassemblyContentProvider;
+ }
+ }
+ if ( adapterType.equals( IDocumentElementLabelProvider.class ) ) {
+ if ( adaptableObject instanceof IDisassemblyLine ) {
+ return fgDisassemblyLabelProvider;
+ }
+ }
+ if ( adapterType.equals( IDocumentElementAnnotationProvider.class ) ) {
+ if ( adaptableObject instanceof IDisassemblyLine ) {
+ return fgDisassemblyAnnotationProvider;
+ }
+ }
return null;
}
@@ -109,6 +131,9 @@ public class CDebugElementAdapterFactory implements IAdapterFactory {
IModelProxyFactory.class,
IElementMementoProvider.class,
IDisassemblyContextProvider.class,
+ IDocumentElementContentProvider.class,
+ IDocumentElementLabelProvider.class,
+ IDocumentElementAnnotationProvider.class,
};
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementAnnotationProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementAnnotationProvider.java
new file mode 100644
index 00000000000..8c7cc1b9a8d
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementAnnotationProvider.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.elements.adapters;
+
+import java.math.BigInteger;
+
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICStackFrame;
+import org.eclipse.cdt.debug.core.model.IDisassemblyInstruction;
+import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
+import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
+import org.eclipse.cdt.debug.internal.core.model.DisassemblyRetrieval;
+import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyInstructionPointerAnnotation;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementAnnotationProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementAnnotationUpdate;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+
+public class DisassemblyElementAnnotationProvider implements IDocumentElementAnnotationProvider {
+
+ /* (non-Javadoc)
+ * @see com.arm.eclipse.rvd.ui.disassembly.IDocumentElementAnnotationProvider#update(com.arm.eclipse.rvd.ui.disassembly.IDocumentElementAnnotationUpdate[])
+ */
+ public void update( final IDocumentElementAnnotationUpdate[] updates ) {
+ Job job = new Job( "Annotations update" ) { //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus run( IProgressMonitor monitor ) {
+ for( int i = 0; i < updates.length; i++ ) {
+ IDocumentElementAnnotationUpdate update = updates[i];
+ if ( !update.isCanceled() ) {
+ retrieveAnnotations( update );
+ }
+ update.done();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem( true );
+ job.schedule();
+ }
+
+ protected void retrieveAnnotations( IDocumentElementAnnotationUpdate update ) {
+ retrieveInstructionPointers( update );
+ retrieveBreakpoints( update );
+ }
+
+ private void retrieveInstructionPointers( IDocumentElementAnnotationUpdate update ) {
+ Object root = update.getRootElement();
+ if ( root instanceof DisassemblyRetrieval ) {
+ DisassemblyRetrieval retrieval = (DisassemblyRetrieval)root;
+ Object input = retrieval.getInput();
+ if ( input instanceof ICStackFrame ) {
+ Object element = update.getElement();
+ if ( element instanceof IDisassemblyInstruction ) {
+ BigInteger address = ((IDisassemblyInstruction)element).getAdress().getValue();
+ ICStackFrame frame = (ICStackFrame)input;
+ BigInteger frameAddress = frame.getAddress().getValue();
+ if ( address.equals( frameAddress ) ) {
+ IThread thread = frame.getThread();
+ boolean topFrame;
+ try {
+ topFrame = ( frame == thread.getTopStackFrame() );
+ update.addAnnotation( new DisassemblyInstructionPointerAnnotation( frame, topFrame ) );
+ }
+ catch( DebugException e ) {
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void retrieveBreakpoints( IDocumentElementAnnotationUpdate update ) {
+ IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDebugCorePlugin.getUniqueIdentifier() );
+ for ( IBreakpoint b : breakpoints ) {
+ if ( b instanceof ICLineBreakpoint ) {
+ try {
+ Object root = update.getRootElement();
+ if ( root instanceof DisassemblyRetrieval ) {
+ Object element = update.getElement();
+ if ( element instanceof IDisassemblyInstruction ) {
+ IDisassemblyInstruction instruction = (IDisassemblyInstruction)element;
+ BigInteger address = ((CDebugTarget)((DisassemblyRetrieval)root).getDebugTarget()).getBreakpointAddress( (ICLineBreakpoint)b ).getValue();
+ BigInteger instrAddress = instruction.getAdress().getValue();
+ if ( address != null && instrAddress != null && instrAddress.compareTo( address ) == 0 ) {
+ update.addAnnotation( new MarkerAnnotation( b.getMarker() ) );
+ }
+ }
+ }
+ }
+ catch( CoreException e ) {
+ }
+ catch( NumberFormatException e ) {
+ }
+ }
+ }
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementContentProvider.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementContentProvider.java
new file mode 100644
index 00000000000..1fec2b4618d
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementContentProvider.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.elements.adapters;
+
+import org.eclipse.cdt.debug.core.model.IDisassemblyLine;
+import org.eclipse.cdt.debug.internal.core.model.DisassemblyRetrieval;
+import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorPresentation;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentBaseChangeUpdate;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentUpdate;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.core.DebugException;
+
+public class DisassemblyElementContentProvider implements IDocumentElementContentProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider#updateContent(org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentUpdate)
+ */
+ public void updateContent( final IDocumentElementContentUpdate update ) {
+ Job job = new Job( "Source content update" ) { //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus run( IProgressMonitor monitor ) {
+ if ( !update.isCanceled() ) {
+ retrieveDisassembly( update );
+ }
+ update.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem( true );
+ job.schedule();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.ui.disassembly.IDocumentElementContentProvider#updateInput(org.eclipse.cdt.debug.ui.disassembly.IDocumentBaseChangeUpdate)
+ */
+ public void updateInput( final IDocumentBaseChangeUpdate update ) {
+ Job job = new Job( "Input update" ) { //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus run( IProgressMonitor monitor ) {
+ if ( !update.isCanceled() ) {
+ changeBaseElement( update );
+ }
+ update.done();
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem( true );
+ job.schedule();
+ }
+
+ protected void changeBaseElement( IDocumentBaseChangeUpdate update ) {
+ Object root = update.getRootElement();
+ if ( root instanceof DisassemblyRetrieval ) {
+ DisassemblyRetrieval retrieval = (DisassemblyRetrieval)root;
+ try {
+ retrieval.changeBase( update.getElement(), update.getOriginalOffset(), getPresentationFlags( (IDocumentPresentation)update.getPresentationContext() ) );
+ update.setBaseElement( retrieval.getBaseElement() );
+ update.setOffset( retrieval.getCurrentOffset() );
+ }
+ catch( DebugException e ) {
+ update.setStatus( e.getStatus() );
+ }
+ }
+ }
+
+ protected void retrieveDisassembly( IDocumentElementContentUpdate update ) {
+ Object root = update.getRootElement();
+ if ( root instanceof DisassemblyRetrieval ) {
+ DisassemblyRetrieval retrieval = (DisassemblyRetrieval)root;
+ try {
+ retrieval.retrieveDisassembly(
+ update.getElement(),
+ update.getBaseElement(),
+ update.getOriginalOffset(),
+ update.getRequestedLineCount(),
+ update.reveal(),
+ getPresentationFlags( (IDocumentPresentation)update.getPresentationContext() ) );
+ IDisassemblyLine[] lines = retrieval.getLines();
+ update.setOffset( retrieval.getCurrentOffset() );
+ update.setLineCount( lines.length );
+ for( int i = 0; i < lines.length; ++i ) {
+ update.addElement( i, lines[i] );
+ }
+ }
+ catch( DebugException e ) {
+ update.setStatus( e.getStatus() );
+ }
+ }
+ }
+
+ private int getPresentationFlags( IDocumentPresentation presentation ) {
+ int flags = 0;
+ if ( presentation instanceof DisassemblyEditorPresentation ) {
+ DisassemblyEditorPresentation dep = (DisassemblyEditorPresentation)presentation;
+ if ( dep.showIntstructions() )
+ flags |= DisassemblyRetrieval.FLAGS_SHOW_INSTRUCTIONS;
+ if ( dep.showSource() )
+ flags |= DisassemblyRetrieval.FLAGS_SHOW_SOURCE;
+ }
+ return flags;
+ }
+}
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
new file mode 100644
index 00000000000..8939ec374a5
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/elements/adapters/DisassemblyElementLabelProvider.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.elements.adapters;
+
+import java.math.BigInteger;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.model.IDisassemblyInstruction;
+import org.eclipse.cdt.debug.core.model.IDisassemblySourceLine;
+import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditorPresentation;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelProvider;
+import org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelUpdate;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+
+/**
+ * org.eclipse.cdt.debug.internal.ui.elements.adapters.DisassemblyElementLabelProvider:
+ * //TODO Add description.
+ */
+public class DisassemblyElementLabelProvider implements IDocumentElementLabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelProvider#update(org.eclipse.cdt.debug.ui.disassembly.IDocumentElementLabelUpdate[])
+ */
+ public void update( final IDocumentElementLabelUpdate[] updates ) {
+ Job job = new Job( "Label update" ) { //$NON-NLS-1$
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus run( IProgressMonitor monitor ) {
+ for( int i = 0; i < updates.length; i++ ) {
+ IDocumentElementLabelUpdate update = updates[i];
+ if ( !update.isCanceled() ) {
+ retrieveLabel( update );
+ }
+ update.done();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setSystem( true );
+ job.schedule();
+ }
+
+ protected void retrieveLabel( IDocumentElementLabelUpdate update ) {
+ IPresentationContext context = update.getPresentationContext();
+ if ( context instanceof DisassemblyEditorPresentation ) {
+ DisassemblyEditorPresentation presentation = (DisassemblyEditorPresentation)context;
+ Object element = update.getElement();
+ if ( element instanceof IDisassemblyInstruction ) {
+ IDisassemblyInstruction instruction = (IDisassemblyInstruction)element;
+ StringBuilder sb = new StringBuilder();
+ if ( presentation.showAddresses() ) {
+ BigInteger address = instruction.getAdress().getValue();
+ sb.append( "0x" ); //$NON-NLS-1$
+ sb.append( CDebugUtils.prependString( Long.toHexString( address.longValue() ), 8, '0' ) );
+ sb.append( '\t' );
+ }
+ sb.append( instruction.getInstructionText() );
+ update.setLabel( DisassemblyEditorPresentation.ATTR_LINE_LABEL, sb.toString() );
+ }
+ else if ( element instanceof IDisassemblySourceLine ) {
+ IDisassemblySourceLine line = (IDisassemblySourceLine)element;
+ StringBuilder sb = new StringBuilder();
+ if ( presentation.showLineNumbers() ) {
+ sb.append( line.getLineNumber() );
+ sb.append( '\t' );
+ }
+ sb.append( line.getFile().getAbsolutePath() );
+ 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
new file mode 100644
index 00000000000..299af79ee23
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/DisassemblyPreferencePage.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.preferences;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class DisassemblyPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ public DisassemblyPreferencePage() {
+ super( GRID );
+ IPreferenceStore store = CDebugUIPlugin.getDefault().getPreferenceStore();
+ setPreferenceStore( store );
+ setDescription( "Disassembly Settings" );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ @Override
+ protected void createFieldEditors() {
+
+ addField( new RadioGroupFieldEditor(
+ ICDebugPreferenceConstants.PREF_OPEN_DISASSEMBLY_MODE,
+ "Open disassembly if source is not available",
+ 3,
+ new String[][] {
+ { "Always", MessageDialogWithToggle.ALWAYS },
+ { "Never", MessageDialogWithToggle.NEVER },
+ { "Prompt", MessageDialogWithToggle.PROMPT },
+ },
+ getFieldEditorParent(),
+ true ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init( IWorkbench workbench ) {
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java
index 116a3232a67..832caebfaac 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ICDebugPreferenceConstants.java
@@ -39,4 +39,9 @@ public interface ICDebugPreferenceConstants {
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$
+
+ /**
+ * Specifies the conditions under which the disassembly editor will be activated
+ */
+ public static final String PREF_OPEN_DISASSEMBLY_MODE = ICDebugUIConstants.PLUGIN_ID + ".openDisassemblyMode"; //$NON-NLS-1$
}

Back to the top