From 214ac8648bc460d13e124510a7fa70bf073d473f Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 26 Nov 2009 08:27:39 +0000 Subject: [PATCH] [295895] DSF Disassembly view attempts to insert source even when 'Show Source' option is off --- .../ui/disassembly/DisassemblyPart.java | 10 +- .../model/DisassemblyDocument.java | 119 +++++++++--------- 2 files changed, 72 insertions(+), 57 deletions(-) diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index d0abb70b86e..4325c51d0b1 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -1752,7 +1752,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem return; } if (DEBUG) System.out.println("retrieveDisassembly "+getAddressText(startAddress)+" "+lines+" lines"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - retrieveDisassembly(startAddress, endAddress, lines, true, false); + retrieveDisassembly(startAddress, endAddress, lines, fShowSource, false); } private void retrieveDisassembly(final BigInteger startAddress, BigInteger endAddress, final int linesHint, boolean mixed, boolean ignoreFile) { @@ -3346,6 +3346,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } else { fPCAnnotationUpdatePending = true; updateInvalidSource(); + if (fShowSource) { + Runnable doit = new Runnable() { + public void run() { + fDocument.invalidateAddressRange(fStartAddress, fEndAddress, true); + fGotoFramePending = true; + }}; + doScrollLocked(doit); + } } } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java index 29c0c2329a6..ccb4434b290 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java @@ -25,6 +25,8 @@ import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultLineTracker; +import org.eclipse.jface.text.DocumentRewriteSession; +import org.eclipse.jface.text.DocumentRewriteSessionType; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; @@ -1228,71 +1230,76 @@ public class DisassemblyDocument extends REDDocument { } public void deleteDisassemblyRange(BigInteger startAddress, BigInteger endAddress, boolean invalidate, boolean collapse) { - String replacement = invalidate ? "...\n" : null; //$NON-NLS-1$ - int replaceLen = replacement != null ? replacement.length() : 0; - AddressRangePosition lastPos = null; - ArrayList toRemove = new ArrayList(); - Iterator it = getModelPositionIterator(startAddress); - while (it.hasNext()) { - AddressRangePosition pos = it.next(); - BigInteger posEndAddress = pos.fAddressOffset.add(pos.fAddressLength); - if (pos instanceof LabelPosition) { - if (!invalidate && pos.length > 0 && posEndAddress.compareTo(endAddress) > 0) { + DocumentRewriteSession session = startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL); + try { + String replacement = invalidate ? "...\n" : null; //$NON-NLS-1$ + int replaceLen = replacement != null ? replacement.length() : 0; + AddressRangePosition lastPos = null; + ArrayList toRemove = new ArrayList(); + Iterator it = getModelPositionIterator(startAddress); + while (it.hasNext()) { + AddressRangePosition pos = it.next(); + BigInteger posEndAddress = pos.fAddressOffset.add(pos.fAddressLength); + if (pos instanceof LabelPosition) { + if (!invalidate && pos.length > 0 && posEndAddress.compareTo(endAddress) > 0) { + try { + int oldLength = pos.length; + pos.length = 0; + replace(pos, oldLength, null); + } catch (BadLocationException e) { + internalError(e); + } + } + pos = null; + } else if (pos instanceof SourcePosition) { + pos = null; + } else if (pos instanceof ErrorPosition) { + pos = null; + } else if (pos instanceof DisassemblyPosition) { + // optimization: join adjacent positions + if (collapse && lastPos != null + && (invalidate || lastPos.fValid == pos.fValid) + && lastPos.offset+lastPos.length == pos.offset) { + assert lastPos.fAddressOffset.add(lastPos.fAddressLength).compareTo(pos.fAddressOffset) == 0; + lastPos.length += pos.length; + lastPos.fAddressLength = lastPos.fAddressLength.add(pos.fAddressLength); + toRemove.add(pos); + if (!pos.fValid) { + fInvalidAddressRanges.remove(pos); + } + pos = null; + if (posEndAddress.compareTo(endAddress) < 0) { + continue; + } + } + } + if (lastPos != null) { try { - int oldLength = pos.length; - pos.length = 0; - replace(pos, oldLength, null); + if (lastPos.length > 0 || replaceLen > 0) { + int oldLength = lastPos.length; + lastPos.length = replaceLen; + replace(lastPos, oldLength, replacement); + } } catch (BadLocationException e) { internalError(e); } } - pos = null; - } else if (pos instanceof SourcePosition) { - pos = null; - } else if (pos instanceof ErrorPosition) { - pos = null; - } else if (pos instanceof DisassemblyPosition) { - // optimization: join adjacent positions - if (collapse && lastPos != null - && (invalidate || lastPos.fValid == pos.fValid) - && lastPos.offset+lastPos.length == pos.offset) { - assert lastPos.fAddressOffset.add(lastPos.fAddressLength).compareTo(pos.fAddressOffset) == 0; - lastPos.length += pos.length; - lastPos.fAddressLength = lastPos.fAddressLength.add(pos.fAddressLength); - toRemove.add(pos); - if (!pos.fValid) { - fInvalidAddressRanges.remove(pos); - } - pos = null; - if (posEndAddress.compareTo(endAddress) < 0) { - continue; + if (pos == null && posEndAddress.compareTo(endAddress) >= 0) { + break; + } + lastPos = null; + if (pos != null) { + if (pos.fValid && invalidate) { + pos.fValid = false; + fInvalidAddressRanges.add(pos); } + lastPos = pos; } } - if (lastPos != null) { - try { - if (lastPos.length > 0 || replaceLen > 0) { - int oldLength = lastPos.length; - lastPos.length = replaceLen; - replace(lastPos, oldLength, replacement); - } - } catch (BadLocationException e) { - internalError(e); - } - } - if (pos == null && posEndAddress.compareTo(endAddress) >= 0) { - break; - } - lastPos = null; - if (pos != null) { - if (pos.fValid && invalidate) { - pos.fValid = false; - fInvalidAddressRanges.add(pos); - } - lastPos = pos; - } + removePositions(CATEGORY_DISASSEMBLY, toRemove); + } finally { + stopRewriteSession(session); } - removePositions(CATEGORY_DISASSEMBLY, toRemove); if (DEBUG) checkConsistency(); }