mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 331552 - [disassembly] Need a way to insert more than one source line
This commit is contained in:
parent
f8f2a9c9a3
commit
40a4382b3e
4 changed files with 31 additions and 43 deletions
|
@ -30,6 +30,9 @@ import org.eclipse.ui.IWorkbenchPartSite;
|
|||
* DisassemblyPart all along. Documentation for those methods were sparse, and
|
||||
* thus this interface is likewise. See the DisassemblyPart for any available
|
||||
* documentation.
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IDisassemblyPartCallback {
|
||||
void gotoFrame(int frame);
|
||||
|
@ -49,6 +52,7 @@ public interface IDisassemblyPartCallback {
|
|||
void unlockScroller();
|
||||
void insertSource(AddressRangePosition pos);
|
||||
AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNumber);
|
||||
AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, int lastLine);
|
||||
void setUpdatePending(boolean pending);
|
||||
boolean getUpdatePending();
|
||||
void setGotoAddressPending(BigInteger address);
|
||||
|
|
|
@ -2665,11 +2665,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
if (fi.fSource != null && lineNr >= 0 && lineNr < fi.fSource.getNumberOfLines()) {
|
||||
fi.fStartAddress = fi.fStartAddress.min(pos.fAddressOffset);
|
||||
fi.fEndAddress = fi.fEndAddress.max(pos.fAddressOffset.add(pos.fAddressLength));
|
||||
int last = pos.fLast > lineNr ? pos.fLast : lineNr;
|
||||
final BigInteger lineAddr = fi.fLine2Addr[lineNr];
|
||||
if (lineAddr == null) {
|
||||
fi.fLine2Addr[lineNr] = pos.fAddressOffset;
|
||||
String sourceLine = fi.getLine(lineNr);
|
||||
fDocument.insertSource(pos, sourceLine, lineNr, true);
|
||||
String source = fi.getLines(lineNr, last);
|
||||
fDocument.insertSource(pos, source, lineNr, true);
|
||||
} else {
|
||||
final int comparison = lineAddr.compareTo(pos.fAddressOffset);
|
||||
if (comparison > 0) {
|
||||
|
@ -2693,11 +2694,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
}
|
||||
fi.fLine2Addr[lineNr] = pos.fAddressOffset;
|
||||
String sourceLine = fi.getLine(lineNr);
|
||||
fDocument.insertSource(pos, sourceLine, lineNr, true);
|
||||
String source = fi.getLines(lineNr, last);
|
||||
fDocument.insertSource(pos, source, lineNr, true);
|
||||
} else if (comparison == 0) {
|
||||
String sourceLine = fi.getLine(lineNr);
|
||||
fDocument.insertSource(pos, sourceLine, lineNr, true);
|
||||
String source = fi.getLines(lineNr, last);
|
||||
fDocument.insertSource(pos, source, lineNr, true);
|
||||
} else {
|
||||
// new source position is after old position
|
||||
try {
|
||||
|
@ -2709,12 +2710,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
fDocument.insertSource(pos, "", lineNr, true); //$NON-NLS-1$
|
||||
fDocument.removeSourcePosition(pos);
|
||||
} else {
|
||||
String sourceLine = fi.getLine(lineNr);
|
||||
fDocument.insertSource(pos, sourceLine, lineNr, true);
|
||||
String source = fi.getLines(lineNr, last);
|
||||
fDocument.insertSource(pos, source, lineNr, true);
|
||||
}
|
||||
} else {
|
||||
String sourceLine = fi.getLine(lineNr);
|
||||
fDocument.insertSource(pos, sourceLine, lineNr, true);
|
||||
String source = fi.getLines(lineNr, last);
|
||||
fDocument.insertSource(pos, source, lineNr, true);
|
||||
}
|
||||
} catch (BadPositionCategoryException e) {
|
||||
internalError(e);
|
||||
|
@ -2846,16 +2847,16 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#insertSource(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, java.lang.String, int)
|
||||
*/
|
||||
public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNumber) {
|
||||
return insertSource(pos, address, file, lineNumber, lineNumber);
|
||||
}
|
||||
public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, int lastLine) {
|
||||
assert isGuiThread();
|
||||
Object sourceElement = null;
|
||||
if (fFile2Storage.containsKey(file)) {
|
||||
sourceElement = fFile2Storage.get(file);
|
||||
} else {
|
||||
sourceElement = fBackend.insertSource(pos, address, file, lineNumber);
|
||||
sourceElement = fBackend.insertSource(pos, address, file, firstLine);
|
||||
}
|
||||
if (sourceElement instanceof File) {
|
||||
sourceElement = new LocalFileStorage((File)sourceElement);
|
||||
|
@ -2898,7 +2899,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
|
|||
}
|
||||
fi.fReadingJob.schedule();
|
||||
}
|
||||
pos = fDocument.insertInvalidSource(pos, address, fi, lineNumber);
|
||||
pos = fDocument.insertInvalidSource(pos, address, fi, firstLine, lastLine);
|
||||
}
|
||||
|
||||
return pos;
|
||||
|
|
|
@ -20,39 +20,21 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo;
|
|||
*/
|
||||
public class SourcePosition extends AddressRangePosition {
|
||||
|
||||
public SourceFileInfo fFileInfo;
|
||||
public final SourceFileInfo fFileInfo;
|
||||
public int fLine;
|
||||
public int fLast = -1;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param addressOffset
|
||||
* @param fileInfo
|
||||
* @param line
|
||||
*/
|
||||
public SourcePosition(int offset, int length, BigInteger addressOffset, SourceFileInfo fileInfo, int line) {
|
||||
this(offset, length, addressOffset, fileInfo, line, true);
|
||||
public SourcePosition(int offset, int length, BigInteger addressOffset, SourceFileInfo fileInfo, int line, int last) {
|
||||
this(offset, length, addressOffset, fileInfo, line, last, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param offset
|
||||
* @param length
|
||||
* @param addressOffset
|
||||
* @param fileInfo
|
||||
* @param line
|
||||
* @param valid
|
||||
*/
|
||||
public SourcePosition(int offset, int length, BigInteger addressOffset, SourceFileInfo fileInfo, int line, boolean valid) {
|
||||
public SourcePosition(int offset, int length, BigInteger addressOffset, SourceFileInfo fileInfo, int line, int last, boolean valid) {
|
||||
super(offset, length, addressOffset, BigInteger.ZERO, valid);
|
||||
fFileInfo = fileInfo;
|
||||
fLine = line;
|
||||
fLast = last;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.AddressRangePosition#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "->["+fFileInfo.fFileKey + ':' + fLine + ']'; //$NON-NLS-1$
|
||||
|
|
|
@ -1203,7 +1203,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
if (pos.length > 0) {
|
||||
SourcePosition oldPos = getSourcePosition(pos.offset+pos.length);
|
||||
if (oldPos == null || oldPos.fAddressOffset.compareTo(pos.fAddressOffset) != 0) {
|
||||
pos = new SourcePosition(pos.offset+pos.length, 0, pos.fAddressOffset, pos.fFileInfo, line, false);
|
||||
pos = new SourcePosition(pos.offset+pos.length, 0, pos.fAddressOffset, pos.fFileInfo, line, pos.fLast, false);
|
||||
addSourcePosition(pos);
|
||||
addModelPosition(pos);
|
||||
addInvalidSourcePositions(pos);
|
||||
|
@ -1223,17 +1223,18 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu
|
|||
* @param pos
|
||||
* @param address
|
||||
* @param fi
|
||||
* @param lineNr
|
||||
* @param firstLine
|
||||
* @param lastLine
|
||||
* @return
|
||||
*/
|
||||
public AddressRangePosition insertInvalidSource(AddressRangePosition pos, BigInteger address, SourceFileInfo fi, int lineNr) {
|
||||
public AddressRangePosition insertInvalidSource(AddressRangePosition pos, BigInteger address, SourceFileInfo fi, int firstLine, int lastLine) {
|
||||
assert isGuiThread();
|
||||
SourcePosition sourcePos = getSourcePosition(address);
|
||||
if (sourcePos != null) {
|
||||
return pos;
|
||||
}
|
||||
String sourceLine = ""; //$NON-NLS-1$
|
||||
sourcePos = new SourcePosition(0, sourceLine.length(), address, fi, lineNr, false);
|
||||
sourcePos = new SourcePosition(0, sourceLine.length(), address, fi, firstLine, lastLine, false);
|
||||
try {
|
||||
pos = insertAddressRange(pos, sourcePos, sourceLine, true);
|
||||
addSourcePosition(sourcePos);
|
||||
|
|
Loading…
Add table
Reference in a new issue