Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 325277 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/cdt/debug/edc/disassembler/EDCInstruction.java (-3 / +12 lines)
Lines 14-29 Link Here
14
import java.math.BigInteger;
14
import java.math.BigInteger;
15
import java.util.StringTokenizer;
15
import java.util.StringTokenizer;
16
16
17
import org.eclipse.cdt.dsf.debug.service.IInstruction;
17
import org.eclipse.cdt.dsf.debug.service.AbstractInstruction;
18
18
19
public class EDCInstruction implements IInstruction {
19
public class EDCInstruction extends AbstractInstruction {
20
20
21
	private final IDisassembledInstruction instruction;
21
	private final IDisassembledInstruction instruction;
22
22
23
	public EDCInstruction(IDisassembledInstruction instruction) {
23
	public EDCInstruction(IDisassembledInstruction instruction) {
24
		this.instruction = instruction;
24
		this.instruction = instruction;
25
	}
25
	}
26
26
	
27
	/*
27
	/*
28
	 * (non-Javadoc)
28
	 * (non-Javadoc)
29
	 * 
29
	 * 
Lines 96-101 Link Here
96
		return null;
96
		return null;
97
	}
97
	}
98
98
99
	/**
100
	 * @since 2.0
101
	 */
102
	@Override
103
    public Integer getSize() {
104
		return instruction.getSize();
105
	}
106
107
	
99
	@Override
108
	@Override
100
	public String toString() {
109
	public String toString() {
101
		return instruction.toString();
110
		return instruction.toString();
(-)src/org/eclipse/cdt/dsf/debug/service/AbstractInstruction.java (+27 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Wind River Systems - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.dsf.debug.service;
12
13
/**
14
 * Implementers of {@link IInstruction} should extend this abstract class
15
 * instead of implementing the interface directly.
16
 *
17
 * @since 2.2
18
 */
19
public abstract class AbstractInstruction implements IInstructionWithSize {
20
    /*
21
     * @see org.eclipse.cdt.dsf.debug.service.IInstructionWithSize#getSize()
22
     */
23
    public Integer getSize() {
24
        // unkown size
25
        return null;
26
    }
27
}
(-)src/org/eclipse/cdt/dsf/debug/service/IInstruction.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 Ericsson and others.
2
 * Copyright (c) 2008, 2010 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-22 Link Here
14
import java.math.BigInteger;
14
import java.math.BigInteger;
15
15
16
/**
16
/**
17
 * Represents an assembly instruction
17
 * Represents an assembly instruction.
18
 * <p>
19
 * Implementers should extend {@link AbstractInstruction} instead of
20
 * implementing this interface directly.
21
 * </p>
18
 * 
22
 * 
19
 * @since 1.0
23
 * @since 1.0
24
 * @see IInstructionWithSize
20
 */
25
 */
21
public interface IInstruction {
26
public interface IInstruction {
22
27
(-)src/org/eclipse/cdt/dsf/debug/service/IInstructionWithSize.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Nokia, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Nokia
10
 *     Wind River Systems
11
 *******************************************************************************/
12
package org.eclipse.cdt.dsf.debug.service;
13
14
import org.eclipse.cdt.dsf.debug.service.IInstruction;
15
16
/**
17
 * Extension interface for instructions knowing their size.
18
 * <p>
19
 * Implementers must extend {@link AbstractInstruction} instead of
20
 * implementing this interface directly.
21
 * </p>
22
 * @since 2.2
23
 * @noimplement This interface is not intended to be implemented by clients.
24
 * @noextend This interface is not intended to be extended by clients.
25
 */
26
public interface IInstructionWithSize extends IInstruction {
27
28
    /**
29
     * @return size of the instruction in bytes or <code>null</code> if unknown
30
     */
31
    Integer getSize();
32
33
}
(-)src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 QNX Software Systems and others.
2
 * Copyright (c) 2000, 2010 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-22 Link Here
14
14
15
import java.math.BigInteger;
15
import java.math.BigInteger;
16
16
17
import org.eclipse.cdt.dsf.debug.service.IInstruction;
17
import org.eclipse.cdt.dsf.debug.service.AbstractInstruction;
18
18
19
public class MIInstruction implements IInstruction {
19
public class MIInstruction extends AbstractInstruction {
20
20
21
    // The parsed information
21
    // The parsed information
22
    BigInteger address;
22
    BigInteger address;
(-)src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java (-21 / +31 lines)
Lines 40-45 Link Here
40
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
40
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
41
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
41
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
42
import org.eclipse.cdt.dsf.debug.service.IInstruction;
42
import org.eclipse.cdt.dsf.debug.service.IInstruction;
43
import org.eclipse.cdt.dsf.debug.service.IInstructionWithSize;
43
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
44
import org.eclipse.cdt.dsf.debug.service.IMixedInstruction;
44
import org.eclipse.cdt.dsf.debug.service.IRunControl;
45
import org.eclipse.cdt.dsf.debug.service.IRunControl;
45
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
46
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
Lines 613-624 Link Here
613
				}
614
				}
614
				// determine instruction byte length
615
				// determine instruction byte length
615
				BigInteger instrLength= null;
616
				BigInteger instrLength= null;
616
				if (j < instructions.length - 1) {
617
				if (instruction instanceof IInstructionWithSize
617
					instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
618
				        && ((IInstructionWithSize)instruction).getSize() != null) {
618
				}
619
					instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
619
				if (instrLength == null) {
620
				} else {
620
					// cannot determine length of last instruction
621
					if (j < instructions.length - 1) {
621
					break;
622
						instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
623
					}
624
					if (instrLength == null) {
625
						// cannot determine length of last instruction
626
						break;
627
					}
622
				}
628
				}
623
				final String opCode;
629
				final String opCode;
624
				// insert function name+offset instead of opcode bytes
630
				// insert function name+offset instead of opcode bytes
Lines 667-673 Link Here
667
	 * @param showDisassembly
673
	 * @param showDisassembly
668
	 * @return whether [startAddress] was inserted
674
	 * @return whether [startAddress] was inserted
669
	 */
675
	 */
670
671
	private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) {
676
	private boolean insertDisassembly(BigInteger startAddress, BigInteger endAddress, IMixedInstruction[] mixedInstructions, boolean showSymbols, boolean showDisassembly) {
672
		if (!fCallback.hasViewer() || fDsfSessionId == null) {
677
		if (!fCallback.hasViewer() || fDsfSessionId == null) {
673
			// return true to avoid a retry
678
			// return true to avoid a retry
Lines 730-755 Link Here
730
					}
735
					}
731
					// determine instruction byte length
736
					// determine instruction byte length
732
					BigInteger instrLength= null;
737
					BigInteger instrLength= null;
733
					if (j < instructions.length - 1) {
738
					if (instruction instanceof IInstructionWithSize
734
						instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
739
					        && ((IInstructionWithSize)instruction).getSize() != null) {
735
					} else if (i < mixedInstructions.length - 1) {
740
						instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
736
						int nextSrcLineIdx= i+1;
741
					} else {
737
						while (nextSrcLineIdx < mixedInstructions.length) {
742
						if (j < instructions.length - 1) {
738
							IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
743
							instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
739
							if (nextInstrs.length > 0) {
744
						} else if (i < mixedInstructions.length - 1) {
740
								instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
745
							int nextSrcLineIdx= i+1;
746
							while (nextSrcLineIdx < mixedInstructions.length) {
747
								IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
748
								if (nextInstrs.length > 0) {
749
									instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
750
									break;
751
								}
752
								++nextSrcLineIdx;
753
							}
754
							if (nextSrcLineIdx >= mixedInstructions.length) {
741
								break;
755
								break;
742
							}
756
							}
743
							++nextSrcLineIdx;
744
						}
757
						}
745
						if (nextSrcLineIdx >= mixedInstructions.length) {
758
						if (instrLength == null) {
759
							// cannot determine length of last instruction
746
							break;
760
							break;
747
						}
761
						}
748
					}
762
					}
749
					if (instrLength == null) {
750
						// cannot determine length of last instruction
751
						break;
752
					}
753
					final String opCode;
763
					final String opCode;
754
					// insert function name+offset instead of opcode bytes
764
					// insert function name+offset instead of opcode bytes
755
					if (functionName != null && functionName.length() > 0) {
765
					if (functionName != null && functionName.length() > 0) {
(-)src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java (-1 / +1 lines)
Lines 697-703 Link Here
697
			if (functionLength > fMaxFunctionLength) {
697
			if (functionLength > fMaxFunctionLength) {
698
				fMaxFunctionLength = functionLength;
698
				fMaxFunctionLength = functionLength;
699
			}
699
			}
700
			if (fNumberOfInstructions < 100) {
700
			if (fNumberOfInstructions < 100 && fMeanSizeOfInstructions < 16.0) {
701
				fMeanSizeOfInstructions = (fMeanSizeOfInstructions * fNumberOfInstructions + pos.fAddressLength.floatValue()) / (++fNumberOfInstructions);
701
				fMeanSizeOfInstructions = (fMeanSizeOfInstructions * fNumberOfInstructions + pos.fAddressLength.floatValue()) / (++fNumberOfInstructions);
702
			}
702
			}
703
		}
703
		}

Return to bug 325277