mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-09 19:43:27 +02:00
Bug 325277 - [disassembly] add IInstruction#getSize() to fill single-instruction gaps, allow large pseudo-mnemonics
This commit is contained in:
parent
9883f18413
commit
ef4a1226fe
6 changed files with 102 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,9 +14,9 @@ package org.eclipse.cdt.dsf.mi.service.command.output;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
import org.eclipse.cdt.dsf.debug.service.AbstractInstruction;
|
||||||
|
|
||||||
public class MIInstruction implements IInstruction {
|
public class MIInstruction extends AbstractInstruction {
|
||||||
|
|
||||||
// The parsed information
|
// The parsed information
|
||||||
BigInteger address;
|
BigInteger address;
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IInstructionWithSize;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
|
@ -613,12 +614,17 @@ public class DisassemblyBackendDsf implements IDisassemblyBackend, SessionEndedL
|
||||||
}
|
}
|
||||||
// determine instruction byte length
|
// determine instruction byte length
|
||||||
BigInteger instrLength= null;
|
BigInteger instrLength= null;
|
||||||
if (j < instructions.length - 1) {
|
if (instruction instanceof IInstructionWithSize
|
||||||
instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
|
&& ((IInstructionWithSize)instruction).getSize() != null) {
|
||||||
}
|
instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
|
||||||
if (instrLength == null) {
|
} else {
|
||||||
// cannot determine length of last instruction
|
if (j < instructions.length - 1) {
|
||||||
break;
|
instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
|
||||||
|
}
|
||||||
|
if (instrLength == null) {
|
||||||
|
// cannot determine length of last instruction
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
final String opCode;
|
final String opCode;
|
||||||
// insert function name+offset instead of opcode bytes
|
// insert function name+offset instead of opcode bytes
|
||||||
|
@ -667,7 +673,6 @@ public class DisassemblyBackendDsf implements IDisassemblyBackend, SessionEndedL
|
||||||
* @param showDisassembly
|
* @param showDisassembly
|
||||||
* @return whether [startAddress] was inserted
|
* @return whether [startAddress] was inserted
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) {
|
private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) {
|
||||||
if (!fCallback.hasViewer() || fDsfSessionId == null) {
|
if (!fCallback.hasViewer() || fDsfSessionId == null) {
|
||||||
// return true to avoid a retry
|
// return true to avoid a retry
|
||||||
|
@ -730,26 +735,31 @@ public class DisassemblyBackendDsf implements IDisassemblyBackend, SessionEndedL
|
||||||
}
|
}
|
||||||
// determine instruction byte length
|
// determine instruction byte length
|
||||||
BigInteger instrLength= null;
|
BigInteger instrLength= null;
|
||||||
if (j < instructions.length - 1) {
|
if (instruction instanceof IInstructionWithSize
|
||||||
instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
|
&& ((IInstructionWithSize)instruction).getSize() != null) {
|
||||||
} else if (i < mixedInstructions.length - 1) {
|
instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
|
||||||
int nextSrcLineIdx= i+1;
|
} else {
|
||||||
while (nextSrcLineIdx < mixedInstructions.length) {
|
if (j < instructions.length - 1) {
|
||||||
IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
|
instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
|
||||||
if (nextInstrs.length > 0) {
|
} else if (i < mixedInstructions.length - 1) {
|
||||||
instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
|
int nextSrcLineIdx= i+1;
|
||||||
|
while (nextSrcLineIdx < mixedInstructions.length) {
|
||||||
|
IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
|
||||||
|
if (nextInstrs.length > 0) {
|
||||||
|
instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++nextSrcLineIdx;
|
||||||
|
}
|
||||||
|
if (nextSrcLineIdx >= mixedInstructions.length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++nextSrcLineIdx;
|
|
||||||
}
|
}
|
||||||
if (nextSrcLineIdx >= mixedInstructions.length) {
|
if (instrLength == null) {
|
||||||
|
// cannot determine length of last instruction
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (instrLength == null) {
|
|
||||||
// cannot determine length of last instruction
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final String opCode;
|
final String opCode;
|
||||||
// insert function name+offset instead of opcode bytes
|
// insert function name+offset instead of opcode bytes
|
||||||
if (functionName != null && functionName.length() > 0) {
|
if (functionName != null && functionName.length() > 0) {
|
||||||
|
|
|
@ -697,7 +697,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
||||||
if (functionLength > fMaxFunctionLength) {
|
if (functionLength > fMaxFunctionLength) {
|
||||||
fMaxFunctionLength = functionLength;
|
fMaxFunctionLength = functionLength;
|
||||||
}
|
}
|
||||||
if (fNumberOfInstructions < 100) {
|
if (fNumberOfInstructions < 100 && fMeanSizeOfInstructions < 16.0) {
|
||||||
fMeanSizeOfInstructions = (fMeanSizeOfInstructions * fNumberOfInstructions + pos.fAddressLength.floatValue()) / (++fNumberOfInstructions);
|
fMeanSizeOfInstructions = (fMeanSizeOfInstructions * fNumberOfInstructions + pos.fAddressLength.floatValue()) / (++fNumberOfInstructions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Wind River Systems - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementers of {@link IInstruction} should extend this abstract class
|
||||||
|
* instead of implementing the interface directly.
|
||||||
|
*
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
public abstract class AbstractInstruction implements IInstructionWithSize {
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.cdt.dsf.debug.service.IInstructionWithSize#getSize()
|
||||||
|
*/
|
||||||
|
public Integer getSize() {
|
||||||
|
// unkown size
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2009 Ericsson and others.
|
* Copyright (c) 2008, 2010 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,9 +14,14 @@ package org.eclipse.cdt.dsf.debug.service;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an assembly instruction
|
* Represents an assembly instruction.
|
||||||
|
* <p>
|
||||||
|
* Implementers should extend {@link AbstractInstruction} instead of
|
||||||
|
* implementing this interface directly.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
|
* @see IInstructionWithSize
|
||||||
*/
|
*/
|
||||||
public interface IInstruction {
|
public interface IInstruction {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 Nokia, 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
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Nokia
|
||||||
|
* Wind River Systems
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.debug.service;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IInstruction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface for instructions knowing their size.
|
||||||
|
* <p>
|
||||||
|
* Implementers must extend {@link AbstractInstruction} instead of
|
||||||
|
* implementing this interface directly.
|
||||||
|
* </p>
|
||||||
|
* @since 2.2
|
||||||
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
|
*/
|
||||||
|
public interface IInstructionWithSize extends IInstruction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return size of the instruction in bytes or <code>null</code> if unknown
|
||||||
|
*/
|
||||||
|
Integer getSize();
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue