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 (-1 / +12 lines)
Lines 14-22 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.internal.provisional.service.IInstructionWithSize;
17
import org.eclipse.cdt.dsf.debug.service.IInstruction;
18
import org.eclipse.cdt.dsf.debug.service.IInstruction;
18
19
19
public class EDCInstruction implements IInstruction {
20
public class EDCInstruction implements IInstruction, IInstructionWithSize {
20
21
21
	private final IDisassembledInstruction instruction;
22
	private final IDisassembledInstruction instruction;
22
23
Lines 96-101 Link Here
96
		return null;
97
		return null;
97
	}
98
	}
98
99
100
	/*
101
	 * (non-Javadoc)
102
	 * 
103
	 * @see org.eclipse.cdt.dsf.debug.internal.provisional.service.IInstructionWithSize#getSize()
104
	 */
105
	public Integer getSize() {
106
		return (Integer)instruction.getSize();
107
	}
108
109
	
99
	@Override
110
	@Override
100
	public String toString() {
111
	public String toString() {
101
		return instruction.toString();
112
		return instruction.toString();
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 3-9 Link Here
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-Vendor: %providerName
4
Bundle-Vendor: %providerName
5
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
5
Bundle-SymbolicName: org.eclipse.cdt.dsf;singleton:=true
6
Bundle-Version: 2.1.0.qualifier
6
Bundle-Version: 2.2.0.qualifier
7
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
7
Bundle-Activator: org.eclipse.cdt.dsf.internal.DsfPlugin
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime,
9
Require-Bundle: org.eclipse.core.runtime,
Lines 14-19 Link Here
14
Export-Package: org.eclipse.cdt.dsf.concurrent,
14
Export-Package: org.eclipse.cdt.dsf.concurrent,
15
 org.eclipse.cdt.dsf.datamodel,
15
 org.eclipse.cdt.dsf.datamodel,
16
 org.eclipse.cdt.dsf.debug.internal.provisional.model;x-friends:="org.eclipse.cdt.dsf.ui",
16
 org.eclipse.cdt.dsf.debug.internal.provisional.model;x-friends:="org.eclipse.cdt.dsf.ui",
17
 org.eclipse.cdt.dsf.debug.internal.provisional.service,
17
 org.eclipse.cdt.dsf.debug.model,
18
 org.eclipse.cdt.dsf.debug.model,
18
 org.eclipse.cdt.dsf.debug.service,
19
 org.eclipse.cdt.dsf.debug.service,
19
 org.eclipse.cdt.dsf.debug.service.command,
20
 org.eclipse.cdt.dsf.debug.service.command,
(-)src/org/eclipse/cdt/dsf/debug/internal/provisional/service/IInstructionWithSize.java (+30 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.internal.provisional.service;
13
14
import org.eclipse.cdt.dsf.debug.service.IInstruction;
15
16
/**
17
 * a provisional API to provide access to size for use in CDT 7.0.x releases
18
 * to be replaced in CDT 8.x by moving getSize() to IInstruction
19
 * @author kirk.beitz@nokia.com
20
 * @since 2.2
21
 */
22
public interface IInstructionWithSize extends IInstruction {
23
24
    /**
25
    * @return size of the instruction
26
    * @since 2.2
27
    */
28
    Integer getSize();
29
30
}
(-)src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyBackendDsf.java (-35 / +47 lines)
Lines 31-36 Link Here
31
import org.eclipse.cdt.dsf.concurrent.Query;
31
import org.eclipse.cdt.dsf.concurrent.Query;
32
import org.eclipse.cdt.dsf.datamodel.DMContexts;
32
import org.eclipse.cdt.dsf.datamodel.DMContexts;
33
import org.eclipse.cdt.dsf.datamodel.IDMContext;
33
import org.eclipse.cdt.dsf.datamodel.IDMContext;
34
import org.eclipse.cdt.dsf.debug.internal.provisional.service.IInstructionWithSize;
34
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
35
import org.eclipse.cdt.dsf.debug.service.IDisassembly;
35
import org.eclipse.cdt.dsf.debug.service.IExpressions;
36
import org.eclipse.cdt.dsf.debug.service.IExpressions;
36
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
37
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
Lines 568-575 Link Here
568
			// return true to avoid a retry
569
			// return true to avoid a retry
569
			return true;
570
			return true;
570
		}
571
		}
571
		// indicates whether [startAddress] was inserted
572
572
		boolean insertedStartAddress = startAddress == null;
573
		boolean insertedAnyAddress = false;
573
574
574
		try {
575
		try {
575
			fCallback.lockScroller();
576
			fCallback.lockScroller();
Lines 590-596 Link Here
590
					fCallback.getDocument().addInvalidAddressRange(p);
591
					fCallback.getDocument().addInvalidAddressRange(p);
591
				} else if (p == null || address.compareTo(endAddress) > 0) {
592
				} else if (p == null || address.compareTo(endAddress) > 0) {
592
					if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
593
					if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
593
					return insertedStartAddress;
594
					return insertedAnyAddress;
594
				} else if (p.fValid) {
595
				} else if (p.fValid) {
595
					if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
596
					if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
596
					if (!p.fAddressOffset.equals(address)) {
597
					if (!p.fAddressOffset.equals(address)) {
Lines 598-604 Link Here
598
						p.fValid = false;
599
						p.fValid = false;
599
						fCallback.getDocument().addInvalidAddressRange(p);
600
						fCallback.getDocument().addInvalidAddressRange(p);
600
					} else {
601
					} else {
601
						return insertedStartAddress;
602
						continue;
602
					}
603
					}
603
				}
604
				}
604
				boolean hasSource= false;
605
				boolean hasSource= false;
Lines 610-621 Link Here
610
				}
611
				}
611
				// determine instruction byte length
612
				// determine instruction byte length
612
				BigInteger instrLength= null;
613
				BigInteger instrLength= null;
613
				if (j < instructions.length - 1) {
614
				if (instruction instanceof IInstructionWithSize
614
					instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
615
					&& ((IInstructionWithSize)instruction).getSize() != null) {
615
				}
616
					instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
616
				if (instrLength == null) {
617
				} else {
617
					// cannot determine length of last instruction
618
					if (j < instructions.length - 1) {
618
					break;
619
						instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
620
					}
621
					if (instrLength == null) {
622
						// cannot determine length of last instruction
623
						break;
624
					}
619
				}
625
				}
620
				final String opCode;
626
				final String opCode;
621
				// insert function name+offset instead of opcode bytes
627
				// insert function name+offset instead of opcode bytes
Lines 624-641 Link Here
624
				} else {
630
				} else {
625
					opCode= ""; //$NON-NLS-1$
631
					opCode= ""; //$NON-NLS-1$
626
				}
632
				}
627
				insertedStartAddress= insertedStartAddress || address.compareTo(startAddress) == 0;
633
628
				p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), compilationPath, -1);
634
				p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), compilationPath, -1);
629
				if (p == null && insertedStartAddress) {
635
				if (p == null) {
630
					break;
636
					break;
631
				}
637
				}
638
				insertedAnyAddress = true;
632
			}
639
			}
633
		} catch (BadLocationException e) {
640
		} catch (BadLocationException e) {
634
			// should not happen
641
			// should not happen
635
			DisassemblyUtils.internalError(e);
642
			DisassemblyUtils.internalError(e);
636
		} finally {
643
		} finally {
637
			fCallback.setUpdatePending(false);
644
			fCallback.setUpdatePending(false);
638
			if (insertedStartAddress) {
645
			if (insertedAnyAddress) {
639
				fCallback.updateInvalidSource();
646
				fCallback.updateInvalidSource();
640
				fCallback.unlockScroller();
647
				fCallback.unlockScroller();
641
				fCallback.doPending();
648
				fCallback.doPending();
Lines 644-650 Link Here
644
				fCallback.unlockScroller();
651
				fCallback.unlockScroller();
645
			}
652
			}
646
		}
653
		}
647
		return insertedStartAddress;
654
		return insertedAnyAddress;
648
	}
655
	}
649
656
650
	/**
657
	/**
Lines 676-683 Link Here
676
			// return true to avoid a retry
683
			// return true to avoid a retry
677
			return true;
684
			return true;
678
		}
685
		}
679
		// indicates whether [startAddress] was inserted
686
680
		boolean insertedStartAddress = startAddress == null;
687
		boolean insertedAnyAddress = false;
681
		try {
688
		try {
682
			fCallback.lockScroller();
689
			fCallback.lockScroller();
683
			
690
			
Lines 702-708 Link Here
702
						fCallback.getDocument().addInvalidAddressRange(p);
709
						fCallback.getDocument().addInvalidAddressRange(p);
703
					} else if (p == null || address.compareTo(endAddress) > 0) {
710
					} else if (p == null || address.compareTo(endAddress) > 0) {
704
						if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
711
						if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
705
						return insertedStartAddress;
712
						return insertedAnyAddress;
706
					} else if (p.fValid) {
713
					} else if (p.fValid) {
707
						if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
714
						if (DEBUG) System.out.println("Excess disassembly lines at " + DisassemblyUtils.getAddressText(address)); //$NON-NLS-1$
708
						if (!p.fAddressOffset.equals(address)) {
715
						if (!p.fAddressOffset.equals(address)) {
Lines 725-750 Link Here
725
					}
732
					}
726
					// determine instruction byte length
733
					// determine instruction byte length
727
					BigInteger instrLength= null;
734
					BigInteger instrLength= null;
728
					if (j < instructions.length - 1) {
735
					if (instruction instanceof IInstructionWithSize
729
						instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
736
						&& ((IInstructionWithSize)instruction).getSize() != null) {
730
					} else if (i < mixedInstructions.length - 1) {
737
						instrLength= new BigInteger(((IInstructionWithSize)instruction).getSize().toString());
731
						int nextSrcLineIdx= i+1;
738
					} else {
732
						while (nextSrcLineIdx < mixedInstructions.length) {
739
						if (j < instructions.length - 1) {
733
							IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
740
							instrLength= instructions[j+1].getAdress().subtract(instruction.getAdress()).abs();
734
							if (nextInstrs.length > 0) {
741
						} else if (i < mixedInstructions.length - 1) {
735
								instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
742
							int nextSrcLineIdx= i+1;
743
							while (nextSrcLineIdx < mixedInstructions.length) {
744
								IInstruction[] nextInstrs= mixedInstructions[nextSrcLineIdx].getInstructions();
745
								if (nextInstrs.length > 0) {
746
									instrLength= nextInstrs[0].getAdress().subtract(instruction.getAdress()).abs();
747
									break;
748
								}
749
								++nextSrcLineIdx;
750
							}
751
							if (nextSrcLineIdx >= mixedInstructions.length) {
736
								break;
752
								break;
737
							}
753
							}
738
							++nextSrcLineIdx;
739
						}
754
						}
740
						if (nextSrcLineIdx >= mixedInstructions.length) {
755
						if (instrLength == null) {
756
							// cannot determine length of last instruction
741
							break;
757
							break;
742
						}
758
						}
743
					}
759
					}
744
					if (instrLength == null) {
745
						// cannot determine length of last instruction
746
						break;
747
					}
748
					final String opCode;
760
					final String opCode;
749
					// insert function name+offset instead of opcode bytes
761
					// insert function name+offset instead of opcode bytes
750
					if (functionName != null && functionName.length() > 0) {
762
					if (functionName != null && functionName.length() > 0) {
Lines 752-762 Link Here
752
					} else {
764
					} else {
753
						opCode= ""; //$NON-NLS-1$
765
						opCode= ""; //$NON-NLS-1$
754
					}
766
					}
755
					insertedStartAddress= insertedStartAddress || address.compareTo(startAddress) == 0;
756
					p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), file, lineNumber);
767
					p = fCallback.getDocument().insertDisassemblyLine(p, address, instrLength.intValue(), opCode, instruction.getInstruction(), file, lineNumber);
757
					if (p == null && insertedStartAddress) {
768
					if (p == null) {
758
						break;
769
						break;
759
					}
770
					}
771
					insertedAnyAddress = true;
760
				}
772
				}
761
			}
773
			}
762
			
774
			
Lines 765-771 Link Here
765
			DisassemblyUtils.internalError(e);
777
			DisassemblyUtils.internalError(e);
766
		} finally {
778
		} finally {
767
			fCallback.setUpdatePending(false);
779
			fCallback.setUpdatePending(false);
768
			if (insertedStartAddress) {
780
			if (insertedAnyAddress) {
769
				fCallback.updateInvalidSource();
781
				fCallback.updateInvalidSource();
770
				fCallback.unlockScroller();
782
				fCallback.unlockScroller();
771
				fCallback.doPending();
783
				fCallback.doPending();
Lines 774-780 Link Here
774
				fCallback.unlockScroller();
786
				fCallback.unlockScroller();
775
			}
787
			}
776
		}
788
		}
777
		return insertedStartAddress;
789
		return insertedAnyAddress;
778
	}
790
	}
779
791
780
	/* (non-Javadoc)
792
	/* (non-Javadoc)
(-)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