mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-14 20:45:22 +02:00
Bug 357440 - [disassembly] Add opcode ruler column to the disassembly view
This commit is contained in:
parent
9fe6dfee8e
commit
6f21f0999c
12 changed files with 306 additions and 56 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -18,18 +18,20 @@ import java.math.BigInteger;
|
|||
public class DisassemblyPosition extends AddressRangePosition {
|
||||
|
||||
public char[] fFunction;
|
||||
public BigInteger fOpcodes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param addressOffset
|
||||
* @param addressLength
|
||||
* @param functionOffset
|
||||
* @param opcodes
|
||||
*/
|
||||
public DisassemblyPosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, String opcodes) {
|
||||
public DisassemblyPosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, String functionOffset, BigInteger opcodes) {
|
||||
super(offset, length, addressOffset, addressLength);
|
||||
fFunction = opcodes.toCharArray();
|
||||
fOpcodes = opcodes;
|
||||
fFunction = functionOffset.toCharArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2010, 2011 Wind River Systems, Inc. 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
|
||||
|
@ -28,6 +28,11 @@ public interface IDisassemblyDocument {
|
|||
throws BadLocationException;
|
||||
|
||||
AddressRangePosition insertDisassemblyLine(AddressRangePosition p,
|
||||
BigInteger address, int intValue, String opCode, String string,
|
||||
BigInteger address, int intValue, String functionOffset, String instruction,
|
||||
String compilationPath, int lineNumber) throws BadLocationException;
|
||||
|
||||
AddressRangePosition insertDisassemblyLine(AddressRangePosition p,
|
||||
BigInteger address, int length, String functionOffset, BigInteger opcode,
|
||||
String instruction, String compilationPath, int lineNumber)
|
||||
throws BadLocationException;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
|
|||
Bundle-Name: %pluginName
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.dsf.ui;singleton:=true
|
||||
Bundle-Version: 2.2.1.qualifier
|
||||
Bundle-Version: 2.3.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui;bundle-version="3.5.0",
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>2.2.1-SNAPSHOT</version>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.dsf.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -31,6 +31,7 @@ public final class DisassemblyMessages extends NLS {
|
|||
|
||||
public static String Disassembly_action_ShowAddresses_label;
|
||||
public static String Disassembly_action_ShowFunctionOffsets_label;
|
||||
public static String Disassembly_action_ShowOpcode_label;
|
||||
public static String Disassembly_action_ShowSource_label;
|
||||
public static String Disassembly_action_ShowSymbols_label;
|
||||
public static String Disassembly_action_GotoPC_label;
|
||||
|
@ -65,6 +66,10 @@ public final class DisassemblyMessages extends NLS {
|
|||
public static String DisassemblyPreferencePage_radix_hexadecimal;
|
||||
public static String DisassemblyPreferencePage_showFunctionOffsets;
|
||||
public static String DisassemblyPreferencePage_showFunctionOffsetsTooltip;
|
||||
public static String DisassemblyPreferencePage_showCodeBytes;
|
||||
public static String DisassemblyPreferencePage_showCodeBytesTooltip;
|
||||
public static String DisassemblyPreferencePage_OpcodeFormat;
|
||||
public static String DisassemblyPreferencePage_OpcodeFormatTooltip;
|
||||
public static String DisassemblyPreferencePage_showAddress;
|
||||
public static String DisassemblyPreferencePage_showAddressTooltip;
|
||||
public static String DisassemblyPreferencePage_showRadixTooltip;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
##########################################################################
|
||||
# Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
# Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -13,6 +13,7 @@
|
|||
|
||||
Disassembly_action_ShowAddresses_label=Show Addresses
|
||||
Disassembly_action_ShowFunctionOffsets_label=Show Function Offsets
|
||||
Disassembly_action_ShowOpcode_label=Show Opcodes
|
||||
Disassembly_action_ShowSource_label=Show Source
|
||||
Disassembly_action_ShowSymbols_label=Show Symbols
|
||||
Disassembly_action_GotoPC_label=Go to Program Counter
|
||||
|
@ -57,7 +58,11 @@ DisassemblyPreferencePage_radix_decimal=Decimal
|
|||
DisassemblyPreferencePage_radix_hexadecimal=Hexadecimal
|
||||
DisassemblyPreferencePage_showFunctionOffsets=Show function offsets
|
||||
DisassemblyPreferencePage_showFunctionOffsetsTooltip=Show offsets of addresses in a function
|
||||
DisassemblyPreferencePage_showCodeBytes=Show instruction code bytes
|
||||
DisassemblyPreferencePage_showCodeBytesTooltip=Show the value of the address for the instruction code bytes
|
||||
DisassemblyPreferencePage_showAddress=Show instruction address
|
||||
DisassemblyPreferencePage_OpcodeFormatTooltip=Use this format for the instruction value
|
||||
DisassemblyPreferencePage_OpcodeFormat=Opcode display format:
|
||||
DisassemblyPreferencePage_showAddressTooltip=Show the address of each instruction
|
||||
DisassemblyPreferencePage_showRadixTooltip=Show '0x' with hexadecimal addresses
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
protected AbstractDisassemblyAction fActionGotoAddress;
|
||||
protected AbstractDisassemblyAction fActionToggleSource;
|
||||
private AbstractDisassemblyAction fActionToggleFunctionColumn;
|
||||
private AbstractDisassemblyAction fActionToggleOpcodeColumn;
|
||||
protected AbstractDisassemblyAction fActionToggleSymbols;
|
||||
protected AbstractDisassemblyAction fActionRefreshView;
|
||||
protected Action fActionOpenPreferences;
|
||||
|
@ -243,7 +244,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
private TextViewerDragAdapter fDragSourceAdapter;
|
||||
private DisassemblyDropAdapter fDropTargetAdapter;
|
||||
|
||||
private FunctionOffsetRulerColumn fOpcodeRulerColumn;
|
||||
private FunctionOffsetRulerColumn fFunctionOffsetRulerColumn;
|
||||
private OpcodeRulerColumn fOpcodeRulerColumn;
|
||||
private AddressRulerColumn fAddressRulerColumn;
|
||||
|
||||
private BigInteger fStartAddress;
|
||||
|
@ -270,6 +272,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
private List<Action> fSelectionActions = new ArrayList<Action>();
|
||||
private List<AbstractDisassemblyAction> fStateDependentActions = new ArrayList<AbstractDisassemblyAction>();
|
||||
private boolean fShowSource;
|
||||
private boolean fShowFunctionOffsets;
|
||||
private boolean fShowOpcodes;
|
||||
private boolean fShowSymbols;
|
||||
private Map<String, Object> fFile2Storage = new HashMap<String, Object>();
|
||||
|
@ -409,6 +412,22 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
}
|
||||
|
||||
private final class ActionToggleOpcodeColumn extends AbstractDisassemblyAction {
|
||||
ActionToggleOpcodeColumn() {
|
||||
super(DisassemblyPart.this);
|
||||
setText(DisassemblyMessages.Disassembly_action_ShowOpcode_label);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(DisassemblyPreferenceConstants.SHOW_CODE_BYTES, !isOpcodeRulerVisible());
|
||||
}
|
||||
@Override
|
||||
public void update() {
|
||||
setChecked(isOpcodeRulerVisible());
|
||||
}
|
||||
}
|
||||
|
||||
private final class ActionToggleBreakpointEnablement extends AbstractDisassemblyAction {
|
||||
private IBreakpoint fBreakpoint;
|
||||
public ActionToggleBreakpointEnablement() {
|
||||
|
@ -518,7 +537,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
else
|
||||
fEndAddress = new BigInteger(endAddressString, 16);
|
||||
fShowSource = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SOURCE);
|
||||
fShowOpcodes = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS);
|
||||
fShowFunctionOffsets = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS);
|
||||
fShowOpcodes = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_CODE_BYTES);
|
||||
fShowSymbols = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SYMBOLS);
|
||||
fUpdateBeforeFocus = !prefs.getBoolean(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC);
|
||||
fPCHistorySizeMax = prefs.getInt(DisassemblyPreferenceConstants.PC_HISTORY_SIZE);
|
||||
|
@ -602,6 +622,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
hideAddressRuler();
|
||||
showAddressRuler();
|
||||
}
|
||||
} else if (property.equals(DisassemblyPreferenceConstants.OPCODE_RADIX)) {
|
||||
if (isOpcodeRulerVisible()) {
|
||||
hideOpcodeRuler();
|
||||
showOpcodeRuler();
|
||||
}
|
||||
} else if (property.equals(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX)) {
|
||||
if (fAddressRulerColumn != null) {
|
||||
hideAddressRuler();
|
||||
|
@ -624,13 +649,21 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
fActionToggleSymbols.update();
|
||||
refreshView(10);
|
||||
} else if (property.equals(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS)) {
|
||||
fShowOpcodes = store.getBoolean(property);
|
||||
fShowFunctionOffsets = store.getBoolean(property);
|
||||
fActionToggleFunctionColumn.update();
|
||||
if (isFunctionOffsetsRulerVisible()) {
|
||||
showFunctionOffsetsRuler();
|
||||
} else {
|
||||
hideFunctionOffsetsRuler();
|
||||
}
|
||||
} else if (property.equals(DisassemblyPreferenceConstants.SHOW_CODE_BYTES)) {
|
||||
fShowOpcodes = store.getBoolean(property);
|
||||
fActionToggleOpcodeColumn.update();
|
||||
if (isOpcodeRulerVisible()) {
|
||||
showOpcodeRuler();
|
||||
} else {
|
||||
hideOpcodeRuler();
|
||||
}
|
||||
} else if (property.equals(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC)) {
|
||||
fUpdateBeforeFocus = !store.getBoolean(property);
|
||||
updateVisibleArea();
|
||||
|
@ -699,6 +732,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
if (isFunctionOffsetsRulerVisible()) {
|
||||
showFunctionOffsetsRuler();
|
||||
}
|
||||
if (isOpcodeRulerVisible()) {
|
||||
showOpcodeRuler();
|
||||
}
|
||||
|
||||
initDragAndDrop();
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(fViewer.getControl(), IDisassemblyHelpContextIds.DISASSEMBLY_VIEW);
|
||||
updateTitle();
|
||||
|
@ -1025,8 +1062,21 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
* @return the created line number column
|
||||
*/
|
||||
protected IVerticalRulerColumn createFunctionOffsetsRulerColumn() {
|
||||
fOpcodeRulerColumn= new FunctionOffsetRulerColumn();
|
||||
initializeRulerColumn(fOpcodeRulerColumn, DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR);
|
||||
fFunctionOffsetRulerColumn= new FunctionOffsetRulerColumn();
|
||||
|
||||
initializeRulerColumn(fFunctionOffsetRulerColumn, DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR);
|
||||
|
||||
return fFunctionOffsetRulerColumn;
|
||||
}
|
||||
|
||||
protected IVerticalRulerColumn createOpcodeRulerColumn() {
|
||||
fOpcodeRulerColumn= new OpcodeRulerColumn();
|
||||
|
||||
initializeRulerColumn(fOpcodeRulerColumn, DisassemblyPreferenceConstants.CODE_BYTES_COLOR);
|
||||
|
||||
IPreferenceStore prefs = getPreferenceStore();
|
||||
fOpcodeRulerColumn.setRadix(prefs.getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
|
||||
|
||||
return fOpcodeRulerColumn;
|
||||
}
|
||||
|
||||
|
@ -1110,18 +1160,49 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
|
||||
private boolean isFunctionOffsetsRulerVisible() {
|
||||
return fShowFunctionOffsets;
|
||||
}
|
||||
|
||||
private boolean isOpcodeRulerVisible() {
|
||||
return fShowOpcodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the function offset ruler column.
|
||||
*/
|
||||
private void showFunctionOffsetsRuler() {
|
||||
if (fFunctionOffsetRulerColumn == null) {
|
||||
IVerticalRuler v= getVerticalRuler();
|
||||
if (v instanceof CompositeRuler) {
|
||||
CompositeRuler c= (CompositeRuler) v;
|
||||
c.addDecorator(3, createFunctionOffsetsRulerColumn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides the function offset ruler column.
|
||||
*/
|
||||
private void hideFunctionOffsetsRuler() {
|
||||
if (fFunctionOffsetRulerColumn != null) {
|
||||
IVerticalRuler v= getVerticalRuler();
|
||||
if (v instanceof CompositeRuler) {
|
||||
CompositeRuler c= (CompositeRuler) v;
|
||||
c.removeDecorator(fFunctionOffsetRulerColumn);
|
||||
}
|
||||
fFunctionOffsetRulerColumn = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the opcode ruler column.
|
||||
*/
|
||||
private void showFunctionOffsetsRuler() {
|
||||
private void showOpcodeRuler() {
|
||||
if (fOpcodeRulerColumn == null) {
|
||||
IVerticalRuler v= getVerticalRuler();
|
||||
if (v instanceof CompositeRuler) {
|
||||
CompositeRuler c= (CompositeRuler) v;
|
||||
c.addDecorator(2, createFunctionOffsetsRulerColumn());
|
||||
c.addDecorator(2, createOpcodeRulerColumn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1129,7 +1210,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
/**
|
||||
* Hides the opcode ruler column.
|
||||
*/
|
||||
private void hideFunctionOffsetsRuler() {
|
||||
private void hideOpcodeRuler() {
|
||||
if (fOpcodeRulerColumn != null) {
|
||||
IVerticalRuler v= getVerticalRuler();
|
||||
if (v instanceof CompositeRuler) {
|
||||
|
@ -1235,6 +1316,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
protected void fillRulerContextMenu(IMenuManager manager) {
|
||||
fActionToggleBreakpointEnablement.update();
|
||||
fActionToggleAddressColumn.update();
|
||||
fActionToggleOpcodeColumn.update();
|
||||
fActionToggleFunctionColumn.update();
|
||||
|
||||
manager.add(new GroupMarker("group.top")); // ICommonMenuConstants.GROUP_TOP //$NON-NLS-1$
|
||||
|
@ -1246,6 +1328,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
manager.add(new Separator("add")); //$NON-NLS-1$
|
||||
manager.add(new Separator(ITextEditorActionConstants.GROUP_RULERS));
|
||||
manager.add(fActionToggleAddressColumn);
|
||||
manager.add(fActionToggleOpcodeColumn);
|
||||
manager.add(fActionToggleFunctionColumn);
|
||||
manager.add(new Separator(ITextEditorActionConstants.GROUP_REST));
|
||||
|
||||
|
@ -1347,6 +1430,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
});
|
||||
fActionToggleBreakpointEnablement = new ActionToggleBreakpointEnablement();
|
||||
fActionToggleAddressColumn = new ActionToggleAddressColumn();
|
||||
fActionToggleOpcodeColumn = new ActionToggleOpcodeColumn();
|
||||
fActionToggleFunctionColumn = new ActionToggleFunctionColumn();
|
||||
fActionToggleSymbols = new ActionToggleSymbols();
|
||||
fActionRefreshView = new ActionRefreshView();
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 Wind River Systems 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:
|
||||
* Wind River Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
|
||||
import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
|
||||
/**
|
||||
* A vertical ruler column to display the opcodes of instructions.
|
||||
*/
|
||||
public class OpcodeRulerColumn extends DisassemblyRulerColumn {
|
||||
|
||||
private int fRadix;
|
||||
private String fRadixPrefix;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public OpcodeRulerColumn() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setRadix(int radix) {
|
||||
fRadix= radix;
|
||||
setShowRadixPrefix();
|
||||
}
|
||||
|
||||
public void setShowRadixPrefix() {
|
||||
if (fRadix == 16) {
|
||||
fRadixPrefix = "0x"; //$NON-NLS-1$
|
||||
} else if (fRadix == 8) {
|
||||
fRadixPrefix = "0"; //$NON-NLS-1$
|
||||
} else {
|
||||
fRadixPrefix = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
|
||||
*/
|
||||
@Override
|
||||
protected String createDisplayString(int line) {
|
||||
int nChars = computeNumberOfCharacters();
|
||||
if (nChars > 0) {
|
||||
DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
|
||||
try {
|
||||
int offset = doc.getLineOffset(line);
|
||||
AddressRangePosition pos = doc.getDisassemblyPosition(offset);
|
||||
if (pos instanceof DisassemblyPosition && pos.length > 0 && pos.offset == offset && pos.fValid) {
|
||||
DisassemblyPosition disassPos = (DisassemblyPosition)pos;
|
||||
if (disassPos.fOpcodes != null) {
|
||||
// Format the output.
|
||||
String str = disassPos.fOpcodes.toString(fRadix);
|
||||
int prefixLength = 0;
|
||||
|
||||
if (fRadixPrefix != null)
|
||||
prefixLength = fRadixPrefix.length();
|
||||
|
||||
StringBuilder buf = new StringBuilder(nChars);
|
||||
|
||||
if (prefixLength != 0)
|
||||
buf.append(fRadixPrefix);
|
||||
|
||||
for (int i=str.length()+prefixLength; i < nChars; ++i)
|
||||
buf.append('0');
|
||||
buf.append(str);
|
||||
return buf.toString();
|
||||
}
|
||||
} else if (pos != null && !pos.fValid) {
|
||||
return DOTS.substring(0, nChars);
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
// silently ignored
|
||||
}
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int computeNumberOfCharacters() {
|
||||
DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
|
||||
return doc.getMaxOpcodeLength(fRadix);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -71,13 +71,14 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
private final Map<IStorage, SourceFileInfo> fFileInfoMap = new HashMap<IStorage, SourceFileInfo>();
|
||||
|
||||
private int fMaxFunctionLength = 0;
|
||||
private BigInteger fMaxOpcodeLength = null;
|
||||
|
||||
private boolean fShowAddresses = false;
|
||||
private int fRadix = 16;
|
||||
private boolean fShowRadixPrefix = false;
|
||||
private String fRadixPrefix;
|
||||
private int fNumberOfDigits;
|
||||
private boolean fShowCodeBytes = false;
|
||||
private boolean fShowFunctionOffset = false;
|
||||
|
||||
private int fNumberOfInstructions;
|
||||
private double fMeanSizeOfInstructions = 4;
|
||||
|
@ -140,7 +141,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
return fInvalidAddressRanges.toArray(new AddressRangePosition[fInvalidAddressRanges.size()]);
|
||||
}
|
||||
|
||||
public void setMaxOpcodeLength(int opcodeLength) {
|
||||
public void setMaxFunctionLength(int opcodeLength) {
|
||||
fMaxFunctionLength = opcodeLength;
|
||||
}
|
||||
|
||||
|
@ -148,6 +149,29 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
return fMaxFunctionLength;
|
||||
}
|
||||
|
||||
public void setMaxOpcodeLength(BigInteger longOpcode ) {
|
||||
fMaxOpcodeLength = longOpcode;
|
||||
}
|
||||
|
||||
public int getMaxOpcodeLength(int radix ) {
|
||||
int retVal = 0;
|
||||
if (fMaxOpcodeLength != null) {
|
||||
String str = fMaxOpcodeLength.toString(radix);
|
||||
retVal = str.length();
|
||||
switch (radix) {
|
||||
case 8:
|
||||
retVal += 1; // Padded for 0 prefix
|
||||
break;
|
||||
case 16:
|
||||
retVal += 2; // Padded for 0x prefix
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public int getAddressLength() {
|
||||
return fNumberOfDigits+2;
|
||||
}
|
||||
|
@ -694,10 +718,16 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
// cannot happen
|
||||
}
|
||||
if (pos instanceof DisassemblyPosition) {
|
||||
int functionLength = ((DisassemblyPosition)pos).fFunction.length;
|
||||
DisassemblyPosition disassPos = (DisassemblyPosition)pos;
|
||||
int functionLength = disassPos.fFunction.length;
|
||||
if (functionLength > fMaxFunctionLength) {
|
||||
fMaxFunctionLength = functionLength;
|
||||
}
|
||||
if (disassPos.fOpcodes != null) {
|
||||
if (fMaxOpcodeLength == null || fMaxOpcodeLength.compareTo(disassPos.fOpcodes) == -1) {
|
||||
fMaxOpcodeLength = disassPos.fOpcodes;
|
||||
}
|
||||
}
|
||||
if (fNumberOfInstructions < 100 && fMeanSizeOfInstructions < 16.0) {
|
||||
fMeanSizeOfInstructions = (fMeanSizeOfInstructions * fNumberOfInstructions + pos.fAddressLength.floatValue()) / (++fNumberOfInstructions);
|
||||
}
|
||||
|
@ -989,21 +1019,29 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int)
|
||||
*/
|
||||
public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String opcode, String instruction, String file, int lineNr)
|
||||
public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, String instruction, String file, int lineNr)
|
||||
throws BadLocationException {
|
||||
return insertDisassemblyLine(pos, address, length, functionOffset, null, instruction, file, lineNr);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int)
|
||||
*/
|
||||
public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, BigInteger opcode, String instruction, String file, int lineNr)
|
||||
throws BadLocationException {
|
||||
assert isGuiThread();
|
||||
String disassLine = null;
|
||||
if (instruction == null || instruction.length() == 0) {
|
||||
disassLine = ""; //$NON-NLS-1$
|
||||
} else {
|
||||
disassLine = buildDisassemblyLine(address, opcode, instruction);
|
||||
disassLine = buildDisassemblyLine(address, functionOffset, instruction);
|
||||
}
|
||||
AddressRangePosition disassPos;
|
||||
if (lineNr < 0) {
|
||||
disassPos = new DisassemblyPosition(0, disassLine.length(), address, BigInteger.valueOf(length), opcode);
|
||||
disassPos = new DisassemblyPosition(0, disassLine.length(), address, BigInteger.valueOf(length), functionOffset, opcode);
|
||||
} else {
|
||||
disassPos = new DisassemblyWithSourcePosition(0, disassLine.length(), address, BigInteger.valueOf(length),
|
||||
opcode, file, lineNr);
|
||||
functionOffset, opcode, file, lineNr);
|
||||
}
|
||||
pos = insertAddressRange(pos, disassPos, disassLine, true);
|
||||
addDisassemblyPosition(disassPos);
|
||||
|
@ -1011,10 +1049,10 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
}
|
||||
/**
|
||||
* @param address
|
||||
* @param opcode
|
||||
* @param functionOffset
|
||||
* @param instruction
|
||||
*/
|
||||
private String buildDisassemblyLine(BigInteger address, String opcode, String instruction) {
|
||||
private String buildDisassemblyLine(BigInteger address, String functionOffset, String instruction) {
|
||||
StringBuffer buf = new StringBuffer(40);
|
||||
if (fShowAddresses) {
|
||||
if (fRadixPrefix != null) {
|
||||
|
@ -1027,13 +1065,13 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
buf.append(':');
|
||||
buf.append(' ');
|
||||
}
|
||||
if (fShowCodeBytes && opcode != null && opcode.length() > 0) {
|
||||
buf.append(opcode);
|
||||
if (fShowFunctionOffset && functionOffset != null && functionOffset.length() > 0) {
|
||||
buf.append(functionOffset);
|
||||
int tab = 16;
|
||||
if (opcode.length() >= 16) {
|
||||
tab = (opcode.length() + 8) & ~7;
|
||||
if (functionOffset.length() >= 16) {
|
||||
tab = (functionOffset.length() + 8) & ~7;
|
||||
}
|
||||
int diff = tab - opcode.length();
|
||||
int diff = tab - functionOffset.length();
|
||||
while (diff-- > 0) {
|
||||
buf.append(' ');
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -27,10 +27,11 @@ public class DisassemblyWithSourcePosition extends DisassemblyPosition {
|
|||
* @param length
|
||||
* @param addressOffset
|
||||
* @param addressLength
|
||||
* @param opcodes
|
||||
* @param functionOffset
|
||||
* @param opcode
|
||||
*/
|
||||
public DisassemblyWithSourcePosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, String opcodes, String file, int lineNr) {
|
||||
super(offset, length, addressOffset, addressLength, opcodes);
|
||||
public DisassemblyWithSourcePosition(int offset, int length, BigInteger addressOffset, BigInteger addressLength, String functionOffset, BigInteger opcode, String file, int lineNr) {
|
||||
super(offset, length, addressOffset, addressLength, functionOffset, opcode);
|
||||
fFile = file;
|
||||
fLine = lineNr;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,14 @@ public class DisassemblyPreferenceConstants {
|
|||
public static final String SHOW_SOURCE = "disassembly.showSource"; //$NON-NLS-1$
|
||||
public static final String SHOW_SYMBOLS = "disassembly.showSymbols"; //$NON-NLS-1$
|
||||
public static final String ADDRESS_RADIX = "disassembly.addressRadix"; //$NON-NLS-1$
|
||||
public static final String OPCODE_RADIX = "disassembly.opcodeRadix"; //$NON-NLS-1$
|
||||
public static final String SHOW_ADDRESS_RADIX = "disassembly.showAddressRadix"; //$NON-NLS-1$
|
||||
public static final String SHOW_ADDRESS_RULER = "disassembly.showAddressRuler"; //$NON-NLS-1$
|
||||
public static final String ADDRESS_COLOR = "disassembly.addressColor"; //$NON-NLS-1$
|
||||
public static final String SHOW_FUNCTION_OFFSETS = "disassembly.showFunctionOffsetRuler"; //$NON-NLS-1$
|
||||
public static final String FUNCTION_OFFSETS_COLOR = "disassembly.functionOffsetsColor"; //$NON-NLS-1$
|
||||
public static final String SHOW_CODE_BYTES = "disassembly.showCodeBytesRuler"; //$NON-NLS-1$
|
||||
public static final String CODE_BYTES_COLOR = "disassembly.codeBytesColor"; //$NON-NLS-1$
|
||||
public static final String AVOID_READ_BEFORE_PC = "disassembly.avoidReadBeforePC"; //$NON-NLS-1$
|
||||
public static final String TRACK_EXPRESSION = "disassembly.trackExpression"; //$NON-NLS-1$
|
||||
public static final String SYNC_ACTIVE_CONTEXT = "disassembly.syncActiveContext"; //$NON-NLS-1$
|
||||
|
@ -56,13 +59,16 @@ public class DisassemblyPreferenceConstants {
|
|||
store.setDefault(PC_HISTORY_SIZE, 4);
|
||||
store.setDefault(SHOW_SOURCE, true);
|
||||
store.setDefault(SHOW_FUNCTION_OFFSETS, false);
|
||||
store.setDefault(SHOW_CODE_BYTES, false);
|
||||
store.setDefault(SHOW_SYMBOLS, true);
|
||||
store.setDefault(ADDRESS_RADIX, 16);
|
||||
store.setDefault(OPCODE_RADIX, 16);
|
||||
store.setDefault(SHOW_ADDRESS_RADIX, false);
|
||||
store.setDefault(SHOW_ADDRESS_RULER, true);
|
||||
store.setDefault(AVOID_READ_BEFORE_PC, false);
|
||||
PreferenceConverter.setDefault(store, ADDRESS_COLOR, new RGB(0, 96, 0));
|
||||
PreferenceConverter.setDefault(store, FUNCTION_OFFSETS_COLOR, new RGB(96, 0, 0));
|
||||
PreferenceConverter.setDefault(store, CODE_BYTES_COLOR, new RGB(96, 0, 0));
|
||||
}
|
||||
|
||||
public static class Initializer extends AbstractPreferenceInitializer {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010 Wind River Systems and others.
|
||||
* Copyright (c) 2007, 2011 Wind River Systems 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
|
||||
|
@ -51,6 +51,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
|
|||
}
|
||||
};
|
||||
private Combo fAddressFormatCombo;
|
||||
private Combo fOpcodeFormatCombo;
|
||||
private final static String[] fcRadixItems = {
|
||||
DisassemblyMessages.DisassemblyPreferencePage_radix_octal,
|
||||
DisassemblyMessages.DisassemblyPreferencePage_radix_decimal,
|
||||
|
@ -100,16 +101,28 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
|
|||
label = DisassemblyMessages.DisassemblyPreferencePage_showAddress;
|
||||
final Button showAddressCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER, 0);
|
||||
showAddressCB.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fAddressFormatCombo.setEnabled(showAddressCB.getSelection());
|
||||
}
|
||||
});
|
||||
});
|
||||
showAddressCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showAddressTooltip);
|
||||
label = DisassemblyMessages.DisassemblyPreferencePage_addressRadix;
|
||||
fAddressFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.ADDRESS_RADIX, fcRadixItems);
|
||||
fAddressFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_addressFormatTooltip);
|
||||
|
||||
label = DisassemblyMessages.DisassemblyPreferencePage_showCodeBytes;
|
||||
final Button showCodeBytes= addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_CODE_BYTES, 0);
|
||||
showCodeBytes.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
fOpcodeFormatCombo.setEnabled(showCodeBytes.getSelection());
|
||||
}
|
||||
});
|
||||
showCodeBytes.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showCodeBytesTooltip);
|
||||
label = DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormat;
|
||||
fOpcodeFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.OPCODE_RADIX, fcRadixItems);
|
||||
fOpcodeFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormatTooltip);
|
||||
// label = DisassemblyMessages.DisassemblyPreferencePage_instructionRadix;
|
||||
// addComboBox(composite, label, DisassemblyPreferenceConstants.INSTRUCTION_RADIX, fcRadixItems);
|
||||
|
||||
|
@ -185,13 +198,10 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe
|
|||
|
||||
private Combo addComboBox(Composite parent, String label, String key, String[] items) {
|
||||
Label labelControl= new Label(parent, SWT.NONE);
|
||||
labelControl.setText(""); //$NON-NLS-1$
|
||||
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||
labelControl.setLayoutData(gd);
|
||||
|
||||
labelControl= new Label(parent, SWT.NONE);
|
||||
labelControl.setText(label);
|
||||
gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||
gd.horizontalIndent = 16;
|
||||
gd.horizontalSpan = 2;
|
||||
labelControl.setLayoutData(gd);
|
||||
|
||||
Combo combo = new Combo(parent, SWT.READ_ONLY);
|
||||
|
|
Loading…
Add table
Reference in a new issue