From 5dea774f912a8589c9154d8d44a6324edbedce29 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 30 May 2006 01:29:54 +0000 Subject: [PATCH 001/118] The memory rendering was approved for cvs commit by the eclipse Intellectual Property Manager. The source matches the bugzilla 137391 attachment. The code could still use some refactoring and clean up. --- .classpath | 7 +++++++ .project | 28 ++++++++++++++++++++++++++++ build.properties | 4 ++++ plugin.xml | 19 +++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 build.properties create mode 100644 plugin.xml diff --git a/.classpath b/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000000..29e3e81ee28 --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + org.eclipse.dsdp.debug.memory.renderings + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/build.properties b/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 00000000000..eefe54fac80 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + From b7444a53e00b138a2ebbf6473d9e8668b3454fc4 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 29 Sep 2006 20:00:24 +0000 Subject: [PATCH 002/118] dsdp -> dd --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index eefe54fac80..f37b383bd95 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,7 +5,7 @@ + class="org.eclipse.dd.debug.memory.renderings.MemoryRenderingTypeDelegate"> Date: Mon, 16 Oct 2006 02:36:26 +0000 Subject: [PATCH 003/118] dsdp -> dd --- plugin.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.xml b/plugin.xml index f37b383bd95..2970422aa1c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -4,12 +4,12 @@ + renderingIds="org.eclipse.dd.debug.memory.renderings.MemoryRenderingTraditional" + defaultIds="org.eclipse.dd.debug.memory.renderings.MemoryRenderingTraditional"> From 4de8c38ea87f87f939466dfa6e741142c98fd666 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 22 Oct 2006 05:58:58 +0000 Subject: [PATCH 004/118] 158599 Visual indication when memory window is in Edit mode 161859 Traditional Memory Rendering - Addressable Size General Failures 161860 Traditional Memory Rendering - Colors should be a user preference 161861 Traditional Memory Rendering - Cells should optionally alternate color --- plugin.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugin.xml b/plugin.xml index 2970422aa1c..8ad6adfe1e5 100644 --- a/plugin.xml +++ b/plugin.xml @@ -15,5 +15,16 @@ + + + + + + From 94f8ff9cbf9f450bf12e69f1d9feb27f0123bd66 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 04:55:18 +0000 Subject: [PATCH 005/118] Relocated plugin to the plugins directory. Repackaged to .traditional Restructured, moving AbstractPane, AddressPane, DataPane and TextPane to their own files. --- .../.classpath | 7 + .../.project | 28 + .../META-INF/MANIFEST.MF | 14 + .../build.properties | 4 + .../plugin.xml | 30 + .../renderings/traditional/AbstractPane.java | 636 ++++ .../renderings/traditional/AddressPane.java | 232 ++ .../renderings/traditional/DataPane.java | 341 ++ .../renderings/traditional/TextPane.java | 299 ++ .../traditional/TraditionalRendering.java | 2803 +++++++++++++++++ .../TraditionalRenderingMessages.java | 43 + .../TraditionalRenderingPlugin.java | 22 + ...aditionalRenderingPreferenceConstants.java | 32 + ...itionalRenderingPreferenceInitializer.java | 49 + .../TraditionalRenderingPreferencePage.java | 80 + .../TraditionalRenderingTypeDelegate.java | 29 + .../TraditionalRendering_messages.properties | 36 + 17 files changed, 4685 insertions(+) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/.classpath create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/.project create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingMessages.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.classpath b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.project b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.project new file mode 100644 index 00000000000..fdfc9de5d6c --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/.project @@ -0,0 +1,28 @@ + + + org.eclipse.dd.debug.memory.renderings.traditional + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..bc570b8f754 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Traditional Memory Rendering +Bundle-SymbolicName: org.eclipse.dd.debug.memory.renderings.traditional;singleton:=true +Bundle-Version: 0.9.0.qualifier +Bundle-Localization: plugin +Require-Bundle: org.eclipse.debug.core, + org.eclipse.debug.ui, + org.eclipse.core.runtime, + org.eclipse.swt, + org.eclipse.jface, + org.eclipse.ui +Eclipse-LazyStart: true +Bundle-Activator: org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties new file mode 100644 index 00000000000..34d2e4d2dad --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml new file mode 100644 index 00000000000..ff1f06d09a5 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java new file mode 100644 index 00000000000..670c4427868 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -0,0 +1,636 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Caret; + +public abstract class AbstractPane extends Canvas +{ + protected Rendering fRendering; + + // selection state + protected boolean fSelectionInProgress = false; + + protected BigInteger fSelectionStartAddress = null; + + protected int fSelectionStartAddressSubPosition; + + // caret + protected Caret fCaret = null; + + protected int fSubCellCaretPosition = 0; // character may not fall on + + // byte boundary + + protected boolean fCaretEnabled = false; + + protected BigInteger fCaretAddress = null; + + // storage + protected int fRowCount = 0; + + protected boolean fPaneVisible = true; + + public AbstractPane(Rendering rendering) + { + super(rendering, SWT.DOUBLE_BUFFERED); + + fRendering = rendering; + + try + { + fCaretAddress = rendering.getMemoryBlock().getBigBaseAddress(); + } + catch(Exception e) + { + // do nothing + } + + // pref + + this.setFont(fRendering.getFont()); + + GC gc = new GC(this); + gc.setFont(this.getFont()); + fCaret = new Caret(this, SWT.NONE); + fCaret.setSize(1, gc.stringExtent("|").y); //$NON-NLS-1$ + gc.dispose(); + + this.addPaintListener(new PaintListener() + { + public void paintControl(PaintEvent pe) + { + AbstractPane.this.paint(pe); + } + }); + + this.addMouseListener(new MouseListener() + { + public void mouseUp(MouseEvent me) + { + positionCaret(me.x, me.y); + + fCaret.setVisible(true); + + if(me.button == 1) + { + endSelection(me.x, me.y); + } + } + + public void mouseDown(MouseEvent me) + { + AbstractPane.this.forceFocus(); + + positionCaret(me.x, me.y); + + fCaret.setVisible(false); + + if(me.button == 1) + { + // if shift is down and we have an existing start address, + // append selection + if((me.stateMask & SWT.SHIFT) != 0 + && fRendering.getSelection().getStart() != null) + { + + // if the pane doesn't have a selection start (the + // selection was created in a different pane) + // then initialize the pane's selection start to the + // rendering's selection start + if(AbstractPane.this.fSelectionStartAddress == null) + AbstractPane.this.fSelectionStartAddress = fRendering + .getSelection().getStart(); + + AbstractPane.this.fSelectionInProgress = true; + + AbstractPane.this.appendSelection(me.x, me.y); + + } + else + { + // start a new selection + + AbstractPane.this.startSelection(me.x, me.y); + } + } + } + + public void mouseDoubleClick(MouseEvent me) + { + } + }); + + this.addMouseMoveListener(new MouseMoveListener() + { + public void mouseMove(MouseEvent me) + { + if(fSelectionInProgress) + { + appendSelection(me.x, me.y); + } + } + }); + + this.addKeyListener(new KeyListener() + { + public void keyPressed(KeyEvent ke) + { + if((ke.stateMask & SWT.SHIFT) != 0) + { + switch(ke.keyCode) + { + case SWT.ARROW_RIGHT: + case SWT.ARROW_LEFT: + case SWT.ARROW_UP: + case SWT.ARROW_DOWN: + case SWT.PAGE_DOWN: + case SWT.PAGE_UP: + if(fRendering.getSelection().getStart() == null) + { + fRendering.getSelection().setStart(fCaretAddress.add(BigInteger.valueOf( + fRendering.getAddressesPerColumn())), fCaretAddress); + } + break; + } + } + + if(ke.keyCode == SWT.ARROW_RIGHT) + { + fSubCellCaretPosition++; + if(fSubCellCaretPosition >= getCellCharacterCount()) + { + fSubCellCaretPosition = 0; + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); + if(newCaretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0) + { + fSubCellCaretPosition = getCellCharacterCount(); + } + else + { + setCaretAddress(newCaretAddress); + } + } + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.ARROW_LEFT || ke.keyCode == SWT.BS) + { + fSubCellCaretPosition--; + if(fSubCellCaretPosition < 0) + { + fSubCellCaretPosition = getCellCharacterCount() - 1; + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); + if(newCaretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0) + { + fSubCellCaretPosition = 0; + } + else + { + setCaretAddress(newCaretAddress); + } + + } + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.ARROW_DOWN) + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow())); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.ARROW_UP) + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow())); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.PAGE_DOWN) + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow() + * (fRendering.getRowCount() - 1))); + + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.PAGE_UP) + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow() + * (fRendering.getRowCount() - 1))); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + else if(ke.keyCode == SWT.ESC) + { + fRendering.getViewportCache().clearEditBuffer(); + } + else if(ke.character == '\r') + { + fRendering.getViewportCache().writeEditBuffer(); + } + else if(Rendering.isValidEditCharacter(ke.character)) + { + editCell(fCaretAddress, fSubCellCaretPosition, ke.character); + } + + if((ke.stateMask & SWT.SHIFT) != 0) + { + switch(ke.keyCode) + { + case SWT.ARROW_RIGHT: + case SWT.ARROW_LEFT: + case SWT.ARROW_UP: + case SWT.ARROW_DOWN: + case SWT.PAGE_DOWN: + case SWT.PAGE_UP: + fRendering.getSelection().setEnd(fCaretAddress.add(BigInteger.valueOf( + fRendering.getAddressesPerColumn())), + fCaretAddress); + break; + } + } + else if(ke.keyCode != SWT.SHIFT) + // if shift key, keep selection, we might add to it + { + fRendering.getSelection().clear(); + } + + } + + public void keyReleased(KeyEvent ke) + { + // do nothing + } + }); + + this.addFocusListener(new FocusListener() + { + public void focusLost(FocusEvent fe) + { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + if(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY + .equals(store.getString(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE))) + { + fRendering.getViewportCache().clearEditBuffer(); + } + else + { + fRendering.getViewportCache().writeEditBuffer(); + } + + // clear the pane local selection start + AbstractPane.this.fSelectionStartAddress = null; + } + + public void focusGained(FocusEvent fe) + { + } + }); + } + + protected boolean isPaneVisible() + { + return fPaneVisible; + } + + protected void setPaneVisible(boolean visible) + { + fPaneVisible = visible; + this.setVisible(visible); + } + + protected int getNumberOfBytesRepresentedByColumn() + { + return fRendering.getBytesPerColumn(); + } + + protected void editCell(BigInteger address, int subCellPosition, + char character) + { + // do nothing + } + + // Set the caret address + protected void setCaretAddress(BigInteger caretAddress) + { + // Ensure that caret is within the addressable range + if((caretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) >= 0) && + (caretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) <= 0)) + { + fCaretAddress = caretAddress; + } + else if(caretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0) + { + // calculate offset from the beginning of the row + int cellOffset = fCaretAddress.subtract(fRendering.getViewportStartAddress()).intValue(); + int row = cellOffset / (fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter()); + + cellOffset -= row * fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter(); + + fCaretAddress = fRendering.getMemoryBlockStartAddress().add( + BigInteger.valueOf(cellOffset / fRendering.getAddressableSize())); + } + else if(caretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0) + { + // calculate offset from the end of the row + int cellOffset = fCaretAddress.subtract(fRendering.getViewportEndAddress()).intValue() + 1; + int row = cellOffset / (fRendering.getBytesPerRow() / fRendering.getBytesPerCharacter()); + + cellOffset -= row * fRendering.getBytesPerRow()/ fRendering.getBytesPerCharacter(); + + fCaretAddress = fRendering.getMemoryBlockEndAddress().add( + BigInteger.valueOf(cellOffset / fRendering.getAddressableSize())); + } + } + + protected boolean isOdd(int value) + { + return (value / 2) * 2 == value; + } + + protected void updateCaret() + { + try + { + if(fCaretAddress != null) + { + Point cellPosition = getCellLocation(fCaretAddress); + if(cellPosition != null) + { + fCaret.setLocation(cellPosition.x + fSubCellCaretPosition + * getCellCharacterWidth(), cellPosition.y); + } + } + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$ + } + } + + protected void ensureCaretWithinViewport() // TODO getAddressableSize() > 1 ? + { + // determine if caret is before the viewport start + // if so, scroll viewport up by appropriate rows + if(fCaretAddress.compareTo(fRendering.getViewportStartAddress()) < 0) + { + BigInteger difference = fRendering.getViewportStartAddress() + .subtract(fCaretAddress); + BigInteger rows = difference.divide(BigInteger.valueOf(fRendering.getBytesPerRow())); + if(rows.multiply( + BigInteger.valueOf(fRendering.getBytesPerRow())).compareTo(difference) != 0) + rows = rows.add(BigInteger.valueOf(1)); + + fRendering.setViewportStartAddress(fRendering.getViewportStartAddress() + .subtract(rows.multiply(BigInteger.valueOf(fRendering.getBytesPerRow())))); + fRendering.ensureViewportAddressDisplayable(); + fRendering.gotoAddress(fRendering.getViewportStartAddress()); + } + // determine if caret is after the viewport end + // if so, scroll viewport down by appropriate rows + else if(fCaretAddress.compareTo(fRendering.getViewportEndAddress()) >= 0) + { + BigInteger difference = fCaretAddress.subtract(fRendering + .getViewportEndAddress().subtract(BigInteger.valueOf(1))); + BigInteger rows = difference.divide(BigInteger.valueOf(fRendering.getBytesPerRow())); + if(rows.multiply( + BigInteger.valueOf(fRendering.getBytesPerRow())).compareTo(difference) != 0) + rows = rows.add(BigInteger.valueOf(1)); + + fRendering.setViewportStartAddress(fRendering.getViewportStartAddress().add( + rows.multiply(BigInteger.valueOf(fRendering.getBytesPerRow())))); + fRendering.ensureViewportAddressDisplayable(); + fRendering.gotoAddress(fRendering.getViewportStartAddress()); + } + } + + protected void advanceCursor() + { + fSubCellCaretPosition++; + if(fSubCellCaretPosition >= getCellCharacterCount()) + { + fSubCellCaretPosition = 0; + fCaretAddress = fCaretAddress.add(BigInteger + .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); + + } + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void positionCaret(int x, int y) + { + // do nothing + } + + protected int getRowCount() + { + return fRowCount; + } + + protected void setRowCount() + { + fRowCount = getBounds().height / getCellHeight(); + } + + protected void settingsChanged() + { + fSubCellCaretPosition = 0; + } + + protected void startSelection(int x, int y) + { + try + { + BigInteger address = getViewportAddress(x / getCellWidth(), y + / getCellHeight()); + + if(address != null) + { + this.fSelectionStartAddress = address; + Point cellPosition = getCellLocation(address); + + if(cellPosition != null) + { + int offset = x - cellPosition.x; + fSelectionStartAddressSubPosition = offset + / getCellCharacterWidth(); + } + fRendering.getSelection().clear(); + fRendering.getSelection().setStart(address.add(BigInteger.valueOf( + fRendering.getBytesPerColumn() / fRendering.getAddressableSize())), address); + + fSelectionInProgress = true; + } + } + catch(DebugException e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_START_SELECTION"), e); //$NON-NLS-1$ + } + } + + protected void endSelection(int x, int y) + { + appendSelection(x, y); + + fSelectionInProgress = false; + } + + protected void appendSelection(int x, int y) + { + try + { + BigInteger address = getViewportAddress(x / getCellWidth(), y + / getCellHeight()); + + if(address.compareTo(this.fSelectionStartAddress) == 0) + { + // deal with sub cell selection + Point cellPosition = getCellLocation(address); + int offset = x - cellPosition.x; + int subCellCharacterPosition = offset / getCellCharacterWidth(); + + if(Math.abs(subCellCharacterPosition + - this.fSelectionStartAddressSubPosition) > this + .getCellCharacterCount() / 4) + { + fRendering.getSelection().setEnd(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + } + else + { + fRendering.getSelection().setEnd(null, null); + } + } + else + { + fRendering.getSelection().setEnd(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + } + + if(fRendering.getSelection().getEnd() != null) + { + this.fCaretAddress = fRendering.getSelection().getEnd(); + this.fSubCellCaretPosition = 0; + } + + updateCaret(); + } + catch(DebugException e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_APPEND_SELECTION"), e); //$NON-NLS-1$ + } + } + + protected void paint(PaintEvent pe) + { + fRowCount = getBounds().height / getCellHeight(); + } + + abstract protected BigInteger getViewportAddress(int col, int row) + throws DebugException; + + protected Point getCellLocation(BigInteger address) + { + return null; + } + + protected String getCellText(MemoryByte bytes[]) + { + return null; + } + + abstract protected int getCellWidth(); + + abstract protected int getCellCharacterCount(); + + private int fCellHeight = -1; // called often, cache + + protected int getCellHeight() + { + if(fCellHeight == -1) + { + fCellHeight = getCellTextHeight() + + (fRendering.getCellPadding() * 2); + } + + return fCellHeight; + } + + private int fCharacterWidth = -1; // called often, cache + + protected int getCellCharacterWidth() + { + if(fCharacterWidth == -1) + { + GC gc = new GC(this); + gc.setFont(fRendering.getFont()); + fCharacterWidth = gc.getAdvanceWidth('F'); + gc.dispose(); + } + + return fCharacterWidth; + } + + private int fTextHeight = -1; // called often, cache + + protected int getCellTextHeight() + { + if(fTextHeight == -1) + { + GC gc = new GC(this); + gc.setFont(fRendering.getFont()); + FontMetrics fontMetrics = gc.getFontMetrics(); + fTextHeight = fontMetrics.getHeight(); + gc.dispose(); + } + return fTextHeight; + } +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java new file mode 100644 index 00000000000..6dffd0bcd42 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -0,0 +1,232 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.FontMetrics; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; + +public class AddressPane extends AbstractPane +{ + public AddressPane(Rendering parent) + { + super(parent); + } + + protected BigInteger getViewportAddress(int col, int row) + throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + address = address.add(BigInteger.valueOf((row + * fRendering.getColumnCount() + col) + * fRendering.getAddressesPerColumn())); + + return address; + } + + protected void appendSelection(int x, int y) + { + try + { + BigInteger address = getViewportAddress(x / getCellWidth(), y + / getCellHeight()); + + if(address.compareTo(this.fSelectionStartAddress) == 0) + { + fRendering.getSelection().setEnd(null, null); + } + else + { + fRendering.getSelection().setEnd(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn() * fRendering.getColumnCount())), address); + } + } + catch(DebugException e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_APPEND_SELECTION"), e); //$NON-NLS-1$ + } + } + + public Point computeSize(int wHint, int hHint) + { + return new Point(getCellWidth() + fRendering.getRenderSpacing(), 100); + } + + protected int getCellCharacterCount() + { + // two characters per byte of hex address + + return fRendering.getAddressBytes() * 2 + + 2; // 0x + } + + protected int getCellWidth() + { + GC gc = new GC(this); + gc.setFont(fRendering.getFont()); + int width = gc.getAdvanceWidth('0'); + gc.dispose(); + + return getCellCharacterCount() * width + + (fRendering.getCellPadding() * 2); + } + + private int getColumnCount() + { + return 0; + } + + private BigInteger getCellAddressAt(int x, int y) throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + + int col = x / getCellWidth(); + int row = y / getCellHeight(); + + if(col > getColumnCount()) + return null; + + address = address.add(BigInteger.valueOf(row + * fRendering.getColumnCount() * fRendering.getAddressesPerColumn() + / fRendering.getBytesPerCharacter())); + + address = address.add(BigInteger.valueOf(col + * fRendering.getAddressesPerColumn())); + + return address; + } + + protected Point getCellLocation(BigInteger cellAddress) + { + try + { + BigInteger address = fRendering.getViewportStartAddress(); + + int cellOffset = cellAddress.subtract(address).intValue(); + + cellOffset *= fRendering.getAddressableSize(); + + int row = cellOffset + / (fRendering.getColumnCount() * fRendering.getBytesPerColumn() / fRendering + .getBytesPerCharacter()); + + cellOffset -= row * fRendering.getColumnCount() + * fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + + int col = cellOffset / fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + + int x = col * getCellWidth() + fRendering.getCellPadding(); + int y = row * getCellHeight() + fRendering.getCellPadding(); + + return new Point(x, y); + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$ + return null; + } + } + + protected int getNumberOfBytesRepresentedByColumn() + { + return fRendering.getBytesPerRow(); + } + + protected void positionCaret(int x, int y) + { + try + { + BigInteger cellAddress = getCellAddressAt(x, y); + if(cellAddress != null) + { + Point cellPosition = getCellLocation(cellAddress); + + int offset = x - cellPosition.x; + int x2 = offset / getCellCharacterWidth(); + + if(x2 >= this.getCellCharacterCount()) + { + cellAddress = cellAddress.add(BigInteger.valueOf(this + .getNumberOfBytesRepresentedByColumn())); + x2 = 0; + cellPosition = getCellLocation(cellAddress); + } + + fCaret.setLocation(cellPosition.x + x2 + * getCellCharacterWidth(), cellPosition.y); + + this.fCaretAddress = cellAddress; + this.fSubCellCaretPosition = x2; + } + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$ + } + } + + protected void paint(PaintEvent pe) + { + super.paint(pe); + + GC gc = pe.gc; + + FontMetrics fontMetrics = gc.getFontMetrics(); + int textHeight = fontMetrics.getHeight(); + int cellHeight = textHeight + (fRendering.getCellPadding() * 2); + + try + { + BigInteger start = fRendering.getViewportStartAddress(); + + for(int i = 0; i < this.getBounds().height / cellHeight; i++) + { + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + BigInteger lineAddress = start.add(BigInteger.valueOf(i + * fRendering.getColumnCount() + * fRendering.getAddressesPerColumn())); + + if(fRendering.getSelection().isSelected(lineAddress)) + { + gc.setBackground(fRendering.getTraditionalRendering().getColorSelection()); + gc.fillRectangle(fRendering.getCellPadding() * 2, + cellHeight * i, getCellWidth(), cellHeight); + + gc.setForeground(fRendering.getTraditionalRendering().getColorBackground()); + } + else + { + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + + gc.fillRectangle(fRendering.getCellPadding() * 2, + cellHeight * i, getCellWidth(), cellHeight); + + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + } + + gc.drawText(fRendering.getAddressString(lineAddress), + fRendering.getCellPadding() * 2, cellHeight * i + + fRendering.getCellPadding()); + } + } + catch(Exception e) + { + fRendering.logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$ + } + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java new file mode 100644 index 00000000000..4703f332ee9 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -0,0 +1,341 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; + +public class DataPane extends AbstractPane +{ + public DataPane(Rendering parent) + { + super(parent); + } + + protected String getCellText(MemoryByte bytes[]) + { + return fRendering.getRadixText(bytes, fRendering.getRadix(), fRendering + .isLittleEndian()); + } + + protected void editCell(BigInteger address, int subCellPosition, + char character) + { + try + { + MemoryByte bytes[] = fRendering.getBytes(fCaretAddress, fRendering + .getBytesPerColumn()); + + String cellText = getCellText(bytes); + if(cellText == null) + return; + + StringBuffer cellTextBuffer = new StringBuffer(cellText); + cellTextBuffer.setCharAt(subCellPosition, character); + BigInteger value = new BigInteger(cellTextBuffer.toString().trim(), + fRendering.getNumericRadix(fRendering.getRadix())); + final boolean isSignedType = fRendering.getRadix() == Rendering.RADIX_DECIMAL_SIGNED; + final boolean isSigned = isSignedType + && value.compareTo(BigInteger.valueOf(0)) < 0; + + int bitCount = value.bitLength(); + if(isSignedType) + bitCount++; + if(bitCount > fRendering.getBytesPerColumn() * 8) + return; + + int byteLen = fRendering.getBytesPerColumn(); + byte[] byteData = new byte[byteLen]; + for(int i = 0; i < byteLen; i++) + { + int bits = 255; + if(isSignedType && i == byteLen - 1) + bits = 127; + + byteData[i] = (byte) (value.and(BigInteger.valueOf(bits)) + .intValue() & bits); + value = value.shiftRight(8); + } + + if(isSigned) + byteData[byteLen - 1] |= 128; + + boolean shouldReorderBytes = fRendering.isLittleEndian() == bytes[0].isBigEndian(); // swapped in presentation + if(!bytes[0].isBigEndian()) // swapped by BigInteger/java endianness + shouldReorderBytes = !shouldReorderBytes; + + if(shouldReorderBytes) + { + byte[] byteDataSwapped = new byte[byteData.length]; + for(int i = 0; i < byteData.length; i++) + byteDataSwapped[i] = byteData[byteData.length - 1 - i]; + byteData = byteDataSwapped; + } + + if(byteData.length != bytes.length) + return; + + TraditionalMemoryByte bytesToSet[] = new TraditionalMemoryByte[bytes.length]; + + for(int i = 0; i < byteData.length; i++) + { + bytesToSet[i] = new TraditionalMemoryByte(byteData[i]); + bytesToSet[i].setBigEndian(bytes[i].isBigEndian()); + + if(bytes[i].getValue() != byteData[i]) + { + bytesToSet[i].setEdited(true); + } + else + { + bytesToSet[i].setChanged(bytes[i].isChanged()); + } + } + + fRendering.getViewportCache().setEditedValue(address, bytesToSet); + + advanceCursor(); + + redraw(); + } + catch(Exception e) + { + // do nothing + } + } + + protected int getCellWidth() + { + return getCellCharacterCount() * getCellCharacterWidth() + + (fRendering.getCellPadding() * 2); + } + + protected int getCellCharacterCount() + { + return fRendering.getRadixCharacterCount(fRendering.getRadix(), + fRendering.getBytesPerColumn()); + } + + public Point computeSize(int wHint, int hHint) + { + return new Point(fRendering.getColumnCount() * getCellWidth() + + fRendering.getRenderSpacing(), 100); + } + + private BigInteger getCellAddressAt(int x, int y) throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + + int col = x / getCellWidth(); + int row = y / getCellHeight(); + + if(col >= fRendering.getColumnCount()) + return null; + + address = address.add(BigInteger.valueOf(row + * fRendering.getColumnCount() * fRendering.getAddressesPerColumn())); + + address = address.add(BigInteger.valueOf(col + * fRendering.getAddressesPerColumn())); + + return address; + } + + protected Point getCellLocation(BigInteger cellAddress) + { + try + { + BigInteger address = fRendering.getViewportStartAddress(); + + int cellOffset = cellAddress.subtract(address).intValue(); + cellOffset *= fRendering.getAddressableSize(); + + int row = cellOffset + / (fRendering.getColumnCount() * fRendering.getBytesPerColumn()); + cellOffset -= row * fRendering.getColumnCount() + * fRendering.getBytesPerColumn(); + + int col = cellOffset / fRendering.getBytesPerColumn(); + + int x = col * getCellWidth() + fRendering.getCellPadding(); + int y = row * getCellHeight() + fRendering.getCellPadding(); + + return new Point(x, y); + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$ + return null; + } + } + + protected void positionCaret(int x, int y) + { + try + { + BigInteger cellAddress = getCellAddressAt(x, y); + if(cellAddress != null) + { + Point cellPosition = getCellLocation(cellAddress); + int offset = x - cellPosition.x; + int subCellCharacterPosition = offset / getCellCharacterWidth(); + + if(subCellCharacterPosition == this.getCellCharacterCount()) + { + cellAddress = cellAddress.add(BigInteger.valueOf(fRendering + .getAddressesPerColumn())); + subCellCharacterPosition = 0; + cellPosition = getCellLocation(cellAddress); + } + + fCaret.setLocation(cellPosition.x + subCellCharacterPosition + * getCellCharacterWidth(), cellPosition.y); + + this.fCaretAddress = cellAddress; + this.fSubCellCaretPosition = subCellCharacterPosition; + } + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$ + } + } + + protected BigInteger getViewportAddress(int col, int row) + throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + address = address.add(BigInteger.valueOf((row + * fRendering.getColumnCount() + col) + * fRendering.getAddressesPerColumn())); + + return address; + } + + protected void paint(PaintEvent pe) + { + super.paint(pe); + + IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock(); + // TODO what if it is null? + + GC gc = pe.gc; + gc.setFont(fRendering.getFont()); + + int cellHeight = getCellHeight(); + int cellWidth = getCellWidth(); + + int columns = fRendering.getColumnCount(); + + try + { + BigInteger start = fRendering.getViewportStartAddress(); + + for(int i = 0; i < this.getBounds().height / cellHeight; i++) + { + for(int col = 0; col < columns; col++) + { + if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + BigInteger cellAddress = start.add(BigInteger.valueOf((i + * fRendering.getColumnCount() + col) + * fRendering.getAddressesPerColumn())); + + MemoryByte bytes[] = fRendering.getBytes(cellAddress, + fRendering.getBytesPerColumn()); + + if(fRendering.getSelection().isSelected(cellAddress)) + { + gc.setBackground(fRendering.getTraditionalRendering().getColorSelection()); + gc.fillRectangle(cellWidth * col + + fRendering.getCellPadding(), cellHeight * i, + cellWidth, cellHeight); + + gc.setForeground(fRendering.getTraditionalRendering().getColorBackground()); + } + else + { + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + gc.fillRectangle(cellWidth * col + + fRendering.getCellPadding(), cellHeight * i, + cellWidth, cellHeight); + + // TODO consider adding finer granularity? + boolean anyByteChanged = false; + for(int n = 0; n < bytes.length && !anyByteChanged; n++) + if(bytes[n].isChanged()) + anyByteChanged = true; + + // TODO consider adding finer granularity? + boolean anyByteEditing = false; + for(int n = 0; n < bytes.length && !anyByteEditing; n++) + if(bytes[n] instanceof TraditionalMemoryByte) + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; + + if(anyByteEditing) + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + else if(anyByteChanged) + gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); + else if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + } + + gc.drawText(getCellText(bytes), cellWidth * col + + fRendering.getCellPadding(), cellHeight * i + + fRendering.getCellPadding()); + + BigInteger cellEndAddress = cellAddress.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())); + cellEndAddress = cellEndAddress.subtract(BigInteger + .valueOf(1)); + + if(fCaretEnabled) + { + if(cellAddress.compareTo(fCaretAddress) <= 0 + && cellEndAddress.compareTo(fCaretAddress) >= 0) + { + int x = cellWidth * col + + fRendering.getCellPadding() + + fSubCellCaretPosition + * this.getCellCharacterWidth(); + int y = cellHeight * i + + fRendering.getCellPadding(); + fCaret.setLocation(x, y); + } + } + + if(fRendering.isDebug()) + gc.drawRectangle(cellWidth * col + + fRendering.getCellPadding(), cellHeight * i + + fRendering.getCellPadding(), cellWidth, + cellHeight); + } + } + } + catch(Exception e) + { + fRendering.logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$ + } + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java new file mode 100644 index 00000000000..86426e6ad08 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -0,0 +1,299 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; + +public class TextPane extends AbstractPane +{ + public TextPane(Rendering parent) + { + super(parent); + } + + protected int getCellCharacterCount() + { + return fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + } + + protected String getCellText(MemoryByte bytes[]) + { + return fRendering.formatText(bytes, fRendering + .isLittleEndian(), fRendering.getTextMode()); + } + + protected void editCell(BigInteger address, int subCellPosition, + char character) + { + try + { + MemoryByte bytes[] = fRendering.getBytes(fCaretAddress, fRendering + .getBytesPerColumn()); + + String cellText = getCellText(bytes); + if(cellText == null) + return; + + StringBuffer cellTextBuffer = new StringBuffer(cellText); + cellTextBuffer.setCharAt(subCellPosition, character); + + byte byteData[] = cellTextBuffer.toString().getBytes(); + if(byteData.length != bytes.length) + return; + + TraditionalMemoryByte bytesToSet[] = new TraditionalMemoryByte[bytes.length]; + + for(int i = 0; i < byteData.length; i++) + { + bytesToSet[i] = new TraditionalMemoryByte(byteData[i]); + + if(bytes[i].getValue() != byteData[i]) + { + bytesToSet[i].setEdited(true); + } + else + { + bytesToSet[i].setChanged(bytes[i].isChanged()); + } + } + + fRendering.getViewportCache().setEditedValue(address, bytesToSet); + + advanceCursor(); + + redraw(); + } + catch(Exception e) + { + // this is ok + } + } + + protected int getCellWidth() + { + GC gc = new GC(this); + gc.setFont(fRendering.getFont()); + int width = gc.getAdvanceWidth('F'); + gc.dispose(); + + return fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter() * width; + } + + public Point computeSize(int wHint, int hHint) + { + return new Point(fRendering.getColumnCount() * getCellWidth() + + fRendering.getRenderSpacing(), 100); + + } + + protected Point getCellLocation(BigInteger cellAddress) + { + try + { + BigInteger address = fRendering.getViewportStartAddress(); + + int cellOffset = cellAddress.subtract(address).intValue(); + cellOffset *= fRendering.getAddressableSize(); + + int row = cellOffset + / (fRendering.getColumnCount() * fRendering.getBytesPerColumn() / fRendering + .getBytesPerCharacter()); + cellOffset -= row * fRendering.getColumnCount() + * fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + + int col = cellOffset / fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + + int x = col * getCellWidth() + fRendering.getCellPadding(); + int y = row * getCellHeight() + fRendering.getCellPadding(); + + return new Point(x, y); + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION"), e); //$NON-NLS-1$ + return null; + } + } + + private BigInteger getCellAddressAt(int x, int y) throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + + int col = x / getCellWidth(); + int row = y / getCellHeight(); + + if(col >= fRendering.getColumnCount()) + return null; + + address = address.add(BigInteger.valueOf(row + * fRendering.getColumnCount() * fRendering.getAddressesPerColumn() + / fRendering.getBytesPerCharacter())); + + address = address.add(BigInteger.valueOf(col + * fRendering.getAddressesPerColumn())); + + return address; + } + + protected void positionCaret(int x, int y) + { + try + { + BigInteger cellAddress = getCellAddressAt(x, y); + + if(cellAddress != null) + { + Point cellPosition = getCellLocation(cellAddress); + + int offset = x - cellPosition.x; + int x2 = offset / getCellCharacterWidth(); + + if(x2 == this.getCellCharacterCount()) + { + cellAddress = cellAddress.add(BigInteger.valueOf(fRendering + .getAddressesPerColumn())); + x2 = 0; + cellPosition = getCellLocation(cellAddress); + } + + fCaret.setLocation(cellPosition.x + x2 + * getCellCharacterWidth(), cellPosition.y); + + this.fCaretAddress = cellAddress; + this.fSubCellCaretPosition = x2; + } + } + catch(Exception e) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_POSITION_CURSOR"), e); //$NON-NLS-1$ + } + } + + protected BigInteger getViewportAddress(int col, int row) + throws DebugException + { + BigInteger address = fRendering.getViewportStartAddress(); + address = address.add(BigInteger.valueOf((row + * fRendering.getColumnCount() + col) + * fRendering.getAddressesPerColumn() + / fRendering.getBytesPerCharacter())); + + return address; + } + + protected void paint(PaintEvent pe) + { + super.paint(pe); + + IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock(); + // FIXME what if it is null? + + GC gc = pe.gc; + gc.setFont(fRendering.getFont()); + + int cellHeight = getCellHeight(); + int cellWidth = getCellWidth(); + + final int columns = fRendering.getColumnCount(); + + final boolean isLittleEndian = fRendering.isLittleEndian(); + + gc.setForeground(fRendering.getTraditionalRendering().getColorBackground()); + gc.fillRectangle(columns * cellWidth, 0, this.getBounds().width, this + .getBounds().height); + + try + { + BigInteger start = fRendering.getViewportStartAddress(); + + for(int i = 0; i < this.getBounds().height / cellHeight; i++) + { + for(int col = 0; col < columns; col++) + { + if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + BigInteger cellAddress = start.add(BigInteger.valueOf((i + * columns + col) + * fRendering.getAddressesPerColumn())); + + MemoryByte bytes[] = fRendering.getBytes(cellAddress, + fRendering.getBytesPerColumn()); + + if(fRendering.getSelection().isSelected(cellAddress)) + { + gc.setBackground(fRendering.getTraditionalRendering().getColorSelection()); + gc.fillRectangle(cellWidth * col, cellHeight * i, + cellWidth, cellHeight); + + gc.setForeground(fRendering.getTraditionalRendering().getColorBackground()); + } + else + { + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + gc.fillRectangle(cellWidth * col, cellHeight * i, + cellWidth, cellHeight); + + // TODO reuse, this could be in the abstract base + // TODO consider adding finer granularity? + boolean anyByteChanged = false; + for(int n = 0; n < bytes.length && !anyByteChanged; n++) + if(bytes[n].isChanged()) + anyByteChanged = true; + + // TODO consider adding finer granularity? + boolean anyByteEditing = false; + for(int n = 0; n < bytes.length && !anyByteEditing; n++) + if(bytes[n] instanceof TraditionalMemoryByte) + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; + + if(anyByteEditing) + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + else if(anyByteChanged) + gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); + else if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + } + + gc.drawText(fRendering.formatText(bytes, + isLittleEndian, fRendering.getTextMode()), cellWidth * col, cellHeight * i + + fRendering.getCellPadding()); + + if(fRendering.isDebug()) + gc.drawRectangle(cellWidth * col, cellHeight * i + + fRendering.getCellPadding(), cellWidth, + cellHeight); + } + } + } + catch(Exception e) + { + fRendering.logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$ + } + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java new file mode 100644 index 00000000000..4d062859d00 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -0,0 +1,2803 @@ +/******************************************************************************* + * Copyright (c) 2006 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.IDebugEventSetListener; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.ui.memory.AbstractMemoryRendering; +import org.eclipse.debug.ui.memory.AbstractTableRendering; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.Slider; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.model.IWorkbenchAdapter; + +/** + * A memory rendering displaying memory in a traditional + * memory view look and feel, optimized for minimal IO traffic. + *

+ * requirements of the debug model implementation: + * - An IMemoryBlockExtension is required. + * + * Since it is not possible to size the memory block to match + * the size of the viewport, memory block change notification + * is not useful. Such events are ignored by this rendering. + * + * Value validation happens on a per character basis at edit time. + * A minor drawback to this approach, the user may have to decrement + * a less significant digit before being able to increment a more + * significant digit. + * + * TODO: - refactoring (reduce code duplication) + * - comments (javadoc) / clean up + * - unicode - the cell boundaries make multi-byte character display + * not so useful. the text pane could be reworked. or, maybe this + * style of memory view is not appropriate for unicode. + * - utf 16 support + *

+ */ + +public class TraditionalRendering extends AbstractMemoryRendering +{ + + Rendering fRendering; + + private Action displayEndianBigAction; + private Action displayEndianLittleAction; + + private IWorkbenchAdapter fWorkbenchAdapter; + + public TraditionalRendering(String id) + { + super(id); + + JFaceResources.getFontRegistry().addListener( + new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + if(event.getProperty().equals( + IInternalDebugUIConstants.FONT_NAME)) + { + TraditionalRendering.this.fRendering + .handleFontPreferenceChange(JFaceResources + .getFont(IInternalDebugUIConstants.FONT_NAME)); + } + } + }); + + this.addPropertyChangeListener(new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + IMemoryRendering sourceRendering = (IMemoryRendering) event + .getSource(); + if(!sourceRendering.getMemoryBlock().equals(getMemoryBlock())) + return; + + Object address = event.getNewValue(); + + if(event.getProperty().equals( + AbstractTableRendering.PROPERTY_SELECTED_ADDRESS) + && address instanceof BigInteger) + { + TraditionalRendering.this.fRendering + .ensureVisible((BigInteger) address); + } + } + }); + + TraditionalRenderingPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( + new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + disposeColors(); + allocateColors(); + applyPreferences(); + } + }); + + } + + public Control createControl(Composite parent) + { + allocateColors(); + + this.fRendering = new Rendering(parent, this); + + applyPreferences(); + + createMenus(); + + return this.fRendering; + } + + public void gotoAddress(BigInteger address) + { + this.fRendering.gotoAddress(address); + } + + private Color colorBackground; + private Color colorChanged; + private Color colorEdit; + private Color colorSelection; + private Color colorText; + private Color colorTextAlternate; + + public void allocateColors() + { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + + colorBackground = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND)); + + colorChanged = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED)); + + colorEdit = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_EDIT)); + + colorSelection = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_SELECTION)); + + colorText = new Color(Display.getDefault(), PreferenceConverter.getColor(store, + TraditionalRenderingPreferenceConstants.MEM_COLOR_TEXT)); + + // alternate cell color + Color textColor = getColorText(); + int red = textColor.getRed(); + int green = textColor.getGreen(); + int blue = textColor.getBlue(); + + float scale = (float) store.getInt( + TraditionalRenderingPreferenceConstants.MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS); + + red = (int) Math.min(red + ((255 - red) / 10) * scale, 255); + green = (int) Math.min(green + ((255 - green) / 10) * scale, 255); + blue = (int) Math.min(blue + ((255 - blue) / 10) * scale, 255); + + colorTextAlternate = new Color(Display.getDefault(), new RGB(red, green, blue)); + } + + public void disposeColors() + { + if(colorBackground != null) + colorBackground.dispose(); + colorBackground = null; + + if(colorChanged != null) + colorChanged.dispose(); + colorChanged = null; + + if(colorEdit != null) + colorEdit.dispose(); + colorEdit = null; + + if(colorSelection != null) + colorSelection.dispose(); + colorSelection = null; + + if(colorText != null) + colorText.dispose(); + colorText = null; + + if(colorTextAlternate != null) + colorTextAlternate.dispose(); + colorTextAlternate = null; + } + + public void applyPreferences() + { + fRendering.setBackground(getColorBackground()); + + AbstractPane panes[] = fRendering.getRenderingPanes(); + for(int i = 0; i < panes.length; i++) + panes[i].setBackground(getColorBackground()); + + fRendering.redrawPanes(); + } + + public Color getColorBackground() + { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + + if(store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND)) + return Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND); + else + return colorBackground; + } + + public Color getColorChanged() + { + return colorChanged; + } + + public Color getColorEdit() + { + return colorEdit; + } + + public Color getColorSelection() + { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + + if(store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_SELECTION)) + return Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION); + else + return colorSelection; + } + + public Color getColorText() + { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + + if(store.getBoolean(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_TEXT)) + return Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND); + else + return colorText; + } + + public Color getColorTextAlternate() + { + return colorTextAlternate; + } + + public void createMenus() + { + // add the menu to each of the rendering panes + Control[] renderingControls = this.fRendering.getRenderingPanes(); + for(int i = 0; i < renderingControls.length; i++) + super.createPopupMenu(renderingControls[i]); + super.createPopupMenu(this.fRendering); + + // copy + + final Action copyAction = new CopyAction(this.fRendering); + + // go to address + + final Action gotoAddressAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.GO_TO_ADDRESS")) //$NON-NLS-1$ + { + public void run() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + TraditionalRendering.this.fRendering + .setVisibleAddressBar(true); + } + }); + } + }; + gotoAddressAction.setAccelerator(SWT.CTRL | 'G'); + + // reset to base address + + final Action gotoBaseAddressAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.RESET_TO_BASE_ADDRESS")) //$NON-NLS-1$ + { + public void run() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + TraditionalRendering.this.fRendering + .gotoAddress(TraditionalRendering.this.fRendering.fBaseAddress); + } + }); + } + }; + + + // refresh + + final Action refreshAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.REFRESH")) //$NON-NLS-1$ + { + public void run() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + TraditionalRendering.this.fRendering.refresh(); + } + }); + } + }; + + // display address + + final Action displayAddressPaneAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.ADDRESS"), //$NON-NLS-1$ + IAction.AS_CHECK_BOX) + { + public void run() + { + TraditionalRendering.this.fRendering.setPaneVisible( + Rendering.PANE_ADDRESS, isChecked()); + } + }; + displayAddressPaneAction.setChecked(this.fRendering + .getPaneVisible(Rendering.PANE_ADDRESS)); + + // display hex + + final Action displayBinaryPaneAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.BINARY"), //$NON-NLS-1$ + IAction.AS_CHECK_BOX) + { + public void run() + { + TraditionalRendering.this.fRendering.setPaneVisible( + Rendering.PANE_BINARY, isChecked()); + } + }; + displayBinaryPaneAction.setChecked(this.fRendering + .getPaneVisible(Rendering.PANE_BINARY)); + + // display text + + final Action displayTextPaneAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.TEXT"), //$NON-NLS-1$ + IAction.AS_CHECK_BOX) + { + public void run() + { + TraditionalRendering.this.fRendering.setPaneVisible( + Rendering.PANE_TEXT, isChecked()); + } + }; + displayTextPaneAction.setChecked(this.fRendering + .getPaneVisible(Rendering.PANE_TEXT)); + + // display size + + final Action displaySize1BytesAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.1_BYTE"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setBytesPerColumn(1); + } + }; + displaySize1BytesAction + .setChecked(this.fRendering.getBytesPerColumn() == 1); + + final Action displaySize2BytesAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.2_BYTES"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering.setBytesPerColumn(2); + } + }; + displaySize2BytesAction + .setChecked(this.fRendering.getBytesPerColumn() == 2); + + final Action displaySize4BytesAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.4_BYTES"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering.setBytesPerColumn(4); + } + }; + displaySize4BytesAction + .setChecked(this.fRendering.getBytesPerColumn() == 4); + + final Action displaySize8BytesAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.8_BYTES"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering.setBytesPerColumn(8); + } + }; + displaySize8BytesAction + .setChecked(this.fRendering.getBytesPerColumn() == 8); + + // text / unicode ? + + final Action displayCharactersISO8859Action = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.ISO-8859-1"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setTextMode(Rendering.TEXT_ISO_8859_1); + } + }; + displayCharactersISO8859Action.setChecked(this.fRendering + .getTextMode() == Rendering.TEXT_ISO_8859_1); + + final Action displayCharactersUSASCIIAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.USASCII"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setTextMode(Rendering.TEXT_USASCII); + } + }; + displayCharactersUSASCIIAction.setChecked(this.fRendering + .getTextMode() == Rendering.TEXT_USASCII); + + final Action displayCharactersUTF8Action = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.UTF8"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering + .setTextMode(Rendering.TEXT_UTF8); + } + }; + displayCharactersUTF8Action.setChecked(this.fRendering + .getTextMode() == Rendering.TEXT_UTF8); + +// final Action displayCharactersUTF16Action = new Action( +// TraditionalRenderingMessages +// .getString("TraditionalRendering.UTF16"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ +// { +// @Override +// public void run() +// { +// TraditionalRendering.this.fRendering +// .setTextMode(Rendering.TEXT_UTF16); +// } +// }; +// displayCharactersUTF16Action.setChecked(this.fRendering +// .getTextMode() == Rendering.TEXT_UTF16); + + // endian + + displayEndianBigAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.BIG"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setLittleEndian(false); + } + }; + displayEndianBigAction.setChecked(!this.fRendering.isLittleEndian()); + + displayEndianLittleAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.LITTLE"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setLittleEndian(true); + } + }; + displayEndianLittleAction.setChecked(this.fRendering.isLittleEndian()); + + // radix + + final Action displayRadixHexAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.HEX"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setRadix(Rendering.RADIX_HEX); + } + }; + displayRadixHexAction + .setChecked(this.fRendering.getRadix() == Rendering.RADIX_HEX); + + final Action displayRadixDecSignedAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.DECIMAL_SIGNED"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering + .setRadix(Rendering.RADIX_DECIMAL_SIGNED); + } + }; + displayRadixDecSignedAction + .setChecked(this.fRendering.getRadix() == Rendering.RADIX_DECIMAL_SIGNED); + + final Action displayRadixDecUnsignedAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.DECIMAL_UNSIGNED"), IAction.AS_RADIO_BUTTON) //$NON-NLS-1$ + { + public void run() + { + TraditionalRendering.this.fRendering + .setRadix(Rendering.RADIX_DECIMAL_UNSIGNED); + } + }; + displayRadixDecUnsignedAction + .setChecked(this.fRendering.getRadix() == Rendering.RADIX_DECIMAL_UNSIGNED); + + final Action displayRadixOctAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.OCTAL"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setRadix(Rendering.RADIX_OCTAL); + } + }; + displayRadixOctAction + .setChecked(this.fRendering.getRadix() == Rendering.RADIX_OCTAL); + + final Action displayRadixBinAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.BINARY"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering + .setRadix(Rendering.RADIX_BINARY); + } + }; + displayRadixBinAction + .setChecked(this.fRendering.getRadix() == Rendering.RADIX_BINARY); + + getPopupMenuManager().addMenuListener(new IMenuListener() + { + public void menuAboutToShow(IMenuManager manager) + { + manager.add(new Separator()); + + MenuManager sub = new MenuManager( + TraditionalRenderingMessages + .getString("TraditionalRendering.PANES")); //$NON-NLS-1$ + sub.add(displayAddressPaneAction); + sub.add(displayBinaryPaneAction); + sub.add(displayTextPaneAction); + manager.add(sub); + + sub = new MenuManager(TraditionalRenderingMessages + .getString("TraditionalRendering.ENDIAN")); //$NON-NLS-1$ + sub.add(displayEndianBigAction); + sub.add(displayEndianLittleAction); + manager.add(sub); + + sub = new MenuManager(TraditionalRenderingMessages + .getString("TraditionalRendering.TEXT")); //$NON-NLS-1$ + sub.add(displayCharactersISO8859Action); + sub.add(displayCharactersUSASCIIAction); + sub.add(displayCharactersUTF8Action); + //sub.add(displayCharactersUTF16Action); + manager.add(sub); + + sub = new MenuManager(TraditionalRenderingMessages + .getString("TraditionalRendering.CELL_SIZE")); //$NON-NLS-1$ + sub.add(displaySize1BytesAction); + sub.add(displaySize2BytesAction); + sub.add(displaySize4BytesAction); + sub.add(displaySize8BytesAction); + manager.add(sub); + + sub = new MenuManager(TraditionalRenderingMessages + .getString("TraditionalRendering.RADIX")); //$NON-NLS-1$ + sub.add(displayRadixHexAction); + sub.add(displayRadixDecSignedAction); + sub.add(displayRadixDecUnsignedAction); + sub.add(displayRadixOctAction); + sub.add(displayRadixBinAction); + manager.add(sub); + manager.add(new Separator()); + + manager.add(copyAction); + + manager.add(gotoAddressAction); + manager.add(gotoBaseAddressAction); + manager.add(refreshAction); + manager.add(new Separator()); + manager.add(new Separator( + IWorkbenchActionConstants.MB_ADDITIONS)); + } + }); + + } + + public Control getControl() + { + return this.fRendering; + } + + protected void bytesAreLittleEndian(boolean areLE) + { + // once we actually read memory we can determine the + // endianess and need to set these actions accordingly. + displayEndianBigAction.setChecked(!areLE); + displayEndianLittleAction.setChecked(areLE); + } + + public void dispose() + { + if(this.fRendering != null) + this.fRendering.dispose(); + super.dispose(); + } + + public Object getAdapter(Class adapter) + { + + if(adapter == IWorkbenchAdapter.class) + { + if(this.fWorkbenchAdapter == null) + { + this.fWorkbenchAdapter = new IWorkbenchAdapter() + { + public Object[] getChildren(Object o) + { + return new Object[0]; + } + + public ImageDescriptor getImageDescriptor(Object object) + { + return null; + } + + public String getLabel(Object o) + { + return TraditionalRenderingMessages + .getString("TraditionalRendering.RENDERING_NAME"); //$NON-NLS-1$ + } + + public Object getParent(Object o) + { + return null; + } + }; + } + return this.fWorkbenchAdapter; + } + + return super.getAdapter(adapter); + } + +} + + +/* + * A place holder address bar for go to address. For consistency, + * this will eventually be replaced by a standard memory view + * address bar. + */ + +class AddressBar extends Composite +{ + Text fTextControl; + + Label fLabelControl; + + private final static int DUMMY_WIDTH = 100; + + public AddressBar(final Rendering rendering) + { + super(rendering, SWT.BORDER); + + this.fLabelControl = new Label(this, SWT.SINGLE); + this.fTextControl = new Text(this, SWT.SINGLE); + + GridData layoutData = new GridData(); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + layout.marginHeight = 0; + layout.marginLeft = 0; + + this.setLayout(layout); + + layoutData.horizontalAlignment = SWT.FILL; + layoutData.grabExcessHorizontalSpace = true; + layoutData.grabExcessVerticalSpace = true; + + fLabelControl.setText(TraditionalRenderingMessages + .getString("TraditionalRendering.GO_TO_ADDRESS")); //$NON-NLS-1$ + + this.fTextControl.setLayoutData(layoutData); + + this.fTextControl.addFocusListener(new FocusListener() + { + public void focusGained(FocusEvent e) + { + // do nothing + } + + public void focusLost(FocusEvent e) + { + rendering.setVisibleAddressBar(false); + } + }); + + this.fTextControl.addKeyListener(new KeyListener() + { + public void keyPressed(KeyEvent ke) + { + if(ke.keyCode == SWT.ESC) + { + rendering.setVisibleAddressBar(false); + } + else if(ke.character == '\r') + { + int radix = 10; + String s = fTextControl.getText().trim(); + if(s.toUpperCase().indexOf("0X") >= 0) //$NON-NLS-1$ + { + s = s.substring(2); + radix = 16; + } + try + { + BigInteger newAddress = new BigInteger(s, radix); + rendering.setVisibleAddressBar(false); + rendering.gotoAddress(newAddress); + } + catch(Exception e) + { + // do nothing + } + + } + } + + public void keyReleased(KeyEvent ke) + { + // do nothing + } + }); + } + + public void setText(String data) + { + this.fTextControl.setText(data); + this.fTextControl.forceFocus(); + this.fTextControl.selectAll(); + } + + public Point computeSize(int wHint, int hHint) + { + return new Point(DUMMY_WIDTH, this.fTextControl.computeSize(10, 24, + true).y); + } +} + +class TraditionalMemoryByte extends MemoryByte +{ + private boolean isEdited = false; + + public TraditionalMemoryByte(byte byteValue) + { + super(byteValue); + } + + public boolean isEdited() + { + return isEdited; + } + + public void setEdited(boolean edited) + { + isEdited = edited; + } +} + +class Rendering extends Composite implements IDebugEventSetListener +{ + // the IMemoryRendering parent + private TraditionalRendering fParent; + + // controls + private Slider fScrollBar; + + private AddressPane fAddressPane; + + private DataPane fBinaryPane; + + private TextPane fTextPane; + + private AddressBar fAddressBar; + + private Selection fSelection = new Selection(); + + // storage + + BigInteger fViewportAddress = null; // default visibility for performance + + BigInteger fMemoryBlockStartAddress = null; + BigInteger fMemoryBlockEndAddress = null; + + BigInteger fBaseAddress = null; // remember the base address + + private int fColumnCount = 0; // auto calculate can be disabled by user, + // making this user settable + + private int fBytesPerRow = 0; // current number of bytes per row are displayed + + private int fCurrentScrollSelection = 0; // current scroll selection; + + // user settings + + private int fTextMode = 1; // ASCII default, TODO make preference? + + private int fBytesPerColumn = 4; // 4 byte cell width default + + private int fRadix = RADIX_HEX; + + private boolean fLittleEndian = false; + + private boolean fCheckedLittleEndian = false; + + // constants used to identify radix + protected final static int RADIX_HEX = 1; + + protected final static int RADIX_DECIMAL_SIGNED = 2; + + protected final static int RADIX_DECIMAL_UNSIGNED = 3; + + protected final static int RADIX_OCTAL = 4; + + protected final static int RADIX_BINARY = 5; + + // constants used to identify panes + protected final static int PANE_ADDRESS = 1; + + protected final static int PANE_BINARY = 2; + + protected final static int PANE_TEXT = 3; + + // constants used to identify text, maybe java should be queried for all available sets + protected final static int TEXT_ISO_8859_1 = 1; + protected final static int TEXT_USASCII = 2; + protected final static int TEXT_UTF8 = 3; + protected final static int TEXT_UTF16 = 4; + + // view internal settings + private int fCellPadding = 2; + + private int fPaneSpacing = 16; + + public Rendering(Composite parent, + TraditionalRendering renderingParent) + { + super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND); + + this.setFont(JFaceResources + .getFont(IInternalDebugUIConstants.FONT_NAME)); // TODO internal? + + this.fParent = renderingParent; + + // instantiate the panes, TODO default visibility from state or + // plugin.xml? + this.fAddressPane = new AddressPane(this); + this.fBinaryPane = new DataPane(this); + this.fTextPane = new TextPane(this); + + // FIXME temporary address bar; will be replaced by standard Memory bar + this.fAddressBar = new AddressBar(this); + this.fAddressBar.setVisible(false); + + // initialize the viewport start + IMemoryBlockExtension memoryBlock = getMemoryBlock(); + if(memoryBlock != null) + { + try + { + fViewportAddress = memoryBlock.getMemoryBlockStartAddress(); + // this will be null if memory may be retrieved at any address less than + // this memory block's base. if so use the base address. + if (fViewportAddress == null) + fViewportAddress = memoryBlock.getBigBaseAddress(); + fBaseAddress = fViewportAddress; + } + catch(DebugException e) + { + fViewportAddress = null; + if(isDebug()) + Rendering.this + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), e); //$NON-NLS-1$ + } + } + + fScrollBar = new Slider(this, SWT.V_SCROLL); + fScrollBar.addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent se) + { + int addressableSize = getAddressableSize(); + + switch(se.detail) + { + case SWT.ARROW_DOWN: + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.PAGE_DOWN: + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.ARROW_UP: + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.PAGE_UP: + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.SCROLL_LINE: + if(fScrollBar.getSelection() == fScrollBar.getMinimum()) + { + // Set view port start address to the start address of the Memory Block + fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); + } + else if(fScrollBar.getSelection() == fScrollBar.getMaximum()) + { + // The view port end address should be less or equal to the the end address of the Memory Block + // Set view port address to be bigger than the end address of the Memory Block for now + // and let ensureViewportAddressDisplayable() to figure out the correct view port start address + fViewportAddress = Rendering.this.getMemoryBlockEndAddress(); + } + else + { + // Figure out the delta + int delta = fScrollBar.getSelection() - fCurrentScrollSelection; + fViewportAddress = fViewportAddress.add(BigInteger.valueOf( + getAddressableCellsPerRow() * delta)); + } + ensureViewportAddressDisplayable(); + // Update tooltip + fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + // Update the addresses on the Address pane. + // Do not update the Binary and Text panes until dragging of the thumb nail stops + if(fAddressPane.isPaneVisible()) + { + fAddressPane.redraw(); + } + break; + case SWT.NONE: + // Dragging of the thumb nail stops. Redraw the panes + redrawPanes(); + break; + } + + } + + public void widgetDefaultSelected(SelectionEvent se) + { + // do nothing + } + }); + + this.addPaintListener(new PaintListener() + { + public void paintControl(PaintEvent pe) + { + pe.gc.setBackground(Rendering.this.getTraditionalRendering().getColorBackground()); + pe.gc.fillRectangle(0, 0, Rendering.this.getBounds().width, + Rendering.this.getBounds().height); + } + }); + + this.setLayout(new Layout() + { + public void layout(Composite composite, boolean changed) + { + int x = 0; + int y = 0; + + if(fAddressBar.isVisible()) + { + fAddressBar.setBounds(0, 0, + Rendering.this.getBounds().width, fAddressBar + .computeSize(1, 1).y); + y = fAddressBar.getBounds().height; + } + + if(fAddressPane.isPaneVisible()) + { + fAddressPane.setBounds(0, y, + fAddressPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fAddressPane.getBounds().x + + fAddressPane.getBounds().width; + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.setBounds(x, y, + fBinaryPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fBinaryPane.getBounds().x + + fBinaryPane.getBounds().width; + } + + Point scrollBarPreferredSize = fScrollBar.computeSize(20, + Rendering.this.getBounds().height); + + if(fTextPane.isPaneVisible()) + { + fTextPane.setBounds(x, y, Rendering.this.getBounds().width + - x - scrollBarPreferredSize.x, Rendering.this + .getBounds().height + - y); + } + + fScrollBar.setBounds(Rendering.this.getBounds().width + - scrollBarPreferredSize.x, y, scrollBarPreferredSize.x, + Rendering.this.getBounds().height - y); + + fScrollBar.moveAbove(null); + } + + protected Point computeSize(Composite composite, int wHint, + int hHint, boolean flushCache) + { + return new Point(100, 100); // dummy data + } + }); + + this.addControlListener(new ControlListener() + { + public void controlMoved(ControlEvent ce) + { + } + + public void controlResized(ControlEvent ce) + { + packColumns(); + } + }); + + DebugPlugin.getDefault().addDebugEventListener(this); + } + + protected TraditionalRendering getTraditionalRendering() // TODO rename + { + return fParent; + } + + // Ensure that all addresses displayed are within the addressable range + protected void ensureViewportAddressDisplayable() + { + if(fViewportAddress.compareTo(Rendering.this.getMemoryBlockStartAddress()) < 0) + { + fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); + } + else if(getViewportEndAddress().compareTo(getMemoryBlockEndAddress().add(BigInteger.ONE)) > 0) + { + fViewportAddress = getMemoryBlockEndAddress().subtract(BigInteger.valueOf(getAddressableCellsPerRow() + * getRowCount() - 1)); + } + + setCurrentScrollSelection(); + } + + protected Selection getSelection() + { + return fSelection; + } + + protected void logError(String message, Exception e) + { + Status status = new Status(IStatus.ERROR, fParent.getRenderingId(), + DebugException.INTERNAL_ERROR, message, e); + + DebugUIPlugin.getDefault().getLog().log(status); + } + + public void handleFontPreferenceChange(Font font) + { + setFont(font); + + Control controls[] = this.getRenderingPanes(); + for(int i = 0; i < controls.length; i++) + controls[i].setFont(font); + + packColumns(); + redrawPanes(); + } + + public void handleDebugEvents(DebugEvent[] events) + { + for(int i = 0; i < events.length; i++) + { + if(events[0].getSource() instanceof IDebugElement) + { + final int kind = events[i].getKind(); + final int detail = events[i].getDetail(); + final IDebugElement source = (IDebugElement) events[i] + .getSource(); + + // TODO allow extensible customization of event handling; + // integration with user configurable update policies should happen here. + if(source.getDebugTarget() == getMemoryBlock() + .getDebugTarget()) + { + if(kind == DebugEvent.SUSPEND && detail == 0) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + refresh(); + } + }); + } + else if(kind == DebugEvent.CHANGE) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + refresh(); + } + }); + } + else if(kind == DebugEvent.RESUME) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + archiveDeltas(); + } + }); + } + } + } + } + } + + // return true to enable development debug print statements + protected boolean isDebug() + { + return false; + } + + protected IMemoryBlockExtension getMemoryBlock() + { + IMemoryBlock block = fParent.getMemoryBlock(); + if(block != null) + return (IMemoryBlockExtension) block + .getAdapter(IMemoryBlockExtension.class); + + return null; + } + + protected int getAddressableSize() + { + try + { + return getMemoryBlock().getAddressableSize(); + } + catch(DebugException e) + { + return 1; + } + } + + protected ViewportCache getViewportCache() + { + return fViewportCache; + } + + protected MemoryByte[] getBytes(BigInteger address, int bytes) + throws DebugException + { + return fViewportCache.getBytes(address, bytes); + } + + // default visibility for performance + ViewportCache fViewportCache = new ViewportCache(); + + private interface Request + { + } + + class ViewportCache extends Thread + { + class ArchiveDeltas implements Request + { + + } + + class AddressPair implements Request + { + BigInteger startAddress; + + BigInteger endAddress; + } + + class MemoryUnit + { + BigInteger start; + + BigInteger end; + + MemoryByte[] bytes; + + public MemoryUnit clone() + { + MemoryUnit b = new MemoryUnit(); + + b.start = this.start; + b.end = this.end; + b.bytes = new MemoryByte[this.bytes.length]; + for(int i = 0; i < this.bytes.length; i++) + b.bytes[i] = new MemoryByte(this.bytes[i].getValue()); + + return b; + } + + public boolean isValid() + { + return this.start != null && this.end != null + && this.bytes != null; + } + } + + private HashMap fEditBuffer = new HashMap(); + + private boolean fDisposed = false; + + private Vector fQueue = new Vector(); + + protected MemoryUnit fCache = null; + + protected MemoryUnit fHistoryCache = null; + + public ViewportCache() + { + start(); + } + + public void dispose() + { + fDisposed = true; + synchronized(this) + { + this.notify(); + } + } + + protected void refresh() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(fCache != null) + { + queueRequest(fViewportAddress, getViewportEndAddress()); + } + } + + protected void archiveDeltas() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(fCache != null) + { + queueRequestArchiveDeltas(); + } + } + + + + private void queueRequest(BigInteger startAddress, BigInteger endAddress) + { + AddressPair pair = new AddressPair(); + pair.startAddress = startAddress; + pair.endAddress = endAddress; + synchronized(fQueue) + { + fQueue.addElement(pair); + } + synchronized(this) + { + this.notify(); + } + } + + private void queueRequestArchiveDeltas() + { + ArchiveDeltas archive = new ArchiveDeltas(); + synchronized(fQueue) + { + fQueue.addElement(archive); + } + synchronized(this) + { + this.notify(); + } + } + + public void run() + { + while(!fDisposed) + { + AddressPair pair = null; + boolean archiveDeltas = false; + synchronized(fQueue) + { + if(fQueue.size() > 0) + { + Request request = (Request) fQueue.elementAt(0); + Class type = null; + if(request instanceof ArchiveDeltas) + { + archiveDeltas = true; + type = ArchiveDeltas.class; + } + else if(request instanceof AddressPair) + { + pair = (AddressPair) request; + type = AddressPair.class; + } + + while(fQueue.size() > 0 && type.isInstance(fQueue.elementAt(0))) + fQueue.removeElementAt(0); + } + } + if(archiveDeltas) + { + fHistoryCache = fCache.clone(); + } + else if(pair != null) + { + populateCache(pair.startAddress, pair.endAddress); + } + else + { + synchronized(this) + { + try + { + this.wait(); + } + catch(Exception e) + { + // do nothing + } + } + } + } + } + + // cache memory necessary to paint viewport + // TODO: user setting to buffer +/- x lines + // TODO: reuse existing cache? probably only a minor performance gain + private void populateCache(final BigInteger startAddress, + final BigInteger endAddress) + { + try + { + final IMemoryBlockExtension memoryBlock = getMemoryBlock(); + + final BigInteger lengthInBytes = endAddress.subtract(startAddress); + final BigInteger addressableSize = BigInteger.valueOf(getAddressableSize()); + + final long units = lengthInBytes.divide(addressableSize).add( + lengthInBytes.mod(addressableSize).compareTo(BigInteger.ZERO) > 0 + ? BigInteger.ONE : BigInteger.ZERO).longValue(); + + // CDT (and maybe other backends) will call setValue() on these MemoryBlock objects. + // We don't want this to happen, because it interferes with this rendering's own + // change history. Ideally, we should strictly use the back end change notification + // and history, but it is only guaranteed to work for bytes within the address range + // of the MemoryBlock. + final MemoryByte readBytes[] = memoryBlock + .getBytesFromAddress(startAddress, units); + + final MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; + for(int i = 0; i < readBytes.length; i++) + cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); + + // we need to set the default endianess. before it was set to BE + // by default which wasn't very useful for LE targets. now we will + // query the first byte to get the endianess. if not known then we'll + // leave it as BE. note that we only do this when reading the first + // bit of memory for this rendering. what happens when scrolling + // through memory and it changes endianess? for now we just leave + // it in the original endianess. + if (!fCheckedLittleEndian && cachedBytes.length > 0) { + if (cachedBytes[0].isEndianessKnown()) { + fLittleEndian = !cachedBytes[0].isBigEndian(); + fCheckedLittleEndian = true; + fParent.bytesAreLittleEndian(fLittleEndian); + } + } + + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + // generate deltas + if(fHistoryCache != null && fHistoryCache.isValid()) + { + BigInteger maxStart = startAddress + .max(fHistoryCache.start); + BigInteger minEnd = endAddress + .min(fHistoryCache.end).subtract( + BigInteger.valueOf(1)); + + BigInteger overlapLength = minEnd + .subtract(maxStart); + if(overlapLength.compareTo(BigInteger.valueOf(0)) > 0) + { + // there is overlap + + int offsetIntoOld = maxStart.subtract( + fHistoryCache.start).intValue(); + int offsetIntoNew = maxStart.subtract( + startAddress).intValue(); + + for(int i = overlapLength.intValue(); i >= 0; i--) + { + cachedBytes[offsetIntoNew + i] + .setChanged(cachedBytes[offsetIntoNew + + i].getValue() != fHistoryCache.bytes[offsetIntoOld + + i].getValue()); + } + } + } + + fCache = new MemoryUnit(); + fCache.start = startAddress; + fCache.end = endAddress; + fCache.bytes = cachedBytes; + + Rendering.this.redrawPanes(); + } + }); + + } + catch(Exception e) + { + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_READ_MEMORY"), e); //$NON-NLS-1$ + } + } + + // bytes will be fetched from cache + protected MemoryByte[] getBytes(BigInteger address, int bytesRequested) + throws DebugException + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(containsEditedCell(address)) // cell size cannot be switched during an edit + return getEditedMemory(address); + + IMemoryBlockExtension memoryBlock = getMemoryBlock(); + + boolean contains = false; + if(fCache != null && fCache.start != null) + { + // see if all of the data requested is in the cache + BigInteger dataEnd = address.add(BigInteger.valueOf(bytesRequested)); + + if(fCache.start.compareTo(address) <= 0 + && fCache.end.compareTo(dataEnd) >= 0) + contains = true; + } + + if(contains) + { + int offset = address.subtract(fCache.start).intValue(); + MemoryByte bytes[] = new MemoryByte[bytesRequested]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = fCache.bytes[offset + i]; + } + + return bytes; + } + + MemoryByte bytes[] = new MemoryByte[bytesRequested]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = new MemoryByte(); + bytes[i].setReadable(false); + } + + fViewportCache.queueRequest(fViewportAddress, + getViewportEndAddress()); + + return bytes; + } + + private boolean containsEditedCell(BigInteger address) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + return fEditBuffer.containsKey(address); + } + + private MemoryByte[] getEditedMemory(BigInteger address) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + return (MemoryByte[]) fEditBuffer.get(address); + } + + protected void clearEditBuffer() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + fEditBuffer.clear(); + Rendering.this.redrawPanes(); + } + + protected void writeEditBuffer() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + Set keySet = fEditBuffer.keySet(); + Iterator iterator = keySet.iterator(); + + while(iterator.hasNext()) + { + try + { + BigInteger address = (BigInteger) iterator.next(); + MemoryByte[] bytes = (MemoryByte[]) fEditBuffer + .get(address); + + byte byteValue[] = new byte[bytes.length]; + for(int i = 0; i < bytes.length; i++) + byteValue[i] = bytes[i].getValue(); + + getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); + } + catch(Exception e) + { + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), e); //$NON-NLS-1$ + } + } + + clearEditBuffer(); + } + + protected void setEditedValue(BigInteger address, MemoryByte[] bytes) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + fEditBuffer.put(address, bytes); + Rendering.this.redrawPanes(); + } + } + + public void setVisibleAddressBar(boolean visible) + { + fAddressBar.setVisible(visible); + layout(true); + layoutPanes(); + fAddressBar.layout(true); + fAddressBar.setText(getAddressString(getViewportStartAddress())); + } + + public void dispose() + { + if(fViewportCache != null) + { + fViewportCache.dispose(); + fViewportCache = null; + } + super.dispose(); + } + + class Selection + { + private BigInteger fStartHigh; + private BigInteger fStartLow; + + private BigInteger fEndHigh; + private BigInteger fEndLow; + + protected void clear() + { + fEndHigh = fEndLow = fStartHigh = fStartLow = null; + redrawPanes(); + } + + protected boolean isSelected(BigInteger address) + { + // do we have valid start and end addresses + if(getEnd() == null || getStart() == null) + return false; + + // if end is greater than start + if(getEnd().compareTo(getStart()) >= 0) + { + if(address.compareTo(getStart()) >= 0 + && address.compareTo(getEnd()) < 0) + return true; + } + // if start is greater than end + else if(getStart().compareTo(getEnd()) >= 0) + { + if(address.compareTo(getEnd()) >= 0 + && address.compareTo(getStart()) < 0) + return true; + } + + return false; + } + + protected void setStart(BigInteger high, BigInteger low) + { + if(high == null && low == null) + { + if(fStartHigh != null && fStartLow != null) + { + fStartHigh = null; + fStartLow = null; + redrawPanes(); + } + + return; + } + + boolean changed = false; + + if(fStartHigh == null || !high.equals(fStartHigh)) + { + fStartHigh = high; + changed = true; + } + + if(fStartLow == null || !low.equals(fStartLow)) + { + fStartLow = low; + changed = true; + } + + if(changed) + redrawPanes(); + } + + protected void setEnd(BigInteger high, BigInteger low) + { + if(high == null && low == null) + { + if(fEndHigh != null && fEndLow != null) + { + fEndHigh = null; + fEndLow = null; + redrawPanes(); + } + + return; + } + + boolean changed = false; + + if(fEndHigh == null || !high.equals(fEndHigh)) + { + fEndHigh = high; + changed = true; + } + + if(fEndLow == null || !low.equals(fEndLow)) + { + fEndLow = low; + changed = true; + } + + if(changed) + redrawPanes(); + } + + protected BigInteger getStart() + { + // if there is no start, return null + if(fStartHigh == null) + return null; + + // if there is no end, return the high address of the start + if(fEndHigh == null) + return fStartHigh; + + // if Start High/Low equal End High/Low, return a low start and high end + if(fStartHigh.equals(fEndHigh) + && fStartLow.equals(fEndLow)) + return fStartLow; + + BigInteger differenceEndToStartHigh = fEndHigh.subtract(fStartHigh).abs(); + BigInteger differenceEndToStartLow = fEndHigh.subtract(fStartLow).abs(); + + // return the start high or start low based on which creates a larger selection + if(differenceEndToStartHigh.compareTo(differenceEndToStartLow) > 0) + return fStartHigh; + else + return fStartLow; + } + + protected BigInteger getEnd() + { + // if there is no end, return null + if(fEndHigh == null) + return null; + + // if Start High/Low equal End High/Low, return a low start and high end + if(fStartHigh.equals(fEndHigh) + && fStartLow.equals(fEndLow)) + return fStartHigh; + + BigInteger differenceStartToEndHigh = fStartHigh.subtract(fEndHigh).abs(); + BigInteger differenceStartToEndLow = fStartHigh.subtract(fEndLow).abs(); + + // return the start high or start low based on which creates a larger selection + if(differenceStartToEndHigh.compareTo(differenceStartToEndLow) >= 0) + return fEndHigh; + else + return fEndLow; + } + } + + protected void setPaneVisible(int pane, boolean visible) + { + switch(pane) + { + case PANE_ADDRESS: + fAddressPane.setPaneVisible(visible); + break; + case PANE_BINARY: + fBinaryPane.setPaneVisible(visible); + break; + case PANE_TEXT: + fTextPane.setPaneVisible(visible); + break; + } + + fireSettingsChanged(); + layoutPanes(); + } + + protected boolean getPaneVisible(int pane) + { + switch(pane) + { + case PANE_ADDRESS: + return fAddressPane.isPaneVisible(); + case PANE_BINARY: + return fBinaryPane.isPaneVisible(); + case PANE_TEXT: + return fTextPane.isPaneVisible(); + default: + return false; + } + } + + protected void packColumns() + { + int availableWidth = Rendering.this.getSize().x; + + if(fAddressPane.isPaneVisible()) + { + availableWidth -= fAddressPane.computeSize(0, 0).x; + availableWidth -= Rendering.this.getRenderSpacing() * 2; + } + + int combinedWidth = 0; + + if(fBinaryPane.isPaneVisible()) + combinedWidth += fBinaryPane.getCellWidth(); + + if(fTextPane.isPaneVisible()) + combinedWidth += fTextPane.getCellWidth(); + + if(combinedWidth == 0) + fColumnCount = 0; + else + { + fColumnCount = availableWidth / combinedWidth; + if(fColumnCount == 0) + fColumnCount = 1; // paint one column even if only part can show in view + } + + try + { + // Update the number of bytes per row; + // the max and min scroll range and the current thumb nail position. + fBytesPerRow = getBytesPerColumn() * getColumnCount(); + BigInteger difference = getMemoryBlockEndAddress().subtract(getMemoryBlockStartAddress()).add(BigInteger.ONE); + BigInteger maxScrollRange = difference.divide(BigInteger.valueOf(getAddressableCellsPerRow())); + if(maxScrollRange.multiply(BigInteger.valueOf(getAddressableCellsPerRow())).compareTo(difference) != 0) + maxScrollRange = maxScrollRange.add(BigInteger.ONE); + + // support targets with an addressable size greater than 1 + maxScrollRange = maxScrollRange.divide(BigInteger.valueOf(getAddressableSize())); + + fScrollBar.setMinimum(1); + fScrollBar.setMaximum(maxScrollRange.intValue()); + fScrollBar.setIncrement(1); + fScrollBar.setPageIncrement(this.getRowCount()-1); + fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + setCurrentScrollSelection(); + } + catch(Exception e) + { + // FIXME precautionary + } + + Rendering.this.redraw(); + Rendering.this.redrawPanes(); + } + + protected AbstractPane[] getRenderingPanes() + { + return new AbstractPane[] { fAddressPane, fBinaryPane, + fTextPane }; + } + + protected int getCellPadding() + { + return fCellPadding; + } + + protected int getRenderSpacing() + { + return fPaneSpacing; + } + + protected void refresh() + { + fViewportCache.refresh(); + } + + protected void archiveDeltas() + { + fViewportCache.archiveDeltas(); + } + + protected void gotoAddress(BigInteger address) + { + // Ensure that the GoTo address is within the addressable range + if((address.compareTo(this.getMemoryBlockStartAddress())< 0) || + (address.compareTo(this.getMemoryBlockEndAddress()) > 0)) + { + return; + } + + fViewportAddress = address; // TODO update fCaretAddress + redrawPanes(); + } + + protected void setViewportStartAddress(BigInteger newAddress) + { + fViewportAddress = newAddress; + } + + protected BigInteger getViewportStartAddress() + { + return fViewportAddress; + } + + protected BigInteger getViewportEndAddress() + { + return fViewportAddress.add(BigInteger.valueOf(this.getBytesPerRow() * getRowCount() / getAddressableSize())); + } + + protected String getAddressString(BigInteger address) + { + StringBuffer addressString = new StringBuffer(address.toString(16) + .toUpperCase()); + for(int chars = getAddressBytes() * 2 - addressString.length(); chars > 0; chars--) + { + addressString.insert(0, '0'); + } + addressString.insert(0, "0x"); //$NON-NLS-1$ + + return addressString.toString(); + } + + private int fAddressBytes = -1; // called often, cache + + protected int getAddressBytes() + { + if(fAddressBytes == -1) + { + try + { + IMemoryBlockExtension block = getMemoryBlock(); + fAddressBytes = block.getAddressSize(); + } + catch(DebugException e) + { + fAddressBytes = 0; + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE"), e); //$NON-NLS-1$ + } + } + + return fAddressBytes; + } + + protected int getColumnCount() + { + return fColumnCount; + } + + protected void ensureVisible(BigInteger address) + { + BigInteger viewportStart = this.getViewportStartAddress(); + BigInteger viewportEnd = this.getViewportEndAddress(); + + boolean isAddressBeforeViewportStart = address.compareTo(viewportStart) < 0; + boolean isAddressAfterViewportEnd = address.compareTo(viewportEnd) > 0; + + if(isAddressBeforeViewportStart || isAddressAfterViewportEnd) + gotoAddress(address); + } + + protected int getRowCount() + { + int rowCount = 0; + Control panes[] = getRenderingPanes(); + for(int i = 0; i < panes.length; i++) + { + if(panes[i] instanceof AbstractPane) + rowCount = Math.max(rowCount, + ((AbstractPane) panes[i]).getRowCount()); + } + + return rowCount; + } + + protected int getBytesPerColumn() + { + return fBytesPerColumn; + } + + protected int getBytesPerRow() + { + return fBytesPerRow; + } + + protected int getAddressableCellsPerRow() + { + return getBytesPerRow() / getAddressableSize(); + } + + protected int getAddressesPerColumn() + { + return this.getBytesPerColumn() / getAddressableSize(); + } + + /** + * @return Set current scroll selection + */ + protected void setCurrentScrollSelection() + { + BigInteger selection = getViewportStartAddress().divide( + BigInteger.valueOf(getAddressableCellsPerRow()).add(BigInteger.ONE)); + fScrollBar.setSelection(selection.intValue()); + fCurrentScrollSelection = selection.intValue(); + } + + /** + * @return start address of the memory block + */ + protected BigInteger getMemoryBlockStartAddress() + { + if (fMemoryBlockStartAddress == null) + { + try { + IMemoryBlock memoryBlock = this.getMemoryBlock(); + if(memoryBlock instanceof IMemoryBlockExtension) + { + BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); + if (startAddress != null) + fMemoryBlockStartAddress = startAddress; + } + } catch (DebugException e) { + fMemoryBlockStartAddress = null; + } + + // default to 0 if we have trouble getting the start address + if (fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = BigInteger.valueOf(0); + } + return fMemoryBlockStartAddress; + } + + /** + * @return end address of the memory block + */ + protected BigInteger getMemoryBlockEndAddress() + { + if (fMemoryBlockEndAddress == null) + { + IMemoryBlock memoryBlock = this.getMemoryBlock(); + if(memoryBlock instanceof IMemoryBlockExtension) + { + BigInteger endAddress; + try { + endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); + if (endAddress != null) + fMemoryBlockEndAddress = endAddress; + } catch (DebugException e) { + fMemoryBlockEndAddress = null; + } + + if (fMemoryBlockEndAddress == null) + { + int addressSize; + try { + addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); + } catch (DebugException e) { + addressSize = 4; + } + + endAddress = BigInteger.valueOf(2); + endAddress = endAddress.pow(addressSize*8); + endAddress = endAddress.subtract(BigInteger.valueOf(1)); + fMemoryBlockEndAddress = endAddress; + } + } + + // default to MAX_VALUE if we have trouble getting the end address + if (fMemoryBlockEndAddress == null) + fMemoryBlockEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); + } + return fMemoryBlockEndAddress; + } + + protected int getRadix() + { + return fRadix; + } + + protected int getNumericRadix(int radix) + { + switch(radix) + { + case RADIX_BINARY: + return 2; + case RADIX_OCTAL: + return 8; + case RADIX_DECIMAL_SIGNED: + case RADIX_DECIMAL_UNSIGNED: + return 10; + case RADIX_HEX: + return 16; + } + + return -1; + } + + protected void setRadix(int mode) + { + if(fRadix == mode) + return; + + fRadix = mode; + fireSettingsChanged(); + layoutPanes(); + } + + protected void setTextMode(int mode) + { + fTextMode = mode; + + fireSettingsChanged(); + layoutPanes(); + } + + protected int getTextMode() + { + return fTextMode; + } + + protected String getCharacterSet(int mode) + { + switch(mode) + { + case Rendering.TEXT_UTF8: + return "UTF8"; + case Rendering.TEXT_UTF16: + return "UTF16"; + case Rendering.TEXT_USASCII: + return "US-ASCII"; + case Rendering.TEXT_ISO_8859_1: + default: + return "ISO-8859-1"; + } + } + + protected int getBytesPerCharacter() + { + if(fTextMode == Rendering.TEXT_UTF16) + return 2; + + return 1; + } + + protected boolean isLittleEndian() + { + return fLittleEndian; + } + + protected void setLittleEndian(boolean enable) + { + if(fLittleEndian == enable) + return; + + fLittleEndian = enable; + fireSettingsChanged(); + layoutPanes(); + } + + protected void setBytesPerColumn(int byteCount) + { + if(fBytesPerColumn != byteCount) + { + fBytesPerColumn = byteCount; + fireSettingsChanged(); + layoutPanes(); + } + } + + protected void redrawPanes() + { + if(fAddressPane.isPaneVisible()) + { + fAddressPane.redraw(); + fAddressPane.setRowCount(); + if(fAddressPane.isFocusControl()) + fAddressPane.updateCaret(); + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.redraw(); + fBinaryPane.setRowCount(); + if(fBinaryPane.isFocusControl()) + fBinaryPane.updateCaret(); + } + + if(fTextPane.isPaneVisible()) + { + fTextPane.redraw(); + fTextPane.setRowCount(); + if(fTextPane.isFocusControl()) + fTextPane.updateCaret(); + } + } + + private void layoutPanes() + { + packColumns(); + layout(true); + + redraw(); + redrawPanes(); + } + + private void fireSettingsChanged() + { + fAddressPane.settingsChanged(); + fBinaryPane.settingsChanged(); + fTextPane.settingsChanged(); + } + + static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + protected String getRadixText(MemoryByte bytes[], int radix, + boolean isLittleEndian) + { + boolean readable = true; + for(int i = 0; i < bytes.length; i++) + if(!bytes[i].isReadable()) + readable = false; + + if(readable) + { + // see if we need to swap the data or not. if the bytes are BE + // and we want to view in LE then we need to swap. if the bytes + // are LE and we want to view BE then we need to swap. + boolean needsSwap = false; + boolean bytesAreLittleEndian = !bytes[0].isBigEndian(); + if ((isLittleEndian && !bytesAreLittleEndian) || (!isLittleEndian && bytesAreLittleEndian)) + needsSwap = true; + + switch(radix) + { + case Rendering.RADIX_HEX: + case Rendering.RADIX_OCTAL: + case Rendering.RADIX_BINARY: + { + long value = 0; + if(needsSwap) + { + for(int i = 0; i < bytes.length; i++) + { + value = value << 8; + value = value + | (bytes[bytes.length - 1 - i].getValue() & 0xFF); + } + } + else + { + for(int i = 0; i < bytes.length; i++) + { + value = value << 8; + value = value | (bytes[i].getValue() & 0xFF); + } + } + + char buf[] = new char[getRadixCharacterCount(radix, + bytes.length)]; + + switch(radix) + { + case Rendering.RADIX_BINARY: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 1)]; + value = value >>> 1; + } + break; + } + case Rendering.RADIX_OCTAL: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 7)]; + value = value >>> 3; + } + break; + } + case Rendering.RADIX_HEX: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 15)]; + value = value >>> 4; + } + break; + } + } + + return new String(buf); + } + case Rendering.RADIX_DECIMAL_UNSIGNED: + case Rendering.RADIX_DECIMAL_SIGNED: + { + boolean isSignedType = radix == Rendering.RADIX_DECIMAL_SIGNED ? true + : false; + + int textWidth = getRadixCharacterCount(radix, bytes.length); + + char buf[] = new char[textWidth]; + + byte[] value = new byte[bytes.length + 1]; + + if(needsSwap) + { + for(int i = 0; i < bytes.length; i++) + { + value[bytes.length - i] = bytes[i].getValue(); + } + } + else + { + for(int i = 0; i < bytes.length; i++) + { + value[i + 1] = bytes[i].getValue(); + } + } + + BigInteger bigValue; + boolean isNegative = false; + if(isSignedType && (value[1] & 0x80) != 0) + { + value[0] = -1; + isNegative = true; + bigValue = new BigInteger(value).abs(); + } + else + { + value[0] = 0; + bigValue = new BigInteger(value); + } + + for(int i = 0; i < textWidth; i++) + { + BigInteger divideRemainder[] = bigValue.divideAndRemainder( + BigInteger.valueOf(10)); + int remainder = divideRemainder[1].intValue(); + buf[textWidth - 1 - i] = hexdigits[remainder % 10]; + bigValue = divideRemainder[0]; + } + + if(isSignedType) + { + buf[0] = isNegative ? '-' : ' '; + } + + return new String(buf); + } + } + } + + StringBuffer errorText = new StringBuffer(); + for(int i = getRadixCharacterCount(radix, bytes.length); i > 0; i--) + errorText.append('?'); + + return errorText.toString(); + } + + protected int getRadixCharacterCount(int radix, int bytes) + { + switch(radix) + { + case Rendering.RADIX_HEX: + return bytes * 2; + case Rendering.RADIX_BINARY: + return bytes * 8; + case Rendering.RADIX_OCTAL: + { + switch(bytes) + { + case 1: + return 3; + case 2: + return 6; + case 4: + return 11; + case 8: + return 22; + } + } + case Rendering.RADIX_DECIMAL_UNSIGNED: + { + switch(bytes) + { + case 1: + return 3; + case 2: + return 5; + case 4: + return 10; + case 8: + return 20; + } + } + case Rendering.RADIX_DECIMAL_SIGNED: + { + switch(bytes) + { + case 1: + return 4; + case 2: + return 6; + case 4: + return 11; + case 8: + return 21; + } + } + } + + return 0; + } + + protected static boolean isValidEditCharacter(char character) + { + return (character >= '0' && character <= '9') + || (character >= 'a' && character <= 'z') + || (character >= 'A' && character <= 'Z') || character == '-' + || character == ' '; + } + + protected String formatText(MemoryByte[] memoryBytes, + boolean isLittleEndian, int textMode) + { + // check memory byte for unreadable bytes + boolean readable = true; + for(int i = 0; i < memoryBytes.length; i++) + if(!memoryBytes[i].isReadable()) + readable = false; + + // if any bytes are not readable, return ?'s + if(!readable) + { + StringBuffer errorText = new StringBuffer(); + for(int i = memoryBytes.length; i > 0; i--) + errorText.append('?'); + return errorText.toString(); + } + + // TODO + // does endian mean anything for text? ah, unicode? + + // create byte array from MemoryByte array + byte bytes[] = new byte[memoryBytes.length]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = memoryBytes[i].getValue(); + } + + // replace invalid characters with '.' + // maybe there is a way to query the character set for + // valid characters? + + // replace invalid US-ASCII with '.' + if(textMode == Rendering.TEXT_USASCII) + { + for(int i = 0; i < bytes.length; i++) + { + int byteValue = bytes[i]; + if(byteValue < 0) + byteValue += 256; + + if(byteValue < 0x20 || byteValue > 0x7e) + bytes[i] = '.'; + } + } + + // replace invalid ISO-8859-1 with '.' + if(textMode == Rendering.TEXT_ISO_8859_1) + { + for(int i = 0; i < bytes.length; i++) + { + int byteValue = bytes[i]; + if(byteValue < 0) + byteValue += 256; + + if(byteValue < 0x20 || + (byteValue >= 0x7f && byteValue < 0x9f)) + bytes[i] = '.'; + } + } + + try + { + // convert bytes to string using desired character set + StringBuffer buf = new StringBuffer(new String(bytes, this.getCharacterSet(textMode))); + + // pad string to (byte count - string length) with spaces + for(int i = 0; i < memoryBytes.length - buf.length(); i++) + buf.append(' '); + return buf.toString(); + } + catch(Exception e) + { + // return ?s the length of byte count + StringBuffer buf = new StringBuffer(); + for(int i = 0; i < memoryBytes.length - buf.length(); i++) + buf.append('?'); + return buf.toString(); + } + } + +} + +class CopyAction extends Action +{ + // TODO for the sake of large copies, this action should probably read in + // blocks on a Job. + + private Rendering fRendering; + + public CopyAction(Rendering rendering) + { + super(); + fRendering = rendering; + setText(DebugUIMessages.CopyViewToClipboardAction_title); + setToolTipText(DebugUIMessages.CopyViewToClipboardAction_tooltip); + setImageDescriptor(DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_COPY_VIEW_TO_CLIPBOARD)); + setHoverImageDescriptor(DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_LCL_COPY_VIEW_TO_CLIPBOARD)); + setDisabledImageDescriptor(DebugPluginImages + .getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_COPY_VIEW_TO_CLIPBOARD)); + } + + public void run() + { + final int COLUMNS = 80; // FIXME user preference + final String PANE_SPACING = " "; // preference also ? //$NON-NLS-1$ + + Clipboard clip = null; + try + { + clip = new Clipboard(fRendering.getDisplay()); + + BigInteger start = fRendering.getSelection().getStart(); + BigInteger end = fRendering.getSelection().getEnd(); + // end will be null when there is nothing selected + if (end == null) + return; + + if(start.compareTo(end) > 0) + { + // swap start and end + + BigInteger bigI = end; + end = start; + start = bigI; + } + + final int radix = fRendering.getRadix(); + final int bytesPerColumn = fRendering.getBytesPerColumn(); + final boolean isLittleEndian = fRendering.isLittleEndian(); + final int bytesPerCharacter = fRendering.getBytesPerCharacter(); + + final int addressWidth = fRendering.getAddressString(start) + .length(); + + final int binaryCellWidth = fRendering.getRadixCharacterCount( + radix, bytesPerColumn) + 1; + + final int asciiCellWidth = fRendering.getBytesPerColumn() + / fRendering.getBytesPerCharacter(); + + final int combindCellWidths = (fRendering + .getPaneVisible(Rendering.PANE_BINARY) ? binaryCellWidth : 0) + + (fRendering.getPaneVisible(Rendering.PANE_TEXT) ? asciiCellWidth + : 0); + + int availableWidth = COLUMNS; + + if(fRendering.getPaneVisible(Rendering.PANE_ADDRESS)) + { + availableWidth -= addressWidth; + availableWidth -= PANE_SPACING.length(); // between address + // and next + } + + if(fRendering.getPaneVisible(Rendering.PANE_BINARY) + && fRendering.getPaneVisible(Rendering.PANE_TEXT)) + { + availableWidth -= PANE_SPACING.length(); // between binary + // and text + } + + final int columns = availableWidth / combindCellWidths; + + BigInteger lengthToRead = end.subtract(start); + + int rows = lengthToRead.divide( + BigInteger.valueOf(columns * bytesPerColumn)).intValue(); + + if(rows * columns * bytesPerColumn < lengthToRead.intValue()) + rows++; + + StringBuffer buffer = new StringBuffer(); + + for(int row = 0; row < rows; row++) + { + BigInteger rowAddress = start.add(BigInteger.valueOf(row + * columns * bytesPerColumn)); + + if(fRendering.getPaneVisible(Rendering.PANE_ADDRESS)) + { + buffer.append(fRendering.getAddressString(rowAddress)); + buffer.append(PANE_SPACING); + } + + if(fRendering.getPaneVisible(Rendering.PANE_BINARY)) + { + for(int col = 0; col < columns; col++) + { + BigInteger cellAddress = rowAddress.add(BigInteger + .valueOf(col * bytesPerColumn)); + + if(cellAddress.compareTo(end) < 0) + { + try + { + MemoryByte bytes[] = fRendering.getBytes( + cellAddress, bytesPerColumn); + buffer.append(fRendering.getRadixText(bytes, + radix, isLittleEndian)); + } + catch(DebugException de) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_COPY_OPERATION"), de); //$NON-NLS-1$ + return; + } + } + else + { + for(int i = fRendering.getRadixCharacterCount( + radix, bytesPerColumn); i > 0; i--) + buffer.append(' '); + } + + if(col != columns - 1) + buffer.append(' '); + } + } + + if(fRendering.getPaneVisible(Rendering.PANE_BINARY) + && fRendering.getPaneVisible(Rendering.PANE_TEXT)) + { + buffer.append(PANE_SPACING); + } + + if(fRendering.getPaneVisible(Rendering.PANE_TEXT)) + { + for(int col = 0; col < columns; col++) + { + BigInteger cellAddress = rowAddress.add(BigInteger + .valueOf(col * fRendering.getBytesPerColumn())); + + if(cellAddress.compareTo(end) < 0) + { + try + { + MemoryByte bytes[] = fRendering + .getBytes(cellAddress, fRendering + .getBytesPerColumn()); + buffer.append(fRendering.formatText(bytes, + isLittleEndian, fRendering.getTextMode())); + } + catch(DebugException de) + { + fRendering + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_COPY_OPERATION"), de); //$NON-NLS-1$ + return; + } + } + else + { + + } + } + } + + buffer.append("\n"); //$NON-NLS-1$ + } + + if(buffer.length() > 0) + { + TextTransfer plainTextTransfer = TextTransfer.getInstance(); + clip.setContents(new Object[] { buffer.toString() }, + new Transfer[] { plainTextTransfer }); + } + } + finally + { + if(clip != null) + { + clip.dispose(); + } + } + } +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingMessages.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingMessages.java new file mode 100644 index 00000000000..1cc9cf4f2b4 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingMessages.java @@ -0,0 +1,43 @@ + +/******************************************************************************* + * Copyright (c) 2006 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + * + *******************************************************************************/ + + +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class TraditionalRenderingMessages +{ + private static final String BUNDLE_NAME = "org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRendering_messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private TraditionalRenderingMessages() + { + } + + public static String getString(String key) + { + // TODO Auto-generated method stub + try + { + return RESOURCE_BUNDLE.getString(key); + } + catch(MissingResourceException e) + { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java new file mode 100644 index 00000000000..2fa0f510e22 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java @@ -0,0 +1,22 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class TraditionalRenderingPlugin extends AbstractUIPlugin +{ + + private static TraditionalRenderingPlugin plugin; + + public TraditionalRenderingPlugin() + { + super(); + plugin = this; + } + + /** + * Returns the shared instance. + */ + public static TraditionalRenderingPlugin getDefault() { + return plugin; + } +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java new file mode 100644 index 00000000000..8af55f78cd6 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java @@ -0,0 +1,32 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +/** + * Constant definitions for plug-in preferences + */ +public class TraditionalRenderingPreferenceConstants { + + public static final String MEM_COLOR_CHANGED = "memoryColorChanged"; + + public static final String MEM_USE_GLOBAL_BACKGROUND = "memUseGlobalBackground"; + + public static final String MEM_COLOR_BACKGROUND = "memoryColorBackground"; + + public static final String MEM_COLOR_EDIT = "memoryColorEdit"; + + public static final String MEM_COLOR_TEXT = "memoryColorText"; + + public static final String MEM_USE_GLOBAL_SELECTION = "memUseGlobalSelection"; + + public static final String MEM_COLOR_SELECTION = "memoryColorSelection"; + + public static final String MEM_USE_GLOBAL_TEXT = "memUseGlobalText"; + + public static final String MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS = "memoryColorScaleTextAlternate"; + + public static final String MEM_EDIT_BUFFER_SAVE = "memoryEditBufferSave"; + + public static final String MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY = "saveOnEnterCancelOnFocusLost"; + + public static final String MEM_EDIT_BUFFER_SAVE_ON_ENTER_OR_FOCUS_LOST = "saveOnEnterOrFocusLost"; + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java new file mode 100644 index 00000000000..61af5345b2d --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java @@ -0,0 +1,49 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; + +/** + * Class used to initialize default preference values. + */ +public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault() + .getPreferenceStore(); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_TEXT, true); + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND, true); + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_SELECTION, true); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED, "255,0,0"); + + Color systemSelection = Display.getDefault().getSystemColor(SWT.COLOR_LIST_SELECTION); + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_SELECTION, systemSelection.getRed() + + "," + systemSelection.getGreen() + "," + systemSelection.getBlue()); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS, "5"); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_EDIT, "0,255,0"); + + Color systemText = Display.getDefault().getSystemColor(SWT.COLOR_LIST_FOREGROUND); + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_TEXT, systemText.getRed() + + "," + systemText.getGreen() + "," + systemText.getBlue()); + + Color systemBackground = Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND); + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND, systemBackground.getRed() + + "," + systemBackground.getGreen() + "," + systemBackground.getBlue()); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE, + TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY); + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java new file mode 100644 index 00000000000..e08ab51d699 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java @@ -0,0 +1,80 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ColorFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.ScaleFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class TraditionalRenderingPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + public TraditionalRenderingPreferencePage() { + super(GRID); + setPreferenceStore(TraditionalRenderingPlugin.getDefault().getPreferenceStore()); + //setDescription("Traditional Memory Rendering"); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_TEXT, + "Use Global Te&xt Color", getFieldEditorParent())); + + addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_TEXT, + "&Text Color:", getFieldEditorParent())); + + addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_LIGHTEN_DARKEN_ALTERNATE_CELLS, + "Brighten Alternate Cells", getFieldEditorParent(), 0, 8, 1, 1)); + + addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_BACKGROUND, + "Use Global B&ackground Color", getFieldEditorParent())); + + addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_BACKGROUND, + "&Background Color:", getFieldEditorParent())); + + addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_CHANGED, + "&Changed Color:", getFieldEditorParent())); + + addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_EDIT, + "&Edit Color:", getFieldEditorParent())); + + addField(new BooleanFieldEditor(TraditionalRenderingPreferenceConstants.MEM_USE_GLOBAL_SELECTION, + "Use Global Se&lection Color", getFieldEditorParent())); + + addField(new ColorFieldEditor(TraditionalRenderingPreferenceConstants.MEM_COLOR_SELECTION, + "&Selection Color:", getFieldEditorParent())); + + addField(new RadioGroupFieldEditor(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE, + "Edit Buffer", 1, new String[][] { { "Save on E&nter, Cancel on Focus Lost", "saveOnEnterCancelOnFocusLost" }, + { "Save on Enter or Focus L&ost", "saveOnEnterOrFocusLost" } }, getFieldEditorParent())); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + } + +} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java new file mode 100644 index 00000000000..b39434fa28e --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2006 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + * + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.traditional; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate; + +public class TraditionalRenderingTypeDelegate + implements IMemoryRenderingTypeDelegate +{ + + public IMemoryRendering createRendering(String id) throws CoreException { + return new TraditionalRendering(id); + } + + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties new file mode 100644 index 00000000000..7abecab8efb --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -0,0 +1,36 @@ +TraditionalRendering.GO_TO_ADDRESS=Go To Address +TraditionalRendering.RESET_TO_BASE_ADDRESS=Reset To Base Address +TraditionalRendering.REFRESH=Refresh +TraditionalRendering.ADDRESS=Address +TraditionalRendering.BINARY=Binary +TraditionalRendering.TEXT=Text +TraditionalRendering.1_BYTE=1 byte +TraditionalRendering.2_BYTES=2 bytes +TraditionalRendering.4_BYTES=4 bytes +TraditionalRendering.8_BYTES=8 bytes +TraditionalRendering.ISO-8859-1=ISO-8859-1 +TraditionalRendering.USASCII=US-ASCII +TraditionalRendering.UTF8=UTF-8 +TraditionalRendering.UTF16=UTF-16 +TraditionalRendering.BIG=Big +TraditionalRendering.LITTLE=Little +TraditionalRendering.HEX=Hex +TraditionalRendering.DECIMAL_SIGNED=Decimal Signed +TraditionalRendering.DECIMAL_UNSIGNED=Decimal Unsigned +TraditionalRendering.OCTAL=Octal +TraditionalRendering.PANES=Panes +TraditionalRendering.ENDIAN=Endian +TraditionalRendering.CELL_SIZE=Cell Size +TraditionalRendering.RADIX=Radix +TraditionalRendering.RENDERING_NAME=Traditional +TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS=Failure in retrieving start address. +TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD=Called on non-dispatch thread +TraditionalRendering.FAILURE_READ_MEMORY=Failed reading memory. +TraditionalRendering.FAILURE_WRITE_MEMORY=Error writing memory. +TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE=Failed to determine address size. +TraditionalRendering.FAILURE_POSITION_CURSOR=Failed to position cursor. +TraditionalRendering.FAILURE_START_SELECTION=Failed to start selection. +TraditionalRendering.FAILURE_APPEND_SELECTION=Failed to append selection. +TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION=Failed to determine cell location. +TraditionalRendering.FAILURE_PAINT=Failed to paint. +TraditionalRendering.FAILURE_COPY_OPERATION=Failed copy operation. From c5f5f33ebff9ae174127e43a534547e2bda22327 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 04:58:36 +0000 Subject: [PATCH 006/118] Created for nightly build and update site. --- .../.project | 17 ++++++++++ .../build.properties | 1 + .../feature.xml | 33 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 features/org.eclipse.dd.debug.memory.renderings-feature/.project create mode 100644 features/org.eclipse.dd.debug.memory.renderings-feature/build.properties create mode 100644 features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/.project b/features/org.eclipse.dd.debug.memory.renderings-feature/.project new file mode 100644 index 00000000000..fc8b126146c --- /dev/null +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/.project @@ -0,0 +1,17 @@ + + + org.eclipse.dd.debug.memory.renderings-feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties new file mode 100644 index 00000000000..64f93a9f0b7 --- /dev/null +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml new file mode 100644 index 00000000000..faf85ea2576 --- /dev/null +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -0,0 +1,33 @@ + + + + + Device Software Development Platform Project +Device Debug +Memory Renderings + + + + Copyright (c) 2006-2007 Wind River Systems 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 + + + + [Enter License Description here.] + + + + + From 80a07c93139a25adef68c2650536611436449a6e Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 05:08:15 +0000 Subject: [PATCH 007/118] restructured module --- build.properties | 4 ---- plugin.xml | 30 ------------------------------ 2 files changed, 34 deletions(-) delete mode 100644 build.properties delete mode 100644 plugin.xml diff --git a/build.properties b/build.properties deleted file mode 100644 index 34d2e4d2dad..00000000000 --- a/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/plugin.xml b/plugin.xml deleted file mode 100644 index 8ad6adfe1e5..00000000000 --- a/plugin.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - From 57d3112adedf9c8e813e68ff4a4bf63c9e5a9ae5 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 06:41:30 +0000 Subject: [PATCH 008/118] 172860 Traditional memory rendering: Null pointer exception at R... 173323 Traditional Memory Rendering: Memory View Tab Label is no... 173331 Traditional Memory Rendering: Performance Issue - Unneces... --- .../renderings/traditional/AbstractPane.java | 6 ++ .../traditional/TraditionalRendering.java | 96 ++++++++++++++----- 2 files changed, 78 insertions(+), 24 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 670c4427868..c346c5939d5 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -572,6 +572,12 @@ public abstract class AbstractPane extends Canvas protected void paint(PaintEvent pe) { fRowCount = getBounds().height / getCellHeight(); + + if(fRendering.isDirty()) + { + fRendering.setDirty(false); + fRendering.refresh(); + } } abstract protected BigInteger getViewportAddress(int col, int row) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 4d062859d00..c64599d2b36 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -17,6 +17,7 @@ import java.util.Iterator; import java.util.Set; import java.util.Vector; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugEvent; @@ -46,6 +47,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; @@ -75,6 +77,7 @@ import org.eclipse.swt.widgets.Slider; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.model.IWorkbenchAdapter; +import org.eclipse.ui.progress.UIJob; /** * A memory rendering displaying memory in a traditional @@ -182,6 +185,22 @@ public class TraditionalRendering extends AbstractMemoryRendering this.fRendering.gotoAddress(address); } + public void updateRenderingLabels() + { + UIJob job = new UIJob("updateLabels"){ //$NON-NLS-1$ + public IStatus runInUIThread(IProgressMonitor monitor) { + + // update tab labels + String fLabel = getLabel(); + firePropertyChangedEvent(new PropertyChangeEvent(TraditionalRendering.this, + IBasicPropertyConstants.P_TEXT, null, fLabel)); + + return Status.OK_STATUS; + }}; + job.setSystem(true); + job.schedule(); + } + private Color colorBackground; private Color colorChanged; private Color colorEdit; @@ -949,6 +968,9 @@ class Rendering extends Composite implements IDebugEventSetListener private int fCellPadding = 2; private int fPaneSpacing = 16; + + // flag whether the memory cache is dirty + private boolean fCacheDirty = false; public Rendering(Composite parent, TraditionalRendering renderingParent) @@ -1699,6 +1721,16 @@ class Rendering extends Composite implements IDebugEventSetListener fAddressBar.layout(true); fAddressBar.setText(getAddressString(getViewportStartAddress())); } + + public void setDirty(boolean needRefresh) + { + fCacheDirty = needRefresh; + } + + public boolean isDirty() + { + return fCacheDirty; + } public void dispose() { @@ -1967,7 +1999,18 @@ class Rendering extends Composite implements IDebugEventSetListener protected void refresh() { - fViewportCache.refresh(); + if(!this.isDisposed()) + { + if(this.isVisible()) + { + fViewportCache.refresh(); + } + else + { + setDirty(true); + fParent.updateRenderingLabels(); + } + } } protected void archiveDeltas() @@ -2266,29 +2309,34 @@ class Rendering extends Composite implements IDebugEventSetListener protected void redrawPanes() { - if(fAddressPane.isPaneVisible()) - { - fAddressPane.redraw(); - fAddressPane.setRowCount(); - if(fAddressPane.isFocusControl()) - fAddressPane.updateCaret(); - } - - if(fBinaryPane.isPaneVisible()) - { - fBinaryPane.redraw(); - fBinaryPane.setRowCount(); - if(fBinaryPane.isFocusControl()) - fBinaryPane.updateCaret(); - } - - if(fTextPane.isPaneVisible()) - { - fTextPane.redraw(); - fTextPane.setRowCount(); - if(fTextPane.isFocusControl()) - fTextPane.updateCaret(); - } + if(this.isVisible()) + { + if(fAddressPane.isPaneVisible()) + { + fAddressPane.redraw(); + fAddressPane.setRowCount(); + if(fAddressPane.isFocusControl()) + fAddressPane.updateCaret(); + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.redraw(); + fBinaryPane.setRowCount(); + if(fBinaryPane.isFocusControl()) + fBinaryPane.updateCaret(); + } + + if(fTextPane.isPaneVisible()) + { + fTextPane.redraw(); + fTextPane.setRowCount(); + if(fTextPane.isFocusControl()) + fTextPane.updateCaret(); + } + } + + fParent.updateRenderingLabels(); } private void layoutPanes() From 19311472a685dca5a38b3b3c3617d44fbb90d9cb Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 06:53:44 +0000 Subject: [PATCH 009/118] 176407 Provider missing in MANIFEST.MF --- .../META-INF/MANIFEST.MF | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index bc570b8f754..e0188a0963c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -12,3 +12,4 @@ Require-Bundle: org.eclipse.debug.core, org.eclipse.ui Eclipse-LazyStart: true Bundle-Activator: org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin +Bundle-Vendor: %providerName From b30041aff354fcd7c226ba4c455b01f35433f871 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:18:56 +0000 Subject: [PATCH 010/118] 146670 Editing memory when memory is highlighted does not edit the address one would expect --- .../renderings/traditional/AbstractPane.java | 3 +++ .../traditional/TraditionalRendering.java | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index c346c5939d5..fc1a11ec95c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -268,6 +268,9 @@ public abstract class AbstractPane extends Canvas } else if(Rendering.isValidEditCharacter(ke.character)) { + if(fRendering.getSelection().hasSelection()) + setCaretAddress(fRendering.getSelection().getLow()); + editCell(fCaretAddress, fSubCellCaretPosition, ke.character); } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index c64599d2b36..796e588f804 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1756,6 +1756,12 @@ class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); } + protected boolean hasSelection() + { + return fStartHigh != null && fStartLow != null + && fEndHigh != null && fEndLow != null; + } + protected boolean isSelected(BigInteger address) { // do we have valid start and end addresses @@ -1844,6 +1850,22 @@ class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); } + protected BigInteger getHigh() + { + if(!hasSelection()) + return null; + + return getStart().max(getEnd()); + } + + protected BigInteger getLow() + { + if(!hasSelection()) + return null; + + return getStart().min(getEnd()); + } + protected BigInteger getStart() { // if there is no start, return null From d4992c3d0885ff7f2b764c12991f274fa814751d Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:23:09 +0000 Subject: [PATCH 011/118] fixed warning, unused variable --- .../dd/debug/memory/renderings/traditional/DataPane.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index 4703f332ee9..a6ac2d35406 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -3,7 +3,6 @@ package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.graphics.GC; @@ -226,9 +225,6 @@ public class DataPane extends AbstractPane { super.paint(pe); - IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock(); - // TODO what if it is null? - GC gc = pe.gc; gc.setFont(fRendering.getFont()); From 3e9c29b573ede2046af6764769053fbd591c97c6 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:23:45 +0000 Subject: [PATCH 012/118] removed warning, unused variable --- .../dd/debug/memory/renderings/traditional/TextPane.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 86426e6ad08..da28ceab052 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -200,9 +200,6 @@ public class TextPane extends AbstractPane { super.paint(pe); - IMemoryBlockExtension memoryBlock = fRendering.getMemoryBlock(); - // FIXME what if it is null? - GC gc = pe.gc; gc.setFont(fRendering.getFont()); From dab3a786af60d7e85f5f33c7ec27950d3e9c85b4 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:25:04 +0000 Subject: [PATCH 013/118] fixed warnings --- .../memory/renderings/traditional/TraditionalRendering.java | 2 -- .../traditional/TraditionalRenderingTypeDelegate.java | 1 - 2 files changed, 3 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 796e588f804..b28c075ce02 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1602,8 +1602,6 @@ class Rendering extends Composite implements IDebugEventSetListener if(containsEditedCell(address)) // cell size cannot be switched during an edit return getEditedMemory(address); - IMemoryBlockExtension memoryBlock = getMemoryBlock(); - boolean contains = false; if(fCache != null && fCache.start != null) { diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java index b39434fa28e..1a2c142beb2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingTypeDelegate.java @@ -13,7 +13,6 @@ package org.eclipse.dd.debug.memory.renderings.traditional; import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingTypeDelegate; From 4aa55aa2077542f16173f86a4f2367d3dd65ed31 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:25:33 +0000 Subject: [PATCH 014/118] fixed warning --- .../eclipse/dd/debug/memory/renderings/traditional/TextPane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index da28ceab052..073fa8a7fb5 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -3,7 +3,6 @@ package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.graphics.GC; From 87988bb1a107d509becc48e9b033b57104b8dcef Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 Mar 2007 07:49:05 +0000 Subject: [PATCH 015/118] 146683 Double clicking on a cell should highlight that cell --- .../renderings/traditional/AbstractPane.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index fc1a11ec95c..05440625199 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -26,6 +26,7 @@ public abstract class AbstractPane extends Canvas protected Rendering fRendering; // selection state + protected boolean fSelectionStarted = false; protected boolean fSelectionInProgress = false; protected BigInteger fSelectionStartAddress = null; @@ -84,15 +85,17 @@ public abstract class AbstractPane extends Canvas this.addMouseListener(new MouseListener() { public void mouseUp(MouseEvent me) - { + { positionCaret(me.x, me.y); fCaret.setVisible(true); - if(me.button == 1) + if(fSelectionInProgress && me.button == 1) { endSelection(me.x, me.y); } + + fSelectionInProgress = fSelectionStarted = false; } public void mouseDown(MouseEvent me) @@ -119,7 +122,7 @@ public abstract class AbstractPane extends Canvas AbstractPane.this.fSelectionStartAddress = fRendering .getSelection().getStart(); - AbstractPane.this.fSelectionInProgress = true; + AbstractPane.this.fSelectionStarted = true; AbstractPane.this.appendSelection(me.x, me.y); @@ -135,6 +138,21 @@ public abstract class AbstractPane extends Canvas public void mouseDoubleClick(MouseEvent me) { + try + { + BigInteger address = getViewportAddress(me.x / getCellWidth(), me.y + / getCellHeight()); + + fRendering.getSelection().clear(); + fRendering.getSelection().setStart(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + fRendering.getSelection().setEnd(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + } + catch(DebugException de) + { + // do nothing + } } }); @@ -142,8 +160,9 @@ public abstract class AbstractPane extends Canvas { public void mouseMove(MouseEvent me) { - if(fSelectionInProgress) + if(fSelectionStarted) { + fSelectionInProgress = true; appendSelection(me.x, me.y); } } @@ -269,7 +288,10 @@ public abstract class AbstractPane extends Canvas else if(Rendering.isValidEditCharacter(ke.character)) { if(fRendering.getSelection().hasSelection()) + { setCaretAddress(fRendering.getSelection().getLow()); + fSubCellCaretPosition = 0; + } editCell(fCaretAddress, fSubCellCaretPosition, ke.character); } @@ -504,7 +526,7 @@ public abstract class AbstractPane extends Canvas fRendering.getSelection().setStart(address.add(BigInteger.valueOf( fRendering.getBytesPerColumn() / fRendering.getAddressableSize())), address); - fSelectionInProgress = true; + fSelectionStarted = true; } } catch(DebugException e) From 67faf9596953a04416944aa5e45941f4bbe49544 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 16 Mar 2007 02:07:50 +0000 Subject: [PATCH 016/118] 158596 Address column shows same address in all rows Horizontal Scrollbar User configurable column count Fixed missing copyright notice in new files --- .../renderings/traditional/AbstractPane.java | 11 + .../renderings/traditional/AddressPane.java | 11 + .../renderings/traditional/DataPane.java | 12 + .../renderings/traditional/TextPane.java | 11 + .../traditional/TraditionalRendering.java | 331 +++++++++++++++--- .../TraditionalRenderingPlugin.java | 11 + ...aditionalRenderingPreferenceConstants.java | 11 + ...itionalRenderingPreferenceInitializer.java | 12 + .../TraditionalRenderingPreferencePage.java | 11 + .../TraditionalRendering_messages.properties | 11 + 10 files changed, 382 insertions(+), 50 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 05440625199..b4ce8abf804 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index 6dffd0bcd42..0ab2cf378ae 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index a6ac2d35406..5fc835944cf 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + + package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 073fa8a7fb5..5f07888b079 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index b28c075ce02..7d4edfa7d58 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -41,6 +41,8 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.IInputValidator; +import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageDescriptor; @@ -48,6 +50,7 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IBasicPropertyConstants; +import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; @@ -73,7 +76,7 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Slider; +import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -649,7 +652,165 @@ public class TraditionalRendering extends AbstractMemoryRendering }; displayRadixBinAction .setChecked(this.fRendering.getRadix() == Rendering.RADIX_BINARY); + + final Action displayColumnCountAuto = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_AUTO"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(Rendering.COLUMNS_AUTO_SIZE_TO_FIT); + } + }; + displayColumnCountAuto.setChecked(fRendering.getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT); + + final Action displayColumnCount1 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_1"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(1); + } + }; + displayColumnCount1.setChecked(fRendering.getColumnsSetting() == 1); + final Action displayColumnCount2 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_2"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(2); + } + }; + displayColumnCount2.setChecked(fRendering.getColumnsSetting() == 2); + + final Action displayColumnCount3 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_3"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(3); + } + }; + displayColumnCount3.setChecked(fRendering.getColumnsSetting() == 3); + + final Action displayColumnCount4 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_4"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(4); + } + }; + displayColumnCount4.setChecked(fRendering.getColumnsSetting() == 4); + + final Action displayColumnCount5 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_5"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(5); + } + }; + displayColumnCount5.setChecked(fRendering.getColumnsSetting() == 5); + + final Action displayColumnCount6 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_6"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(6); + } + }; + displayColumnCount6.setChecked(fRendering.getColumnsSetting() == 6); + + final Action displayColumnCount7 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_7"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(7); + } + }; + displayColumnCount7.setChecked(fRendering.getColumnsSetting() == 7); + + final Action displayColumnCount8 = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_8"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(8); + } + }; + displayColumnCount8.setChecked(fRendering.getColumnsSetting() == 8); + + final Action displayColumnCountCustomValue = new Action("", IAction.AS_RADIO_BUTTON) + { + public void run() + { + + } + }; + displayColumnCountCustomValue.setChecked(fRendering.getColumnsSetting() > 8); + + + final Action displayColumnCountCustom = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_CUSTOM"), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) + { + public void run() + { + InputDialog inputDialog = new InputDialog( + fRendering.getShell(), + "Set Column Count", //$NON-NLS-1$ + "Please enter column count", //$NON-NLS-1$ + "", //$NON-NLS-1$ + new IInputValidator() { + public String isValid(String input) { + try { + int i= Integer.parseInt(input); + if (i <= 0) + return "Please enter a positive integer"; //$NON-NLS-1$ + + } catch (NumberFormatException x) { + return "Please enter a positive integer"; //$NON-NLS-1$ + } + return null; + } + } + ); + if (inputDialog.open() != Window.OK) return; + int newColumnCount = -1; + try { + newColumnCount = Integer.parseInt(inputDialog.getValue()); + } catch (NumberFormatException x) { assert false; } + + TraditionalRendering.this.fRendering.setColumnsSetting(newColumnCount); + this.setChecked(false); + displayColumnCountCustomValue.setChecked(true); + displayColumnCountCustomValue.setText(Integer.valueOf( + fRendering.getColumnsSetting()).toString()); + } + }; + getPopupMenuManager().addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) @@ -694,8 +855,24 @@ public class TraditionalRendering extends AbstractMemoryRendering sub.add(displayRadixOctAction); sub.add(displayRadixBinAction); manager.add(sub); + + sub = new MenuManager(TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT")); //$NON-NLS-1$ + sub.add(displayColumnCountAuto); + sub.add(displayColumnCount1); + sub.add(displayColumnCount2); + sub.add(displayColumnCount3); + sub.add(displayColumnCount4); + sub.add(displayColumnCount5); + sub.add(displayColumnCount6); + sub.add(displayColumnCount7); + sub.add(displayColumnCount8); + if(displayColumnCountCustomValue.isChecked()) + sub.add(displayColumnCountCustomValue); + sub.add(displayColumnCountCustom); + manager.add(sub); manager.add(new Separator()); - + manager.add(copyAction); manager.add(gotoAddressAction); @@ -900,7 +1077,6 @@ class Rendering extends Composite implements IDebugEventSetListener private TraditionalRendering fParent; // controls - private Slider fScrollBar; private AddressPane fAddressPane; @@ -935,6 +1111,8 @@ class Rendering extends Composite implements IDebugEventSetListener private int fBytesPerColumn = 4; // 4 byte cell width default private int fRadix = RADIX_HEX; + + private int fColumnsSetting = COLUMNS_AUTO_SIZE_TO_FIT; private boolean fLittleEndian = false; @@ -964,6 +1142,9 @@ class Rendering extends Composite implements IDebugEventSetListener protected final static int TEXT_UTF8 = 3; protected final static int TEXT_UTF16 = 4; + // internal constants + protected final static int COLUMNS_AUTO_SIZE_TO_FIT = 0; + // view internal settings private int fCellPadding = 2; @@ -975,8 +1156,9 @@ class Rendering extends Composite implements IDebugEventSetListener public Rendering(Composite parent, TraditionalRendering renderingParent) { - super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND); - + super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.H_SCROLL + | SWT.V_SCROLL); + this.setFont(JFaceResources .getFont(IInternalDebugUIConstants.FONT_NAME)); // TODO internal? @@ -1016,8 +1198,21 @@ class Rendering extends Composite implements IDebugEventSetListener } } - fScrollBar = new Slider(this, SWT.V_SCROLL); - fScrollBar.addSelectionListener(new SelectionListener() + getHorizontalBar().addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent se) + { + Rendering.this.layout(); + } + + public void widgetDefaultSelected(SelectionEvent se) + { + // do nothing + } + }); + + getVerticalBar().addSelectionListener( + new SelectionListener() { public void widgetSelected(SelectionEvent se) { @@ -1052,12 +1247,12 @@ class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); break; case SWT.SCROLL_LINE: - if(fScrollBar.getSelection() == fScrollBar.getMinimum()) + if(getVerticalBar().getSelection() == getVerticalBar().getMinimum()) { // Set view port start address to the start address of the Memory Block fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); } - else if(fScrollBar.getSelection() == fScrollBar.getMaximum()) + else if(getVerticalBar().getSelection() == getVerticalBar().getMaximum()) { // The view port end address should be less or equal to the the end address of the Memory Block // Set view port address to be bigger than the end address of the Memory Block for now @@ -1067,13 +1262,15 @@ class Rendering extends Composite implements IDebugEventSetListener else { // Figure out the delta - int delta = fScrollBar.getSelection() - fCurrentScrollSelection; + int delta = getVerticalBar().getSelection() - fCurrentScrollSelection; fViewportAddress = fViewportAddress.add(BigInteger.valueOf( getAddressableCellsPerRow() * delta)); } ensureViewportAddressDisplayable(); // Update tooltip - fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + // FIXME conversion from slider to scrollbar + // getVerticalBar().setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + // Update the addresses on the Address pane. // Do not update the Binary and Text panes until dragging of the thumb nail stops if(fAddressPane.isPaneVisible()) @@ -1109,9 +1306,13 @@ class Rendering extends Composite implements IDebugEventSetListener { public void layout(Composite composite, boolean changed) { - int x = 0; + int xOffset = 0; + if(Rendering.this.getHorizontalBar().isVisible()) + xOffset = Rendering.this.getHorizontalBar().getSelection(); + + int x = xOffset * -1; int y = 0; - + if(fAddressBar.isVisible()) { fAddressBar.setBounds(0, 0, @@ -1122,7 +1323,7 @@ class Rendering extends Composite implements IDebugEventSetListener if(fAddressPane.isPaneVisible()) { - fAddressPane.setBounds(0, y, + fAddressPane.setBounds(x, y, fAddressPane.computeSize(0, 0).x, Rendering.this .getBounds().height - y); @@ -1140,22 +1341,29 @@ class Rendering extends Composite implements IDebugEventSetListener + fBinaryPane.getBounds().width; } - Point scrollBarPreferredSize = fScrollBar.computeSize(20, - Rendering.this.getBounds().height); - if(fTextPane.isPaneVisible()) { - fTextPane.setBounds(x, y, Rendering.this.getBounds().width - - x - scrollBarPreferredSize.x, Rendering.this - .getBounds().height - - y); + fTextPane.setBounds(x, y, + Math.max(fTextPane.computeSize(0, 0).x, Rendering.this.getClientArea().width + - x - xOffset), Rendering.this.getBounds().height - y); } - fScrollBar.setBounds(Rendering.this.getBounds().width - - scrollBarPreferredSize.x, y, scrollBarPreferredSize.x, - Rendering.this.getBounds().height - y); - - fScrollBar.moveAbove(null); + if(getClientArea().width >= fTextPane.getBounds().x + fTextPane.getBounds().width + xOffset) + { + Rendering.this.getHorizontalBar().setVisible(false); + } + else + { + ScrollBar horizontal = Rendering.this.getHorizontalBar(); + + horizontal.setVisible(true); + horizontal.setMinimum(0); + horizontal.setMaximum(fTextPane.getBounds().x + + fTextPane.getBounds().width + xOffset); + horizontal.setThumb(getClientArea().width); + horizontal.setPageIncrement(40); // TODO ? + horizontal.setIncrement(20); // TODO ? + } } protected Point computeSize(Composite composite, int wHint, @@ -1963,34 +2171,42 @@ class Rendering extends Composite implements IDebugEventSetListener if(fTextPane.isPaneVisible()) combinedWidth += fTextPane.getCellWidth(); - if(combinedWidth == 0) - fColumnCount = 0; + if(getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT) + { + if(combinedWidth == 0) + fColumnCount = 0; + else + { + fColumnCount = availableWidth / combinedWidth; + if(fColumnCount == 0) + fColumnCount = 1; // paint one column even if only part can show in view + } + } else { - fColumnCount = availableWidth / combinedWidth; - if(fColumnCount == 0) - fColumnCount = 1; // paint one column even if only part can show in view + fColumnCount = getColumnsSetting(); } try { - // Update the number of bytes per row; - // the max and min scroll range and the current thumb nail position. - fBytesPerRow = getBytesPerColumn() * getColumnCount(); - BigInteger difference = getMemoryBlockEndAddress().subtract(getMemoryBlockStartAddress()).add(BigInteger.ONE); - BigInteger maxScrollRange = difference.divide(BigInteger.valueOf(getAddressableCellsPerRow())); - if(maxScrollRange.multiply(BigInteger.valueOf(getAddressableCellsPerRow())).compareTo(difference) != 0) - maxScrollRange = maxScrollRange.add(BigInteger.ONE); - - // support targets with an addressable size greater than 1 - maxScrollRange = maxScrollRange.divide(BigInteger.valueOf(getAddressableSize())); - - fScrollBar.setMinimum(1); - fScrollBar.setMaximum(maxScrollRange.intValue()); - fScrollBar.setIncrement(1); - fScrollBar.setPageIncrement(this.getRowCount()-1); - fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); - setCurrentScrollSelection(); + // Update the number of bytes per row; + // the max and min scroll range and the current thumb nail position. + fBytesPerRow = getBytesPerColumn() * getColumnCount(); + BigInteger difference = getMemoryBlockEndAddress().subtract(getMemoryBlockStartAddress()).add(BigInteger.ONE); + BigInteger maxScrollRange = difference.divide(BigInteger.valueOf(getAddressableCellsPerRow())); + if(maxScrollRange.multiply(BigInteger.valueOf(getAddressableCellsPerRow())).compareTo(difference) != 0) + maxScrollRange = maxScrollRange.add(BigInteger.ONE); + + // support targets with an addressable size greater than 1 + maxScrollRange = maxScrollRange.divide(BigInteger.valueOf(getAddressableSize())); + + getVerticalBar().setMinimum(1); + getVerticalBar().setMaximum(maxScrollRange.intValue()); + getVerticalBar().setIncrement(1); + getVerticalBar().setPageIncrement(this.getRowCount() -1); + //TW FIXME conversion of slider to scrollbar + // fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + setCurrentScrollSelection(); } catch(Exception e) { @@ -2107,7 +2323,22 @@ class Rendering extends Composite implements IDebugEventSetListener return fColumnCount; } - protected void ensureVisible(BigInteger address) + public int getColumnsSetting() + { + return fColumnsSetting; + } + + public void setColumnsSetting(int columns) + { + if(fColumnsSetting != columns) + { + fColumnsSetting = columns; + fireSettingsChanged(); + layoutPanes(); + } + } + + protected void ensureVisible(BigInteger address) { BigInteger viewportStart = this.getViewportStartAddress(); BigInteger viewportEnd = this.getViewportEndAddress(); @@ -2160,7 +2391,7 @@ class Rendering extends Composite implements IDebugEventSetListener { BigInteger selection = getViewportStartAddress().divide( BigInteger.valueOf(getAddressableCellsPerRow()).add(BigInteger.ONE)); - fScrollBar.setSelection(selection.intValue()); + getVerticalBar().setSelection(selection.intValue()); fCurrentScrollSelection = selection.intValue(); } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java index 2fa0f510e22..0518366a1e8 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import org.eclipse.ui.plugin.AbstractUIPlugin; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java index 8af55f78cd6..c6be1afd5db 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; /** diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java index 61af5345b2d..d41e0bb1363 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + + package org.eclipse.dd.debug.memory.renderings.traditional; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java index e08ab51d699..1d58cb08055 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import org.eclipse.jface.preference.BooleanFieldEditor; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties index 7abecab8efb..04ddb74484c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -34,3 +34,14 @@ TraditionalRendering.FAILURE_APPEND_SELECTION=Failed to append selection. TraditionalRendering.FAILURE_DETERMINE_CELL_LOCATION=Failed to determine cell location. TraditionalRendering.FAILURE_PAINT=Failed to paint. TraditionalRendering.FAILURE_COPY_OPERATION=Failed copy operation. +TraditionalRendering.COLUMN_COUNT=Columns +TraditionalRendering.COLUMN_COUNT_AUTO=Auto Size to Fill +TraditionalRendering.COLUMN_COUNT_1=1 +TraditionalRendering.COLUMN_COUNT_2=2 +TraditionalRendering.COLUMN_COUNT_3=3 +TraditionalRendering.COLUMN_COUNT_4=4 +TraditionalRendering.COLUMN_COUNT_5=5 +TraditionalRendering.COLUMN_COUNT_6=6 +TraditionalRendering.COLUMN_COUNT_7=7 +TraditionalRendering.COLUMN_COUNT_8=8 +TraditionalRendering.COLUMN_COUNT_CUSTOM=Custom... \ No newline at end of file From 05e28af4db9a7a164a95aeb28a5fdd944528aac1 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 16 Mar 2007 05:39:00 +0000 Subject: [PATCH 017/118] 177701 Adopt the platform GoToAddressComposite --- .../renderings/traditional/AbstractPane.java | 3 +- .../traditional/TraditionalRendering.java | 434 ++++++++---------- 2 files changed, 191 insertions(+), 246 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index b4ce8abf804..12bf6edcf79 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -328,7 +328,6 @@ public abstract class AbstractPane extends Canvas { fRendering.getSelection().clear(); } - } public void keyReleased(KeyEvent ke) @@ -479,6 +478,8 @@ public abstract class AbstractPane extends Canvas fRendering.ensureViewportAddressDisplayable(); fRendering.gotoAddress(fRendering.getViewportStartAddress()); } + + fRendering.setCaretAddress(fCaretAddress); } protected void advanceCursor() diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 7d4edfa7d58..0f33de2f7e0 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -17,6 +17,10 @@ import java.util.Iterator; import java.util.Set; import java.util.Vector; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -32,15 +36,19 @@ import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; +import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.preference.IPreferenceStore; @@ -59,10 +67,12 @@ import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; @@ -71,6 +81,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -78,7 +89,11 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Layout; import org.eclipse.swt.widgets.ScrollBar; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.progress.UIJob; @@ -107,14 +122,13 @@ import org.eclipse.ui.progress.UIJob; *

*/ -public class TraditionalRendering extends AbstractMemoryRendering +public class TraditionalRendering extends AbstractMemoryRendering implements IRepositionableMemoryRendering { - - Rendering fRendering; + Rendering fRendering; private Action displayEndianBigAction; private Action displayEndianLittleAction; - + private IWorkbenchAdapter fWorkbenchAdapter; public TraditionalRendering(String id) @@ -183,7 +197,51 @@ public class TraditionalRendering extends AbstractMemoryRendering return this.fRendering; } - public void gotoAddress(BigInteger address) + // FIXME + private static final String ID_GO_TO_ADDRESS_COMMAND = "org.eclipse.debug.ui.command.gotoaddress"; //$NON-NLS-1$ + private AbstractHandler fGoToAddressHandler; + + public void activated() + { + super.activated(); + + IWorkbench workbench = PlatformUI.getWorkbench(); + ICommandService commandSupport = (ICommandService)workbench.getAdapter(ICommandService.class); + + if(commandSupport != null) + { + Command gotoCommand = commandSupport.getCommand(ID_GO_TO_ADDRESS_COMMAND); + + if(fGoToAddressHandler == null) + { + fGoToAddressHandler = new AbstractHandler() { + public Object execute(ExecutionEvent event) throws ExecutionException { + // TODO + return null; + } + }; + } + gotoCommand.setHandler(fGoToAddressHandler); + } + + } + + public void deactivated() + { + IWorkbench workbench = PlatformUI.getWorkbench(); + ICommandService commandSupport = (ICommandService) workbench.getAdapter(ICommandService.class); + + if(commandSupport != null) + { + // remove handler + Command command = commandSupport.getCommand(ID_GO_TO_ADDRESS_COMMAND); + command.setHandler(null); + } + + super.deactivated(); + } + + public void gotoAddress(BigInteger address) { this.fRendering.gotoAddress(address); } @@ -343,24 +401,14 @@ public class TraditionalRendering extends AbstractMemoryRendering // go to address - final Action gotoAddressAction = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.GO_TO_ADDRESS")) //$NON-NLS-1$ - { - public void run() - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - TraditionalRendering.this.fRendering - .setVisibleAddressBar(true); - } - }); - } - }; - gotoAddressAction.setAccelerator(SWT.CTRL | 'G'); - + final Action gotoAddressAction = new GoToAddressAction(TraditionalRendering.this) + { + public void run() { + TraditionalRendering.this.fRendering + .setVisibleAddressBar(true); + } + }; + // reset to base address final Action gotoBaseAddressAction = new Action( @@ -665,107 +713,27 @@ public class TraditionalRendering extends AbstractMemoryRendering }; displayColumnCountAuto.setChecked(fRendering.getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT); - final Action displayColumnCount1 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_1"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) + final int maxMenuColumnCount = 8; + final Action[] displayColumnCounts = new Action[maxMenuColumnCount]; + for(int i = 0; i < maxMenuColumnCount; i++) { - public void run() + displayColumnCounts[i] = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COLUMN_COUNT_" + (i + 1)), //$NON-NLS-1$ + IAction.AS_RADIO_BUTTON) { - TraditionalRendering.this.fRendering.setColumnsSetting(1); - } - }; - displayColumnCount1.setChecked(fRendering.getColumnsSetting() == 1); + public void run() + { + TraditionalRendering.this.fRendering.setColumnsSetting(1); + } + }; + displayColumnCounts[i].setChecked(fRendering.getColumnsSetting() == i + 1); + } - final Action displayColumnCount2 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_2"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(2); - } - }; - displayColumnCount2.setChecked(fRendering.getColumnsSetting() == 2); - - final Action displayColumnCount3 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_3"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(3); - } - }; - displayColumnCount3.setChecked(fRendering.getColumnsSetting() == 3); - - final Action displayColumnCount4 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_4"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(4); - } - }; - displayColumnCount4.setChecked(fRendering.getColumnsSetting() == 4); - - final Action displayColumnCount5 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_5"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(5); - } - }; - displayColumnCount5.setChecked(fRendering.getColumnsSetting() == 5); - - final Action displayColumnCount6 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_6"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(6); - } - }; - displayColumnCount6.setChecked(fRendering.getColumnsSetting() == 6); - - final Action displayColumnCount7 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_7"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(7); - } - }; - displayColumnCount7.setChecked(fRendering.getColumnsSetting() == 7); - - final Action displayColumnCount8 = new Action( - TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_8"), //$NON-NLS-1$ - IAction.AS_RADIO_BUTTON) - { - public void run() - { - TraditionalRendering.this.fRendering.setColumnsSetting(8); - } - }; - displayColumnCount8.setChecked(fRendering.getColumnsSetting() == 8); - final Action displayColumnCountCustomValue = new Action("", IAction.AS_RADIO_BUTTON) { public void run() { - } }; displayColumnCountCustomValue.setChecked(fRendering.getColumnsSetting() > 8); @@ -859,14 +827,8 @@ public class TraditionalRendering extends AbstractMemoryRendering sub = new MenuManager(TraditionalRenderingMessages .getString("TraditionalRendering.COLUMN_COUNT")); //$NON-NLS-1$ sub.add(displayColumnCountAuto); - sub.add(displayColumnCount1); - sub.add(displayColumnCount2); - sub.add(displayColumnCount3); - sub.add(displayColumnCount4); - sub.add(displayColumnCount5); - sub.add(displayColumnCount6); - sub.add(displayColumnCount7); - sub.add(displayColumnCount8); + for(int i = 0; i < displayColumnCounts.length; i++) + sub.add(displayColumnCounts[i]); if(displayColumnCountCustomValue.isChecked()) sub.add(displayColumnCountCustomValue); sub.add(displayColumnCountCustom); @@ -891,6 +853,29 @@ public class TraditionalRendering extends AbstractMemoryRendering return this.fRendering; } + + // selection is terminology for caret position + public BigInteger getSelectedAddress() { + return fRendering.getCaretAddress(); + } + + public MemoryByte[] getSelectedAsBytes() { + try + { + return fRendering.getViewportCache().getBytes( + fRendering.getCaretAddress(), fRendering.getBytesPerColumn()); + } + catch(DebugException de) + { + // FIXME log? + return null; + } + } + + public void goToAddress(BigInteger address) throws DebugException { + fRendering.gotoAddress(address); + } + protected void bytesAreLittleEndian(boolean areLE) { // once we actually read memory we can determine the @@ -945,112 +930,6 @@ public class TraditionalRendering extends AbstractMemoryRendering } - -/* - * A place holder address bar for go to address. For consistency, - * this will eventually be replaced by a standard memory view - * address bar. - */ - -class AddressBar extends Composite -{ - Text fTextControl; - - Label fLabelControl; - - private final static int DUMMY_WIDTH = 100; - - public AddressBar(final Rendering rendering) - { - super(rendering, SWT.BORDER); - - this.fLabelControl = new Label(this, SWT.SINGLE); - this.fTextControl = new Text(this, SWT.SINGLE); - - GridData layoutData = new GridData(); - - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.makeColumnsEqualWidth = false; - layout.marginHeight = 0; - layout.marginLeft = 0; - - this.setLayout(layout); - - layoutData.horizontalAlignment = SWT.FILL; - layoutData.grabExcessHorizontalSpace = true; - layoutData.grabExcessVerticalSpace = true; - - fLabelControl.setText(TraditionalRenderingMessages - .getString("TraditionalRendering.GO_TO_ADDRESS")); //$NON-NLS-1$ - - this.fTextControl.setLayoutData(layoutData); - - this.fTextControl.addFocusListener(new FocusListener() - { - public void focusGained(FocusEvent e) - { - // do nothing - } - - public void focusLost(FocusEvent e) - { - rendering.setVisibleAddressBar(false); - } - }); - - this.fTextControl.addKeyListener(new KeyListener() - { - public void keyPressed(KeyEvent ke) - { - if(ke.keyCode == SWT.ESC) - { - rendering.setVisibleAddressBar(false); - } - else if(ke.character == '\r') - { - int radix = 10; - String s = fTextControl.getText().trim(); - if(s.toUpperCase().indexOf("0X") >= 0) //$NON-NLS-1$ - { - s = s.substring(2); - radix = 16; - } - try - { - BigInteger newAddress = new BigInteger(s, radix); - rendering.setVisibleAddressBar(false); - rendering.gotoAddress(newAddress); - } - catch(Exception e) - { - // do nothing - } - - } - } - - public void keyReleased(KeyEvent ke) - { - // do nothing - } - }); - } - - public void setText(String data) - { - this.fTextControl.setText(data); - this.fTextControl.forceFocus(); - this.fTextControl.selectAll(); - } - - public Point computeSize(int wHint, int hHint) - { - return new Point(DUMMY_WIDTH, this.fTextControl.computeSize(10, 24, - true).y); - } -} - class TraditionalMemoryByte extends MemoryByte { private boolean isEdited = false; @@ -1084,7 +963,9 @@ class Rendering extends Composite implements IDebugEventSetListener private TextPane fTextPane; - private AddressBar fAddressBar; + private GoToAddressComposite fAddressBar; + + private Control fAddressBarControl; // FIXME why isn't there a getControl() ? private Selection fSelection = new Selection(); @@ -1104,6 +985,8 @@ class Rendering extends Composite implements IDebugEventSetListener private int fCurrentScrollSelection = 0; // current scroll selection; + private BigInteger fCaretAddress = BigInteger.valueOf(0); // -1 ? + // user settings private int fTextMode = 1; // ASCII default, TODO make preference? @@ -1153,8 +1036,7 @@ class Rendering extends Composite implements IDebugEventSetListener // flag whether the memory cache is dirty private boolean fCacheDirty = false; - public Rendering(Composite parent, - TraditionalRendering renderingParent) + public Rendering(Composite parent, TraditionalRendering renderingParent) { super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.H_SCROLL | SWT.V_SCROLL); @@ -1170,9 +1052,43 @@ class Rendering extends Composite implements IDebugEventSetListener this.fBinaryPane = new DataPane(this); this.fTextPane = new TextPane(this); - // FIXME temporary address bar; will be replaced by standard Memory bar - this.fAddressBar = new AddressBar(this); - this.fAddressBar.setVisible(false); + fAddressBar = new GoToAddressComposite(); + fAddressBarControl = fAddressBar.createControl(parent); + Button button = fAddressBar.getButton(IDialogConstants.OK_ID); + if (button != null) + { + button.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + doGoToAddress(); + } + }); + + button = fAddressBar.getButton(IDialogConstants.CANCEL_ID); + if (button != null) + { + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setVisibleAddressBar(false); + }}); + } + } + + fAddressBar.getExpressionWidget().addSelectionListener(new SelectionAdapter() { + public void widgetDefaultSelected(SelectionEvent e) { + doGoToAddress(); + }}); + + fAddressBar.getExpressionWidget().addKeyListener(new KeyAdapter() { + + public void keyPressed(KeyEvent e) { + if (e.keyCode == SWT.ESC) + setVisibleAddressBar(false); + super.keyPressed(e); + } + }); + + this.fAddressBarControl.setVisible(false); // initialize the viewport start IMemoryBlockExtension memoryBlock = getMemoryBlock(); @@ -1313,12 +1229,12 @@ class Rendering extends Composite implements IDebugEventSetListener int x = xOffset * -1; int y = 0; - if(fAddressBar.isVisible()) + if(fAddressBarControl.isVisible()) { - fAddressBar.setBounds(0, 0, - Rendering.this.getBounds().width, fAddressBar - .computeSize(1, 1).y); - y = fAddressBar.getBounds().height; + fAddressBarControl.setBounds(0, 0, + Rendering.this.getBounds().width, fAddressBarControl + .computeSize(100, 30).y); // FIXME + //y = fAddressBarControl.getBounds().height; } if(fAddressPane.isPaneVisible()) @@ -1393,6 +1309,27 @@ class Rendering extends Composite implements IDebugEventSetListener return fParent; } + protected void setCaretAddress(BigInteger address) + { + fCaretAddress = address; + } + + protected BigInteger getCaretAddress() + { + return fCaretAddress; + } + + private void doGoToAddress() { + try { + BigInteger address = fAddressBar.getGoToAddress(this.getMemoryBlockStartAddress(), this.getCaretAddress()); + getTraditionalRendering().gotoAddress(address); + setVisibleAddressBar(false); + } catch (NumberFormatException e1) + { + // FIXME log? + } + } + // Ensure that all addresses displayed are within the addressable range protected void ensureViewportAddressDisplayable() { @@ -1921,11 +1858,18 @@ class Rendering extends Composite implements IDebugEventSetListener public void setVisibleAddressBar(boolean visible) { - fAddressBar.setVisible(visible); + fAddressBarControl.setVisible(visible); + if(visible) + { + String selectedStr = "0x" + getCaretAddress().toString(16); + Text text = fAddressBar.getExpressionWidget(); + text.setText(selectedStr); + text.setSelection(0, text.getCharCount()); + fAddressBar.getExpressionWidget().setFocus(); + } + layout(true); layoutPanes(); - fAddressBar.layout(true); - fAddressBar.setText(getAddressString(getViewportStartAddress())); } public void setDirty(boolean needRefresh) From e07c5facaaaa9e296e055783f588e18e147a4eaf Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 5 Apr 2007 21:49:50 +0000 Subject: [PATCH 018/118] plugin names --- .../feature.xml | 102 +++++++++++++++++- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index faf85ea2576..7c574a462a7 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -3,7 +3,7 @@ id="org.eclipse.dd.debug.memory.renderings" label="Device Debug Memory Renderings" version="0.9.0.qualifier" - provider-name="org.eclipse"> + provider-name="Eclipse.org"> Device Software Development Platform Project @@ -19,10 +19,106 @@ v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html - - [Enter License Description here.] + + ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT +March 17, 2005 +Usage Of Content +THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, +INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY +"CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS +OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE +AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING +THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED +BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE +LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. +IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT +AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS +OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE +THE CONTENT. +Applicable Licenses +Unless otherwise indicated, all Content made available by the +Eclipse Foundation is provided to you under the terms and conditions +of the Eclipse Public License Version 1.0 ("EPL"). A copy of +the EPL is provided with this Content and is also available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the +EPL, "Program" will mean the Content. +Content includes, but is not limited to, source code, object +code, documentation and other files maintained in the Eclipse.org +CVS repository ("Repository") in CVS modules ("Modules") and +made available as downloadable archives ("Downloads"). +- Content may be structured and packaged into modules to facilitate +delivering, +extending, and upgrading the Content. Typical modules may include +plug-ins ("Plug-ins"), +plug-in fragments ("Fragments"), and features ("Features"). +- Each Plug-in or Fragment may be packaged as a sub-directory +or JAR (Java? ARchive) +in a directory named "plugins". +- A Feature is a bundle of one or more Plug-ins and/or Fragments +and associated material. +Each Feature may be packaged as a sub-directory in a directory +named "features". +Within a Feature, files named "feature.xml" may contain a list +of the names and version +numbers of the Plug-ins and/or Fragments associated with that +Feature. +- Features may also include other Features ("Included Features"). +Within a Feature, files +named "feature.xml" may contain a list of the names and version +numbers of Included Features. +Features may also include other Features ("Included Features"). +Files named "feature.xml" may contain a list of the names and +version numbers of Included Features. +The terms and conditions governing Plug-ins and Fragments should +be contained in files named "about.html" ("Abouts"). The terms +and conditions governing Features and Included Features should +be contained in files named "license.html" ("Feature Licenses"). +Abouts and Feature +Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations: +- The top-level (root) directory +- Plug-in and Fragment directories +- Inside Plug-ins and Fragments packaged as JARs +- Sub-directories of the directory named "src" of certain Plug-ins +- Feature directories +Note: if a Feature made available by the Eclipse Foundation is +installed using the Eclipse Update Manager, you must agree to +a license ("Feature Update License") during the installation +process. If the Feature contains Included Features, the Feature +Update License should either provide you +with the terms and conditions governing the Included Features +or inform you where you can locate them. Feature Update Licenses +may be found in the "license" property of files named "feature.properties". +Such Abouts, Feature Licenses and Feature Update Licenses contain +the terms and conditions (or references to such terms and conditions) +that govern your +use of the associated Content in that directory. +THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY +REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS +AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE +(BUT ARE NOT LIMITED TO): +- Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html) +IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS +PRIOR TO USE OF THE CONTENT. If no About, Feature License or +Feature Update License is provided, please contact the Eclipse +Foundation to determine what terms and conditions govern that +particular Content. +Cryptography +Content may contain encryption software. The country in which +you are currently may have restrictions on the import, possession, +and use, and/or re-export to another country, of encryption software. +BEFORE using any encryption software, please check the country's +laws, +regulations and policies concerning the import, possession, or +use, and re-export of encryption software, to see if this is +permitted. +Java and all Java-based trademarks are trademarks of Sun Microsystem + + + + Date: Wed, 16 May 2007 21:22:36 +0000 Subject: [PATCH 019/118] fixed provider name field --- .../META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index e0188a0963c..091efcb421b 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -12,4 +12,4 @@ Require-Bundle: org.eclipse.debug.core, org.eclipse.ui Eclipse-LazyStart: true Bundle-Activator: org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin -Bundle-Vendor: %providerName +Bundle-Vendor: Eclipse.org From 91d9f301a3e5c70b4d936beff9e7e60a26ba63f2 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 17 May 2007 00:14:36 +0000 Subject: [PATCH 020/118] build.properties should include plugin.xml --- .../build.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties index 34d2e4d2dad..e9863e281ea 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -1,4 +1,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - . + .,\ + plugin.xml From 346c18fe10263bfc07d4d3a80b833a3f2abc1023 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 17 May 2007 17:40:47 +0000 Subject: [PATCH 021/118] Bugzilla Bug 187018 --- .../memory/renderings/traditional/AbstractPane.java | 3 +++ .../memory/renderings/traditional/AddressPane.java | 3 +++ .../renderings/traditional/TraditionalRendering.java | 12 ++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 12bf6edcf79..628f8e45b5c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -561,6 +561,9 @@ public abstract class AbstractPane extends Canvas { try { + if(this.fSelectionStartAddress == null) + return; + BigInteger address = getViewportAddress(x / getCellWidth(), y / getCellHeight()); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index 0ab2cf378ae..2c37b1cbff1 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -41,6 +41,9 @@ public class AddressPane extends AbstractPane { try { + if(this.fSelectionStartAddress == null) + return; + BigInteger address = getViewportAddress(x / getCellWidth(), y / getCellHeight()); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 0f33de2f7e0..b20550362ec 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -36,6 +36,7 @@ import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; @@ -1754,7 +1755,8 @@ class Rendering extends Composite implements IDebugEventSetListener BigInteger dataEnd = address.add(BigInteger.valueOf(bytesRequested)); if(fCache.start.compareTo(address) <= 0 - && fCache.end.compareTo(dataEnd) >= 0) + && fCache.end.compareTo(dataEnd) >= 0 + && fCache.bytes.length > 0) contains = true; } @@ -1821,8 +1823,6 @@ class Rendering extends Composite implements IDebugEventSetListener Iterator iterator = keySet.iterator(); while(iterator.hasNext()) - { - try { BigInteger address = (BigInteger) iterator.next(); MemoryByte[] bytes = (MemoryByte[]) fEditBuffer @@ -1832,10 +1832,14 @@ class Rendering extends Composite implements IDebugEventSetListener for(int i = 0; i < bytes.length; i++) byteValue[i] = bytes[i].getValue(); + try + { getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); } catch(Exception e) { + MemoryViewUtil.openError(TraditionalRenderingMessages.getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), "", e); + logError( TraditionalRenderingMessages .getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), e); //$NON-NLS-1$ @@ -2181,7 +2185,7 @@ class Rendering extends Composite implements IDebugEventSetListener { if(!this.isDisposed()) { - if(this.isVisible()) + if(this.isVisible() && fViewportCache != null) { fViewportCache.refresh(); } From 41d29f059f8fef4ef2ef9ec77d482960b94ca091 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 30 May 2007 02:06:46 +0000 Subject: [PATCH 022/118] fixes for 189542 --- .../build.properties | 4 +- .../feature.properties | 126 ++++++++++++++++++ .../feature.xml | 104 +-------------- .../license.html | 79 +++++++++++ .../about.html | 24 ++++ .../build.properties | 3 +- 6 files changed, 238 insertions(+), 102 deletions(-) create mode 100644 features/org.eclipse.dd.debug.memory.renderings-feature/feature.properties create mode 100644 features/org.eclipse.dd.debug.memory.renderings-feature/license.html create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/about.html diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties index 64f93a9f0b7..66d3261e69c 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties @@ -1 +1,3 @@ -bin.includes = feature.xml +bin.includes = feature.xml,\ + feature.properties,\ + license.html diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.properties b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.properties new file mode 100644 index 00000000000..fc88e04d681 --- /dev/null +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.properties @@ -0,0 +1,126 @@ +############################################################################### +# Copyright (c) 2006, 2007 Wind River Systems 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: +# Ted Williams (Wind River) - initial API and implementation +############################################################################### + +# "copyright" property - text of the "Feature Update Copyright" +copyright=\ +Copyright (c) 2000, 2007 Wind River Systems and others.\n\ +All rights reserved. This program and the accompanying materials\n\ +are made available under the terms of the Eclipse Public License v1.0\n\ +which accompanies this distribution, and is available at\n\ +http://www.eclipse.org/legal/epl-v10.html\n\ +################ end of copyright property #################################### + +# "licenseURL" property - URL of the "Feature License" +# do not translate value - just change to point to a locale-specific HTML page +licenseURL=license.html + +# "license" property - text of the "Feature Update License" +# should be plain text version of license agreement pointed to be "licenseURL" +license=\ +* Eclipse Public License v1.0 (http://www.eclipse.org/legal/epl-v10.html)\n\ +\n\ +ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ +March 17, 2005\n\ +\n\ +Usage Of Content\n\ +\n\ +THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ +OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ +USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ +AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ +NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ +AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ +AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ +OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ +TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ +OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ +BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ +\n\ +Applicable Licenses\n\ +\n\ +Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ +is provided to you under the terms and conditions of the Eclipse Public\n\ +License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ +Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ +For purposes of the EPL, "Program" will mean the Content.\n\ +\n\ +Content includes, but is not limited to, source code, object code,\n\ +documentation and other files maintained in the Eclipse.org CVS\n\ +repository ("Repository") in CVS modules ("Modules") and made available\n\ +as downloadable archives ("Downloads").\n\ +\n\ + - Content may be structured and packaged into modules to facilitate delivering,\n\ + extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ + plug-in fragments ("Fragments"), and features ("Features").\n\ + - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ + in a directory named "plugins".\n\ + - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ + Each Feature may be packaged as a sub-directory in a directory named "features".\n\ + Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ + numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ + - Features may also include other Features ("Included Features"). Within a Feature, files\n\ + named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ +\n\ +Features may also include other Features ("Included Features"). Files named\n\ +"feature.xml" may contain a list of the names and version numbers of\n\ +Included Features.\n\ +\n\ +The terms and conditions governing Plug-ins and Fragments should be\n\ +contained in files named "about.html" ("Abouts"). The terms and\n\ +conditions governing Features and Included Features should be contained\n\ +in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ +Licenses may be located in any directory of a Download or Module\n\ +including, but not limited to the following locations:\n\ +\n\ + - The top-level (root) directory\n\ + - Plug-in and Fragment directories\n\ + - Inside Plug-ins and Fragments packaged as JARs\n\ + - Sub-directories of the directory named "src" of certain Plug-ins\n\ + - Feature directories\n\ +\n\ +Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ +Eclipse Update Manager, you must agree to a license ("Feature Update\n\ +License") during the installation process. If the Feature contains\n\ +Included Features, the Feature Update License should either provide you\n\ +with the terms and conditions governing the Included Features or inform\n\ +you where you can locate them. Feature Update Licenses may be found in\n\ +the "license" property of files named "feature.properties". Such Abouts,\n\ +Feature Licenses and Feature Update Licenses contain the terms and\n\ +conditions (or references to such terms and conditions) that govern your\n\ +use of the associated Content in that directory.\n\ +\n\ +THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ +TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ +SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ +\n\ + - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ + - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ + - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ + - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ + - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ + - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ +\n\ +IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ +TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ +is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ +govern that particular Content.\n\ +\n\ +Cryptography\n\ +\n\ +Content may contain encryption software. The country in which you are\n\ +currently may have restrictions on the import, possession, and use,\n\ +and/or re-export to another country, of encryption software. BEFORE\n\ +using any encryption software, please check the country's laws,\n\ +regulations and policies concerning the import, possession, or use,\n\ +and re-export of encryption software, to see if this is permitted.\n\ +\n\ +Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n +########### end of license property ########################################## diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index 7c574a462a7..bd754fbb1ac 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -11,108 +11,12 @@ Device Debug Memory Renderings - - Copyright (c) 2006-2007 Wind River Systems 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 + + %copyright - - ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT -March 17, 2005 -Usage Of Content -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, -INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY -"CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS -OF THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE -AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING -THE CONTENT, YOU AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED -BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE -LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. -IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT -AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS -OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE -THE CONTENT. -Applicable Licenses -Unless otherwise indicated, all Content made available by the -Eclipse Foundation is provided to you under the terms and conditions -of the Eclipse Public License Version 1.0 ("EPL"). A copy of -the EPL is provided with this Content and is also available at -http://www.eclipse.org/legal/epl-v10.html. For purposes of the -EPL, "Program" will mean the Content. -Content includes, but is not limited to, source code, object -code, documentation and other files maintained in the Eclipse.org -CVS repository ("Repository") in CVS modules ("Modules") and -made available as downloadable archives ("Downloads"). -- Content may be structured and packaged into modules to facilitate -delivering, -extending, and upgrading the Content. Typical modules may include -plug-ins ("Plug-ins"), -plug-in fragments ("Fragments"), and features ("Features"). -- Each Plug-in or Fragment may be packaged as a sub-directory -or JAR (Java? ARchive) -in a directory named "plugins". -- A Feature is a bundle of one or more Plug-ins and/or Fragments -and associated material. -Each Feature may be packaged as a sub-directory in a directory -named "features". -Within a Feature, files named "feature.xml" may contain a list -of the names and version -numbers of the Plug-ins and/or Fragments associated with that -Feature. -- Features may also include other Features ("Included Features"). -Within a Feature, files -named "feature.xml" may contain a list of the names and version -numbers of Included Features. -Features may also include other Features ("Included Features"). -Files named "feature.xml" may contain a list of the names and -version numbers of Included Features. -The terms and conditions governing Plug-ins and Fragments should -be contained in files named "about.html" ("Abouts"). The terms -and conditions governing Features and Included Features should -be contained in files named "license.html" ("Feature Licenses"). -Abouts and Feature -Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations: -- The top-level (root) directory -- Plug-in and Fragment directories -- Inside Plug-ins and Fragments packaged as JARs -- Sub-directories of the directory named "src" of certain Plug-ins -- Feature directories -Note: if a Feature made available by the Eclipse Foundation is -installed using the Eclipse Update Manager, you must agree to -a license ("Feature Update License") during the installation -process. If the Feature contains Included Features, the Feature -Update License should either provide you -with the terms and conditions governing the Included Features -or inform you where you can locate them. Feature Update Licenses -may be found in the "license" property of files named "feature.properties". -Such Abouts, Feature Licenses and Feature Update Licenses contain -the terms and conditions (or references to such terms and conditions) -that govern your -use of the associated Content in that directory. -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY -REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS -AND CONDITIONS. SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE -(BUT ARE NOT LIMITED TO): -- Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html) -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS -PRIOR TO USE OF THE CONTENT. If no About, Feature License or -Feature Update License is provided, please contact the Eclipse -Foundation to determine what terms and conditions govern that -particular Content. -Cryptography -Content may contain encryption software. The country in which -you are currently may have restrictions on the import, possession, -and use, and/or re-export to another country, of encryption software. -BEFORE using any encryption software, please check the country's -laws, -regulations and policies concerning the import, possession, or -use, and re-export of encryption software, to see if this is -permitted. -Java and all Java-based trademarks are trademarks of Sun Microsystem + + %license diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/license.html b/features/org.eclipse.dd.debug.memory.renderings-feature/license.html new file mode 100644 index 00000000000..c6af966b61e --- /dev/null +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/license.html @@ -0,0 +1,79 @@ + + + + +Eclipse.org Software User Agreement + + + +

Eclipse Foundation Software User Agreement

+

March 17, 2005

+ +

Usage Of Content

+ +

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS + (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND + CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE + OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR + NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND + CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.

+ +

Applicable Licenses

+ +

Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0 + ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. + For purposes of the EPL, "Program" will mean the Content.

+ +

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS + modules ("Modules") and made available as downloadable archives ("Downloads").

+ +
    +
  • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
  • +
  • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
  • +
  • A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins + and/or Fragments associated with that Feature.
  • +
  • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
  • +
+ +

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and +Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module +including, but not limited to the following locations:

+ +
    +
  • The top-level (root) directory
  • +
  • Plug-in and Fragment directories
  • +
  • Inside Plug-ins and Fragments packaged as JARs
  • +
  • Sub-directories of the directory named "src" of certain Plug-ins
  • +
  • Feature directories
  • +
+ +

Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") during the +installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or +inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature. +Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in +that directory.

+ +

THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE +OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):

+ + + +

IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please +contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.

+ +

Cryptography

+ +

Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to + another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import, + possession, or use, and re-export of encryption software, to see if this is permitted.

+ +Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/about.html b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/about.html new file mode 100644 index 00000000000..cb740ae8bc8 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/about.html @@ -0,0 +1,24 @@ + + + + +About +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties index e9863e281ea..b3a6164b629 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -2,4 +2,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml + plugin.xml \ + about.html From 905afac0b8c343acda5c9be4fb3ca36992e0b958 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 31 May 2007 21:53:33 +0000 Subject: [PATCH 023/118] missing commas --- .../build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties index b3a6164b629..786b1df9364 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -2,5 +2,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml \ + plugin.xml,\ about.html From a0fdd5636df72b6d08fa5a81d2852555349d7d99 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 12 Jun 2007 17:28:20 +0000 Subject: [PATCH 024/118] initial memory import/export prototyping --- .../build.properties | 3 +- .../plugin.properties | 2 + .../plugin.xml | 27 ++ .../actions/ExportMemoryAction.java | 202 +++++++++ .../actions/ExportMemoryDialog.java | 389 ++++++++++++++++++ .../actions/ImportMemoryAction.java | 194 +++++++++ .../actions/ImportMemoryDialog.java | 283 +++++++++++++ 7 files changed, 1099 insertions(+), 1 deletion(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties index 786b1df9364..0041ca9f849 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -1,6 +1,7 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ + plugin.properties,\ .,\ plugin.xml,\ - about.html + about.html \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties new file mode 100644 index 00000000000..1ce59a6a290 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties @@ -0,0 +1,2 @@ +ExportMemoryAction.label=Export +ImportMemoryAction.label=Import \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index ff1f06d09a5..60c1b8911b4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -27,4 +27,31 @@ + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java new file mode 100644 index 00000000000..f2f58d6ffd6 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java @@ -0,0 +1,202 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.io.File; +import java.io.FileWriter; +import java.math.BigInteger; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Action for exporting memory. + */ +public class ExportMemoryAction implements IViewActionDelegate { + + private MemoryView fView; + + public void init(IViewPart view) { + if (view instanceof MemoryView) + fView = (MemoryView) view; + } + + public void run(IAction action) { + + String secondaryId = MemoryViewIdRegistry + .getUniqueSecondaryId(IDebugUIConstants.ID_MEMORY_VIEW); + + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection strucSel = (IStructuredSelection) selection; + + // return if current selection is empty + if (strucSel.isEmpty()) + return; + + Object obj = strucSel.getFirstElement(); + + if (obj == null) + return; + + IMemoryBlock memBlock = null; + + if (obj instanceof IMemoryRendering) { + memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + } else if (obj instanceof IMemoryBlock) { + memBlock = (IMemoryBlock) obj; + } + + Shell shell = DebugUIPlugin.getShell(); + ExportMemoryDialog dialog = new ExportMemoryDialog(shell, memBlock); + dialog.open(); + + Object results[] = dialog.getResult(); + + if(results != null && results.length == 5) + { + String format = (String) results[0]; + BigInteger start = (BigInteger) results[1]; + BigInteger end = (BigInteger) results[2]; + File file = (File) results[4]; + + if("S-Record".equals(format)) + { + exportSRecord(file, start, end, (IMemoryBlockExtension) memBlock); // FIXME + } + } + } + + } + + private void exportSRecord(final File outputFile, final BigInteger startAddress, final BigInteger endAddress, final IMemoryBlockExtension memblock) + { + Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + // FIXME 4 byte default + + BigInteger DATA_PER_RECORD = BigInteger.valueOf(16); + + BigInteger transferAddress = startAddress; + + FileWriter writer = new FileWriter(outputFile); + + BigInteger jobs = endAddress.subtract(transferAddress).divide(DATA_PER_RECORD); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); + + BigInteger jobCount = BigInteger.ZERO; + while(transferAddress.compareTo(endAddress) < 0) + { + BigInteger length = DATA_PER_RECORD; + if(endAddress.subtract(transferAddress).compareTo(length) < 0) + length = endAddress.subtract(transferAddress); + + writer.write("S3"); // FIXME 4 byte address + + StringBuffer buf = new StringBuffer(); + + BigInteger sRecordLength = BigInteger.valueOf(4); // address size + sRecordLength = sRecordLength.add(length); + sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum + + String transferAddressString = transferAddress.toString(16); + + String lengthString = sRecordLength.toString(16); + if(lengthString.length() == 1) + buf.append("0"); + buf.append(lengthString); + for(int i = 0; i < 8 - transferAddressString.length(); i++) + buf.append("0"); + buf.append(transferAddressString); + + // data + + MemoryByte bytes[] = memblock.getBytesFromAddress(transferAddress, + length.longValue() / memblock.getAddressableSize()); + for(MemoryByte b : bytes) + { + String bString = BigInteger.valueOf(0xFF & b.getValue()).toString(16); + if(bString.length() == 1) + buf.append("0"); + buf.append(bString); + } + + BigInteger checksum = BigInteger.ZERO; + + for(int i = 0; i < buf.length(); i+=2) + { + BigInteger value = new BigInteger(buf.substring(i, i+1), 16); + checksum = checksum.add(value); + } + + buf.append(BigInteger.valueOf(0xFF - checksum.byteValue()).and( + BigInteger.valueOf(0xFF)).toString(16)); + + writer.write(buf.toString().toUpperCase()); + writer.write("\n"); + + transferAddress = transferAddress.add(length); + + jobCount = jobCount.add(BigInteger.ONE); + if(jobCount.compareTo(factor) == 0) + { + jobCount = BigInteger.ZERO; + monitor.worked(1); + } + } + + writer.close(); + monitor.done(); + } + catch(Exception e) { e.printStackTrace();} + } + catch(Exception e) {e.printStackTrace();} + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java new file mode 100644 index 00000000000..f11b1eb6b41 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java @@ -0,0 +1,389 @@ +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.io.File; +import java.math.BigInteger; + +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.VerifyEvent; +import org.eclipse.swt.events.VerifyListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +public class ExportMemoryDialog extends SelectionDialog +{ + + private Combo formatCombo; + + private IMemoryBlock fMemoryBlock; + + private Text startText; + private Text endText; + private Text lengthText; + private Text fileText; + + public ExportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + { + super(parent); + super.setTitle("Export Memory"); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fMemoryBlock = memoryBlock; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + super.createButtonsForButtonBar(parent); + validate(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() + */ + public Object[] getResult() { + + Object[] results = super.getResult(); + + if (results != null) + { + return results; + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + protected void cancelPressed() { + + setResult(null); + + super.cancelPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + setSelectionResult(new Object[]{ getFormat(), getStartAddress(), getEndAddress(), getLength(), getFile() }); + + super.okPressed(); + } + + public String getFormat() + { + return formatCombo.getItem(formatCombo.getSelectionIndex()); + } + + public BigInteger getEndAddress() + { + String text = endText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return endAddress; + } + + public BigInteger getStartAddress() + { + String text = startText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public BigInteger getLength() + { + String text = lengthText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return lengthAddress; + } + + public File getFile() + { + return new File(fileText.getText()); + } + + private void validate() + { + boolean isValid = true; + + try + { + getEndAddress(); + + getStartAddress(); + + BigInteger length = getLength(); + + if(length.compareTo(BigInteger.ZERO) <= 0) + isValid = false; + + if(!getFile().getParentFile().exists()) + isValid = false; + } + catch(Exception e) + { + isValid = false; + } + + getButton(IDialogConstants.OK_ID).setEnabled(isValid); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME + Composite composite = new Composite(parent, SWT.NONE); + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // format + + Label textLabel = new Label(composite, SWT.NONE); + textLabel.setText("Format: "); + + formatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); + + FormData data = new FormData(); + data.top = new FormAttachment(formatCombo, 0, SWT.CENTER); + textLabel.setLayoutData(data); + + data = new FormData(); + data.left = new FormAttachment(textLabel); + formatCombo.setLayoutData(data); + formatCombo.setItems( new String[] { "S-Record" }); // TODO offer extension point + formatCombo.select(0); + + // start address + + Label startLabel = new Label(composite, SWT.NONE); + startLabel.setText("Start address: "); + data = new FormData(); + data.top = new FormAttachment(formatCombo); + startLabel.setLayoutData(data); + + startText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(formatCombo); + data.left = new FormAttachment(startLabel); + data.width = 100; + startText.setLayoutData(data); + + // end address + + Label endLabel = new Label(composite, SWT.NONE); + endLabel.setText("End address: "); + data = new FormData(); + data.top = new FormAttachment(startText, 0, SWT.CENTER); + data.left = new FormAttachment(startText); + endLabel.setLayoutData(data); + + endText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(startText, 0, SWT.CENTER); + data.left = new FormAttachment(endLabel); + data.width = 100; + endText.setLayoutData(data); + + // length + + Label lengthLabel = new Label(composite, SWT.NONE); + lengthLabel.setText("Length: "); + data = new FormData(); + data.top = new FormAttachment(startText, 0, SWT.CENTER); + data.left = new FormAttachment(endText); + lengthLabel.setLayoutData(data); + + lengthText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(startText, 0, SWT.CENTER); + data.left = new FormAttachment(lengthLabel); + data.width = 100; + lengthText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(lengthText); + data.left = new FormAttachment(fileText); + fileButton.setLayoutData(data); + + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + startText.setText("0x" + startAddress.toString(16)); + endText.setText("0x" + startAddress.toString(16)); + lengthText.setText("0"); + } + catch(Exception e) + { + e.printStackTrace(); + // TODO + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(ExportMemoryDialog.this.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + startText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + lengthText.setText(endAddress.subtract(startAddress).toString()); + + validate(); + } + + }); + + endText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + getEndAddress(); + endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + String lengthString = endAddress.subtract(startAddress).toString(); + + if(!lengthText.getText().equals(lengthString)) + lengthText.setText(lengthString); + } + catch(Exception ex) + { + endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + lengthText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + BigInteger length = getLength(); + lengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + BigInteger startAddress = getStartAddress(); + String endString = "0x" + startAddress.add(length).toString(16); + if(!endText.getText().equals(endString)) + endText.setText(endString); + } + catch(Exception ex) + { + lengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + fileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + return composite; + } + + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java new file mode 100644 index 00000000000..7475c234e91 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.math.BigInteger; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Action for downloading memory. + */ +public class ImportMemoryAction implements IViewActionDelegate { + + + private MemoryView fView; + + public void init(IViewPart view) { + if (view instanceof MemoryView) + fView = (MemoryView) view; + } + + public void run(IAction action) { + + String secondaryId = MemoryViewIdRegistry + .getUniqueSecondaryId(IDebugUIConstants.ID_MEMORY_VIEW); + + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection strucSel = (IStructuredSelection) selection; + + // return if current selection is empty + if (strucSel.isEmpty()) + return; + + Object obj = strucSel.getFirstElement(); + + if (obj == null) + return; + + IMemoryBlock memBlock = null; + + if (obj instanceof IMemoryRendering) { + memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + } else if (obj instanceof IMemoryBlock) { + memBlock = (IMemoryBlock) obj; + } + + Shell shell = DebugUIPlugin.getShell(); + ImportMemoryDialog dialog = new ImportMemoryDialog(shell, memBlock); + dialog.open(); + + Object results[] = dialog.getResult(); + + if(results != null && results.length == 4) + { + String format = (String) results[0]; + Boolean useCustomAddress = (Boolean) results[1]; + BigInteger start = (BigInteger) results[2]; + File file = (File) results[3]; + + if("S-Record".equals(format)) + { + downloadSRecord(file, start, useCustomAddress.booleanValue(), (IMemoryBlockExtension) memBlock); // FIXME + } + } + } + + } + + private void downloadSRecord(final File inputFile, final BigInteger startAddress, final boolean useCustomAddress, final IMemoryBlockExtension memblock) + { + Job job = new Job("Memory Download from S-Record File"){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + // FIXME 4 byte default + + final int CHECKSUM_LENGTH = 1; + + BigInteger offset = null; + if(!useCustomAddress) + offset = BigInteger.ZERO; + + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); + + BigInteger jobs = BigInteger.valueOf(inputFile.length()); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); + + BigInteger jobCount = BigInteger.ZERO; + String line = reader.readLine(); + while(line != null) + { + String recordType = line.substring(0, 2); + int recordCount = Integer.parseInt(line.substring(2, 4), 16); + int bytesRead = 4 + recordCount; + int position = 4; + int addressSize = 0; + + BigInteger recordAddress = null; + + if("S3".equals(recordType)) + addressSize = 4; + else if("S1".equals(recordType)) + addressSize = 2; + else if("S2".equals(recordType)) + addressSize = 3; + + recordAddress = new BigInteger(line.substring(position, position + addressSize * 2), 16); + recordCount -= addressSize; + position += addressSize * 2; + + if(offset == null) + offset = startAddress.subtract(recordAddress); + + recordAddress = recordAddress.add(offset); + + byte data[] = new byte[recordCount - CHECKSUM_LENGTH]; + for(int i = 0; i < data.length; i++) + { + data[i] = new BigInteger(line.substring(position++, position++ + 1), 16).byteValue(); + } + + // FIXME error on incorrect checksum + + memblock.setValue(recordAddress.subtract(memblock.getBigBaseAddress()), data); + + jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); + while(jobCount.compareTo(factor) >= 0) + { + jobCount = jobCount.subtract(factor); + monitor.worked(1); + } + + line = reader.readLine(); + } + + reader.close(); + monitor.done(); + } + catch(Exception e) { e.printStackTrace();} + } + catch(Exception e) {e.printStackTrace();} + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java new file mode 100644 index 00000000000..19cbd33ac79 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java @@ -0,0 +1,283 @@ +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.io.File; +import java.math.BigInteger; + +import javax.swing.ButtonGroup; + +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +public class ImportMemoryDialog extends SelectionDialog +{ + + private Combo formatCombo; + + private IMemoryBlock fMemoryBlock; + + private Text startText; + private Text fileText; + + private Button comboRestoreToThisAddress; + private Button comboRestoreToFileAddress; + + public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + { + super(parent); + super.setTitle("Download to Memory"); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fMemoryBlock = memoryBlock; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + super.createButtonsForButtonBar(parent); + validate(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() + */ + public Object[] getResult() { + + Object[] results = super.getResult(); + + if (results != null) + { + return results; + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + protected void cancelPressed() { + + setResult(null); + + super.cancelPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + setSelectionResult(new Object[]{ getFormat(), new Boolean(comboRestoreToThisAddress.getSelection()), + getStartAddress(), getFile() }); + + super.okPressed(); + } + + public String getFormat() + { + return formatCombo.getItem(formatCombo.getSelectionIndex()); + } + + public BigInteger getStartAddress() + { + String text = startText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public File getFile() + { + return new File(fileText.getText()); + } + + private void validate() + { + boolean isValid = true; + + try + { + getStartAddress(); + } + catch(Exception e) + { + isValid = false; + } + + getButton(IDialogConstants.OK_ID).setEnabled(isValid); + + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME + Composite composite = new Composite(parent, SWT.NONE); + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // format + + Label textLabel = new Label(composite, SWT.NONE); + textLabel.setText("Format: "); + + formatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); + + FormData data = new FormData(); + data.top = new FormAttachment(formatCombo, 0, SWT.CENTER); + textLabel.setLayoutData(data); + + data = new FormData(); + data.left = new FormAttachment(textLabel); + formatCombo.setLayoutData(data); + formatCombo.setItems( new String[] { "S-Record" }); // TODO offer extension point + formatCombo.select(0); + + // restore to file address + + comboRestoreToFileAddress = new Button(composite, SWT.RADIO); + comboRestoreToFileAddress.setText("Restore to address specified in the file"); + data = new FormData(); + data.top = new FormAttachment(formatCombo); + comboRestoreToFileAddress.setLayoutData(data); + + // restore to this address + + comboRestoreToThisAddress = new Button(composite, SWT.RADIO); + comboRestoreToThisAddress.setText("Restore to this address: "); + data = new FormData(); + data.top = new FormAttachment(comboRestoreToFileAddress); + comboRestoreToThisAddress.setLayoutData(data); + + startText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(comboRestoreToFileAddress); + data.left = new FormAttachment(comboRestoreToThisAddress); + data.width = 100; + startText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(startText); + data.left = new FormAttachment(fileText); + fileButton.setLayoutData(data); + + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + startText.setText("0x" + startAddress.toString(16)); + } + catch(Exception e) + { + e.printStackTrace(); + // TODO + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(ImportMemoryDialog.this.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + startText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger startAddress = getStartAddress(); + + validate(); + } + + }); + fileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + return composite; + } + + +} From 1aef6f95590ddaf128c096560641ebb9d0b57752 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sat, 16 Jun 2007 21:11:25 +0000 Subject: [PATCH 025/118] Moved TraditionalRendering.Rendering to Rendering --- .../renderings/traditional/Rendering.java | 1941 +++++++++++++++++ .../traditional/TraditionalRendering.java | 1927 ---------------- 2 files changed, 1941 insertions(+), 1927 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java new file mode 100644 index 00000000000..bf5da6bead7 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -0,0 +1,1941 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugEvent; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.IDebugEventSetListener; +import org.eclipse.debug.core.model.IDebugElement; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; +import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Layout; +import org.eclipse.swt.widgets.ScrollBar; +import org.eclipse.swt.widgets.Text; + +public class Rendering extends Composite implements IDebugEventSetListener +{ + // the IMemoryRendering parent + private TraditionalRendering fParent; + + // controls + + private AddressPane fAddressPane; + + private DataPane fBinaryPane; + + private TextPane fTextPane; + + private GoToAddressComposite fAddressBar; + + private Control fAddressBarControl; // FIXME why isn't there a getControl() ? + + private Selection fSelection = new Selection(); + + // storage + + BigInteger fViewportAddress = null; // default visibility for performance + + BigInteger fMemoryBlockStartAddress = null; + BigInteger fMemoryBlockEndAddress = null; + + BigInteger fBaseAddress = null; // remember the base address + + private int fColumnCount = 0; // auto calculate can be disabled by user, + // making this user settable + + private int fBytesPerRow = 0; // current number of bytes per row are displayed + + private int fCurrentScrollSelection = 0; // current scroll selection; + + private BigInteger fCaretAddress = BigInteger.valueOf(0); // -1 ? + + // user settings + + private int fTextMode = 1; // ASCII default, TODO make preference? + + private int fBytesPerColumn = 4; // 4 byte cell width default + + private int fRadix = RADIX_HEX; + + private int fColumnsSetting = COLUMNS_AUTO_SIZE_TO_FIT; + + private boolean fLittleEndian = false; + + private boolean fCheckedLittleEndian = false; + + // constants used to identify radix + protected final static int RADIX_HEX = 1; + + protected final static int RADIX_DECIMAL_SIGNED = 2; + + protected final static int RADIX_DECIMAL_UNSIGNED = 3; + + protected final static int RADIX_OCTAL = 4; + + protected final static int RADIX_BINARY = 5; + + // constants used to identify panes + protected final static int PANE_ADDRESS = 1; + + protected final static int PANE_BINARY = 2; + + protected final static int PANE_TEXT = 3; + + // constants used to identify text, maybe java should be queried for all available sets + protected final static int TEXT_ISO_8859_1 = 1; + protected final static int TEXT_USASCII = 2; + protected final static int TEXT_UTF8 = 3; + protected final static int TEXT_UTF16 = 4; + + // internal constants + protected final static int COLUMNS_AUTO_SIZE_TO_FIT = 0; + + // view internal settings + private int fCellPadding = 2; + + private int fPaneSpacing = 16; + + // flag whether the memory cache is dirty + private boolean fCacheDirty = false; + + public Rendering(Composite parent, TraditionalRendering renderingParent) + { + super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.H_SCROLL + | SWT.V_SCROLL); + + this.setFont(JFaceResources + .getFont(IInternalDebugUIConstants.FONT_NAME)); // TODO internal? + + this.fParent = renderingParent; + + // instantiate the panes, TODO default visibility from state or + // plugin.xml? + this.fAddressPane = new AddressPane(this); + this.fBinaryPane = new DataPane(this); + this.fTextPane = new TextPane(this); + + fAddressBar = new GoToAddressComposite(); + fAddressBarControl = fAddressBar.createControl(parent); + Button button = fAddressBar.getButton(IDialogConstants.OK_ID); + if (button != null) + { + button.addSelectionListener(new SelectionAdapter() { + + public void widgetSelected(SelectionEvent e) { + doGoToAddress(); + } + }); + + button = fAddressBar.getButton(IDialogConstants.CANCEL_ID); + if (button != null) + { + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + setVisibleAddressBar(false); + }}); + } + } + + fAddressBar.getExpressionWidget().addSelectionListener(new SelectionAdapter() { + public void widgetDefaultSelected(SelectionEvent e) { + doGoToAddress(); + }}); + + fAddressBar.getExpressionWidget().addKeyListener(new KeyAdapter() { + + public void keyPressed(KeyEvent e) { + if (e.keyCode == SWT.ESC) + setVisibleAddressBar(false); + super.keyPressed(e); + } + }); + + this.fAddressBarControl.setVisible(false); + + // initialize the viewport start + IMemoryBlockExtension memoryBlock = getMemoryBlock(); + if(memoryBlock != null) + { + try + { + fViewportAddress = memoryBlock.getMemoryBlockStartAddress(); + // this will be null if memory may be retrieved at any address less than + // this memory block's base. if so use the base address. + if (fViewportAddress == null) + fViewportAddress = memoryBlock.getBigBaseAddress(); + fBaseAddress = fViewportAddress; + } + catch(DebugException e) + { + fViewportAddress = null; + if(isDebug()) + Rendering.this + .logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), e); //$NON-NLS-1$ + } + } + + getHorizontalBar().addSelectionListener(new SelectionListener() + { + public void widgetSelected(SelectionEvent se) + { + Rendering.this.layout(); + } + + public void widgetDefaultSelected(SelectionEvent se) + { + // do nothing + } + }); + + getVerticalBar().addSelectionListener( + new SelectionListener() + { + public void widgetSelected(SelectionEvent se) + { + int addressableSize = getAddressableSize(); + + switch(se.detail) + { + case SWT.ARROW_DOWN: + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.PAGE_DOWN: + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.ARROW_UP: + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.PAGE_UP: + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + break; + case SWT.SCROLL_LINE: + if(getVerticalBar().getSelection() == getVerticalBar().getMinimum()) + { + // Set view port start address to the start address of the Memory Block + fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); + } + else if(getVerticalBar().getSelection() == getVerticalBar().getMaximum()) + { + // The view port end address should be less or equal to the the end address of the Memory Block + // Set view port address to be bigger than the end address of the Memory Block for now + // and let ensureViewportAddressDisplayable() to figure out the correct view port start address + fViewportAddress = Rendering.this.getMemoryBlockEndAddress(); + } + else + { + // Figure out the delta + int delta = getVerticalBar().getSelection() - fCurrentScrollSelection; + fViewportAddress = fViewportAddress.add(BigInteger.valueOf( + getAddressableCellsPerRow() * delta)); + } + ensureViewportAddressDisplayable(); + // Update tooltip + // FIXME conversion from slider to scrollbar + // getVerticalBar().setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + + // Update the addresses on the Address pane. + // Do not update the Binary and Text panes until dragging of the thumb nail stops + if(fAddressPane.isPaneVisible()) + { + fAddressPane.redraw(); + } + break; + case SWT.NONE: + // Dragging of the thumb nail stops. Redraw the panes + redrawPanes(); + break; + } + + } + + public void widgetDefaultSelected(SelectionEvent se) + { + // do nothing + } + }); + + this.addPaintListener(new PaintListener() + { + public void paintControl(PaintEvent pe) + { + pe.gc.setBackground(Rendering.this.getTraditionalRendering().getColorBackground()); + pe.gc.fillRectangle(0, 0, Rendering.this.getBounds().width, + Rendering.this.getBounds().height); + } + }); + + this.setLayout(new Layout() + { + public void layout(Composite composite, boolean changed) + { + int xOffset = 0; + if(Rendering.this.getHorizontalBar().isVisible()) + xOffset = Rendering.this.getHorizontalBar().getSelection(); + + int x = xOffset * -1; + int y = 0; + + if(fAddressBarControl.isVisible()) + { + fAddressBarControl.setBounds(0, 0, + Rendering.this.getBounds().width, fAddressBarControl + .computeSize(100, 30).y); // FIXME + //y = fAddressBarControl.getBounds().height; + } + + if(fAddressPane.isPaneVisible()) + { + fAddressPane.setBounds(x, y, + fAddressPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fAddressPane.getBounds().x + + fAddressPane.getBounds().width; + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.setBounds(x, y, + fBinaryPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fBinaryPane.getBounds().x + + fBinaryPane.getBounds().width; + } + + if(fTextPane.isPaneVisible()) + { + fTextPane.setBounds(x, y, + Math.max(fTextPane.computeSize(0, 0).x, Rendering.this.getClientArea().width + - x - xOffset), Rendering.this.getBounds().height - y); + } + + if(getClientArea().width >= fTextPane.getBounds().x + fTextPane.getBounds().width + xOffset) + { + Rendering.this.getHorizontalBar().setVisible(false); + } + else + { + ScrollBar horizontal = Rendering.this.getHorizontalBar(); + + horizontal.setVisible(true); + horizontal.setMinimum(0); + horizontal.setMaximum(fTextPane.getBounds().x + + fTextPane.getBounds().width + xOffset); + horizontal.setThumb(getClientArea().width); + horizontal.setPageIncrement(40); // TODO ? + horizontal.setIncrement(20); // TODO ? + } + } + + protected Point computeSize(Composite composite, int wHint, + int hHint, boolean flushCache) + { + return new Point(100, 100); // dummy data + } + }); + + this.addControlListener(new ControlListener() + { + public void controlMoved(ControlEvent ce) + { + } + + public void controlResized(ControlEvent ce) + { + packColumns(); + } + }); + + DebugPlugin.getDefault().addDebugEventListener(this); + } + + protected TraditionalRendering getTraditionalRendering() // TODO rename + { + return fParent; + } + + protected void setCaretAddress(BigInteger address) + { + fCaretAddress = address; + } + + protected BigInteger getCaretAddress() + { + return fCaretAddress; + } + + private void doGoToAddress() { + try { + BigInteger address = fAddressBar.getGoToAddress(this.getMemoryBlockStartAddress(), this.getCaretAddress()); + getTraditionalRendering().gotoAddress(address); + setVisibleAddressBar(false); + } catch (NumberFormatException e1) + { + // FIXME log? + } + } + + // Ensure that all addresses displayed are within the addressable range + protected void ensureViewportAddressDisplayable() + { + if(fViewportAddress.compareTo(Rendering.this.getMemoryBlockStartAddress()) < 0) + { + fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); + } + else if(getViewportEndAddress().compareTo(getMemoryBlockEndAddress().add(BigInteger.ONE)) > 0) + { + fViewportAddress = getMemoryBlockEndAddress().subtract(BigInteger.valueOf(getAddressableCellsPerRow() + * getRowCount() - 1)); + } + + setCurrentScrollSelection(); + } + + protected Selection getSelection() + { + return fSelection; + } + + protected void logError(String message, Exception e) + { + Status status = new Status(IStatus.ERROR, fParent.getRenderingId(), + DebugException.INTERNAL_ERROR, message, e); + + DebugUIPlugin.getDefault().getLog().log(status); + } + + public void handleFontPreferenceChange(Font font) + { + setFont(font); + + Control controls[] = this.getRenderingPanes(); + for(int i = 0; i < controls.length; i++) + controls[i].setFont(font); + + packColumns(); + redrawPanes(); + } + + public void handleDebugEvents(DebugEvent[] events) + { + for(int i = 0; i < events.length; i++) + { + if(events[0].getSource() instanceof IDebugElement) + { + final int kind = events[i].getKind(); + final int detail = events[i].getDetail(); + final IDebugElement source = (IDebugElement) events[i] + .getSource(); + + // TODO allow extensible customization of event handling; + // integration with user configurable update policies should happen here. + if(source.getDebugTarget() == getMemoryBlock() + .getDebugTarget()) + { + if(kind == DebugEvent.SUSPEND && detail == 0) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + refresh(); + } + }); + } + else if(kind == DebugEvent.CHANGE) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + refresh(); + } + }); + } + else if(kind == DebugEvent.RESUME) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + archiveDeltas(); + } + }); + } + } + } + } + } + + // return true to enable development debug print statements + protected boolean isDebug() + { + return false; + } + + protected IMemoryBlockExtension getMemoryBlock() + { + IMemoryBlock block = fParent.getMemoryBlock(); + if(block != null) + return (IMemoryBlockExtension) block + .getAdapter(IMemoryBlockExtension.class); + + return null; + } + + protected int getAddressableSize() + { + try + { + return getMemoryBlock().getAddressableSize(); + } + catch(DebugException e) + { + return 1; + } + } + + protected ViewportCache getViewportCache() + { + return fViewportCache; + } + + protected MemoryByte[] getBytes(BigInteger address, int bytes) + throws DebugException + { + return fViewportCache.getBytes(address, bytes); + } + + // default visibility for performance + ViewportCache fViewportCache = new ViewportCache(); + + private interface Request + { + } + + class ViewportCache extends Thread + { + class ArchiveDeltas implements Request + { + + } + + class AddressPair implements Request + { + BigInteger startAddress; + + BigInteger endAddress; + } + + class MemoryUnit + { + BigInteger start; + + BigInteger end; + + MemoryByte[] bytes; + + public MemoryUnit clone() + { + MemoryUnit b = new MemoryUnit(); + + b.start = this.start; + b.end = this.end; + b.bytes = new MemoryByte[this.bytes.length]; + for(int i = 0; i < this.bytes.length; i++) + b.bytes[i] = new MemoryByte(this.bytes[i].getValue()); + + return b; + } + + public boolean isValid() + { + return this.start != null && this.end != null + && this.bytes != null; + } + } + + private HashMap fEditBuffer = new HashMap(); + + private boolean fDisposed = false; + + private Vector fQueue = new Vector(); + + protected MemoryUnit fCache = null; + + protected MemoryUnit fHistoryCache = null; + + public ViewportCache() + { + start(); + } + + public void dispose() + { + fDisposed = true; + synchronized(this) + { + this.notify(); + } + } + + protected void refresh() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(fCache != null) + { + queueRequest(fViewportAddress, getViewportEndAddress()); + } + } + + protected void archiveDeltas() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(fCache != null) + { + queueRequestArchiveDeltas(); + } + } + + + + private void queueRequest(BigInteger startAddress, BigInteger endAddress) + { + AddressPair pair = new AddressPair(); + pair.startAddress = startAddress; + pair.endAddress = endAddress; + synchronized(fQueue) + { + fQueue.addElement(pair); + } + synchronized(this) + { + this.notify(); + } + } + + private void queueRequestArchiveDeltas() + { + ArchiveDeltas archive = new ArchiveDeltas(); + synchronized(fQueue) + { + fQueue.addElement(archive); + } + synchronized(this) + { + this.notify(); + } + } + + public void run() + { + while(!fDisposed) + { + AddressPair pair = null; + boolean archiveDeltas = false; + synchronized(fQueue) + { + if(fQueue.size() > 0) + { + Request request = (Request) fQueue.elementAt(0); + Class type = null; + if(request instanceof ArchiveDeltas) + { + archiveDeltas = true; + type = ArchiveDeltas.class; + } + else if(request instanceof AddressPair) + { + pair = (AddressPair) request; + type = AddressPair.class; + } + + while(fQueue.size() > 0 && type.isInstance(fQueue.elementAt(0))) + fQueue.removeElementAt(0); + } + } + if(archiveDeltas) + { + fHistoryCache = fCache.clone(); + } + else if(pair != null) + { + populateCache(pair.startAddress, pair.endAddress); + } + else + { + synchronized(this) + { + try + { + this.wait(); + } + catch(Exception e) + { + // do nothing + } + } + } + } + } + + // cache memory necessary to paint viewport + // TODO: user setting to buffer +/- x lines + // TODO: reuse existing cache? probably only a minor performance gain + private void populateCache(final BigInteger startAddress, + final BigInteger endAddress) + { + try + { + final IMemoryBlockExtension memoryBlock = getMemoryBlock(); + + final BigInteger lengthInBytes = endAddress.subtract(startAddress); + final BigInteger addressableSize = BigInteger.valueOf(getAddressableSize()); + + final long units = lengthInBytes.divide(addressableSize).add( + lengthInBytes.mod(addressableSize).compareTo(BigInteger.ZERO) > 0 + ? BigInteger.ONE : BigInteger.ZERO).longValue(); + + // CDT (and maybe other backends) will call setValue() on these MemoryBlock objects. + // We don't want this to happen, because it interferes with this rendering's own + // change history. Ideally, we should strictly use the back end change notification + // and history, but it is only guaranteed to work for bytes within the address range + // of the MemoryBlock. + final MemoryByte readBytes[] = memoryBlock + .getBytesFromAddress(startAddress, units); + + final MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; + for(int i = 0; i < readBytes.length; i++) + cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); + + // we need to set the default endianess. before it was set to BE + // by default which wasn't very useful for LE targets. now we will + // query the first byte to get the endianess. if not known then we'll + // leave it as BE. note that we only do this when reading the first + // bit of memory for this rendering. what happens when scrolling + // through memory and it changes endianess? for now we just leave + // it in the original endianess. + if (!fCheckedLittleEndian && cachedBytes.length > 0) { + if (cachedBytes[0].isEndianessKnown()) { + fLittleEndian = !cachedBytes[0].isBigEndian(); + fCheckedLittleEndian = true; + fParent.bytesAreLittleEndian(fLittleEndian); + } + } + + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + // generate deltas + if(fHistoryCache != null && fHistoryCache.isValid()) + { + BigInteger maxStart = startAddress + .max(fHistoryCache.start); + BigInteger minEnd = endAddress + .min(fHistoryCache.end).subtract( + BigInteger.valueOf(1)); + + BigInteger overlapLength = minEnd + .subtract(maxStart); + if(overlapLength.compareTo(BigInteger.valueOf(0)) > 0) + { + // there is overlap + + int offsetIntoOld = maxStart.subtract( + fHistoryCache.start).intValue(); + int offsetIntoNew = maxStart.subtract( + startAddress).intValue(); + + for(int i = overlapLength.intValue(); i >= 0; i--) + { + cachedBytes[offsetIntoNew + i] + .setChanged(cachedBytes[offsetIntoNew + + i].getValue() != fHistoryCache.bytes[offsetIntoOld + + i].getValue()); + } + } + } + + fCache = new MemoryUnit(); + fCache.start = startAddress; + fCache.end = endAddress; + fCache.bytes = cachedBytes; + + Rendering.this.redrawPanes(); + } + }); + + } + catch(Exception e) + { + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_READ_MEMORY"), e); //$NON-NLS-1$ + } + } + + // bytes will be fetched from cache + protected MemoryByte[] getBytes(BigInteger address, int bytesRequested) + throws DebugException + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + if(containsEditedCell(address)) // cell size cannot be switched during an edit + return getEditedMemory(address); + + boolean contains = false; + if(fCache != null && fCache.start != null) + { + // see if all of the data requested is in the cache + BigInteger dataEnd = address.add(BigInteger.valueOf(bytesRequested)); + + if(fCache.start.compareTo(address) <= 0 + && fCache.end.compareTo(dataEnd) >= 0 + && fCache.bytes.length > 0) + contains = true; + } + + if(contains) + { + int offset = address.subtract(fCache.start).intValue(); + MemoryByte bytes[] = new MemoryByte[bytesRequested]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = fCache.bytes[offset + i]; + } + + return bytes; + } + + MemoryByte bytes[] = new MemoryByte[bytesRequested]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = new MemoryByte(); + bytes[i].setReadable(false); + } + + fViewportCache.queueRequest(fViewportAddress, + getViewportEndAddress()); + + return bytes; + } + + private boolean containsEditedCell(BigInteger address) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + return fEditBuffer.containsKey(address); + } + + private MemoryByte[] getEditedMemory(BigInteger address) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + return (MemoryByte[]) fEditBuffer.get(address); + } + + protected void clearEditBuffer() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + fEditBuffer.clear(); + Rendering.this.redrawPanes(); + } + + protected void writeEditBuffer() + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + Set keySet = fEditBuffer.keySet(); + Iterator iterator = keySet.iterator(); + + while(iterator.hasNext()) + { + BigInteger address = (BigInteger) iterator.next(); + MemoryByte[] bytes = (MemoryByte[]) fEditBuffer + .get(address); + + byte byteValue[] = new byte[bytes.length]; + for(int i = 0; i < bytes.length; i++) + byteValue[i] = bytes[i].getValue(); + + try + { + getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); + } + catch(Exception e) + { + MemoryViewUtil.openError(TraditionalRenderingMessages.getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), "", e); + + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), e); //$NON-NLS-1$ + } + } + + clearEditBuffer(); + } + + protected void setEditedValue(BigInteger address, MemoryByte[] bytes) + { + assert Thread.currentThread().equals( + Display.getDefault().getThread()) : TraditionalRenderingMessages + .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ + + fEditBuffer.put(address, bytes); + Rendering.this.redrawPanes(); + } + } + + public void setVisibleAddressBar(boolean visible) + { + fAddressBarControl.setVisible(visible); + if(visible) + { + String selectedStr = "0x" + getCaretAddress().toString(16); + Text text = fAddressBar.getExpressionWidget(); + text.setText(selectedStr); + text.setSelection(0, text.getCharCount()); + fAddressBar.getExpressionWidget().setFocus(); + } + + layout(true); + layoutPanes(); + } + + public void setDirty(boolean needRefresh) + { + fCacheDirty = needRefresh; + } + + public boolean isDirty() + { + return fCacheDirty; + } + + public void dispose() + { + if(fViewportCache != null) + { + fViewportCache.dispose(); + fViewportCache = null; + } + super.dispose(); + } + + class Selection + { + private BigInteger fStartHigh; + private BigInteger fStartLow; + + private BigInteger fEndHigh; + private BigInteger fEndLow; + + protected void clear() + { + fEndHigh = fEndLow = fStartHigh = fStartLow = null; + redrawPanes(); + } + + protected boolean hasSelection() + { + return fStartHigh != null && fStartLow != null + && fEndHigh != null && fEndLow != null; + } + + protected boolean isSelected(BigInteger address) + { + // do we have valid start and end addresses + if(getEnd() == null || getStart() == null) + return false; + + // if end is greater than start + if(getEnd().compareTo(getStart()) >= 0) + { + if(address.compareTo(getStart()) >= 0 + && address.compareTo(getEnd()) < 0) + return true; + } + // if start is greater than end + else if(getStart().compareTo(getEnd()) >= 0) + { + if(address.compareTo(getEnd()) >= 0 + && address.compareTo(getStart()) < 0) + return true; + } + + return false; + } + + protected void setStart(BigInteger high, BigInteger low) + { + if(high == null && low == null) + { + if(fStartHigh != null && fStartLow != null) + { + fStartHigh = null; + fStartLow = null; + redrawPanes(); + } + + return; + } + + boolean changed = false; + + if(fStartHigh == null || !high.equals(fStartHigh)) + { + fStartHigh = high; + changed = true; + } + + if(fStartLow == null || !low.equals(fStartLow)) + { + fStartLow = low; + changed = true; + } + + if(changed) + redrawPanes(); + } + + protected void setEnd(BigInteger high, BigInteger low) + { + if(high == null && low == null) + { + if(fEndHigh != null && fEndLow != null) + { + fEndHigh = null; + fEndLow = null; + redrawPanes(); + } + + return; + } + + boolean changed = false; + + if(fEndHigh == null || !high.equals(fEndHigh)) + { + fEndHigh = high; + changed = true; + } + + if(fEndLow == null || !low.equals(fEndLow)) + { + fEndLow = low; + changed = true; + } + + if(changed) + redrawPanes(); + } + + protected BigInteger getHigh() + { + if(!hasSelection()) + return null; + + return getStart().max(getEnd()); + } + + protected BigInteger getLow() + { + if(!hasSelection()) + return null; + + return getStart().min(getEnd()); + } + + protected BigInteger getStart() + { + // if there is no start, return null + if(fStartHigh == null) + return null; + + // if there is no end, return the high address of the start + if(fEndHigh == null) + return fStartHigh; + + // if Start High/Low equal End High/Low, return a low start and high end + if(fStartHigh.equals(fEndHigh) + && fStartLow.equals(fEndLow)) + return fStartLow; + + BigInteger differenceEndToStartHigh = fEndHigh.subtract(fStartHigh).abs(); + BigInteger differenceEndToStartLow = fEndHigh.subtract(fStartLow).abs(); + + // return the start high or start low based on which creates a larger selection + if(differenceEndToStartHigh.compareTo(differenceEndToStartLow) > 0) + return fStartHigh; + else + return fStartLow; + } + + protected BigInteger getEnd() + { + // if there is no end, return null + if(fEndHigh == null) + return null; + + // if Start High/Low equal End High/Low, return a low start and high end + if(fStartHigh.equals(fEndHigh) + && fStartLow.equals(fEndLow)) + return fStartHigh; + + BigInteger differenceStartToEndHigh = fStartHigh.subtract(fEndHigh).abs(); + BigInteger differenceStartToEndLow = fStartHigh.subtract(fEndLow).abs(); + + // return the start high or start low based on which creates a larger selection + if(differenceStartToEndHigh.compareTo(differenceStartToEndLow) >= 0) + return fEndHigh; + else + return fEndLow; + } + } + + protected void setPaneVisible(int pane, boolean visible) + { + switch(pane) + { + case PANE_ADDRESS: + fAddressPane.setPaneVisible(visible); + break; + case PANE_BINARY: + fBinaryPane.setPaneVisible(visible); + break; + case PANE_TEXT: + fTextPane.setPaneVisible(visible); + break; + } + + fireSettingsChanged(); + layoutPanes(); + } + + protected boolean getPaneVisible(int pane) + { + switch(pane) + { + case PANE_ADDRESS: + return fAddressPane.isPaneVisible(); + case PANE_BINARY: + return fBinaryPane.isPaneVisible(); + case PANE_TEXT: + return fTextPane.isPaneVisible(); + default: + return false; + } + } + + protected void packColumns() + { + int availableWidth = Rendering.this.getSize().x; + + if(fAddressPane.isPaneVisible()) + { + availableWidth -= fAddressPane.computeSize(0, 0).x; + availableWidth -= Rendering.this.getRenderSpacing() * 2; + } + + int combinedWidth = 0; + + if(fBinaryPane.isPaneVisible()) + combinedWidth += fBinaryPane.getCellWidth(); + + if(fTextPane.isPaneVisible()) + combinedWidth += fTextPane.getCellWidth(); + + if(getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT) + { + if(combinedWidth == 0) + fColumnCount = 0; + else + { + fColumnCount = availableWidth / combinedWidth; + if(fColumnCount == 0) + fColumnCount = 1; // paint one column even if only part can show in view + } + } + else + { + fColumnCount = getColumnsSetting(); + } + + try + { + // Update the number of bytes per row; + // the max and min scroll range and the current thumb nail position. + fBytesPerRow = getBytesPerColumn() * getColumnCount(); + BigInteger difference = getMemoryBlockEndAddress().subtract(getMemoryBlockStartAddress()).add(BigInteger.ONE); + BigInteger maxScrollRange = difference.divide(BigInteger.valueOf(getAddressableCellsPerRow())); + if(maxScrollRange.multiply(BigInteger.valueOf(getAddressableCellsPerRow())).compareTo(difference) != 0) + maxScrollRange = maxScrollRange.add(BigInteger.ONE); + + // support targets with an addressable size greater than 1 + maxScrollRange = maxScrollRange.divide(BigInteger.valueOf(getAddressableSize())); + + getVerticalBar().setMinimum(1); + getVerticalBar().setMaximum(maxScrollRange.intValue()); + getVerticalBar().setIncrement(1); + getVerticalBar().setPageIncrement(this.getRowCount() -1); + //TW FIXME conversion of slider to scrollbar + // fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); + setCurrentScrollSelection(); + } + catch(Exception e) + { + // FIXME precautionary + } + + Rendering.this.redraw(); + Rendering.this.redrawPanes(); + } + + protected AbstractPane[] getRenderingPanes() + { + return new AbstractPane[] { fAddressPane, fBinaryPane, + fTextPane }; + } + + protected int getCellPadding() + { + return fCellPadding; + } + + protected int getRenderSpacing() + { + return fPaneSpacing; + } + + protected void refresh() + { + if(!this.isDisposed()) + { + if(this.isVisible() && fViewportCache != null) + { + fViewportCache.refresh(); + } + else + { + setDirty(true); + fParent.updateRenderingLabels(); + } + } + } + + protected void archiveDeltas() + { + fViewportCache.archiveDeltas(); + } + + protected void gotoAddress(BigInteger address) + { + // Ensure that the GoTo address is within the addressable range + if((address.compareTo(this.getMemoryBlockStartAddress())< 0) || + (address.compareTo(this.getMemoryBlockEndAddress()) > 0)) + { + return; + } + + fViewportAddress = address; // TODO update fCaretAddress + redrawPanes(); + } + + protected void setViewportStartAddress(BigInteger newAddress) + { + fViewportAddress = newAddress; + } + + protected BigInteger getViewportStartAddress() + { + return fViewportAddress; + } + + protected BigInteger getViewportEndAddress() + { + return fViewportAddress.add(BigInteger.valueOf(this.getBytesPerRow() * getRowCount() / getAddressableSize())); + } + + protected String getAddressString(BigInteger address) + { + StringBuffer addressString = new StringBuffer(address.toString(16) + .toUpperCase()); + for(int chars = getAddressBytes() * 2 - addressString.length(); chars > 0; chars--) + { + addressString.insert(0, '0'); + } + addressString.insert(0, "0x"); //$NON-NLS-1$ + + return addressString.toString(); + } + + private int fAddressBytes = -1; // called often, cache + + protected int getAddressBytes() + { + if(fAddressBytes == -1) + { + try + { + IMemoryBlockExtension block = getMemoryBlock(); + fAddressBytes = block.getAddressSize(); + } + catch(DebugException e) + { + fAddressBytes = 0; + logError( + TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE"), e); //$NON-NLS-1$ + } + } + + return fAddressBytes; + } + + protected int getColumnCount() + { + return fColumnCount; + } + + public int getColumnsSetting() + { + return fColumnsSetting; + } + + public void setColumnsSetting(int columns) + { + if(fColumnsSetting != columns) + { + fColumnsSetting = columns; + fireSettingsChanged(); + layoutPanes(); + } + } + + protected void ensureVisible(BigInteger address) + { + BigInteger viewportStart = this.getViewportStartAddress(); + BigInteger viewportEnd = this.getViewportEndAddress(); + + boolean isAddressBeforeViewportStart = address.compareTo(viewportStart) < 0; + boolean isAddressAfterViewportEnd = address.compareTo(viewportEnd) > 0; + + if(isAddressBeforeViewportStart || isAddressAfterViewportEnd) + gotoAddress(address); + } + + protected int getRowCount() + { + int rowCount = 0; + Control panes[] = getRenderingPanes(); + for(int i = 0; i < panes.length; i++) + { + if(panes[i] instanceof AbstractPane) + rowCount = Math.max(rowCount, + ((AbstractPane) panes[i]).getRowCount()); + } + + return rowCount; + } + + protected int getBytesPerColumn() + { + return fBytesPerColumn; + } + + protected int getBytesPerRow() + { + return fBytesPerRow; + } + + protected int getAddressableCellsPerRow() + { + return getBytesPerRow() / getAddressableSize(); + } + + protected int getAddressesPerColumn() + { + return this.getBytesPerColumn() / getAddressableSize(); + } + + /** + * @return Set current scroll selection + */ + protected void setCurrentScrollSelection() + { + BigInteger selection = getViewportStartAddress().divide( + BigInteger.valueOf(getAddressableCellsPerRow()).add(BigInteger.ONE)); + getVerticalBar().setSelection(selection.intValue()); + fCurrentScrollSelection = selection.intValue(); + } + + /** + * @return start address of the memory block + */ + protected BigInteger getMemoryBlockStartAddress() + { + if (fMemoryBlockStartAddress == null) + { + try { + IMemoryBlock memoryBlock = this.getMemoryBlock(); + if(memoryBlock instanceof IMemoryBlockExtension) + { + BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); + if (startAddress != null) + fMemoryBlockStartAddress = startAddress; + } + } catch (DebugException e) { + fMemoryBlockStartAddress = null; + } + + // default to 0 if we have trouble getting the start address + if (fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = BigInteger.valueOf(0); + } + return fMemoryBlockStartAddress; + } + + /** + * @return end address of the memory block + */ + protected BigInteger getMemoryBlockEndAddress() + { + if (fMemoryBlockEndAddress == null) + { + IMemoryBlock memoryBlock = this.getMemoryBlock(); + if(memoryBlock instanceof IMemoryBlockExtension) + { + BigInteger endAddress; + try { + endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); + if (endAddress != null) + fMemoryBlockEndAddress = endAddress; + } catch (DebugException e) { + fMemoryBlockEndAddress = null; + } + + if (fMemoryBlockEndAddress == null) + { + int addressSize; + try { + addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); + } catch (DebugException e) { + addressSize = 4; + } + + endAddress = BigInteger.valueOf(2); + endAddress = endAddress.pow(addressSize*8); + endAddress = endAddress.subtract(BigInteger.valueOf(1)); + fMemoryBlockEndAddress = endAddress; + } + } + + // default to MAX_VALUE if we have trouble getting the end address + if (fMemoryBlockEndAddress == null) + fMemoryBlockEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); + } + return fMemoryBlockEndAddress; + } + + protected int getRadix() + { + return fRadix; + } + + protected int getNumericRadix(int radix) + { + switch(radix) + { + case RADIX_BINARY: + return 2; + case RADIX_OCTAL: + return 8; + case RADIX_DECIMAL_SIGNED: + case RADIX_DECIMAL_UNSIGNED: + return 10; + case RADIX_HEX: + return 16; + } + + return -1; + } + + protected void setRadix(int mode) + { + if(fRadix == mode) + return; + + fRadix = mode; + fireSettingsChanged(); + layoutPanes(); + } + + protected void setTextMode(int mode) + { + fTextMode = mode; + + fireSettingsChanged(); + layoutPanes(); + } + + protected int getTextMode() + { + return fTextMode; + } + + protected String getCharacterSet(int mode) + { + switch(mode) + { + case Rendering.TEXT_UTF8: + return "UTF8"; + case Rendering.TEXT_UTF16: + return "UTF16"; + case Rendering.TEXT_USASCII: + return "US-ASCII"; + case Rendering.TEXT_ISO_8859_1: + default: + return "ISO-8859-1"; + } + } + + protected int getBytesPerCharacter() + { + if(fTextMode == Rendering.TEXT_UTF16) + return 2; + + return 1; + } + + protected boolean isLittleEndian() + { + return fLittleEndian; + } + + protected void setLittleEndian(boolean enable) + { + if(fLittleEndian == enable) + return; + + fLittleEndian = enable; + fireSettingsChanged(); + layoutPanes(); + } + + protected void setBytesPerColumn(int byteCount) + { + if(fBytesPerColumn != byteCount) + { + fBytesPerColumn = byteCount; + fireSettingsChanged(); + layoutPanes(); + } + } + + protected void redrawPanes() + { + if(this.isVisible()) + { + if(fAddressPane.isPaneVisible()) + { + fAddressPane.redraw(); + fAddressPane.setRowCount(); + if(fAddressPane.isFocusControl()) + fAddressPane.updateCaret(); + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.redraw(); + fBinaryPane.setRowCount(); + if(fBinaryPane.isFocusControl()) + fBinaryPane.updateCaret(); + } + + if(fTextPane.isPaneVisible()) + { + fTextPane.redraw(); + fTextPane.setRowCount(); + if(fTextPane.isFocusControl()) + fTextPane.updateCaret(); + } + } + + fParent.updateRenderingLabels(); + } + + private void layoutPanes() + { + packColumns(); + layout(true); + + redraw(); + redrawPanes(); + } + + private void fireSettingsChanged() + { + fAddressPane.settingsChanged(); + fBinaryPane.settingsChanged(); + fTextPane.settingsChanged(); + } + + static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + + protected String getRadixText(MemoryByte bytes[], int radix, + boolean isLittleEndian) + { + boolean readable = true; + for(int i = 0; i < bytes.length; i++) + if(!bytes[i].isReadable()) + readable = false; + + if(readable) + { + // see if we need to swap the data or not. if the bytes are BE + // and we want to view in LE then we need to swap. if the bytes + // are LE and we want to view BE then we need to swap. + boolean needsSwap = false; + boolean bytesAreLittleEndian = !bytes[0].isBigEndian(); + if ((isLittleEndian && !bytesAreLittleEndian) || (!isLittleEndian && bytesAreLittleEndian)) + needsSwap = true; + + switch(radix) + { + case Rendering.RADIX_HEX: + case Rendering.RADIX_OCTAL: + case Rendering.RADIX_BINARY: + { + long value = 0; + if(needsSwap) + { + for(int i = 0; i < bytes.length; i++) + { + value = value << 8; + value = value + | (bytes[bytes.length - 1 - i].getValue() & 0xFF); + } + } + else + { + for(int i = 0; i < bytes.length; i++) + { + value = value << 8; + value = value | (bytes[i].getValue() & 0xFF); + } + } + + char buf[] = new char[getRadixCharacterCount(radix, + bytes.length)]; + + switch(radix) + { + case Rendering.RADIX_BINARY: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 1)]; + value = value >>> 1; + } + break; + } + case Rendering.RADIX_OCTAL: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 7)]; + value = value >>> 3; + } + break; + } + case Rendering.RADIX_HEX: + { + for(int i = buf.length - 1; i >= 0; i--) + { + buf[i] = hexdigits[(int) (value & 15)]; + value = value >>> 4; + } + break; + } + } + + return new String(buf); + } + case Rendering.RADIX_DECIMAL_UNSIGNED: + case Rendering.RADIX_DECIMAL_SIGNED: + { + boolean isSignedType = radix == Rendering.RADIX_DECIMAL_SIGNED ? true + : false; + + int textWidth = getRadixCharacterCount(radix, bytes.length); + + char buf[] = new char[textWidth]; + + byte[] value = new byte[bytes.length + 1]; + + if(needsSwap) + { + for(int i = 0; i < bytes.length; i++) + { + value[bytes.length - i] = bytes[i].getValue(); + } + } + else + { + for(int i = 0; i < bytes.length; i++) + { + value[i + 1] = bytes[i].getValue(); + } + } + + BigInteger bigValue; + boolean isNegative = false; + if(isSignedType && (value[1] & 0x80) != 0) + { + value[0] = -1; + isNegative = true; + bigValue = new BigInteger(value).abs(); + } + else + { + value[0] = 0; + bigValue = new BigInteger(value); + } + + for(int i = 0; i < textWidth; i++) + { + BigInteger divideRemainder[] = bigValue.divideAndRemainder( + BigInteger.valueOf(10)); + int remainder = divideRemainder[1].intValue(); + buf[textWidth - 1 - i] = hexdigits[remainder % 10]; + bigValue = divideRemainder[0]; + } + + if(isSignedType) + { + buf[0] = isNegative ? '-' : ' '; + } + + return new String(buf); + } + } + } + + StringBuffer errorText = new StringBuffer(); + for(int i = getRadixCharacterCount(radix, bytes.length); i > 0; i--) + errorText.append('?'); + + return errorText.toString(); + } + + protected int getRadixCharacterCount(int radix, int bytes) + { + switch(radix) + { + case Rendering.RADIX_HEX: + return bytes * 2; + case Rendering.RADIX_BINARY: + return bytes * 8; + case Rendering.RADIX_OCTAL: + { + switch(bytes) + { + case 1: + return 3; + case 2: + return 6; + case 4: + return 11; + case 8: + return 22; + } + } + case Rendering.RADIX_DECIMAL_UNSIGNED: + { + switch(bytes) + { + case 1: + return 3; + case 2: + return 5; + case 4: + return 10; + case 8: + return 20; + } + } + case Rendering.RADIX_DECIMAL_SIGNED: + { + switch(bytes) + { + case 1: + return 4; + case 2: + return 6; + case 4: + return 11; + case 8: + return 21; + } + } + } + + return 0; + } + + protected static boolean isValidEditCharacter(char character) + { + return (character >= '0' && character <= '9') + || (character >= 'a' && character <= 'z') + || (character >= 'A' && character <= 'Z') || character == '-' + || character == ' '; + } + + protected String formatText(MemoryByte[] memoryBytes, + boolean isLittleEndian, int textMode) + { + // check memory byte for unreadable bytes + boolean readable = true; + for(int i = 0; i < memoryBytes.length; i++) + if(!memoryBytes[i].isReadable()) + readable = false; + + // if any bytes are not readable, return ?'s + if(!readable) + { + StringBuffer errorText = new StringBuffer(); + for(int i = memoryBytes.length; i > 0; i--) + errorText.append('?'); + return errorText.toString(); + } + + // TODO + // does endian mean anything for text? ah, unicode? + + // create byte array from MemoryByte array + byte bytes[] = new byte[memoryBytes.length]; + for(int i = 0; i < bytes.length; i++) + { + bytes[i] = memoryBytes[i].getValue(); + } + + // replace invalid characters with '.' + // maybe there is a way to query the character set for + // valid characters? + + // replace invalid US-ASCII with '.' + if(textMode == Rendering.TEXT_USASCII) + { + for(int i = 0; i < bytes.length; i++) + { + int byteValue = bytes[i]; + if(byteValue < 0) + byteValue += 256; + + if(byteValue < 0x20 || byteValue > 0x7e) + bytes[i] = '.'; + } + } + + // replace invalid ISO-8859-1 with '.' + if(textMode == Rendering.TEXT_ISO_8859_1) + { + for(int i = 0; i < bytes.length; i++) + { + int byteValue = bytes[i]; + if(byteValue < 0) + byteValue += 256; + + if(byteValue < 0x20 || + (byteValue >= 0x7f && byteValue < 0x9f)) + bytes[i] = '.'; + } + } + + try + { + // convert bytes to string using desired character set + StringBuffer buf = new StringBuffer(new String(bytes, this.getCharacterSet(textMode))); + + // pad string to (byte count - string length) with spaces + for(int i = 0; i < memoryBytes.length - buf.length(); i++) + buf.append(' '); + return buf.toString(); + } + catch(Exception e) + { + // return ?s the length of byte count + StringBuffer buf = new StringBuffer(); + for(int i = 0; i < memoryBytes.length - buf.length(); i++) + buf.append('?'); + return buf.toString(); + } + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index b20550362ec..84a5dea1c2b 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -12,10 +12,6 @@ package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; -import java.util.Vector; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.Command; @@ -24,21 +20,12 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IDebugEventSetListener; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; -import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; @@ -49,7 +36,6 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.preference.IPreferenceStore; @@ -64,32 +50,17 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.ScrollBar; -import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; @@ -951,1904 +922,6 @@ class TraditionalMemoryByte extends MemoryByte } } -class Rendering extends Composite implements IDebugEventSetListener -{ - // the IMemoryRendering parent - private TraditionalRendering fParent; - - // controls - - private AddressPane fAddressPane; - - private DataPane fBinaryPane; - - private TextPane fTextPane; - - private GoToAddressComposite fAddressBar; - - private Control fAddressBarControl; // FIXME why isn't there a getControl() ? - - private Selection fSelection = new Selection(); - - // storage - - BigInteger fViewportAddress = null; // default visibility for performance - - BigInteger fMemoryBlockStartAddress = null; - BigInteger fMemoryBlockEndAddress = null; - - BigInteger fBaseAddress = null; // remember the base address - - private int fColumnCount = 0; // auto calculate can be disabled by user, - // making this user settable - - private int fBytesPerRow = 0; // current number of bytes per row are displayed - - private int fCurrentScrollSelection = 0; // current scroll selection; - - private BigInteger fCaretAddress = BigInteger.valueOf(0); // -1 ? - - // user settings - - private int fTextMode = 1; // ASCII default, TODO make preference? - - private int fBytesPerColumn = 4; // 4 byte cell width default - - private int fRadix = RADIX_HEX; - - private int fColumnsSetting = COLUMNS_AUTO_SIZE_TO_FIT; - - private boolean fLittleEndian = false; - - private boolean fCheckedLittleEndian = false; - - // constants used to identify radix - protected final static int RADIX_HEX = 1; - - protected final static int RADIX_DECIMAL_SIGNED = 2; - - protected final static int RADIX_DECIMAL_UNSIGNED = 3; - - protected final static int RADIX_OCTAL = 4; - - protected final static int RADIX_BINARY = 5; - - // constants used to identify panes - protected final static int PANE_ADDRESS = 1; - - protected final static int PANE_BINARY = 2; - - protected final static int PANE_TEXT = 3; - - // constants used to identify text, maybe java should be queried for all available sets - protected final static int TEXT_ISO_8859_1 = 1; - protected final static int TEXT_USASCII = 2; - protected final static int TEXT_UTF8 = 3; - protected final static int TEXT_UTF16 = 4; - - // internal constants - protected final static int COLUMNS_AUTO_SIZE_TO_FIT = 0; - - // view internal settings - private int fCellPadding = 2; - - private int fPaneSpacing = 16; - - // flag whether the memory cache is dirty - private boolean fCacheDirty = false; - - public Rendering(Composite parent, TraditionalRendering renderingParent) - { - super(parent, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.H_SCROLL - | SWT.V_SCROLL); - - this.setFont(JFaceResources - .getFont(IInternalDebugUIConstants.FONT_NAME)); // TODO internal? - - this.fParent = renderingParent; - - // instantiate the panes, TODO default visibility from state or - // plugin.xml? - this.fAddressPane = new AddressPane(this); - this.fBinaryPane = new DataPane(this); - this.fTextPane = new TextPane(this); - - fAddressBar = new GoToAddressComposite(); - fAddressBarControl = fAddressBar.createControl(parent); - Button button = fAddressBar.getButton(IDialogConstants.OK_ID); - if (button != null) - { - button.addSelectionListener(new SelectionAdapter() { - - public void widgetSelected(SelectionEvent e) { - doGoToAddress(); - } - }); - - button = fAddressBar.getButton(IDialogConstants.CANCEL_ID); - if (button != null) - { - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - setVisibleAddressBar(false); - }}); - } - } - - fAddressBar.getExpressionWidget().addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected(SelectionEvent e) { - doGoToAddress(); - }}); - - fAddressBar.getExpressionWidget().addKeyListener(new KeyAdapter() { - - public void keyPressed(KeyEvent e) { - if (e.keyCode == SWT.ESC) - setVisibleAddressBar(false); - super.keyPressed(e); - } - }); - - this.fAddressBarControl.setVisible(false); - - // initialize the viewport start - IMemoryBlockExtension memoryBlock = getMemoryBlock(); - if(memoryBlock != null) - { - try - { - fViewportAddress = memoryBlock.getMemoryBlockStartAddress(); - // this will be null if memory may be retrieved at any address less than - // this memory block's base. if so use the base address. - if (fViewportAddress == null) - fViewportAddress = memoryBlock.getBigBaseAddress(); - fBaseAddress = fViewportAddress; - } - catch(DebugException e) - { - fViewportAddress = null; - if(isDebug()) - Rendering.this - .logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), e); //$NON-NLS-1$ - } - } - - getHorizontalBar().addSelectionListener(new SelectionListener() - { - public void widgetSelected(SelectionEvent se) - { - Rendering.this.layout(); - } - - public void widgetDefaultSelected(SelectionEvent se) - { - // do nothing - } - }); - - getVerticalBar().addSelectionListener( - new SelectionListener() - { - public void widgetSelected(SelectionEvent se) - { - int addressableSize = getAddressableSize(); - - switch(se.detail) - { - case SWT.ARROW_DOWN: - fViewportAddress = fViewportAddress.add(BigInteger - .valueOf(getAddressableCellsPerRow())); - ensureViewportAddressDisplayable(); - redrawPanes(); - break; - case SWT.PAGE_DOWN: - fViewportAddress = fViewportAddress.add(BigInteger - .valueOf(getAddressableCellsPerRow() - * (Rendering.this.getRowCount() - 1))); - ensureViewportAddressDisplayable(); - redrawPanes(); - break; - case SWT.ARROW_UP: - fViewportAddress = fViewportAddress.subtract(BigInteger - .valueOf(getAddressableCellsPerRow())); - ensureViewportAddressDisplayable(); - redrawPanes(); - break; - case SWT.PAGE_UP: - fViewportAddress = fViewportAddress.subtract(BigInteger - .valueOf(getAddressableCellsPerRow() - * (Rendering.this.getRowCount() - 1))); - ensureViewportAddressDisplayable(); - redrawPanes(); - break; - case SWT.SCROLL_LINE: - if(getVerticalBar().getSelection() == getVerticalBar().getMinimum()) - { - // Set view port start address to the start address of the Memory Block - fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); - } - else if(getVerticalBar().getSelection() == getVerticalBar().getMaximum()) - { - // The view port end address should be less or equal to the the end address of the Memory Block - // Set view port address to be bigger than the end address of the Memory Block for now - // and let ensureViewportAddressDisplayable() to figure out the correct view port start address - fViewportAddress = Rendering.this.getMemoryBlockEndAddress(); - } - else - { - // Figure out the delta - int delta = getVerticalBar().getSelection() - fCurrentScrollSelection; - fViewportAddress = fViewportAddress.add(BigInteger.valueOf( - getAddressableCellsPerRow() * delta)); - } - ensureViewportAddressDisplayable(); - // Update tooltip - // FIXME conversion from slider to scrollbar - // getVerticalBar().setToolTipText(Rendering.this.getAddressString(fViewportAddress)); - - // Update the addresses on the Address pane. - // Do not update the Binary and Text panes until dragging of the thumb nail stops - if(fAddressPane.isPaneVisible()) - { - fAddressPane.redraw(); - } - break; - case SWT.NONE: - // Dragging of the thumb nail stops. Redraw the panes - redrawPanes(); - break; - } - - } - - public void widgetDefaultSelected(SelectionEvent se) - { - // do nothing - } - }); - - this.addPaintListener(new PaintListener() - { - public void paintControl(PaintEvent pe) - { - pe.gc.setBackground(Rendering.this.getTraditionalRendering().getColorBackground()); - pe.gc.fillRectangle(0, 0, Rendering.this.getBounds().width, - Rendering.this.getBounds().height); - } - }); - - this.setLayout(new Layout() - { - public void layout(Composite composite, boolean changed) - { - int xOffset = 0; - if(Rendering.this.getHorizontalBar().isVisible()) - xOffset = Rendering.this.getHorizontalBar().getSelection(); - - int x = xOffset * -1; - int y = 0; - - if(fAddressBarControl.isVisible()) - { - fAddressBarControl.setBounds(0, 0, - Rendering.this.getBounds().width, fAddressBarControl - .computeSize(100, 30).y); // FIXME - //y = fAddressBarControl.getBounds().height; - } - - if(fAddressPane.isPaneVisible()) - { - fAddressPane.setBounds(x, y, - fAddressPane.computeSize(0, 0).x, Rendering.this - .getBounds().height - - y); - x = fAddressPane.getBounds().x - + fAddressPane.getBounds().width; - } - - if(fBinaryPane.isPaneVisible()) - { - fBinaryPane.setBounds(x, y, - fBinaryPane.computeSize(0, 0).x, Rendering.this - .getBounds().height - - y); - x = fBinaryPane.getBounds().x - + fBinaryPane.getBounds().width; - } - - if(fTextPane.isPaneVisible()) - { - fTextPane.setBounds(x, y, - Math.max(fTextPane.computeSize(0, 0).x, Rendering.this.getClientArea().width - - x - xOffset), Rendering.this.getBounds().height - y); - } - - if(getClientArea().width >= fTextPane.getBounds().x + fTextPane.getBounds().width + xOffset) - { - Rendering.this.getHorizontalBar().setVisible(false); - } - else - { - ScrollBar horizontal = Rendering.this.getHorizontalBar(); - - horizontal.setVisible(true); - horizontal.setMinimum(0); - horizontal.setMaximum(fTextPane.getBounds().x - + fTextPane.getBounds().width + xOffset); - horizontal.setThumb(getClientArea().width); - horizontal.setPageIncrement(40); // TODO ? - horizontal.setIncrement(20); // TODO ? - } - } - - protected Point computeSize(Composite composite, int wHint, - int hHint, boolean flushCache) - { - return new Point(100, 100); // dummy data - } - }); - - this.addControlListener(new ControlListener() - { - public void controlMoved(ControlEvent ce) - { - } - - public void controlResized(ControlEvent ce) - { - packColumns(); - } - }); - - DebugPlugin.getDefault().addDebugEventListener(this); - } - - protected TraditionalRendering getTraditionalRendering() // TODO rename - { - return fParent; - } - - protected void setCaretAddress(BigInteger address) - { - fCaretAddress = address; - } - - protected BigInteger getCaretAddress() - { - return fCaretAddress; - } - - private void doGoToAddress() { - try { - BigInteger address = fAddressBar.getGoToAddress(this.getMemoryBlockStartAddress(), this.getCaretAddress()); - getTraditionalRendering().gotoAddress(address); - setVisibleAddressBar(false); - } catch (NumberFormatException e1) - { - // FIXME log? - } - } - - // Ensure that all addresses displayed are within the addressable range - protected void ensureViewportAddressDisplayable() - { - if(fViewportAddress.compareTo(Rendering.this.getMemoryBlockStartAddress()) < 0) - { - fViewportAddress = Rendering.this.getMemoryBlockStartAddress(); - } - else if(getViewportEndAddress().compareTo(getMemoryBlockEndAddress().add(BigInteger.ONE)) > 0) - { - fViewportAddress = getMemoryBlockEndAddress().subtract(BigInteger.valueOf(getAddressableCellsPerRow() - * getRowCount() - 1)); - } - - setCurrentScrollSelection(); - } - - protected Selection getSelection() - { - return fSelection; - } - - protected void logError(String message, Exception e) - { - Status status = new Status(IStatus.ERROR, fParent.getRenderingId(), - DebugException.INTERNAL_ERROR, message, e); - - DebugUIPlugin.getDefault().getLog().log(status); - } - - public void handleFontPreferenceChange(Font font) - { - setFont(font); - - Control controls[] = this.getRenderingPanes(); - for(int i = 0; i < controls.length; i++) - controls[i].setFont(font); - - packColumns(); - redrawPanes(); - } - - public void handleDebugEvents(DebugEvent[] events) - { - for(int i = 0; i < events.length; i++) - { - if(events[0].getSource() instanceof IDebugElement) - { - final int kind = events[i].getKind(); - final int detail = events[i].getDetail(); - final IDebugElement source = (IDebugElement) events[i] - .getSource(); - - // TODO allow extensible customization of event handling; - // integration with user configurable update policies should happen here. - if(source.getDebugTarget() == getMemoryBlock() - .getDebugTarget()) - { - if(kind == DebugEvent.SUSPEND && detail == 0) - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - refresh(); - } - }); - } - else if(kind == DebugEvent.CHANGE) - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - refresh(); - } - }); - } - else if(kind == DebugEvent.RESUME) - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - archiveDeltas(); - } - }); - } - } - } - } - } - - // return true to enable development debug print statements - protected boolean isDebug() - { - return false; - } - - protected IMemoryBlockExtension getMemoryBlock() - { - IMemoryBlock block = fParent.getMemoryBlock(); - if(block != null) - return (IMemoryBlockExtension) block - .getAdapter(IMemoryBlockExtension.class); - - return null; - } - - protected int getAddressableSize() - { - try - { - return getMemoryBlock().getAddressableSize(); - } - catch(DebugException e) - { - return 1; - } - } - - protected ViewportCache getViewportCache() - { - return fViewportCache; - } - - protected MemoryByte[] getBytes(BigInteger address, int bytes) - throws DebugException - { - return fViewportCache.getBytes(address, bytes); - } - - // default visibility for performance - ViewportCache fViewportCache = new ViewportCache(); - - private interface Request - { - } - - class ViewportCache extends Thread - { - class ArchiveDeltas implements Request - { - - } - - class AddressPair implements Request - { - BigInteger startAddress; - - BigInteger endAddress; - } - - class MemoryUnit - { - BigInteger start; - - BigInteger end; - - MemoryByte[] bytes; - - public MemoryUnit clone() - { - MemoryUnit b = new MemoryUnit(); - - b.start = this.start; - b.end = this.end; - b.bytes = new MemoryByte[this.bytes.length]; - for(int i = 0; i < this.bytes.length; i++) - b.bytes[i] = new MemoryByte(this.bytes[i].getValue()); - - return b; - } - - public boolean isValid() - { - return this.start != null && this.end != null - && this.bytes != null; - } - } - - private HashMap fEditBuffer = new HashMap(); - - private boolean fDisposed = false; - - private Vector fQueue = new Vector(); - - protected MemoryUnit fCache = null; - - protected MemoryUnit fHistoryCache = null; - - public ViewportCache() - { - start(); - } - - public void dispose() - { - fDisposed = true; - synchronized(this) - { - this.notify(); - } - } - - protected void refresh() - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - if(fCache != null) - { - queueRequest(fViewportAddress, getViewportEndAddress()); - } - } - - protected void archiveDeltas() - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - if(fCache != null) - { - queueRequestArchiveDeltas(); - } - } - - - - private void queueRequest(BigInteger startAddress, BigInteger endAddress) - { - AddressPair pair = new AddressPair(); - pair.startAddress = startAddress; - pair.endAddress = endAddress; - synchronized(fQueue) - { - fQueue.addElement(pair); - } - synchronized(this) - { - this.notify(); - } - } - - private void queueRequestArchiveDeltas() - { - ArchiveDeltas archive = new ArchiveDeltas(); - synchronized(fQueue) - { - fQueue.addElement(archive); - } - synchronized(this) - { - this.notify(); - } - } - - public void run() - { - while(!fDisposed) - { - AddressPair pair = null; - boolean archiveDeltas = false; - synchronized(fQueue) - { - if(fQueue.size() > 0) - { - Request request = (Request) fQueue.elementAt(0); - Class type = null; - if(request instanceof ArchiveDeltas) - { - archiveDeltas = true; - type = ArchiveDeltas.class; - } - else if(request instanceof AddressPair) - { - pair = (AddressPair) request; - type = AddressPair.class; - } - - while(fQueue.size() > 0 && type.isInstance(fQueue.elementAt(0))) - fQueue.removeElementAt(0); - } - } - if(archiveDeltas) - { - fHistoryCache = fCache.clone(); - } - else if(pair != null) - { - populateCache(pair.startAddress, pair.endAddress); - } - else - { - synchronized(this) - { - try - { - this.wait(); - } - catch(Exception e) - { - // do nothing - } - } - } - } - } - - // cache memory necessary to paint viewport - // TODO: user setting to buffer +/- x lines - // TODO: reuse existing cache? probably only a minor performance gain - private void populateCache(final BigInteger startAddress, - final BigInteger endAddress) - { - try - { - final IMemoryBlockExtension memoryBlock = getMemoryBlock(); - - final BigInteger lengthInBytes = endAddress.subtract(startAddress); - final BigInteger addressableSize = BigInteger.valueOf(getAddressableSize()); - - final long units = lengthInBytes.divide(addressableSize).add( - lengthInBytes.mod(addressableSize).compareTo(BigInteger.ZERO) > 0 - ? BigInteger.ONE : BigInteger.ZERO).longValue(); - - // CDT (and maybe other backends) will call setValue() on these MemoryBlock objects. - // We don't want this to happen, because it interferes with this rendering's own - // change history. Ideally, we should strictly use the back end change notification - // and history, but it is only guaranteed to work for bytes within the address range - // of the MemoryBlock. - final MemoryByte readBytes[] = memoryBlock - .getBytesFromAddress(startAddress, units); - - final MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; - for(int i = 0; i < readBytes.length; i++) - cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); - - // we need to set the default endianess. before it was set to BE - // by default which wasn't very useful for LE targets. now we will - // query the first byte to get the endianess. if not known then we'll - // leave it as BE. note that we only do this when reading the first - // bit of memory for this rendering. what happens when scrolling - // through memory and it changes endianess? for now we just leave - // it in the original endianess. - if (!fCheckedLittleEndian && cachedBytes.length > 0) { - if (cachedBytes[0].isEndianessKnown()) { - fLittleEndian = !cachedBytes[0].isBigEndian(); - fCheckedLittleEndian = true; - fParent.bytesAreLittleEndian(fLittleEndian); - } - } - - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - // generate deltas - if(fHistoryCache != null && fHistoryCache.isValid()) - { - BigInteger maxStart = startAddress - .max(fHistoryCache.start); - BigInteger minEnd = endAddress - .min(fHistoryCache.end).subtract( - BigInteger.valueOf(1)); - - BigInteger overlapLength = minEnd - .subtract(maxStart); - if(overlapLength.compareTo(BigInteger.valueOf(0)) > 0) - { - // there is overlap - - int offsetIntoOld = maxStart.subtract( - fHistoryCache.start).intValue(); - int offsetIntoNew = maxStart.subtract( - startAddress).intValue(); - - for(int i = overlapLength.intValue(); i >= 0; i--) - { - cachedBytes[offsetIntoNew + i] - .setChanged(cachedBytes[offsetIntoNew - + i].getValue() != fHistoryCache.bytes[offsetIntoOld - + i].getValue()); - } - } - } - - fCache = new MemoryUnit(); - fCache.start = startAddress; - fCache.end = endAddress; - fCache.bytes = cachedBytes; - - Rendering.this.redrawPanes(); - } - }); - - } - catch(Exception e) - { - logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_READ_MEMORY"), e); //$NON-NLS-1$ - } - } - - // bytes will be fetched from cache - protected MemoryByte[] getBytes(BigInteger address, int bytesRequested) - throws DebugException - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - if(containsEditedCell(address)) // cell size cannot be switched during an edit - return getEditedMemory(address); - - boolean contains = false; - if(fCache != null && fCache.start != null) - { - // see if all of the data requested is in the cache - BigInteger dataEnd = address.add(BigInteger.valueOf(bytesRequested)); - - if(fCache.start.compareTo(address) <= 0 - && fCache.end.compareTo(dataEnd) >= 0 - && fCache.bytes.length > 0) - contains = true; - } - - if(contains) - { - int offset = address.subtract(fCache.start).intValue(); - MemoryByte bytes[] = new MemoryByte[bytesRequested]; - for(int i = 0; i < bytes.length; i++) - { - bytes[i] = fCache.bytes[offset + i]; - } - - return bytes; - } - - MemoryByte bytes[] = new MemoryByte[bytesRequested]; - for(int i = 0; i < bytes.length; i++) - { - bytes[i] = new MemoryByte(); - bytes[i].setReadable(false); - } - - fViewportCache.queueRequest(fViewportAddress, - getViewportEndAddress()); - - return bytes; - } - - private boolean containsEditedCell(BigInteger address) - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - return fEditBuffer.containsKey(address); - } - - private MemoryByte[] getEditedMemory(BigInteger address) - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - return (MemoryByte[]) fEditBuffer.get(address); - } - - protected void clearEditBuffer() - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - fEditBuffer.clear(); - Rendering.this.redrawPanes(); - } - - protected void writeEditBuffer() - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - Set keySet = fEditBuffer.keySet(); - Iterator iterator = keySet.iterator(); - - while(iterator.hasNext()) - { - BigInteger address = (BigInteger) iterator.next(); - MemoryByte[] bytes = (MemoryByte[]) fEditBuffer - .get(address); - - byte byteValue[] = new byte[bytes.length]; - for(int i = 0; i < bytes.length; i++) - byteValue[i] = bytes[i].getValue(); - - try - { - getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); - } - catch(Exception e) - { - MemoryViewUtil.openError(TraditionalRenderingMessages.getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), "", e); - - logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_WRITE_MEMORY"), e); //$NON-NLS-1$ - } - } - - clearEditBuffer(); - } - - protected void setEditedValue(BigInteger address, MemoryByte[] bytes) - { - assert Thread.currentThread().equals( - Display.getDefault().getThread()) : TraditionalRenderingMessages - .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - - fEditBuffer.put(address, bytes); - Rendering.this.redrawPanes(); - } - } - - public void setVisibleAddressBar(boolean visible) - { - fAddressBarControl.setVisible(visible); - if(visible) - { - String selectedStr = "0x" + getCaretAddress().toString(16); - Text text = fAddressBar.getExpressionWidget(); - text.setText(selectedStr); - text.setSelection(0, text.getCharCount()); - fAddressBar.getExpressionWidget().setFocus(); - } - - layout(true); - layoutPanes(); - } - - public void setDirty(boolean needRefresh) - { - fCacheDirty = needRefresh; - } - - public boolean isDirty() - { - return fCacheDirty; - } - - public void dispose() - { - if(fViewportCache != null) - { - fViewportCache.dispose(); - fViewportCache = null; - } - super.dispose(); - } - - class Selection - { - private BigInteger fStartHigh; - private BigInteger fStartLow; - - private BigInteger fEndHigh; - private BigInteger fEndLow; - - protected void clear() - { - fEndHigh = fEndLow = fStartHigh = fStartLow = null; - redrawPanes(); - } - - protected boolean hasSelection() - { - return fStartHigh != null && fStartLow != null - && fEndHigh != null && fEndLow != null; - } - - protected boolean isSelected(BigInteger address) - { - // do we have valid start and end addresses - if(getEnd() == null || getStart() == null) - return false; - - // if end is greater than start - if(getEnd().compareTo(getStart()) >= 0) - { - if(address.compareTo(getStart()) >= 0 - && address.compareTo(getEnd()) < 0) - return true; - } - // if start is greater than end - else if(getStart().compareTo(getEnd()) >= 0) - { - if(address.compareTo(getEnd()) >= 0 - && address.compareTo(getStart()) < 0) - return true; - } - - return false; - } - - protected void setStart(BigInteger high, BigInteger low) - { - if(high == null && low == null) - { - if(fStartHigh != null && fStartLow != null) - { - fStartHigh = null; - fStartLow = null; - redrawPanes(); - } - - return; - } - - boolean changed = false; - - if(fStartHigh == null || !high.equals(fStartHigh)) - { - fStartHigh = high; - changed = true; - } - - if(fStartLow == null || !low.equals(fStartLow)) - { - fStartLow = low; - changed = true; - } - - if(changed) - redrawPanes(); - } - - protected void setEnd(BigInteger high, BigInteger low) - { - if(high == null && low == null) - { - if(fEndHigh != null && fEndLow != null) - { - fEndHigh = null; - fEndLow = null; - redrawPanes(); - } - - return; - } - - boolean changed = false; - - if(fEndHigh == null || !high.equals(fEndHigh)) - { - fEndHigh = high; - changed = true; - } - - if(fEndLow == null || !low.equals(fEndLow)) - { - fEndLow = low; - changed = true; - } - - if(changed) - redrawPanes(); - } - - protected BigInteger getHigh() - { - if(!hasSelection()) - return null; - - return getStart().max(getEnd()); - } - - protected BigInteger getLow() - { - if(!hasSelection()) - return null; - - return getStart().min(getEnd()); - } - - protected BigInteger getStart() - { - // if there is no start, return null - if(fStartHigh == null) - return null; - - // if there is no end, return the high address of the start - if(fEndHigh == null) - return fStartHigh; - - // if Start High/Low equal End High/Low, return a low start and high end - if(fStartHigh.equals(fEndHigh) - && fStartLow.equals(fEndLow)) - return fStartLow; - - BigInteger differenceEndToStartHigh = fEndHigh.subtract(fStartHigh).abs(); - BigInteger differenceEndToStartLow = fEndHigh.subtract(fStartLow).abs(); - - // return the start high or start low based on which creates a larger selection - if(differenceEndToStartHigh.compareTo(differenceEndToStartLow) > 0) - return fStartHigh; - else - return fStartLow; - } - - protected BigInteger getEnd() - { - // if there is no end, return null - if(fEndHigh == null) - return null; - - // if Start High/Low equal End High/Low, return a low start and high end - if(fStartHigh.equals(fEndHigh) - && fStartLow.equals(fEndLow)) - return fStartHigh; - - BigInteger differenceStartToEndHigh = fStartHigh.subtract(fEndHigh).abs(); - BigInteger differenceStartToEndLow = fStartHigh.subtract(fEndLow).abs(); - - // return the start high or start low based on which creates a larger selection - if(differenceStartToEndHigh.compareTo(differenceStartToEndLow) >= 0) - return fEndHigh; - else - return fEndLow; - } - } - - protected void setPaneVisible(int pane, boolean visible) - { - switch(pane) - { - case PANE_ADDRESS: - fAddressPane.setPaneVisible(visible); - break; - case PANE_BINARY: - fBinaryPane.setPaneVisible(visible); - break; - case PANE_TEXT: - fTextPane.setPaneVisible(visible); - break; - } - - fireSettingsChanged(); - layoutPanes(); - } - - protected boolean getPaneVisible(int pane) - { - switch(pane) - { - case PANE_ADDRESS: - return fAddressPane.isPaneVisible(); - case PANE_BINARY: - return fBinaryPane.isPaneVisible(); - case PANE_TEXT: - return fTextPane.isPaneVisible(); - default: - return false; - } - } - - protected void packColumns() - { - int availableWidth = Rendering.this.getSize().x; - - if(fAddressPane.isPaneVisible()) - { - availableWidth -= fAddressPane.computeSize(0, 0).x; - availableWidth -= Rendering.this.getRenderSpacing() * 2; - } - - int combinedWidth = 0; - - if(fBinaryPane.isPaneVisible()) - combinedWidth += fBinaryPane.getCellWidth(); - - if(fTextPane.isPaneVisible()) - combinedWidth += fTextPane.getCellWidth(); - - if(getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT) - { - if(combinedWidth == 0) - fColumnCount = 0; - else - { - fColumnCount = availableWidth / combinedWidth; - if(fColumnCount == 0) - fColumnCount = 1; // paint one column even if only part can show in view - } - } - else - { - fColumnCount = getColumnsSetting(); - } - - try - { - // Update the number of bytes per row; - // the max and min scroll range and the current thumb nail position. - fBytesPerRow = getBytesPerColumn() * getColumnCount(); - BigInteger difference = getMemoryBlockEndAddress().subtract(getMemoryBlockStartAddress()).add(BigInteger.ONE); - BigInteger maxScrollRange = difference.divide(BigInteger.valueOf(getAddressableCellsPerRow())); - if(maxScrollRange.multiply(BigInteger.valueOf(getAddressableCellsPerRow())).compareTo(difference) != 0) - maxScrollRange = maxScrollRange.add(BigInteger.ONE); - - // support targets with an addressable size greater than 1 - maxScrollRange = maxScrollRange.divide(BigInteger.valueOf(getAddressableSize())); - - getVerticalBar().setMinimum(1); - getVerticalBar().setMaximum(maxScrollRange.intValue()); - getVerticalBar().setIncrement(1); - getVerticalBar().setPageIncrement(this.getRowCount() -1); - //TW FIXME conversion of slider to scrollbar - // fScrollBar.setToolTipText(Rendering.this.getAddressString(fViewportAddress)); - setCurrentScrollSelection(); - } - catch(Exception e) - { - // FIXME precautionary - } - - Rendering.this.redraw(); - Rendering.this.redrawPanes(); - } - - protected AbstractPane[] getRenderingPanes() - { - return new AbstractPane[] { fAddressPane, fBinaryPane, - fTextPane }; - } - - protected int getCellPadding() - { - return fCellPadding; - } - - protected int getRenderSpacing() - { - return fPaneSpacing; - } - - protected void refresh() - { - if(!this.isDisposed()) - { - if(this.isVisible() && fViewportCache != null) - { - fViewportCache.refresh(); - } - else - { - setDirty(true); - fParent.updateRenderingLabels(); - } - } - } - - protected void archiveDeltas() - { - fViewportCache.archiveDeltas(); - } - - protected void gotoAddress(BigInteger address) - { - // Ensure that the GoTo address is within the addressable range - if((address.compareTo(this.getMemoryBlockStartAddress())< 0) || - (address.compareTo(this.getMemoryBlockEndAddress()) > 0)) - { - return; - } - - fViewportAddress = address; // TODO update fCaretAddress - redrawPanes(); - } - - protected void setViewportStartAddress(BigInteger newAddress) - { - fViewportAddress = newAddress; - } - - protected BigInteger getViewportStartAddress() - { - return fViewportAddress; - } - - protected BigInteger getViewportEndAddress() - { - return fViewportAddress.add(BigInteger.valueOf(this.getBytesPerRow() * getRowCount() / getAddressableSize())); - } - - protected String getAddressString(BigInteger address) - { - StringBuffer addressString = new StringBuffer(address.toString(16) - .toUpperCase()); - for(int chars = getAddressBytes() * 2 - addressString.length(); chars > 0; chars--) - { - addressString.insert(0, '0'); - } - addressString.insert(0, "0x"); //$NON-NLS-1$ - - return addressString.toString(); - } - - private int fAddressBytes = -1; // called often, cache - - protected int getAddressBytes() - { - if(fAddressBytes == -1) - { - try - { - IMemoryBlockExtension block = getMemoryBlock(); - fAddressBytes = block.getAddressSize(); - } - catch(DebugException e) - { - fAddressBytes = 0; - logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE"), e); //$NON-NLS-1$ - } - } - - return fAddressBytes; - } - - protected int getColumnCount() - { - return fColumnCount; - } - - public int getColumnsSetting() - { - return fColumnsSetting; - } - - public void setColumnsSetting(int columns) - { - if(fColumnsSetting != columns) - { - fColumnsSetting = columns; - fireSettingsChanged(); - layoutPanes(); - } - } - - protected void ensureVisible(BigInteger address) - { - BigInteger viewportStart = this.getViewportStartAddress(); - BigInteger viewportEnd = this.getViewportEndAddress(); - - boolean isAddressBeforeViewportStart = address.compareTo(viewportStart) < 0; - boolean isAddressAfterViewportEnd = address.compareTo(viewportEnd) > 0; - - if(isAddressBeforeViewportStart || isAddressAfterViewportEnd) - gotoAddress(address); - } - - protected int getRowCount() - { - int rowCount = 0; - Control panes[] = getRenderingPanes(); - for(int i = 0; i < panes.length; i++) - { - if(panes[i] instanceof AbstractPane) - rowCount = Math.max(rowCount, - ((AbstractPane) panes[i]).getRowCount()); - } - - return rowCount; - } - - protected int getBytesPerColumn() - { - return fBytesPerColumn; - } - - protected int getBytesPerRow() - { - return fBytesPerRow; - } - - protected int getAddressableCellsPerRow() - { - return getBytesPerRow() / getAddressableSize(); - } - - protected int getAddressesPerColumn() - { - return this.getBytesPerColumn() / getAddressableSize(); - } - - /** - * @return Set current scroll selection - */ - protected void setCurrentScrollSelection() - { - BigInteger selection = getViewportStartAddress().divide( - BigInteger.valueOf(getAddressableCellsPerRow()).add(BigInteger.ONE)); - getVerticalBar().setSelection(selection.intValue()); - fCurrentScrollSelection = selection.intValue(); - } - - /** - * @return start address of the memory block - */ - protected BigInteger getMemoryBlockStartAddress() - { - if (fMemoryBlockStartAddress == null) - { - try { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); - if (startAddress != null) - fMemoryBlockStartAddress = startAddress; - } - } catch (DebugException e) { - fMemoryBlockStartAddress = null; - } - - // default to 0 if we have trouble getting the start address - if (fMemoryBlockStartAddress == null) - fMemoryBlockStartAddress = BigInteger.valueOf(0); - } - return fMemoryBlockStartAddress; - } - - /** - * @return end address of the memory block - */ - protected BigInteger getMemoryBlockEndAddress() - { - if (fMemoryBlockEndAddress == null) - { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger endAddress; - try { - endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); - if (endAddress != null) - fMemoryBlockEndAddress = endAddress; - } catch (DebugException e) { - fMemoryBlockEndAddress = null; - } - - if (fMemoryBlockEndAddress == null) - { - int addressSize; - try { - addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); - } catch (DebugException e) { - addressSize = 4; - } - - endAddress = BigInteger.valueOf(2); - endAddress = endAddress.pow(addressSize*8); - endAddress = endAddress.subtract(BigInteger.valueOf(1)); - fMemoryBlockEndAddress = endAddress; - } - } - - // default to MAX_VALUE if we have trouble getting the end address - if (fMemoryBlockEndAddress == null) - fMemoryBlockEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); - } - return fMemoryBlockEndAddress; - } - - protected int getRadix() - { - return fRadix; - } - - protected int getNumericRadix(int radix) - { - switch(radix) - { - case RADIX_BINARY: - return 2; - case RADIX_OCTAL: - return 8; - case RADIX_DECIMAL_SIGNED: - case RADIX_DECIMAL_UNSIGNED: - return 10; - case RADIX_HEX: - return 16; - } - - return -1; - } - - protected void setRadix(int mode) - { - if(fRadix == mode) - return; - - fRadix = mode; - fireSettingsChanged(); - layoutPanes(); - } - - protected void setTextMode(int mode) - { - fTextMode = mode; - - fireSettingsChanged(); - layoutPanes(); - } - - protected int getTextMode() - { - return fTextMode; - } - - protected String getCharacterSet(int mode) - { - switch(mode) - { - case Rendering.TEXT_UTF8: - return "UTF8"; - case Rendering.TEXT_UTF16: - return "UTF16"; - case Rendering.TEXT_USASCII: - return "US-ASCII"; - case Rendering.TEXT_ISO_8859_1: - default: - return "ISO-8859-1"; - } - } - - protected int getBytesPerCharacter() - { - if(fTextMode == Rendering.TEXT_UTF16) - return 2; - - return 1; - } - - protected boolean isLittleEndian() - { - return fLittleEndian; - } - - protected void setLittleEndian(boolean enable) - { - if(fLittleEndian == enable) - return; - - fLittleEndian = enable; - fireSettingsChanged(); - layoutPanes(); - } - - protected void setBytesPerColumn(int byteCount) - { - if(fBytesPerColumn != byteCount) - { - fBytesPerColumn = byteCount; - fireSettingsChanged(); - layoutPanes(); - } - } - - protected void redrawPanes() - { - if(this.isVisible()) - { - if(fAddressPane.isPaneVisible()) - { - fAddressPane.redraw(); - fAddressPane.setRowCount(); - if(fAddressPane.isFocusControl()) - fAddressPane.updateCaret(); - } - - if(fBinaryPane.isPaneVisible()) - { - fBinaryPane.redraw(); - fBinaryPane.setRowCount(); - if(fBinaryPane.isFocusControl()) - fBinaryPane.updateCaret(); - } - - if(fTextPane.isPaneVisible()) - { - fTextPane.redraw(); - fTextPane.setRowCount(); - if(fTextPane.isFocusControl()) - fTextPane.updateCaret(); - } - } - - fParent.updateRenderingLabels(); - } - - private void layoutPanes() - { - packColumns(); - layout(true); - - redraw(); - redrawPanes(); - } - - private void fireSettingsChanged() - { - fAddressPane.settingsChanged(); - fBinaryPane.settingsChanged(); - fTextPane.settingsChanged(); - } - - static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - - protected String getRadixText(MemoryByte bytes[], int radix, - boolean isLittleEndian) - { - boolean readable = true; - for(int i = 0; i < bytes.length; i++) - if(!bytes[i].isReadable()) - readable = false; - - if(readable) - { - // see if we need to swap the data or not. if the bytes are BE - // and we want to view in LE then we need to swap. if the bytes - // are LE and we want to view BE then we need to swap. - boolean needsSwap = false; - boolean bytesAreLittleEndian = !bytes[0].isBigEndian(); - if ((isLittleEndian && !bytesAreLittleEndian) || (!isLittleEndian && bytesAreLittleEndian)) - needsSwap = true; - - switch(radix) - { - case Rendering.RADIX_HEX: - case Rendering.RADIX_OCTAL: - case Rendering.RADIX_BINARY: - { - long value = 0; - if(needsSwap) - { - for(int i = 0; i < bytes.length; i++) - { - value = value << 8; - value = value - | (bytes[bytes.length - 1 - i].getValue() & 0xFF); - } - } - else - { - for(int i = 0; i < bytes.length; i++) - { - value = value << 8; - value = value | (bytes[i].getValue() & 0xFF); - } - } - - char buf[] = new char[getRadixCharacterCount(radix, - bytes.length)]; - - switch(radix) - { - case Rendering.RADIX_BINARY: - { - for(int i = buf.length - 1; i >= 0; i--) - { - buf[i] = hexdigits[(int) (value & 1)]; - value = value >>> 1; - } - break; - } - case Rendering.RADIX_OCTAL: - { - for(int i = buf.length - 1; i >= 0; i--) - { - buf[i] = hexdigits[(int) (value & 7)]; - value = value >>> 3; - } - break; - } - case Rendering.RADIX_HEX: - { - for(int i = buf.length - 1; i >= 0; i--) - { - buf[i] = hexdigits[(int) (value & 15)]; - value = value >>> 4; - } - break; - } - } - - return new String(buf); - } - case Rendering.RADIX_DECIMAL_UNSIGNED: - case Rendering.RADIX_DECIMAL_SIGNED: - { - boolean isSignedType = radix == Rendering.RADIX_DECIMAL_SIGNED ? true - : false; - - int textWidth = getRadixCharacterCount(radix, bytes.length); - - char buf[] = new char[textWidth]; - - byte[] value = new byte[bytes.length + 1]; - - if(needsSwap) - { - for(int i = 0; i < bytes.length; i++) - { - value[bytes.length - i] = bytes[i].getValue(); - } - } - else - { - for(int i = 0; i < bytes.length; i++) - { - value[i + 1] = bytes[i].getValue(); - } - } - - BigInteger bigValue; - boolean isNegative = false; - if(isSignedType && (value[1] & 0x80) != 0) - { - value[0] = -1; - isNegative = true; - bigValue = new BigInteger(value).abs(); - } - else - { - value[0] = 0; - bigValue = new BigInteger(value); - } - - for(int i = 0; i < textWidth; i++) - { - BigInteger divideRemainder[] = bigValue.divideAndRemainder( - BigInteger.valueOf(10)); - int remainder = divideRemainder[1].intValue(); - buf[textWidth - 1 - i] = hexdigits[remainder % 10]; - bigValue = divideRemainder[0]; - } - - if(isSignedType) - { - buf[0] = isNegative ? '-' : ' '; - } - - return new String(buf); - } - } - } - - StringBuffer errorText = new StringBuffer(); - for(int i = getRadixCharacterCount(radix, bytes.length); i > 0; i--) - errorText.append('?'); - - return errorText.toString(); - } - - protected int getRadixCharacterCount(int radix, int bytes) - { - switch(radix) - { - case Rendering.RADIX_HEX: - return bytes * 2; - case Rendering.RADIX_BINARY: - return bytes * 8; - case Rendering.RADIX_OCTAL: - { - switch(bytes) - { - case 1: - return 3; - case 2: - return 6; - case 4: - return 11; - case 8: - return 22; - } - } - case Rendering.RADIX_DECIMAL_UNSIGNED: - { - switch(bytes) - { - case 1: - return 3; - case 2: - return 5; - case 4: - return 10; - case 8: - return 20; - } - } - case Rendering.RADIX_DECIMAL_SIGNED: - { - switch(bytes) - { - case 1: - return 4; - case 2: - return 6; - case 4: - return 11; - case 8: - return 21; - } - } - } - - return 0; - } - - protected static boolean isValidEditCharacter(char character) - { - return (character >= '0' && character <= '9') - || (character >= 'a' && character <= 'z') - || (character >= 'A' && character <= 'Z') || character == '-' - || character == ' '; - } - - protected String formatText(MemoryByte[] memoryBytes, - boolean isLittleEndian, int textMode) - { - // check memory byte for unreadable bytes - boolean readable = true; - for(int i = 0; i < memoryBytes.length; i++) - if(!memoryBytes[i].isReadable()) - readable = false; - - // if any bytes are not readable, return ?'s - if(!readable) - { - StringBuffer errorText = new StringBuffer(); - for(int i = memoryBytes.length; i > 0; i--) - errorText.append('?'); - return errorText.toString(); - } - - // TODO - // does endian mean anything for text? ah, unicode? - - // create byte array from MemoryByte array - byte bytes[] = new byte[memoryBytes.length]; - for(int i = 0; i < bytes.length; i++) - { - bytes[i] = memoryBytes[i].getValue(); - } - - // replace invalid characters with '.' - // maybe there is a way to query the character set for - // valid characters? - - // replace invalid US-ASCII with '.' - if(textMode == Rendering.TEXT_USASCII) - { - for(int i = 0; i < bytes.length; i++) - { - int byteValue = bytes[i]; - if(byteValue < 0) - byteValue += 256; - - if(byteValue < 0x20 || byteValue > 0x7e) - bytes[i] = '.'; - } - } - - // replace invalid ISO-8859-1 with '.' - if(textMode == Rendering.TEXT_ISO_8859_1) - { - for(int i = 0; i < bytes.length; i++) - { - int byteValue = bytes[i]; - if(byteValue < 0) - byteValue += 256; - - if(byteValue < 0x20 || - (byteValue >= 0x7f && byteValue < 0x9f)) - bytes[i] = '.'; - } - } - - try - { - // convert bytes to string using desired character set - StringBuffer buf = new StringBuffer(new String(bytes, this.getCharacterSet(textMode))); - - // pad string to (byte count - string length) with spaces - for(int i = 0; i < memoryBytes.length - buf.length(); i++) - buf.append(' '); - return buf.toString(); - } - catch(Exception e) - { - // return ?s the length of byte count - StringBuffer buf = new StringBuffer(); - for(int i = 0; i < memoryBytes.length - buf.length(); i++) - buf.append('?'); - return buf.toString(); - } - } - -} - class CopyAction extends Action { // TODO for the sake of large copies, this action should probably read in From 65f1ce19b4425fddb2c3a81bb364717c392cff57 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 6 Jul 2007 20:26:18 +0000 Subject: [PATCH 026/118] import/export toolbar icons --- .../build.properties | 6 ++++-- .../icons/export.png | Bin 0 -> 231 bytes .../icons/import.png | Bin 0 -> 236 bytes .../plugin.xml | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties index 0041ca9f849..bbc45d3cdc8 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/build.properties @@ -1,7 +1,9 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - plugin.properties,\ + plugin.properties,\ .,\ plugin.xml,\ - about.html \ No newline at end of file + about.html,\ + icons/ + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png new file mode 100644 index 0000000000000000000000000000000000000000..7728b4d303904c122b8be1b873f3fa4c1971e7d9 GIT binary patch literal 231 zcmVniSwHNqD+XusWg?tK@7uGQtiD155v5 zS&5i3yrCU}24d<@Z+&jhI{@Hr63pF1OwtpWR-RCE9wLRc$lT0-71kop+iTx!<11Oy h<7KR`b<%h7S-%x&U3J}feYXGr002ovPDHLkV1oNNU)lfw literal 0 HcmV?d00001 diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png new file mode 100644 index 0000000000000000000000000000000000000000..fa02317c7fd36390f9430f68cc5b02e379a9dc94 GIT binary patch literal 236 zcmVk0E<+)KSc5@Yl?tim;9`~XE}6D+WCDT>HjjulUd@M)ln#zKv* Date: Fri, 6 Jul 2007 20:57:38 +0000 Subject: [PATCH 027/118] icons --- .../icons/export.png | Bin 231 -> 227 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png index 7728b4d303904c122b8be1b873f3fa4c1971e7d9..91b2198825cb30c5498bfd5a951713caefbe04d3 100644 GIT binary patch delta 199 zcmV;&0672W0pkIXB!8+&L_t(2&y|r)3c^4Pg%gQEz?nfE-;$n*BvH`|1eEj^yc`cjvBqxP&D0BEbBtw09F12rL5j6y_26!Z1W zT+Z|O9Cagw7IFJu8LpH;RtUhU4(2XC&PY=I4-2;7ZC}Rka$5iZ002ovPDHLkV1lC? BTE+kX delta 203 zcmV;+05t#O0p|gbB!8|+L_t(2&y`WZ4Z<)Cw4;KA>N!}VFT{(TC=c8Y#RIVhgS09L zso`PdI%$X$zs}Ct=X20|4<+HE{IIzzMnptZ@WY~Dc>wVE9CHd0TPt?Frd4u`D2TY4 z6yPjLc)CxpI-(S- Date: Wed, 11 Jul 2007 21:53:14 +0000 Subject: [PATCH 028/118] allow a maximum of 200 columns --- .../memory/renderings/traditional/TraditionalRendering.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 84a5dea1c2b..aae549716d4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -729,6 +729,8 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe int i= Integer.parseInt(input); if (i <= 0) return "Please enter a positive integer"; //$NON-NLS-1$ + if (i > 200) + return "Please enter a positive integer not greater than 200"; //$NON-NLS-1$ } catch (NumberFormatException x) { return "Please enter a positive integer"; //$NON-NLS-1$ From f5439d09a45ffc4e2dd8afcf091056e6be378b54 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 12 Jul 2007 21:57:51 +0000 Subject: [PATCH 029/118] 196392 - calls to MemoryBlock on the UI dispatch thread --- .../META-INF/MANIFEST.MF | 2 +- .../renderings/traditional/AbstractPane.java | 2 +- .../renderings/traditional/Rendering.java | 128 ++++-------------- .../traditional/TraditionalRendering.java | 126 +++++++++++++++-- .../TraditionalRendering_messages.properties | 1 + 5 files changed, 147 insertions(+), 112 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index 091efcb421b..ee4f0610be2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Traditional Memory Rendering Bundle-SymbolicName: org.eclipse.dd.debug.memory.renderings.traditional;singleton:=true -Bundle-Version: 0.9.0.qualifier +Bundle-Version: 1.0.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.debug.core, org.eclipse.debug.ui, diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 628f8e45b5c..b8c399f3086 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -68,7 +68,7 @@ public abstract class AbstractPane extends Canvas try { - fCaretAddress = rendering.getMemoryBlock().getBigBaseAddress(); + fCaretAddress = rendering.getBigBaseAddress(); } catch(Exception e) { diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index bf5da6bead7..b2fdf416399 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -183,27 +183,15 @@ public class Rendering extends Composite implements IDebugEventSetListener this.fAddressBarControl.setVisible(false); // initialize the viewport start - IMemoryBlockExtension memoryBlock = getMemoryBlock(); - if(memoryBlock != null) + if(fParent.getMemoryBlock() != null) { - try - { - fViewportAddress = memoryBlock.getMemoryBlockStartAddress(); - // this will be null if memory may be retrieved at any address less than - // this memory block's base. if so use the base address. - if (fViewportAddress == null) - fViewportAddress = memoryBlock.getBigBaseAddress(); - fBaseAddress = fViewportAddress; - } - catch(DebugException e) - { - fViewportAddress = null; - if(isDebug()) - Rendering.this - .logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), e); //$NON-NLS-1$ - } + fViewportAddress = fParent.getMemoryBlockStartAddress(); + + // this will be null if memory may be retrieved at any address less than + // this memory block's base. if so use the base address. + if (fViewportAddress == null) + fViewportAddress = fParent.getBigBaseAddress(); + fBaseAddress = fViewportAddress; } getHorizontalBar().addSelectionListener(new SelectionListener() @@ -520,7 +508,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return false; } - protected IMemoryBlockExtension getMemoryBlock() + private IMemoryBlockExtension getMemoryBlock() { IMemoryBlock block = fParent.getMemoryBlock(); if(block != null) @@ -529,17 +517,15 @@ public class Rendering extends Composite implements IDebugEventSetListener return null; } + + protected BigInteger getBigBaseAddress() + { + return fParent.getBigBaseAddress(); + } protected int getAddressableSize() { - try - { - return getMemoryBlock().getAddressableSize(); - } - catch(DebugException e) - { - return 1; - } + return fParent.getAddressableSize(); } protected ViewportCache getViewportCache() @@ -925,7 +911,7 @@ public class Rendering extends Composite implements IDebugEventSetListener try { - getMemoryBlock().setValue(address.subtract(getMemoryBlock().getBigBaseAddress()), byteValue); + getMemoryBlock().setValue(address.subtract(fParent.getBigBaseAddress()), byteValue); } catch(Exception e) { @@ -1334,27 +1320,9 @@ public class Rendering extends Composite implements IDebugEventSetListener return addressString.toString(); } - private int fAddressBytes = -1; // called often, cache - protected int getAddressBytes() { - if(fAddressBytes == -1) - { - try - { - IMemoryBlockExtension block = getMemoryBlock(); - fAddressBytes = block.getAddressSize(); - } - catch(DebugException e) - { - fAddressBytes = 0; - logError( - TraditionalRenderingMessages - .getString("TraditionalRendering.FAILURE_DETERMINE_ADDRESS_SIZE"), e); //$NON-NLS-1$ - } - } - - return fAddressBytes; + return fParent.getAddressSize(); } protected int getColumnCount() @@ -1439,25 +1407,12 @@ public class Rendering extends Composite implements IDebugEventSetListener */ protected BigInteger getMemoryBlockStartAddress() { - if (fMemoryBlockStartAddress == null) - { - try { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger startAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockStartAddress(); - if (startAddress != null) - fMemoryBlockStartAddress = startAddress; - } - } catch (DebugException e) { - fMemoryBlockStartAddress = null; - } - - // default to 0 if we have trouble getting the start address - if (fMemoryBlockStartAddress == null) - fMemoryBlockStartAddress = BigInteger.valueOf(0); - } - return fMemoryBlockStartAddress; + if(fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = fParent.getMemoryBlockStartAddress(); + if(fMemoryBlockStartAddress == null) + fMemoryBlockStartAddress = BigInteger.ZERO; + + return fMemoryBlockStartAddress; } /** @@ -1465,40 +1420,9 @@ public class Rendering extends Composite implements IDebugEventSetListener */ protected BigInteger getMemoryBlockEndAddress() { - if (fMemoryBlockEndAddress == null) - { - IMemoryBlock memoryBlock = this.getMemoryBlock(); - if(memoryBlock instanceof IMemoryBlockExtension) - { - BigInteger endAddress; - try { - endAddress = ((IMemoryBlockExtension)memoryBlock).getMemoryBlockEndAddress(); - if (endAddress != null) - fMemoryBlockEndAddress = endAddress; - } catch (DebugException e) { - fMemoryBlockEndAddress = null; - } - - if (fMemoryBlockEndAddress == null) - { - int addressSize; - try { - addressSize = ((IMemoryBlockExtension)memoryBlock).getAddressSize(); - } catch (DebugException e) { - addressSize = 4; - } - - endAddress = BigInteger.valueOf(2); - endAddress = endAddress.pow(addressSize*8); - endAddress = endAddress.subtract(BigInteger.valueOf(1)); - fMemoryBlockEndAddress = endAddress; - } - } - - // default to MAX_VALUE if we have trouble getting the end address - if (fMemoryBlockEndAddress == null) - fMemoryBlockEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); - } + if(fMemoryBlockEndAddress == null) + fMemoryBlockEndAddress = fParent.getMemoryBlockEndAddress(); + return fMemoryBlockEndAddress; } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index aae549716d4..48f47b3bb87 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -21,14 +21,18 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; @@ -50,22 +54,15 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.progress.UIJob; @@ -155,7 +152,121 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe }); } + + protected void logError(String message, Exception e) + { + Status status = new Status(IStatus.ERROR, getRenderingId(), + DebugException.INTERNAL_ERROR, message, e); + DebugUIPlugin.getDefault().getLog().log(status); + } + + private BigInteger fBigBaseAddress; + private BigInteger fStartAddress; + private BigInteger fEndAddress; + private int fAddressableSize; + private int fAddressSize; + + public void init(IMemoryRenderingContainer container, IMemoryBlock block) + { + super.init(container, block); + + try + { + fBigBaseAddress = ((IMemoryBlockExtension) block).getBigBaseAddress(); + } + catch(DebugException de) + { + logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_BASE_ADDRESS"), de); //$NON-NLS-1$ // FIXME + } + + try + { + fAddressableSize = ((IMemoryBlockExtension) block).getAddressableSize(); + } + catch(DebugException de) + { + fAddressableSize = 1; + } + + try + { + fStartAddress = ((IMemoryBlockExtension)block).getMemoryBlockStartAddress(); + } + catch (DebugException de) { + fStartAddress = null; + logError(TraditionalRenderingMessages + .getString("TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS"), de); //$NON-NLS-1$ + } + + + try + { + fAddressSize = ((IMemoryBlockExtension) block).getAddressSize(); + } + catch(DebugException e) + { + fAddressSize = 0; + } + + BigInteger endAddress; + try + { + endAddress = ((IMemoryBlockExtension) block).getMemoryBlockEndAddress(); + if (endAddress != null) + fEndAddress = endAddress; + } + catch (DebugException e) + { + fEndAddress = null; + } + + if (fEndAddress == null) + { + int addressSize; + try { + addressSize = ((IMemoryBlockExtension) block).getAddressSize(); + } catch (DebugException e) { + addressSize = 4; + } + + endAddress = BigInteger.valueOf(2); + endAddress = endAddress.pow(addressSize*8); + endAddress = endAddress.subtract(BigInteger.valueOf(1)); + fEndAddress = endAddress; + } + + // default to MAX_VALUE if we have trouble getting the end address + if (fEndAddress == null) + fEndAddress = BigInteger.valueOf(Integer.MAX_VALUE); + } + + public BigInteger getBigBaseAddress() + { + return fBigBaseAddress; + } + + public BigInteger getMemoryBlockStartAddress() + { + return fStartAddress; + } + + public BigInteger getMemoryBlockEndAddress() + { + return fEndAddress; + } + + public int getAddressableSize() + { + return fAddressableSize; + } + + public int getAddressSize() + { + return fAddressSize; + } + public Control createControl(Composite parent) { allocateColors(); @@ -901,7 +1012,6 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe return super.getAdapter(adapter); } - } class TraditionalMemoryByte extends MemoryByte diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties index 04ddb74484c..a1f4ec4c951 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -24,6 +24,7 @@ TraditionalRendering.CELL_SIZE=Cell Size TraditionalRendering.RADIX=Radix TraditionalRendering.RENDERING_NAME=Traditional TraditionalRendering.FAILURE_RETRIEVE_START_ADDRESS=Failure in retrieving start address. +TraditionalRendering.FAILURE_RETRIEVE_BASE_ADDRESS=Failure in retrieving base address. TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD=Called on non-dispatch thread TraditionalRendering.FAILURE_READ_MEMORY=Failed reading memory. TraditionalRendering.FAILURE_WRITE_MEMORY=Error writing memory. From 522616005d62808a37bf095e80259a49f4eff384 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 19 Jul 2007 03:36:39 +0000 Subject: [PATCH 030/118] *** empty log message *** --- .../memory/renderings/traditional/TraditionalRendering.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 48f47b3bb87..ffdbc98a919 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -800,6 +800,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe final Action[] displayColumnCounts = new Action[maxMenuColumnCount]; for(int i = 0; i < maxMenuColumnCount; i++) { + final int finali = i; displayColumnCounts[i] = new Action( TraditionalRenderingMessages .getString("TraditionalRendering.COLUMN_COUNT_" + (i + 1)), //$NON-NLS-1$ @@ -807,7 +808,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe { public void run() { - TraditionalRendering.this.fRendering.setColumnsSetting(1); + TraditionalRendering.this.fRendering.setColumnsSetting(finali + 1); } }; displayColumnCounts[i].setChecked(fRendering.getColumnsSetting() == i + 1); From 3af711fbbd222d9ed6579aa72a5bc25f07493cba Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 19 Jul 2007 06:59:59 +0000 Subject: [PATCH 031/118] start address text validation --- .../dd/debug/memory/renderings/actions/ImportMemoryDialog.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java index 19cbd33ac79..835ec488ba4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java @@ -263,8 +263,6 @@ public class ImportMemoryDialog extends SelectionDialog Display.getDefault().getSystemColor(SWT.COLOR_RED)); // - - BigInteger startAddress = getStartAddress(); validate(); } From ecac8d4eca7d26f7539361dd71bc8282462c7395 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sat, 21 Jul 2007 01:14:16 +0000 Subject: [PATCH 032/118] check for isDisposed before settings colors --- .../traditional/TraditionalRendering.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index ffdbc98a919..92bd208d622 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -416,13 +416,16 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void applyPreferences() { - fRendering.setBackground(getColorBackground()); + if(!fRendering.isDisposed()) + { + fRendering.setBackground(getColorBackground()); - AbstractPane panes[] = fRendering.getRenderingPanes(); - for(int i = 0; i < panes.length; i++) - panes[i].setBackground(getColorBackground()); - - fRendering.redrawPanes(); + AbstractPane panes[] = fRendering.getRenderingPanes(); + for(int i = 0; i < panes.length; i++) + panes[i].setBackground(getColorBackground()); + + fRendering.redrawPanes(); + } } public Color getColorBackground() From 91a2802384ced5d5001db71b61a78b532f687d0a Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sat, 21 Jul 2007 04:19:37 +0000 Subject: [PATCH 033/118] check for user cancellation --- .../dd/debug/memory/renderings/actions/ExportMemoryAction.java | 2 +- .../dd/debug/memory/renderings/actions/ImportMemoryAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java index f2f58d6ffd6..a0994529168 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java @@ -123,7 +123,7 @@ public class ExportMemoryAction implements IViewActionDelegate { monitor.beginTask("Transferring Data", jobs.intValue()); BigInteger jobCount = BigInteger.ZERO; - while(transferAddress.compareTo(endAddress) < 0) + while(transferAddress.compareTo(endAddress) < 0 && !monitor.isCanceled()) { BigInteger length = DATA_PER_RECORD; if(endAddress.subtract(transferAddress).compareTo(length) < 0) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java index 7475c234e91..0f20900cd0c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java @@ -129,7 +129,7 @@ public class ImportMemoryAction implements IViewActionDelegate { BigInteger jobCount = BigInteger.ZERO; String line = reader.readLine(); - while(line != null) + while(line != null && !monitor.isCanceled()) { String recordType = line.substring(0, 2); int recordCount = Integer.parseInt(line.substring(2, 4), 16); From e58cfb9ff891ca0b4460cd20b9d083697c1a53d7 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 6 Aug 2007 20:45:37 +0000 Subject: [PATCH 034/118] 198979 --- .../renderings/traditional/AbstractPane.java | 2 ++ .../renderings/traditional/AddressPane.java | 1 + .../renderings/traditional/DataPane.java | 1 + .../renderings/traditional/Rendering.java | 25 +++++++++++++++++++ .../renderings/traditional/TextPane.java | 1 + .../traditional/TraditionalRendering.java | 19 ++++++++++++++ .../TraditionalRendering_messages.properties | 3 ++- 7 files changed, 51 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index b8c399f3086..870a842ab89 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -414,6 +414,8 @@ public abstract class AbstractPane extends Canvas fCaretAddress = fRendering.getMemoryBlockEndAddress().add( BigInteger.valueOf(cellOffset / fRendering.getAddressableSize())); } + + fRendering.setCaretAddress(fCaretAddress); } protected boolean isOdd(int value) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index 2c37b1cbff1..0d9769c2566 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -181,6 +181,7 @@ public class AddressPane extends AbstractPane this.fCaretAddress = cellAddress; this.fSubCellCaretPosition = x2; + setCaretAddress(fCaretAddress); } } catch(Exception e) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index 5fc835944cf..e35a7309161 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -211,6 +211,7 @@ public class DataPane extends AbstractPane this.fCaretAddress = cellAddress; this.fSubCellCaretPosition = subCellCharacterPosition; + setCaretAddress(fCaretAddress); } } catch(Exception e) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index b2fdf416399..bd4498e02d6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -23,6 +23,9 @@ import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposit import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; import org.eclipse.swt.events.KeyAdapter; @@ -1568,6 +1571,28 @@ public class Rendering extends Composite implements IDebugEventSetListener fBinaryPane.settingsChanged(); fTextPane.settingsChanged(); } + + protected void copyAddressToClipboard() + { + Clipboard clip = null; + try + { + clip = new Clipboard(getDisplay()); + + String addressString = "0x" + getCaretAddress().toString(16); + + TextTransfer plainTextTransfer = TextTransfer.getInstance(); + clip.setContents(new Object[] { addressString }, + new Transfer[] { plainTextTransfer }); + } + finally + { + if(clip != null) + { + clip.dispose(); + } + } + } static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 5f07888b079..ced26698daa 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -183,6 +183,7 @@ public class TextPane extends AbstractPane this.fCaretAddress = cellAddress; this.fSubCellCaretPosition = x2; + setCaretAddress(fCaretAddress); } } catch(Exception e) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 92bd208d622..faaa4502084 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -484,6 +484,24 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe // copy final Action copyAction = new CopyAction(this.fRendering); + + // copy address + + final Action copyAddressAction = new Action( + TraditionalRenderingMessages + .getString("TraditionalRendering.COPY_ADDRESS")) //$NON-NLS-1$ + { + public void run() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + TraditionalRendering.this.fRendering.copyAddressToClipboard(); + } + }); + } + }; // go to address @@ -925,6 +943,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe manager.add(new Separator()); manager.add(copyAction); + manager.add(copyAddressAction); manager.add(gotoAddressAction); manager.add(gotoBaseAddressAction); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties index a1f4ec4c951..aeea82814a0 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -45,4 +45,5 @@ TraditionalRendering.COLUMN_COUNT_5=5 TraditionalRendering.COLUMN_COUNT_6=6 TraditionalRendering.COLUMN_COUNT_7=7 TraditionalRendering.COLUMN_COUNT_8=8 -TraditionalRendering.COLUMN_COUNT_CUSTOM=Custom... \ No newline at end of file +TraditionalRendering.COLUMN_COUNT_CUSTOM=Custom... +TraditionalRendering.COPY_ADDRESS=Copy Address \ No newline at end of file From 0665f8bad33a9897b65933f65f4b7a092b5b8642 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 8 Aug 2007 05:09:17 +0000 Subject: [PATCH 035/118] 199195 - IMemoryBlockConnection adapter 199197 - endian not properly handled during cell editing 199198 - edit coloring only reflects last keystroke --- .../renderings/traditional/DataPane.java | 8 +++--- .../renderings/traditional/Rendering.java | 24 +++++++++--------- .../traditional/TraditionalRendering.java | 25 ++++++++++++++++++- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index e35a7309161..5021c9e5002 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -75,11 +75,7 @@ public class DataPane extends AbstractPane if(isSigned) byteData[byteLen - 1] |= 128; - boolean shouldReorderBytes = fRendering.isLittleEndian() == bytes[0].isBigEndian(); // swapped in presentation - if(!bytes[0].isBigEndian()) // swapped by BigInteger/java endianness - shouldReorderBytes = !shouldReorderBytes; - - if(shouldReorderBytes) + if(fRendering.isLittleEndian() != bytes[0].isBigEndian()) { byte[] byteDataSwapped = new byte[byteData.length]; for(int i = 0; i < byteData.length; i++) @@ -103,6 +99,8 @@ public class DataPane extends AbstractPane } else { + if(bytes[i] instanceof TraditionalMemoryByte) + bytesToSet[i].setEdited(((TraditionalMemoryByte) bytes[i]).isEdited()); bytesToSet[i].setChanged(bytes[i].isChanged()); } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index bd4498e02d6..379faea1557 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -141,6 +141,18 @@ public class Rendering extends Composite implements IDebugEventSetListener this.fParent = renderingParent; + // initialize the viewport start + if(fParent.getMemoryBlock() != null) + { + fViewportAddress = fParent.getMemoryBlockStartAddress(); + + // this will be null if memory may be retrieved at any address less than + // this memory block's base. if so use the base address. + if (fViewportAddress == null) + fViewportAddress = fParent.getBigBaseAddress(); + fBaseAddress = fViewportAddress; + } + // instantiate the panes, TODO default visibility from state or // plugin.xml? this.fAddressPane = new AddressPane(this); @@ -185,18 +197,6 @@ public class Rendering extends Composite implements IDebugEventSetListener this.fAddressBarControl.setVisible(false); - // initialize the viewport start - if(fParent.getMemoryBlock() != null) - { - fViewportAddress = fParent.getMemoryBlockStartAddress(); - - // this will be null if memory may be retrieved at any address less than - // this memory block's base. if so use the base address. - if (fViewportAddress == null) - fViewportAddress = fParent.getBigBaseAddress(); - fBaseAddress = fViewportAddress; - } - getHorizontalBar().addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent se) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index faaa4502084..dca4dc0fc79 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -28,6 +28,7 @@ import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.memory.IMemoryBlockConnection; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; @@ -99,6 +100,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe private Action displayEndianLittleAction; private IWorkbenchAdapter fWorkbenchAdapter; + private IMemoryBlockConnection fConnection; public TraditionalRendering(String id) { @@ -1001,7 +1003,6 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public Object getAdapter(Class adapter) { - if(adapter == IWorkbenchAdapter.class) { if(this.fWorkbenchAdapter == null) @@ -1032,11 +1033,33 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe } return this.fWorkbenchAdapter; } + + if (adapter == IMemoryBlockConnection.class) + { + if (fConnection == null) + { + fConnection = new IMemoryBlockConnection() + { + public void update() + { + // update UI asynchronously + Display display = DebugUIPlugin.getDefault().getWorkbench().getDisplay(); + display.asyncExec(new Runnable() { + public void run() { + TraditionalRendering.this.fRendering.refresh(); + } + }); + } + }; + } + return fConnection; + } return super.getAdapter(adapter); } } + class TraditionalMemoryByte extends MemoryByte { private boolean isEdited = false; From 9a9012d4ade670b1d57d9f74b73cc952d1cabd65 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 8 Aug 2007 21:03:23 +0000 Subject: [PATCH 036/118] bumped version to 1.0.0 --- .../org.eclipse.dd.debug.memory.renderings-feature/feature.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index bd754fbb1ac..d99f633af00 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -2,7 +2,7 @@ From b8f2b0eb090bb4577661cb94a59c2ecb8cf3f085 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 20:26:04 +0000 Subject: [PATCH 037/118] gotoAddress thread --- .../renderings/traditional/TraditionalRendering.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index dca4dc0fc79..fb611795750 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -326,7 +326,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe super.deactivated(); } - public void gotoAddress(BigInteger address) + public void gotoAddress(final BigInteger address) { this.fRendering.gotoAddress(address); } @@ -982,8 +982,13 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe } } - public void goToAddress(BigInteger address) throws DebugException { - fRendering.gotoAddress(address); + public void goToAddress(final BigInteger address) throws DebugException { + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + fRendering.gotoAddress(address); + } + }); } protected void bytesAreLittleEndian(boolean areLE) From 1533a4c1edbbfd6bf74bb63dbdb0346f2e705355 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 20:26:14 +0000 Subject: [PATCH 038/118] fixed copyright --- .../memory/renderings/traditional/Rendering.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 379faea1557..7266362d0a1 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.traditional; import java.math.BigInteger; From f9da220e1b9a8ace2f1397f4b3ddcca7f1ef17ac Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 20:26:38 +0000 Subject: [PATCH 039/118] fixed copyrights --- .../memory/renderings/actions/ExportMemoryDialog.java | 11 +++++++++++ .../memory/renderings/actions/ImportMemoryDialog.java | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java index f11b1eb6b41..0df1a169e8c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.actions; import java.io.File; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java index 835ec488ba4..bfbf83a9d11 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java @@ -1,3 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + package org.eclipse.dd.debug.memory.renderings.actions; import java.io.File; From d30af2698cd2fd36d3681aca17e567f7588f2ace Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 20:31:38 +0000 Subject: [PATCH 040/118] 201322 - Implement Find/Replace for the Memory View --- .../memory/renderings/actions/FindAction.java | 72 ++ .../renderings/actions/FindReplaceDialog.java | 814 ++++++++++++++++++ 2 files changed, 886 insertions(+) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java new file mode 100644 index 00000000000..6d06fc17f61 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.actions; + +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +public class FindAction implements IViewActionDelegate { + + private MemoryView fView; + + public void init(IViewPart view) { + if (view instanceof MemoryView) + fView = (MemoryView) view; + } + + public void run(IAction action) { + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + + if (selection instanceof IStructuredSelection) { + IStructuredSelection strucSel = (IStructuredSelection) selection; + + // return if current selection is empty + if (strucSel.isEmpty()) + return; + + Object obj = strucSel.getFirstElement(); + + if (obj == null) + return; + + IMemoryBlock memBlock = null; + + if (obj instanceof IMemoryRendering) { + memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + } else if (obj instanceof IMemoryBlock) { + memBlock = (IMemoryBlock) obj; + } + + Shell shell = DebugUIPlugin.getShell(); + FindReplaceDialog dialog = new FindReplaceDialog(shell, (IMemoryBlockExtension) memBlock, fView); + dialog.open(); + + Object results[] = dialog.getResult(); + } + + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java new file mode 100644 index 00000000000..7084e0fae38 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -0,0 +1,814 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.math.BigInteger; +import java.util.Vector; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +public class FindReplaceDialog extends SelectionDialog +{ + + private IMemoryBlockExtension fMemoryBlock; + + private Text findText; + private Text replaceText; + + private Combo startText; + private Combo endText; + + private Button findButton; + private Button replaceButton; + private Button replaceFindButton; + private Button replaceAllButton; + private Button closeButton; + + private MemoryView fMemoryView; + + Button formatAsciiButton; + Button formatHexButton; + Button formatOctalButton; + Button formatBinaryButton; + Button formatDecimalButton; + + Button caseInSensitiveCheckbox; + + Button forwardButton; + + public FindReplaceDialog(Shell parent, IMemoryBlockExtension memoryBlock, MemoryView memoryView) + { + super(parent); + super.setTitle(Messages.getString("FindReplaceDialog.Title")); //$NON-NLS-1$ + setShellStyle(getShellStyle() | SWT.RESIZE); + + fMemoryBlock = memoryBlock; + fMemoryView = memoryView; + this.setBlockOnOpen(false); + } + + private BigInteger getUserStart() + { + String start = startText.getText(); + if(start.toUpperCase().startsWith("0X")) //$NON-NLS-1$ + start = start.substring(2); + return new BigInteger(start, 16); + } + + private BigInteger getUserEnd() + { + String end = endText.getText(); + if(end.toUpperCase().startsWith("0X")) //$NON-NLS-1$ + end = end.substring(2); + return new BigInteger(end, 16); + } + + private boolean getIsDirectionForward() + { + return forwardButton.getSelection(); + } + + private SearchPhrase getSearchPhrase() + { + SearchPhrase phrase = null; + + if(formatAsciiButton.getSelection()) + { + phrase = new AsciiSearchPhrase(findText.getText(), caseInSensitiveCheckbox.getSelection()); + } + else if(formatHexButton.getSelection()) + { + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 16), 16); + } + else if(formatOctalButton.getSelection()) + { + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 8), 8); + } + else if(formatBinaryButton.getSelection()) + { + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 2), 2); + } + else if(formatDecimalButton.getSelection()) + { + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 10), 10); + } + + return phrase; + } + + private byte[] getReplaceData() + { + if(formatAsciiButton.getSelection()) + return replaceText.getText().getBytes(); + else if(formatHexButton.getSelection()) + return new BigInteger(replaceText.getText(), 16).toByteArray(); + else if(formatOctalButton.getSelection()) + return new BigInteger(replaceText.getText(), 8).toByteArray(); + else if(formatBinaryButton.getSelection()) + return new BigInteger(replaceText.getText(), 2).toByteArray(); + else if(formatDecimalButton.getSelection()) + return new BigInteger(replaceText.getText(), 10).toByteArray(); + + return new byte[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + findButton = createButton(parent, 10, Messages.getString("FindReplaceDialog.ButtonFind"), true); //$NON-NLS-1$ + findButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + performFind(getUserStart(), getUserEnd(), getSearchPhrase(), getIsDirectionForward(), null, false, false); + cancelPressed(); + } + }); + + replaceFindButton = createButton(parent, 11, Messages.getString("FindReplaceDialog.ButtonReplaceFind"), false); //$NON-NLS-1$ + replaceFindButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + performFind(getUserStart(), getUserEnd(), getSearchPhrase(), getIsDirectionForward(), getReplaceData(), false, true); + cancelPressed(); + } + }); + + replaceButton = createButton(parent, 12, Messages.getString("FindReplaceDialog.ButtonReplace"), false); //$NON-NLS-1$ + replaceButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + performFind(getUserStart(), getUserEnd(), getSearchPhrase(), getIsDirectionForward(), getReplaceData(), false, false); + cancelPressed(); + } + }); + + replaceAllButton = createButton(parent, 13, Messages.getString("FindReplaceDialog.ButtonReplaceAll"), false); //$NON-NLS-1$ + replaceAllButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + performFind(getUserStart(), getUserEnd(), getSearchPhrase(), getIsDirectionForward(), getReplaceData(), true, false); + cancelPressed(); + } + }); + + closeButton = createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("FindReplaceDialog.Close"), false); //$NON-NLS-1$ + + ((GridLayout) parent.getLayout()).numColumns = 2; + + validate(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() + */ + public Object[] getResult() { + + Object[] results = super.getResult(); + + if (results != null) + { + return results; + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + protected void cancelPressed() { + + setResult(null); + + super.cancelPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + setSelectionResult(new Object[]{ }); + + super.okPressed(); + } + + public BigInteger getEndAddress() + { + String text = endText.getText(); + boolean hex = text.startsWith("0x"); //$NON-NLS-1$ + BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return endAddress; + } + + public BigInteger getStartAddress() + { + String text = startText.getText(); + boolean hex = text.startsWith("0x"); //$NON-NLS-1$ + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + private void validate() + { + // TODO: make sure start & end are valid in relation to the direction + } + + private String pad(int characterCount, String value) + { + StringBuffer sb = new StringBuffer(value); + for(int i = 0; i < characterCount - value.length(); i++) + sb.insert(0, "0"); //$NON-NLS-1$ + return sb.toString(); + } + + private String[] removeNullElements(String strings[]) + { + Vector nonNullStrings = new Vector(); + for(String string : strings) + if(string != null) + nonNullStrings.addElement(string); + return (String[]) nonNullStrings.toArray(new String[0]); + } + + private String getMemoryBlockBaseAddress() + { + BigInteger base = null; + try + { + base = fMemoryBlock.getBigBaseAddress(); + } + catch(DebugException de) + { + } + + if(base == null) + base = BigInteger.ZERO; + + return "0x" + pad(getAddressSize() * 2, base.toString(16).toUpperCase()); //$NON-NLS-1$ + } + + private String getViewportStart() + { + ISelection selection = fMemoryView.getViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1).getSelectionProvider().getSelection(); + if(selection instanceof StructuredSelection) + { + if(((StructuredSelection) selection).getFirstElement() instanceof IRepositionableMemoryRendering) + { + ((IRepositionableMemoryRendering) ((StructuredSelection) selection).getFirstElement()).getSelectedAddress(); + } + } + return null; + } + + private String getStart() + { + BigInteger start = null; + try + { + start = fMemoryBlock.getMemoryBlockStartAddress(); + } + catch(DebugException de) + { + } + + if(start == null) + start = BigInteger.ZERO; + + return "0x" + pad(getAddressSize() * 2, start.toString(16).toUpperCase()); //$NON-NLS-1$ + } + + private String getEnd() + { + BigInteger end = null; + + try + { + end = fMemoryBlock.getMemoryBlockEndAddress(); + } + catch(DebugException de) + { + } + + if(end == null) + { + end = BigInteger.ZERO; + + for(int i = getAddressSize(); i > 0; i--) + { + end = end.shiftLeft(8); + end = end.or(BigInteger.valueOf(255)); + } + } + + return "0x" + pad(getAddressSize() * 2, end.toString(16).toUpperCase()); //$NON-NLS-1$ + } + + private int getAddressSize() + { + int addressSize; + try + { + addressSize = fMemoryBlock.getAddressSize(); + } + catch(DebugException de) + { + addressSize = 4; // default to 32bit? + } + return addressSize; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME + Composite composite = new Composite(parent, SWT.NONE); + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // find + + Label findLabel = new Label(composite, SWT.NONE); + Label replaceLabel = new Label(composite, SWT.NONE); + replaceText = new Text(composite, SWT.BORDER); + + findLabel.setText(Messages.getString("FindReplaceDialog.LabelFind")); //$NON-NLS-1$ + + findText = new Text(composite, SWT.BORDER); + FormData data = new FormData(); + data.left = new FormAttachment(replaceText, 0, SWT.LEFT); + data.width = 260; + findText.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(findText, 0, SWT.CENTER); + findLabel.setLayoutData(data); + + // replace + + replaceLabel.setText(Messages.getString("FindReplaceDialog.LabelReplaceWith")); //$NON-NLS-1$ + data = new FormData(); + data.top = new FormAttachment(findText); + replaceLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(replaceLabel, 0, SWT.CENTER); + data.left = new FormAttachment(replaceLabel); + data.width = 260; + replaceText.setLayoutData(data); + + // group direction + + Group directionGroup = new Group(composite, SWT.NONE); + Group formatGroup = new Group(composite, SWT.NONE); + Group rangeGroup = new Group(composite, SWT.NONE); + directionGroup.setText(Messages.getString("FindReplaceDialog.LabelDirection")); //$NON-NLS-1$ + + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + directionGroup.setLayout(layout); + + forwardButton = new Button(directionGroup, SWT.RADIO); + forwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ + Button backwardButton = new Button(directionGroup, SWT.RADIO); + backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ + + data = new FormData(); + data.top = new FormAttachment(replaceText); + data.right = new FormAttachment(formatGroup, 0, SWT.RIGHT); + data.left = new FormAttachment(formatGroup, 0, SWT.LEFT); + data.bottom = new FormAttachment(rangeGroup, 0, SWT.BOTTOM); + directionGroup.setLayoutData(data); + + // group range + + rangeGroup.setText(Messages.getString("FindReplaceDialog.LabelRange")); //$NON-NLS-1$ + + layout = new GridLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + rangeGroup.setLayout(layout); + + // group range - start address + + Label startLabel = new Label(rangeGroup, SWT.NONE); + startLabel.setText(Messages.getString("FindReplaceDialog.LabelStartAddress")); //$NON-NLS-1$ + + startText = new Combo(rangeGroup, SWT.BORDER); + GridData gridData = new GridData(); + gridData.widthHint = 200; + gridData.grabExcessHorizontalSpace = true; + startText.setLayoutData(gridData); + + // group range - end address + + Label endLabel = new Label(rangeGroup, SWT.NONE); + endLabel.setText(Messages.getString("FindReplaceDialog.LabelEndAddress")); //$NON-NLS-1$ + endText = new Combo(rangeGroup, SWT.BORDER); + gridData = new GridData(); + gridData.widthHint = 200; + gridData.grabExcessHorizontalSpace = true; + endText.setLayoutData(gridData); + + data = new FormData(); + data.left = new FormAttachment(directionGroup); + data.top = new FormAttachment(directionGroup, 0, SWT.TOP); + data.right = new FormAttachment(findText, 0, SWT.RIGHT); + rangeGroup.setLayoutData(data); + + startText.setItems(removeNullElements(new String[] { getViewportStart(), getStart(), getEnd(), getMemoryBlockBaseAddress() })); + endText.setItems(removeNullElements(new String[] { getEnd(), getStart(), getMemoryBlockBaseAddress(), getViewportStart() })); + startText.select(0); + endText.select(0); + + // format group + + formatGroup.setText(Messages.getString("FindReplaceDialog.LabelFormat")); //$NON-NLS-1$ + layout = new GridLayout(); + layout.numColumns = 1; + formatGroup.setLayout(layout); + + formatAsciiButton = new Button(formatGroup, SWT.RADIO); + formatAsciiButton.setText(Messages.getString("FindReplaceDialog.ButtonASCII")); //$NON-NLS-1$ + + formatHexButton = new Button(formatGroup, SWT.RADIO); + formatHexButton.setText(Messages.getString("FindReplaceDialog.ButtonHexadecimal")); //$NON-NLS-1$ + + formatOctalButton = new Button(formatGroup, SWT.RADIO); + formatOctalButton.setText(Messages.getString("FindReplaceDialog.ButtonOctal")); //$NON-NLS-1$ + + formatBinaryButton = new Button(formatGroup, SWT.RADIO); + formatBinaryButton.setText(Messages.getString("FindReplaceDialog.ButtonBinary")); //$NON-NLS-1$ + + formatDecimalButton = new Button(formatGroup, SWT.RADIO); + formatDecimalButton.setText(Messages.getString("FindReplaceDialog.ButtonDecimal")); //$NON-NLS-1$ + + data = new FormData(); + data.top = new FormAttachment(rangeGroup); + formatGroup.setLayoutData(data); + + // options group + + Group optionsGroup = new Group(composite, SWT.NONE); + optionsGroup.setText(Messages.getString("FindReplaceDialog.LabelOptions")); //$NON-NLS-1$ + + data = new FormData(); + data.left = new FormAttachment(formatGroup); + data.top = new FormAttachment(rangeGroup); + data.bottom = new FormAttachment(formatGroup, 0, SWT.BOTTOM); + data.right = new FormAttachment(rangeGroup, 0, SWT.RIGHT); + optionsGroup.setLayoutData(data); + + layout = new GridLayout(); + layout.numColumns = 1; + optionsGroup.setLayout(layout); + + + // wrap + + Button wrapCheckbox = new Button(optionsGroup, SWT.CHECK); + wrapCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonWrapSearch")); //$NON-NLS-1$ + wrapCheckbox.setEnabled(false); // TODO implement wrap + + caseInSensitiveCheckbox = new Button(optionsGroup, SWT.CHECK); + caseInSensitiveCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonCaseInsensitive")); //$NON-NLS-1$ + + formatAsciiButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + caseInSensitiveCheckbox.setEnabled(true); + } + }); + + SelectionListener nonAsciiListener = new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + caseInSensitiveCheckbox.setEnabled(false); + } + }; + formatHexButton.addSelectionListener(nonAsciiListener); + formatOctalButton.addSelectionListener(nonAsciiListener); + formatBinaryButton.addSelectionListener(nonAsciiListener); + formatDecimalButton.addSelectionListener(nonAsciiListener); + + startText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + + validate(); + } + + }); + + endText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + getEndAddress(); + endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + } + catch(Exception ex) + { + endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + forwardButton.setSelection(true); + formatAsciiButton.setSelection(true); + + findText.setFocus(); + + return composite; + } + + private void performFind(final BigInteger start, final BigInteger end, final SearchPhrase searchPhrase, + final boolean searchForward, final byte[] replaceData, final boolean isReplaceAll, final boolean replaceThenFind) + { + Job job = new Job("Searching memory for " + searchPhrase){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); + BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); + BigInteger currentPosition = start; + + boolean isReplace = replaceData != null; + + BigInteger jobs = range.subtract(searchPhraseLength); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + BigInteger jobCount = BigInteger.ZERO; + + BigInteger replaceCount = BigInteger.ZERO; + + monitor.beginTask(Messages.getString("FindReplaceDialog.SearchingMemoryFor") + searchPhrase, jobs.intValue()); //$NON-NLS-1$ + + boolean matched = false; + while(!matched && + ((searchForward && currentPosition.compareTo(end.subtract(searchPhraseLength)) < 0) + || (!searchForward && currentPosition.compareTo(end) > 0)) + && !monitor.isCanceled()) + { + try + { + // TODO cache and reuse previously read bytes? + MemoryByte bytes[] = fMemoryBlock.getBytesFromAddress(currentPosition, searchPhraseLength.longValue()); + matched = searchPhrase.isMatch(bytes); + } + catch(DebugException e) + { + // TODO log ? + // stop search? preference? + } + + if(!matched) + { + if(searchForward) + currentPosition = currentPosition.add(BigInteger.ONE); + else + currentPosition = currentPosition.subtract(BigInteger.ONE); + } + + jobCount = jobCount.add(BigInteger.ONE); + if(jobCount.compareTo(factor) == 0) + { + jobCount = BigInteger.ZERO; + monitor.worked(1); + } + + if(matched) + { + if(isReplace) + { + try + { + fMemoryBlock.setValue(currentPosition, replaceData); + } + catch(DebugException de) + { + // TODO log? + } + + replaceCount = replaceCount.add(BigInteger.ONE); + } + + if(isReplace && replaceThenFind && replaceCount.compareTo(BigInteger.ONE) == 0) + { + isReplace = false; + matched = false; + + if(searchForward) + currentPosition = currentPosition.add(BigInteger.ONE); + else + currentPosition = currentPosition.subtract(BigInteger.ONE); + } + + if(isReplaceAll) + { + matched = false; + + if(searchForward) + currentPosition = currentPosition.add(BigInteger.ONE); + else + currentPosition = currentPosition.subtract(BigInteger.ONE); + } + } + } + + if(matched) + { + ISelection selection = fMemoryView.getViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1).getSelectionProvider().getSelection(); + if(selection instanceof StructuredSelection) + { + if(((StructuredSelection) selection).getFirstElement() instanceof IRepositionableMemoryRendering) + { + try + { + ((IRepositionableMemoryRendering) ((StructuredSelection) selection).getFirstElement()).goToAddress(currentPosition); + } + catch(DebugException de) + { + // log + } + } + } + } + + return Status.OK_STATUS; + } + }; + job.schedule(); + } + + interface SearchPhrase + { + boolean isMatch(MemoryByte[] bytes); + int getByteLength(); + String toString(); + } + + class AsciiSearchPhrase implements SearchPhrase + { + private String fPhrase; + private boolean fIsCaseInsensitive; + + public AsciiSearchPhrase(String phrase, boolean isCaseInsensitive) + { + fPhrase = phrase; + fIsCaseInsensitive = isCaseInsensitive; + } + + public int getByteLength() + { + return fPhrase.length(); + } + + public String toString() + { + return fPhrase; + } + + public boolean isMatch(MemoryByte[] bytes) + { + byte[] targetBytes = new byte[bytes.length]; + for(int i = 0; i < bytes.length; i++) + targetBytes[i] = bytes[i].getValue(); + + String searchString = fPhrase; + String targetString = new String(targetBytes); + + if(fIsCaseInsensitive) + { + searchString = searchString.toUpperCase(); + targetString = targetString.toUpperCase(); + } + + return searchString.equals(targetString); + } + } + + class BigIntegerSearchPhrase implements SearchPhrase + { + private BigInteger fPhrase; + private int fRadix; + + public BigIntegerSearchPhrase(BigInteger phrase, int radix) + { + fPhrase = phrase; + fRadix = radix; + } + + public int getByteLength() + { + return fPhrase.toByteArray().length; + } + + public String toString() + { + return fPhrase.toString(fRadix); + } + + public boolean isMatch(MemoryByte[] bytes) + { + byte[] targetBytes = new byte[bytes.length]; + for(int i = 0; i < bytes.length; i++) + targetBytes[i] = bytes[i].getValue(); + + // TODO endian? + BigInteger targetBigInteger = new BigInteger(targetBytes); + + return fPhrase.equals(targetBigInteger); + } + } + +} From a6ac36ad2ee3f025cd6868db7c9e34ab26b2880b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 21:20:51 +0000 Subject: [PATCH 041/118] move traditional rendering preferences to Run/Debug category --- .../plugin.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index 75ac12cdc2a..e6d2d7755f6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -18,6 +18,7 @@ @@ -52,6 +53,16 @@ toolbarPath="additions" tooltip="%ImportMemoryAction.label"/> + + + + From c63295ed642f65adb936bcb188cbd2afc7116ea5 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Aug 2007 21:46:40 +0000 Subject: [PATCH 042/118] created --- .../memory/renderings/actions/Messages.java | 33 +++++++++++++++++++ .../renderings/actions/messages.properties | 24 ++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java new file mode 100644 index 00000000000..c3317f44bda --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2007 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.actions; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.dd.debug.memory.renderings.actions.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties new file mode 100644 index 00000000000..8547d48ce0b --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties @@ -0,0 +1,24 @@ +FindReplaceDialog.Title=Find / Replace Memory +FindReplaceDialog.ButtonFind=Find +FindReplaceDialog.ButtonReplaceFind=Replace/Find +FindReplaceDialog.ButtonReplace=Replace +FindReplaceDialog.ButtonReplaceAll=Replace All +FindReplaceDialog.Close=Close +FindReplaceDialog.LabelFind=Find: +FindReplaceDialog.LabelReplaceWith=Replace With: +FindReplaceDialog.LabelDirection=Direction +FindReplaceDialog.ButtonForward=Forward +FindReplaceDialog.ButtonBackward=Backward +FindReplaceDialog.LabelRange=Range +FindReplaceDialog.LabelStartAddress=Start address: +FindReplaceDialog.LabelEndAddress=End address: +FindReplaceDialog.LabelFormat=Format +FindReplaceDialog.ButtonASCII=ASCII +FindReplaceDialog.ButtonHexadecimal=Hexadecimal +FindReplaceDialog.ButtonOctal=Octal +FindReplaceDialog.ButtonBinary=Binary +FindReplaceDialog.ButtonDecimal=Decimal +FindReplaceDialog.LabelOptions=Options +FindReplaceDialog.ButtonWrapSearch=Wrap Search +FindReplaceDialog.ButtonCaseInsensitive=Case Insensitive +FindReplaceDialog.SearchingMemoryFor=Searching memory for From b66a1834ea520dc1bbe3fbb6b7b7c19a37e0f749 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 18 Sep 2007 19:34:11 +0000 Subject: [PATCH 043/118] =?UTF-8?q?Bugzilla=20=E2=80=93=20Bug=20203877?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../traditional/TraditionalRendering.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index fb611795750..5f11c2adccd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -101,6 +101,8 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe private IWorkbenchAdapter fWorkbenchAdapter; private IMemoryBlockConnection fConnection; + + private final static int MAX_MENU_COLUMN_COUNT = 8; public TraditionalRendering(String id) { @@ -819,9 +821,8 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe }; displayColumnCountAuto.setChecked(fRendering.getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT); - final int maxMenuColumnCount = 8; - final Action[] displayColumnCounts = new Action[maxMenuColumnCount]; - for(int i = 0; i < maxMenuColumnCount; i++) + final Action[] displayColumnCounts = new Action[MAX_MENU_COLUMN_COUNT]; + for(int i = 0; i < MAX_MENU_COLUMN_COUNT; i++) { final int finali = i; displayColumnCounts[i] = new Action( @@ -874,7 +875,21 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe } } ); - if (inputDialog.open() != Window.OK) return; + + if (inputDialog.open() != Window.OK) + { + this.setChecked(false); + int currentColumnSetting = TraditionalRendering.this.fRendering.getColumnsSetting(); + if(currentColumnSetting == Rendering.COLUMNS_AUTO_SIZE_TO_FIT) + displayColumnCountAuto.setChecked(true); + else if(currentColumnSetting > 0 && currentColumnSetting <= MAX_MENU_COLUMN_COUNT) + displayColumnCounts[currentColumnSetting - 1].setChecked(true); + else + displayColumnCountCustomValue.setChecked(true); + + return; + } + int newColumnCount = -1; try { newColumnCount = Integer.parseInt(inputDialog.getValue()); @@ -882,11 +897,12 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe TraditionalRendering.this.fRendering.setColumnsSetting(newColumnCount); this.setChecked(false); + displayColumnCountCustomValue.setChecked(true); displayColumnCountCustomValue.setText(Integer.valueOf( fRendering.getColumnsSetting()).toString()); } - }; + }; getPopupMenuManager().addMenuListener(new IMenuListener() { From 6a8b708bbe8db394a5cb1a7c08089294c1e8bc4a Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 19 Sep 2007 18:40:15 +0000 Subject: [PATCH 044/118] =?UTF-8?q?Bugzilla=20=E2=80=93=20Bug=20204024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dd/debug/memory/renderings/traditional/Rendering.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 7266362d0a1..bccf6f3be40 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -467,6 +467,9 @@ public class Rendering extends Composite implements IDebugEventSetListener public void handleDebugEvents(DebugEvent[] events) { + if(this.isDisposed()) + return; + for(int i = 0; i < events.length; i++) { if(events[0].getSource() instanceof IDebugElement) @@ -979,6 +982,7 @@ public class Rendering extends Composite implements IDebugEventSetListener public void dispose() { + DebugPlugin.getDefault().removeDebugEventListener(this); if(fViewportCache != null) { fViewportCache.dispose(); From 80e70fc3a44d9e762f4b9ad51f0c5c58ac34292a Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 19 Sep 2007 20:35:36 +0000 Subject: [PATCH 045/118] =?UTF-8?q?Bugzilla=20=E2=80=93=20Bug=20204032?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../memory/renderings/actions/FindReplaceDialog.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index 7084e0fae38..96c2abe2aff 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -121,11 +121,13 @@ public class FindReplaceDialog extends SelectionDialog } else if(formatHexButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 16), 16); + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().toUpperCase().startsWith("0X") + ? findText.getText().substring(2) : findText.getText(), 16), 16); } else if(formatOctalButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 8), 8); + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().startsWith("0") + ? findText.getText().substring(1) : findText.getText(), 8), 8); } else if(formatBinaryButton.getSelection()) { @@ -144,9 +146,9 @@ public class FindReplaceDialog extends SelectionDialog if(formatAsciiButton.getSelection()) return replaceText.getText().getBytes(); else if(formatHexButton.getSelection()) - return new BigInteger(replaceText.getText(), 16).toByteArray(); + return new BigInteger(replaceText.getText().toUpperCase().startsWith("0X") ? replaceText.getText().substring(2) : replaceText.getText(), 16).toByteArray(); else if(formatOctalButton.getSelection()) - return new BigInteger(replaceText.getText(), 8).toByteArray(); + return new BigInteger(replaceText.getText().startsWith("0") ? replaceText.getText().substring(1) : replaceText.getText(), 8).toByteArray(); else if(formatBinaryButton.getSelection()) return new BigInteger(replaceText.getText(), 2).toByteArray(); else if(formatDecimalButton.getSelection()) From 35b3629b8f41dbb6a2e9ed89a9ebb824740a1c38 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 20 Sep 2007 19:12:28 +0000 Subject: [PATCH 046/118] =?UTF-8?q?Bugzilla=20=E2=80=93=20Bug=20204175?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renderings/actions/FindReplaceDialog.java | 125 ++++++++++++++++-- .../renderings/actions/messages.properties | 3 +- 2 files changed, 114 insertions(+), 14 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index 96c2abe2aff..470b2a5a7dd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -12,6 +12,7 @@ package org.eclipse.dd.debug.memory.renderings.actions; import java.math.BigInteger; +import java.util.StringTokenizer; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; @@ -74,6 +75,7 @@ public class FindReplaceDialog extends SelectionDialog Button formatOctalButton; Button formatBinaryButton; Button formatDecimalButton; + Button formatByteSequenceButton; Button caseInSensitiveCheckbox; @@ -137,10 +139,43 @@ public class FindReplaceDialog extends SelectionDialog { phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 10), 10); } + else if(formatByteSequenceButton.getSelection()) + { + phrase = new ByteSequenceSearchPhrase(findText.getText()); + } return phrase; } + protected byte[] parseByteSequence(String s) + { + Vector sequence = new Vector(); + StringTokenizer st = new StringTokenizer(s, " "); + while(st.hasMoreElements()) + { + String element = ((String) st.nextElement()).trim(); + if(element.length() > 0) + { + BigInteger value; + if(element.toUpperCase().startsWith("0X")) + value = new BigInteger(element.substring(2), 16); + else + value = new BigInteger(element, 10); + Byte b = new Byte(value.byteValue()); + + if(value.compareTo(BigInteger.valueOf(255)) > 0) + return null; + + sequence.addElement(b); + } + } + Byte seq[] = sequence.toArray(new Byte[sequence.size()]); + byte[] bytes = new byte[seq.length]; + for(int i = 0; i < seq.length; i++) + bytes[i] = seq[i].byteValue(); + return bytes; + } + private byte[] getReplaceData() { if(formatAsciiButton.getSelection()) @@ -153,6 +188,8 @@ public class FindReplaceDialog extends SelectionDialog return new BigInteger(replaceText.getText(), 2).toByteArray(); else if(formatDecimalButton.getSelection()) return new BigInteger(replaceText.getText(), 10).toByteArray(); + else if(formatByteSequenceButton.getSelection()) + return parseByteSequence(replaceText.getText()); return new byte[0]; } @@ -267,7 +304,28 @@ public class FindReplaceDialog extends SelectionDialog private void validate() { - // TODO: make sure start & end are valid in relation to the direction + boolean valid = false; + boolean replaceValid = false; + + try + { + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + if(getSearchPhrase() != null && getSearchPhrase().getByteLength() > 0) + valid = true; + + if(getReplaceData() != null && getReplaceData().length > 0) + replaceValid = true; + } + catch(Throwable ex) + { + + } + + findButton.setEnabled(valid); + replaceButton.setEnabled(replaceValid); + replaceFindButton.setEnabled(replaceValid); + replaceAllButton.setEnabled(replaceValid); } private String pad(int characterCount, String value) @@ -503,6 +561,9 @@ public class FindReplaceDialog extends SelectionDialog formatDecimalButton = new Button(formatGroup, SWT.RADIO); formatDecimalButton.setText(Messages.getString("FindReplaceDialog.ButtonDecimal")); //$NON-NLS-1$ + formatByteSequenceButton = new Button(formatGroup, SWT.RADIO); + formatByteSequenceButton.setText(Messages.getString("FindReplaceDialog.ButtonByteSequence")); //$NON-NLS-1$ + data = new FormData(); data.top = new FormAttachment(rangeGroup); formatGroup.setLayoutData(data); @@ -554,6 +615,7 @@ public class FindReplaceDialog extends SelectionDialog formatOctalButton.addSelectionListener(nonAsciiListener); formatBinaryButton.addSelectionListener(nonAsciiListener); formatDecimalButton.addSelectionListener(nonAsciiListener); + formatByteSequenceButton.addSelectionListener(nonAsciiListener); startText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { @@ -570,12 +632,6 @@ public class FindReplaceDialog extends SelectionDialog startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : Display.getDefault().getSystemColor(SWT.COLOR_RED)); - // - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - validate(); } @@ -587,10 +643,6 @@ public class FindReplaceDialog extends SelectionDialog { getEndAddress(); endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - } catch(Exception ex) { @@ -602,6 +654,20 @@ public class FindReplaceDialog extends SelectionDialog }); + findText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) + { + validate(); + } + }); + + replaceText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) + { + validate(); + } + }); + forwardButton.setSelection(true); formatAsciiButton.setSelection(true); @@ -623,9 +689,9 @@ public class FindReplaceDialog extends SelectionDialog BigInteger jobs = range.subtract(searchPhraseLength); BigInteger factor = BigInteger.ONE; - if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + if(jobs.compareTo(BigInteger.valueOf(0x07FFFFFF)) > 0) { - factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + factor = jobs.divide(BigInteger.valueOf(0x07FFFFFF)); jobs = jobs.divide(factor); } @@ -779,6 +845,39 @@ public class FindReplaceDialog extends SelectionDialog } } + class ByteSequenceSearchPhrase implements SearchPhrase + { + private byte[] fBytes = null; + + public ByteSequenceSearchPhrase(String phrase) + { + fBytes = parseByteSequence(phrase); + } + + public int getByteLength() + { + return fBytes.length; + } + + public String toString() + { + if(fBytes == null) + return ""; + StringBuffer buf = new StringBuffer(); + for(int i = 0; i < fBytes.length; i++) + buf.append(BigInteger.valueOf(fBytes[i]).toString(16) + " "); + return buf.toString(); + } + + public boolean isMatch(MemoryByte[] bytes) + { + for(int i = 0; i < bytes.length; i++) + if(bytes[i].getValue() != fBytes[i]) + return false; + return true; + } + } + class BigIntegerSearchPhrase implements SearchPhrase { private BigInteger fPhrase; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties index 8547d48ce0b..8f9bd5d5c47 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties @@ -13,11 +13,12 @@ FindReplaceDialog.LabelRange=Range FindReplaceDialog.LabelStartAddress=Start address: FindReplaceDialog.LabelEndAddress=End address: FindReplaceDialog.LabelFormat=Format -FindReplaceDialog.ButtonASCII=ASCII +FindReplaceDialog.ButtonASCII=ASCII String FindReplaceDialog.ButtonHexadecimal=Hexadecimal FindReplaceDialog.ButtonOctal=Octal FindReplaceDialog.ButtonBinary=Binary FindReplaceDialog.ButtonDecimal=Decimal +FindReplaceDialog.ButtonByteSequence=Byte Sequence FindReplaceDialog.LabelOptions=Options FindReplaceDialog.ButtonWrapSearch=Wrap Search FindReplaceDialog.ButtonCaseInsensitive=Case Insensitive From 0e65733fdb8376330b3544073646b8c3dc3379ec Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 4 Oct 2007 22:08:47 +0000 Subject: [PATCH 047/118] [205526] Some font choices/sizes do not render well in the traditional memory rendering --- .../renderings/traditional/AbstractPane.java | 11 ++++++++++- .../memory/renderings/traditional/AddressPane.java | 14 +++++++------- .../memory/renderings/traditional/DataPane.java | 2 +- .../memory/renderings/traditional/Rendering.java | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 870a842ab89..8ae821d7de8 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -26,6 +26,7 @@ import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; @@ -639,6 +640,14 @@ public abstract class AbstractPane extends Canvas abstract protected int getCellCharacterCount(); + public void setFont(Font font) + { + super.setFont(font); + fCharacterWidth = -1; + fCellHeight = -1; + fTextHeight = -1; + } + private int fCellHeight = -1; // called often, cache protected int getCellHeight() @@ -659,7 +668,7 @@ public abstract class AbstractPane extends Canvas if(fCharacterWidth == -1) { GC gc = new GC(this); - gc.setFont(fRendering.getFont()); + gc.setFont(fRendering.getFont()); fCharacterWidth = gc.getAdvanceWidth('F'); gc.dispose(); } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index 0d9769c2566..c6a4ae77495 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -80,14 +80,14 @@ public class AddressPane extends AbstractPane } protected int getCellWidth() - { - GC gc = new GC(this); - gc.setFont(fRendering.getFont()); - int width = gc.getAdvanceWidth('0'); + { + GC gc = new GC(this); + StringBuffer buf = new StringBuffer(); + for(int i = 0; i < getCellCharacterCount(); i++) + buf.append("0"); + int width = gc.textExtent(buf.toString()).x; gc.dispose(); - - return getCellCharacterCount() * width - + (fRendering.getCellPadding() * 2); + return width; } private int getColumnCount() diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index 5021c9e5002..bc3e0630c0c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -241,7 +241,7 @@ public class DataPane extends AbstractPane int cellHeight = getCellHeight(); int cellWidth = getCellWidth(); - + int columns = fRendering.getColumnCount(); try diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index bccf6f3be40..447745f6962 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -462,7 +462,7 @@ public class Rendering extends Composite implements IDebugEventSetListener controls[i].setFont(font); packColumns(); - redrawPanes(); + layout(true); } public void handleDebugEvents(DebugEvent[] events) From d9e5b657eb52f0283e0b97627ea33284268ced3d Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 4 Oct 2007 23:06:06 +0000 Subject: [PATCH 048/118] [205529] Traditional memory rendering should archive cache for change history on Suspend, not Resume --- .../renderings/traditional/Rendering.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 447745f6962..a631bc11f66 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -490,6 +490,7 @@ public class Rendering extends Composite implements IDebugEventSetListener { public void run() { + archiveDeltas(); refresh(); } }); @@ -504,16 +505,16 @@ public class Rendering extends Composite implements IDebugEventSetListener } }); } - else if(kind == DebugEvent.RESUME) - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - archiveDeltas(); - } - }); - } +// else if(kind == DebugEvent.RESUME) +// { +// Display.getDefault().asyncExec(new Runnable() +// { +// public void run() +// { +// //archiveDeltas(); +// } +// }); +// } } } } From 1db10b1da91322b8e27d0773d353bc61184b953c Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 5 Oct 2007 19:41:49 +0000 Subject: [PATCH 049/118] [205606] Edits should be colorized even if the value has not been changed; embedded users want to see that the memory will be written. --- .../dd/debug/memory/renderings/traditional/DataPane.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index bc3e0630c0c..b46b48a41e4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -93,11 +93,14 @@ public class DataPane extends AbstractPane bytesToSet[i] = new TraditionalMemoryByte(byteData[i]); bytesToSet[i].setBigEndian(bytes[i].isBigEndian()); - if(bytes[i].getValue() != byteData[i]) + // for embedded, the user wants feedback that the change will be sent to the target, + // even if does not change the value. eventually, maybe we need another color to + // indicate change. + //if(bytes[i].getValue() != byteData[i]) { bytesToSet[i].setEdited(true); } - else + //else { if(bytes[i] instanceof TraditionalMemoryByte) bytesToSet[i].setEdited(((TraditionalMemoryByte) bytes[i]).isEdited()); From 3674468f2f4f8edb3d653b8364ad8488878db58c Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 16 Oct 2007 21:55:31 +0000 Subject: [PATCH 050/118] [206543] FindReplace incorrectly sets value on the memoryblock at the absolute address; should use offset --- .../dd/debug/memory/renderings/actions/FindReplaceDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index 470b2a5a7dd..b4d4c918946 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -740,7 +740,7 @@ public class FindReplaceDialog extends SelectionDialog { try { - fMemoryBlock.setValue(currentPosition, replaceData); + fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), replaceData); } catch(DebugException de) { From b24b901b3338e0b0b895b953ec308abdfa188aa1 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 18 Oct 2007 22:15:27 +0000 Subject: [PATCH 051/118] [206828] new selection should set DND.SELECTION_CLIPBOARD data --- .../memory/renderings/traditional/AbstractPane.java | 5 +++++ .../renderings/traditional/TraditionalRendering.java | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 8ae821d7de8..5953fef5fe5 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -17,6 +17,7 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyEvent; @@ -542,6 +543,8 @@ public abstract class AbstractPane extends Canvas fRendering.getBytesPerColumn() / fRendering.getAddressableSize())), address); fSelectionStarted = true; + + new CopyAction(fRendering, DND.SELECTION_CLIPBOARD).run(); } } catch(DebugException e) @@ -602,6 +605,8 @@ public abstract class AbstractPane extends Canvas } updateCaret(); + + new CopyAction(fRendering, DND.SELECTION_CLIPBOARD).run(); } catch(DebugException e) { diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 5f11c2adccd..d81324ff9c4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -53,6 +53,7 @@ import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; +import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.graphics.Color; @@ -1107,10 +1108,17 @@ class CopyAction extends Action // blocks on a Job. private Rendering fRendering; + private int fType = DND.CLIPBOARD; public CopyAction(Rendering rendering) + { + this(rendering, DND.CLIPBOARD); + } + + public CopyAction(Rendering rendering, int clipboardType) { super(); + fType = clipboardType; fRendering = rendering; setText(DebugUIMessages.CopyViewToClipboardAction_title); setToolTipText(DebugUIMessages.CopyViewToClipboardAction_tooltip); @@ -1288,7 +1296,7 @@ class CopyAction extends Action { TextTransfer plainTextTransfer = TextTransfer.getInstance(); clip.setContents(new Object[] { buffer.toString() }, - new Transfer[] { plainTextTransfer }); + new Transfer[] { plainTextTransfer }, fType); } } finally From 0d914fc773ca5043a5146f498d729571b536b00e Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 29 Oct 2007 16:46:13 +0000 Subject: [PATCH 052/118] [207807] missing !isDisposed() check in Rendering.redrawPanes() --- .../dd/debug/memory/renderings/traditional/Rendering.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index a631bc11f66..c33c317e92d 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -1542,7 +1542,7 @@ public class Rendering extends Composite implements IDebugEventSetListener protected void redrawPanes() { - if(this.isVisible()) + if(!isDisposed() && this.isVisible()) { if(fAddressPane.isPaneVisible()) { From 4cecd6c03dc4fb22abfdeef73456820e4d7f47b6 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 31 Oct 2007 16:42:17 +0000 Subject: [PATCH 053/118] [208278] endian cleanup --- .../renderings/traditional/DataPane.java | 4 +- .../renderings/traditional/Rendering.java | 57 ++++++++++++------- .../renderings/traditional/TextPane.java | 4 +- .../traditional/TraditionalRendering.java | 20 ++++--- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index b46b48a41e4..d9393056100 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -30,7 +30,7 @@ public class DataPane extends AbstractPane protected String getCellText(MemoryByte bytes[]) { return fRendering.getRadixText(bytes, fRendering.getRadix(), fRendering - .isLittleEndian()); + .isTargetLittleEndian()); } protected void editCell(BigInteger address, int subCellPosition, @@ -75,7 +75,7 @@ public class DataPane extends AbstractPane if(isSigned) byteData[byteLen - 1] |= 128; - if(fRendering.isLittleEndian() != bytes[0].isBigEndian()) + if(fRendering.isTargetLittleEndian() != bytes[0].isBigEndian()) { byte[] byteDataSwapped = new byte[byteData.length]; for(int i = 0; i < byteData.length; i++) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index c33c317e92d..73ab1c056bc 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -103,9 +103,9 @@ public class Rendering extends Composite implements IDebugEventSetListener private int fColumnsSetting = COLUMNS_AUTO_SIZE_TO_FIT; - private boolean fLittleEndian = false; + private boolean fIsTargetLittleEndian = false; - private boolean fCheckedLittleEndian = false; + private boolean fIsDisplayLittleEndian = false; // constants used to identify radix protected final static int RADIX_HEX = 1; @@ -765,18 +765,10 @@ public class Rendering extends Composite implements IDebugEventSetListener for(int i = 0; i < readBytes.length; i++) cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); - // we need to set the default endianess. before it was set to BE - // by default which wasn't very useful for LE targets. now we will - // query the first byte to get the endianess. if not known then we'll - // leave it as BE. note that we only do this when reading the first - // bit of memory for this rendering. what happens when scrolling - // through memory and it changes endianess? for now we just leave - // it in the original endianess. - if (!fCheckedLittleEndian && cachedBytes.length > 0) { + // derive the target endian from the read MemoryBytes. + if (cachedBytes.length > 0) { if (cachedBytes[0].isEndianessKnown()) { - fLittleEndian = !cachedBytes[0].isBigEndian(); - fCheckedLittleEndian = true; - fParent.bytesAreLittleEndian(fLittleEndian); + setTargetLittleEndian(!cachedBytes[0].isBigEndian()); } } @@ -1515,21 +1507,43 @@ public class Rendering extends Composite implements IDebugEventSetListener return 1; } - protected boolean isLittleEndian() + protected boolean isTargetLittleEndian() { - return fLittleEndian; + return fIsTargetLittleEndian; } - protected void setLittleEndian(boolean enable) + protected void setTargetLittleEndian(boolean littleEndian) { - if(fLittleEndian == enable) + if(fIsTargetLittleEndian == littleEndian) return; - fLittleEndian = enable; - fireSettingsChanged(); - layoutPanes(); + fParent.setTargetMemoryLittleEndian(littleEndian); + fIsTargetLittleEndian = littleEndian; + Display.getDefault().asyncExec(new Runnable() { + public void run() + { + fireSettingsChanged(); + layoutPanes(); + } + }); } + public boolean isDisplayLittleEndian() + { + return fIsDisplayLittleEndian; + } + + public void setDisplayLittleEndian(boolean littleEndian) + { + if(fIsDisplayLittleEndian = littleEndian) + return; + + fIsDisplayLittleEndian = littleEndian; + + fireSettingsChanged(); + layoutPanes(); + } + protected void setBytesPerColumn(int byteCount) { if(fBytesPerColumn != byteCount) @@ -1627,8 +1641,7 @@ public class Rendering extends Composite implements IDebugEventSetListener // and we want to view in LE then we need to swap. if the bytes // are LE and we want to view BE then we need to swap. boolean needsSwap = false; - boolean bytesAreLittleEndian = !bytes[0].isBigEndian(); - if ((isLittleEndian && !bytesAreLittleEndian) || (!isLittleEndian && bytesAreLittleEndian)) + if ((isDisplayLittleEndian() && !isTargetLittleEndian()) || (!isDisplayLittleEndian() && isTargetLittleEndian())) needsSwap = true; switch(radix) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index ced26698daa..59caae71841 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -35,7 +35,7 @@ public class TextPane extends AbstractPane protected String getCellText(MemoryByte bytes[]) { return fRendering.formatText(bytes, fRendering - .isLittleEndian(), fRendering.getTextMode()); + .isTargetLittleEndian(), fRendering.getTextMode()); } protected void editCell(BigInteger address, int subCellPosition, @@ -219,7 +219,7 @@ public class TextPane extends AbstractPane final int columns = fRendering.getColumnCount(); - final boolean isLittleEndian = fRendering.isLittleEndian(); + final boolean isLittleEndian = fRendering.isTargetLittleEndian(); gc.setForeground(fRendering.getTraditionalRendering().getColorBackground()); gc.fillRectangle(columns * cellWidth, 0, this.getBounds().width, this diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index d81324ff9c4..5ea13b70c6b 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -722,10 +722,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void run() { TraditionalRendering.this.fRendering - .setLittleEndian(false); + .setDisplayLittleEndian(false); } }; - displayEndianBigAction.setChecked(!this.fRendering.isLittleEndian()); + displayEndianBigAction.setChecked(!this.fRendering.isTargetLittleEndian()); displayEndianLittleAction = new Action( TraditionalRenderingMessages @@ -735,10 +735,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void run() { TraditionalRendering.this.fRendering - .setLittleEndian(true); + .setDisplayLittleEndian(true); } }; - displayEndianLittleAction.setChecked(this.fRendering.isLittleEndian()); + displayEndianLittleAction.setChecked(this.fRendering.isTargetLittleEndian()); // radix @@ -1008,12 +1008,16 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe }); } - protected void bytesAreLittleEndian(boolean areLE) + protected void setTargetMemoryLittleEndian(boolean littleEndian) { // once we actually read memory we can determine the // endianess and need to set these actions accordingly. - displayEndianBigAction.setChecked(!areLE); - displayEndianLittleAction.setChecked(areLE); + displayEndianBigAction.setChecked(!littleEndian); + displayEndianLittleAction.setChecked(littleEndian); + + // when target endian changes, force display endian to track. + // user can then change display endian if desired. + fRendering.setDisplayLittleEndian(littleEndian); } public void dispose() @@ -1157,7 +1161,7 @@ class CopyAction extends Action final int radix = fRendering.getRadix(); final int bytesPerColumn = fRendering.getBytesPerColumn(); - final boolean isLittleEndian = fRendering.isLittleEndian(); + final boolean isLittleEndian = fRendering.isTargetLittleEndian(); final int bytesPerCharacter = fRendering.getBytesPerCharacter(); final int addressWidth = fRendering.getAddressString(start) From b72cf3c87a7f4e9f9ec8879fda4eb03c6b4ac69c Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 1 Nov 2007 23:54:13 +0000 Subject: [PATCH 054/118] [208278] endian cleanup --- .../renderings/traditional/Rendering.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 73ab1c056bc..525e026f3b9 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -761,7 +761,7 @@ public class Rendering extends Composite implements IDebugEventSetListener final MemoryByte readBytes[] = memoryBlock .getBytesFromAddress(startAddress, units); - final MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; + MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; for(int i = 0; i < readBytes.length; i++) cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); @@ -771,7 +771,27 @@ public class Rendering extends Composite implements IDebugEventSetListener setTargetLittleEndian(!cachedBytes[0].isBigEndian()); } } + + // reorder bytes within unit to be a sequential byte stream if the endian is already little + if(isTargetLittleEndian()) + { + // there isn't an order when the unit size is one, so skip for performance + if(addressableSize.compareTo(BigInteger.ONE) != 0) + { + int unitSize = addressableSize.intValue(); + MemoryByte cachedBytesAsByteSequence[] = new MemoryByte[cachedBytes.length]; + for(int unit = 0; unit < units; unit++) + { + for(int unitbyte = 0; unitbyte < unitSize; unitbyte++) + { + cachedBytesAsByteSequence[unit * unitSize + unitbyte] = cachedBytes[unit * unitSize + unitSize - unitbyte]; + } + } + cachedBytes = cachedBytesAsByteSequence; + } + } + final MemoryByte[] cachedBytesFinal = cachedBytes; Display.getDefault().asyncExec(new Runnable() { public void run() @@ -798,8 +818,8 @@ public class Rendering extends Composite implements IDebugEventSetListener for(int i = overlapLength.intValue(); i >= 0; i--) { - cachedBytes[offsetIntoNew + i] - .setChanged(cachedBytes[offsetIntoNew + cachedBytesFinal[offsetIntoNew + i] + .setChanged(cachedBytesFinal[offsetIntoNew + i].getValue() != fHistoryCache.bytes[offsetIntoOld + i].getValue()); } @@ -809,7 +829,7 @@ public class Rendering extends Composite implements IDebugEventSetListener fCache = new MemoryUnit(); fCache.start = startAddress; fCache.end = endAddress; - fCache.bytes = cachedBytes; + fCache.bytes = cachedBytesFinal; Rendering.this.redrawPanes(); } @@ -1637,11 +1657,11 @@ public class Rendering extends Composite implements IDebugEventSetListener if(readable) { - // see if we need to swap the data or not. if the bytes are BE - // and we want to view in LE then we need to swap. if the bytes - // are LE and we want to view BE then we need to swap. + // bytes from the cache are stored as a sequential byte sequence regardless of target endian. + // the endian attribute tells us the recommended endian for display. the user may change this + // from the default. if the endian is little, we must swap the byte order. boolean needsSwap = false; - if ((isDisplayLittleEndian() && !isTargetLittleEndian()) || (!isDisplayLittleEndian() && isTargetLittleEndian())) + if(isDisplayLittleEndian()) needsSwap = true; switch(radix) From 9026af2c92bf5cf673ad4a312175c7bc25fb4462 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 2 Nov 2007 01:06:25 +0000 Subject: [PATCH 055/118] [208278] endian cleanup --- .../dd/debug/memory/renderings/traditional/DataPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index d9393056100..a92f541542c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -75,7 +75,7 @@ public class DataPane extends AbstractPane if(isSigned) byteData[byteLen - 1] |= 128; - if(fRendering.isTargetLittleEndian() != bytes[0].isBigEndian()) + if(!fRendering.isDisplayLittleEndian()) { byte[] byteDataSwapped = new byte[byteData.length]; for(int i = 0; i < byteData.length; i++) From ff501148f5bd2d07e6706d8e13ceae82fd75f62c Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 2 Nov 2007 02:35:43 +0000 Subject: [PATCH 056/118] [208500] find replace mishandles searches for values greater than the max signed value of byte --- .../renderings/actions/FindReplaceDialog.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index b4d4c918946..2bd63c116fc 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -181,13 +181,13 @@ public class FindReplaceDialog extends SelectionDialog if(formatAsciiButton.getSelection()) return replaceText.getText().getBytes(); else if(formatHexButton.getSelection()) - return new BigInteger(replaceText.getText().toUpperCase().startsWith("0X") ? replaceText.getText().substring(2) : replaceText.getText(), 16).toByteArray(); + return removeZeroPrefixByte(new BigInteger(replaceText.getText().toUpperCase().startsWith("0X") ? replaceText.getText().substring(2) : replaceText.getText(), 16).toByteArray()); else if(formatOctalButton.getSelection()) - return new BigInteger(replaceText.getText().startsWith("0") ? replaceText.getText().substring(1) : replaceText.getText(), 8).toByteArray(); + return removeZeroPrefixByte(new BigInteger(replaceText.getText().startsWith("0") ? replaceText.getText().substring(1) : replaceText.getText(), 8).toByteArray()); else if(formatBinaryButton.getSelection()) - return new BigInteger(replaceText.getText(), 2).toByteArray(); + return removeZeroPrefixByte(new BigInteger(replaceText.getText(), 2).toByteArray()); else if(formatDecimalButton.getSelection()) - return new BigInteger(replaceText.getText(), 10).toByteArray(); + return removeZeroPrefixByte(new BigInteger(replaceText.getText(), 10).toByteArray()); else if(formatByteSequenceButton.getSelection()) return parseByteSequence(replaceText.getText()); @@ -891,7 +891,7 @@ public class FindReplaceDialog extends SelectionDialog public int getByteLength() { - return fPhrase.toByteArray().length; + return removeZeroPrefixByte(fPhrase.toByteArray()).length; } public String toString() @@ -906,10 +906,20 @@ public class FindReplaceDialog extends SelectionDialog targetBytes[i] = bytes[i].getValue(); // TODO endian? - BigInteger targetBigInteger = new BigInteger(targetBytes); + BigInteger targetBigInteger = new BigInteger(targetBytes).and(BigInteger.valueOf(0xFF)); return fPhrase.equals(targetBigInteger); } } + private byte[] removeZeroPrefixByte(byte[] bytes) + { + if(bytes[0] != 0) + return bytes; + + byte[] processedBytes = new byte[bytes.length - 1]; + System.arraycopy(bytes, 1, processedBytes, 0, processedBytes.length); + return processedBytes; + } + } From 3ce419b7b1884a0efcd1f6cb696d48779a858b2b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 11 Nov 2007 23:44:28 +0000 Subject: [PATCH 057/118] [209436] Change history color does not work until after the first suspend event [209437] Find/Replace performance is poor [209438] Find/Replace dialog tab ordering is wrong [209439] Find/Replace mismanages conversion to byte[] --- .../renderings/actions/FindReplaceDialog.java | 64 ++++++++++++++++--- .../renderings/traditional/Rendering.java | 8 +++ 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index 2bd63c116fc..08d74dcf52d 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -56,6 +56,8 @@ public class FindReplaceDialog extends SelectionDialog private IMemoryBlockExtension fMemoryBlock; + final static int preFetchSize = 10 * 1024; + private Text findText; private Text replaceText; @@ -671,11 +673,50 @@ public class FindReplaceDialog extends SelectionDialog forwardButton.setSelection(true); formatAsciiButton.setSelection(true); + composite.setTabList(new Control[] { + findText, + replaceText, + directionGroup, + rangeGroup, + formatGroup, + optionsGroup, + }); + findText.setFocus(); return composite; } + + class FindReplaceMemoryCache + { + BigInteger memoryCacheStartAddress = BigInteger.ZERO; + MemoryByte memoryCacheData[] = new MemoryByte[0]; + } + + MemoryByte[] getBytesFromAddress(final BigInteger address, final int length, FindReplaceMemoryCache cache) + throws DebugException + { + if(! (address.compareTo(cache.memoryCacheStartAddress) >= 0 + && address.add(BigInteger.valueOf(length)).compareTo(cache.memoryCacheStartAddress + .add(BigInteger.valueOf(cache.memoryCacheData.length))) < 0)) + { + BigInteger fetchAddress = address.subtract(BigInteger.valueOf(preFetchSize)); + if(fetchAddress.compareTo(BigInteger.ZERO) < 0) // TODO replace ZERO with address space start + fetchAddress = BigInteger.ZERO; + + MemoryByte bytes[] = fMemoryBlock.getBytesFromAddress(fetchAddress, preFetchSize * 2); + + cache.memoryCacheStartAddress = fetchAddress; + cache.memoryCacheData = bytes; + } + + MemoryByte bytes[] = new MemoryByte[length]; + System.arraycopy(cache.memoryCacheData, address.subtract(cache.memoryCacheStartAddress).intValue(), + bytes, 0, length); + return bytes; + } + private void performFind(final BigInteger start, final BigInteger end, final SearchPhrase searchPhrase, final boolean searchForward, final byte[] replaceData, final boolean isReplaceAll, final boolean replaceThenFind) { @@ -685,6 +726,7 @@ public class FindReplaceDialog extends SelectionDialog BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); BigInteger currentPosition = start; + boolean isReplace = replaceData != null; BigInteger jobs = range.subtract(searchPhraseLength); @@ -699,18 +741,20 @@ public class FindReplaceDialog extends SelectionDialog BigInteger replaceCount = BigInteger.ZERO; + FindReplaceMemoryCache cache = new FindReplaceMemoryCache(); + monitor.beginTask(Messages.getString("FindReplaceDialog.SearchingMemoryFor") + searchPhrase, jobs.intValue()); //$NON-NLS-1$ boolean matched = false; while(!matched && ((searchForward && currentPosition.compareTo(end.subtract(searchPhraseLength)) < 0) || (!searchForward && currentPosition.compareTo(end) > 0)) - && !monitor.isCanceled()) + && !monitor.isCanceled()) { try { // TODO cache and reuse previously read bytes? - MemoryByte bytes[] = fMemoryBlock.getBytesFromAddress(currentPosition, searchPhraseLength.longValue()); + MemoryByte bytes[] = getBytesFromAddress(currentPosition, searchPhraseLength.intValue(), cache); matched = searchPhrase.isMatch(bytes); } catch(DebugException e) @@ -772,7 +816,10 @@ public class FindReplaceDialog extends SelectionDialog } } } - + + if(monitor.isCanceled()) + return Status.CANCEL_STATUS; + if(matched) { ISelection selection = fMemoryView.getViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1).getSelectionProvider().getSelection(); @@ -901,20 +948,21 @@ public class FindReplaceDialog extends SelectionDialog public boolean isMatch(MemoryByte[] bytes) { - byte[] targetBytes = new byte[bytes.length]; + byte[] targetBytes = new byte[bytes.length + 1]; + targetBytes[0] = 0; for(int i = 0; i < bytes.length; i++) - targetBytes[i] = bytes[i].getValue(); + targetBytes[i + 1] = bytes[i].getValue(); // TODO endian? - BigInteger targetBigInteger = new BigInteger(targetBytes).and(BigInteger.valueOf(0xFF)); - + BigInteger targetBigInteger = new BigInteger(targetBytes); + return fPhrase.equals(targetBigInteger); } } private byte[] removeZeroPrefixByte(byte[] bytes) { - if(bytes[0] != 0) + if(bytes[0] != 0 || bytes.length == 1) return bytes; byte[] processedBytes = new byte[bytes.length - 1]; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 525e026f3b9..9b47e0238fc 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -464,6 +464,8 @@ public class Rendering extends Composite implements IDebugEventSetListener packColumns(); layout(true); } + + static int suspendCount = 0; public void handleDebugEvents(DebugEvent[] events) { @@ -830,6 +832,12 @@ public class Rendering extends Composite implements IDebugEventSetListener fCache.start = startAddress; fCache.end = endAddress; fCache.bytes = cachedBytesFinal; + + // If the history does not exist, populate the history with the just populated cache. This solves the + // use case of 1) connect to target; 2) edit memory before the first suspend debug event; 3) paint + // differences in changed color. + if(fHistoryCache == null) + fHistoryCache = fCache.clone(); Rendering.this.redrawPanes(); } From 87ab767fb7d938de334cefcfea7a9e4a47a86570 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 12 Nov 2007 02:25:11 +0000 Subject: [PATCH 058/118] [209445] text pane should respect the set character mode, US-ASCII, ISO_8859_1, ... --- .../dd/debug/memory/renderings/traditional/TextPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 59caae71841..25680be5fdd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -53,7 +53,7 @@ public class TextPane extends AbstractPane StringBuffer cellTextBuffer = new StringBuffer(cellText); cellTextBuffer.setCharAt(subCellPosition, character); - byte byteData[] = cellTextBuffer.toString().getBytes(); + byte byteData[] = cellTextBuffer.toString().getBytes(fRendering.getCharacterSet(fRendering.getTextMode())); if(byteData.length != bytes.length) return; From a89f4371450412341e983355a1ddb10f852cebde Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 26 Nov 2007 04:25:52 +0000 Subject: [PATCH 059/118] [200853] Enhancements focused on inheritance --- .../renderings/traditional/AbstractPane.java | 7 +- .../renderings/traditional/AddressPane.java | 8 +- .../renderings/traditional/DataPane.java | 64 ++++--- .../renderings/traditional/Rendering.java | 173 +++++++++++------- .../renderings/traditional/TextPane.java | 52 +++--- 5 files changed, 182 insertions(+), 122 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 5953fef5fe5..2c882749109 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -49,9 +49,9 @@ public abstract class AbstractPane extends Canvas // caret protected Caret fCaret = null; - protected int fSubCellCaretPosition = 0; // character may not fall on - - // byte boundary + // character may not fall on byte boundary + protected int fSubCellCaretPosition = 0; + protected int fOldSubCellCaretPosition = 0; protected boolean fCaretEnabled = false; @@ -185,6 +185,7 @@ public abstract class AbstractPane extends Canvas { public void keyPressed(KeyEvent ke) { + fOldSubCellCaretPosition = fSubCellCaretPosition; if((ke.stateMask & SWT.SHIFT) != 0) { switch(ke.keyCode) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index c6a4ae77495..402eff0139b 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -229,7 +229,8 @@ public class AddressPane extends AbstractPane gc.fillRectangle(fRendering.getCellPadding() * 2, cellHeight * i, getCellWidth(), cellHeight); - gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + // Allow subclass to override this method to do its own coloring + applyCustomColor(gc); } gc.drawText(fRendering.getAddressString(lineAddress), @@ -244,4 +245,9 @@ public class AddressPane extends AbstractPane } } + // Allow subclass to override this method to do its own coloring + protected void applyCustomColor(GC gc) + { + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index a92f541542c..b1668d63bea 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -239,12 +239,20 @@ public class DataPane extends AbstractPane { super.paint(pe); + // Allow subclasses to override this method to do their own painting + doPaintData(pe); + + } + + // Allow subclasses to override this method to do their own painting + protected void doPaintData(PaintEvent pe) + { GC gc = pe.gc; gc.setFont(fRendering.getFont()); int cellHeight = getCellHeight(); int cellWidth = getCellWidth(); - + int columns = fRendering.getColumnCount(); try @@ -282,30 +290,10 @@ public class DataPane extends AbstractPane gc.fillRectangle(cellWidth * col + fRendering.getCellPadding(), cellHeight * i, cellWidth, cellHeight); + + // Allow subclasses to override this method to do their own coloring + applyCustomColor(gc, bytes, col); - // TODO consider adding finer granularity? - boolean anyByteChanged = false; - for(int n = 0; n < bytes.length && !anyByteChanged; n++) - if(bytes[n].isChanged()) - anyByteChanged = true; - - // TODO consider adding finer granularity? - boolean anyByteEditing = false; - for(int n = 0; n < bytes.length && !anyByteEditing; n++) - if(bytes[n] instanceof TraditionalMemoryByte) - if(((TraditionalMemoryByte) bytes[n]).isEdited()) - anyByteEditing = true; - - if(anyByteEditing) - gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); - else if(anyByteChanged) - gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); - else if(isOdd(col)) - gc.setForeground(fRendering.getTraditionalRendering().getColorText()); - else - gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); - - gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); } gc.drawText(getCellText(bytes), cellWidth * col @@ -345,7 +333,35 @@ public class DataPane extends AbstractPane fRendering.logError(TraditionalRenderingMessages .getString("TraditionalRendering.FAILURE_PAINT"), e); //$NON-NLS-1$ } + + } + // Allow subclasses to override this method to do their own coloring + protected void applyCustomColor(GC gc, MemoryByte bytes[], int col) + { + // TODO consider adding finer granularity? + boolean anyByteChanged = false; + for(int n = 0; n < bytes.length && !anyByteChanged; n++) + if(bytes[n].isChanged()) + anyByteChanged = true; + + // TODO consider adding finer granularity? + boolean anyByteEditing = false; + for(int n = 0; n < bytes.length && !anyByteEditing; n++) + if(bytes[n] instanceof TraditionalMemoryByte) + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; + + if(anyByteEditing) + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + else if(anyByteChanged) + gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); + else if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 9b47e0238fc..3371296eb9c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -82,7 +82,7 @@ public class Rendering extends Composite implements IDebugEventSetListener BigInteger fMemoryBlockStartAddress = null; BigInteger fMemoryBlockEndAddress = null; - BigInteger fBaseAddress = null; // remember the base address + protected BigInteger fBaseAddress = null; // remember the base address private int fColumnCount = 0; // auto calculate can be disabled by user, // making this user settable @@ -108,31 +108,31 @@ public class Rendering extends Composite implements IDebugEventSetListener private boolean fIsDisplayLittleEndian = false; // constants used to identify radix - protected final static int RADIX_HEX = 1; + public final static int RADIX_HEX = 1; - protected final static int RADIX_DECIMAL_SIGNED = 2; + public final static int RADIX_DECIMAL_SIGNED = 2; - protected final static int RADIX_DECIMAL_UNSIGNED = 3; + public final static int RADIX_DECIMAL_UNSIGNED = 3; - protected final static int RADIX_OCTAL = 4; + public final static int RADIX_OCTAL = 4; - protected final static int RADIX_BINARY = 5; + public final static int RADIX_BINARY = 5; // constants used to identify panes - protected final static int PANE_ADDRESS = 1; + public final static int PANE_ADDRESS = 1; - protected final static int PANE_BINARY = 2; + public final static int PANE_BINARY = 2; - protected final static int PANE_TEXT = 3; + public final static int PANE_TEXT = 3; // constants used to identify text, maybe java should be queried for all available sets - protected final static int TEXT_ISO_8859_1 = 1; - protected final static int TEXT_USASCII = 2; - protected final static int TEXT_UTF8 = 3; + public final static int TEXT_ISO_8859_1 = 1; + public final static int TEXT_USASCII = 2; + public final static int TEXT_UTF8 = 3; protected final static int TEXT_UTF16 = 4; // internal constants - protected final static int COLUMNS_AUTO_SIZE_TO_FIT = 0; + public final static int COLUMNS_AUTO_SIZE_TO_FIT = 0; // view internal settings private int fCellPadding = 2; @@ -166,9 +166,9 @@ public class Rendering extends Composite implements IDebugEventSetListener // instantiate the panes, TODO default visibility from state or // plugin.xml? - this.fAddressPane = new AddressPane(this); - this.fBinaryPane = new DataPane(this); - this.fTextPane = new TextPane(this); + this.fAddressPane = createAddressPane(); + this.fBinaryPane = createDataPane(); + this.fTextPane = createTextPane(); fAddressBar = new GoToAddressComposite(); fAddressBarControl = fAddressBar.createControl(parent); @@ -398,7 +398,22 @@ public class Rendering extends Composite implements IDebugEventSetListener DebugPlugin.getDefault().addDebugEventListener(this); } - protected TraditionalRendering getTraditionalRendering() // TODO rename + protected AddressPane createAddressPane() + { + return new AddressPane(this); + } + + protected DataPane createDataPane() + { + return new DataPane(this); + } + + protected TextPane createTextPane() + { + return new TextPane(this); + } + + public TraditionalRendering getTraditionalRendering() // TODO rename { return fParent; } @@ -440,12 +455,12 @@ public class Rendering extends Composite implements IDebugEventSetListener setCurrentScrollSelection(); } - protected Selection getSelection() + public Selection getSelection() { return fSelection; } - - protected void logError(String message, Exception e) + + public void logError(String message, Exception e) { Status status = new Status(IStatus.ERROR, fParent.getRenderingId(), DebugException.INTERNAL_ERROR, message, e); @@ -486,44 +501,62 @@ public class Rendering extends Composite implements IDebugEventSetListener if(source.getDebugTarget() == getMemoryBlock() .getDebugTarget()) { - if(kind == DebugEvent.SUSPEND && detail == 0) + if(kind == DebugEvent.SUSPEND) { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - archiveDeltas(); - refresh(); - } - }); + handleSuspendEvent(detail); } else if(kind == DebugEvent.CHANGE) { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - refresh(); - } - }); + handleChangeEvent(); } // else if(kind == DebugEvent.RESUME) // { -// Display.getDefault().asyncExec(new Runnable() -// { -// public void run() -// { -// //archiveDeltas(); -// } -// }); +// handleResumeEvent(); // } } } } } + protected void handleSuspendEvent(int detail) + { + if(detail == 0) + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + archiveDeltas(); + refresh(); + } + }); + } + } + + protected void handleChangeEvent() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + refresh(); + } + }); + } + + protected void handleResumeEvent() + { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { +// archiveDeltas(); + } + }); + } + // return true to enable development debug print statements - protected boolean isDebug() + public boolean isDebug() { return false; } @@ -537,8 +570,8 @@ public class Rendering extends Composite implements IDebugEventSetListener return null; } - - protected BigInteger getBigBaseAddress() + + public BigInteger getBigBaseAddress() { return fParent.getBigBaseAddress(); } @@ -553,7 +586,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fViewportCache; } - protected MemoryByte[] getBytes(BigInteger address, int bytes) + public MemoryByte[] getBytes(BigInteger address, int bytes) throws DebugException { return fViewportCache.getBytes(address, bytes); @@ -1183,7 +1216,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } } - protected void setPaneVisible(int pane, boolean visible) + public void setPaneVisible(int pane, boolean visible) { switch(pane) { @@ -1202,7 +1235,7 @@ public class Rendering extends Composite implements IDebugEventSetListener layoutPanes(); } - protected boolean getPaneVisible(int pane) + public boolean getPaneVisible(int pane) { switch(pane) { @@ -1281,13 +1314,13 @@ public class Rendering extends Composite implements IDebugEventSetListener Rendering.this.redrawPanes(); } - protected AbstractPane[] getRenderingPanes() + public AbstractPane[] getRenderingPanes() { return new AbstractPane[] { fAddressPane, fBinaryPane, fTextPane }; } - protected int getCellPadding() + public int getCellPadding() { return fCellPadding; } @@ -1297,7 +1330,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fPaneSpacing; } - protected void refresh() + public void refresh() { if(!this.isDisposed()) { @@ -1318,7 +1351,7 @@ public class Rendering extends Composite implements IDebugEventSetListener fViewportCache.archiveDeltas(); } - protected void gotoAddress(BigInteger address) + public void gotoAddress(BigInteger address) { // Ensure that the GoTo address is within the addressable range if((address.compareTo(this.getMemoryBlockStartAddress())< 0) || @@ -1336,17 +1369,17 @@ public class Rendering extends Composite implements IDebugEventSetListener fViewportAddress = newAddress; } - protected BigInteger getViewportStartAddress() + public BigInteger getViewportStartAddress() { return fViewportAddress; } - protected BigInteger getViewportEndAddress() + public BigInteger getViewportEndAddress() { return fViewportAddress.add(BigInteger.valueOf(this.getBytesPerRow() * getRowCount() / getAddressableSize())); } - protected String getAddressString(BigInteger address) + public String getAddressString(BigInteger address) { StringBuffer addressString = new StringBuffer(address.toString(16) .toUpperCase()); @@ -1364,7 +1397,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fParent.getAddressSize(); } - protected int getColumnCount() + public int getColumnCount() { return fColumnCount; } @@ -1410,7 +1443,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return rowCount; } - protected int getBytesPerColumn() + public int getBytesPerColumn() { return fBytesPerColumn; } @@ -1425,7 +1458,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return getBytesPerRow() / getAddressableSize(); } - protected int getAddressesPerColumn() + public int getAddressesPerColumn() { return this.getBytesPerColumn() / getAddressableSize(); } @@ -1465,7 +1498,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fMemoryBlockEndAddress; } - protected int getRadix() + public int getRadix() { return fRadix; } @@ -1488,7 +1521,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return -1; } - protected void setRadix(int mode) + public void setRadix(int mode) { if(fRadix == mode) return; @@ -1498,7 +1531,7 @@ public class Rendering extends Composite implements IDebugEventSetListener layoutPanes(); } - protected void setTextMode(int mode) + public void setTextMode(int mode) { fTextMode = mode; @@ -1506,7 +1539,7 @@ public class Rendering extends Composite implements IDebugEventSetListener layoutPanes(); } - protected int getTextMode() + public int getTextMode() { return fTextMode; } @@ -1527,7 +1560,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } } - protected int getBytesPerCharacter() + public int getBytesPerCharacter() { if(fTextMode == Rendering.TEXT_UTF16) return 2; @@ -1535,12 +1568,12 @@ public class Rendering extends Composite implements IDebugEventSetListener return 1; } - protected boolean isTargetLittleEndian() + public boolean isTargetLittleEndian() { return fIsTargetLittleEndian; } - protected void setTargetLittleEndian(boolean littleEndian) + public void setTargetLittleEndian(boolean littleEndian) { if(fIsTargetLittleEndian == littleEndian) return; @@ -1572,7 +1605,7 @@ public class Rendering extends Composite implements IDebugEventSetListener layoutPanes(); } - protected void setBytesPerColumn(int byteCount) + public void setBytesPerColumn(int byteCount) { if(fBytesPerColumn != byteCount) { @@ -1655,7 +1688,7 @@ public class Rendering extends Composite implements IDebugEventSetListener static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - protected String getRadixText(MemoryByte bytes[], int radix, + public String getRadixText(MemoryByte bytes[], int radix, boolean isLittleEndian) { boolean readable = true; @@ -1800,7 +1833,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return errorText.toString(); } - protected int getRadixCharacterCount(int radix, int bytes) + public int getRadixCharacterCount(int radix, int bytes) { switch(radix) { @@ -1863,7 +1896,7 @@ public class Rendering extends Composite implements IDebugEventSetListener || character == ' '; } - protected String formatText(MemoryByte[] memoryBytes, + public String formatText(MemoryByte[] memoryBytes, boolean isLittleEndian, int textMode) { // check memory byte for unreadable bytes diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 25680be5fdd..799e43c7be9 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -259,30 +259,7 @@ public class TextPane extends AbstractPane gc.fillRectangle(cellWidth * col, cellHeight * i, cellWidth, cellHeight); - // TODO reuse, this could be in the abstract base - // TODO consider adding finer granularity? - boolean anyByteChanged = false; - for(int n = 0; n < bytes.length && !anyByteChanged; n++) - if(bytes[n].isChanged()) - anyByteChanged = true; - - // TODO consider adding finer granularity? - boolean anyByteEditing = false; - for(int n = 0; n < bytes.length && !anyByteEditing; n++) - if(bytes[n] instanceof TraditionalMemoryByte) - if(((TraditionalMemoryByte) bytes[n]).isEdited()) - anyByteEditing = true; - - if(anyByteEditing) - gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); - else if(anyByteChanged) - gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); - else if(isOdd(col)) - gc.setForeground(fRendering.getTraditionalRendering().getColorText()); - else - gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); - - gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + applyCustomColor(gc, bytes, col); } gc.drawText(fRendering.formatText(bytes, @@ -304,4 +281,31 @@ public class TextPane extends AbstractPane } + protected void applyCustomColor(GC gc, MemoryByte bytes[], int col) + { + // TODO reuse, this could be in the abstract base + // TODO consider adding finer granularity? + boolean anyByteChanged = false; + for(int n = 0; n < bytes.length && !anyByteChanged; n++) + if(bytes[n].isChanged()) + anyByteChanged = true; + + // TODO consider adding finer granularity? + boolean anyByteEditing = false; + for(int n = 0; n < bytes.length && !anyByteEditing; n++) + if(bytes[n] instanceof TraditionalMemoryByte) + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; + + if(anyByteEditing) + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + else if(anyByteChanged) + gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); + else if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + } } From 0669b2c27a7477b2de70b88df531acf80dda5d37 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 26 Nov 2007 04:35:39 +0000 Subject: [PATCH 060/118] [200853] Refacted patch to make getSelection() return an IMemorySelection --- .../traditional/IMemorySelection.java | 24 +++++++++++++++++++ .../renderings/traditional/Rendering.java | 22 ++++++++--------- 2 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java new file mode 100644 index 00000000000..ac5c02995f9 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java @@ -0,0 +1,24 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +public interface IMemorySelection +{ + public boolean hasSelection(); + + public boolean isSelected(BigInteger address); + + public BigInteger getStart(); + + public BigInteger getEnd(); + + public void setStart(BigInteger high, BigInteger low); + + public void setEnd(BigInteger high, BigInteger low); + + public BigInteger getHigh(); + + public BigInteger getLow(); + + public void clear(); +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 3371296eb9c..2f63034c75c 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -455,7 +455,7 @@ public class Rendering extends Composite implements IDebugEventSetListener setCurrentScrollSelection(); } - public Selection getSelection() + public IMemorySelection getSelection() { return fSelection; } @@ -1045,7 +1045,7 @@ public class Rendering extends Composite implements IDebugEventSetListener super.dispose(); } - class Selection + class Selection implements IMemorySelection { private BigInteger fStartHigh; private BigInteger fStartLow; @@ -1053,19 +1053,19 @@ public class Rendering extends Composite implements IDebugEventSetListener private BigInteger fEndHigh; private BigInteger fEndLow; - protected void clear() + public void clear() { fEndHigh = fEndLow = fStartHigh = fStartLow = null; redrawPanes(); } - protected boolean hasSelection() + public boolean hasSelection() { return fStartHigh != null && fStartLow != null && fEndHigh != null && fEndLow != null; } - protected boolean isSelected(BigInteger address) + public boolean isSelected(BigInteger address) { // do we have valid start and end addresses if(getEnd() == null || getStart() == null) @@ -1089,7 +1089,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return false; } - protected void setStart(BigInteger high, BigInteger low) + public void setStart(BigInteger high, BigInteger low) { if(high == null && low == null) { @@ -1121,7 +1121,7 @@ public class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); } - protected void setEnd(BigInteger high, BigInteger low) + public void setEnd(BigInteger high, BigInteger low) { if(high == null && low == null) { @@ -1153,7 +1153,7 @@ public class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); } - protected BigInteger getHigh() + public BigInteger getHigh() { if(!hasSelection()) return null; @@ -1161,7 +1161,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return getStart().max(getEnd()); } - protected BigInteger getLow() + public BigInteger getLow() { if(!hasSelection()) return null; @@ -1169,7 +1169,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return getStart().min(getEnd()); } - protected BigInteger getStart() + public BigInteger getStart() { // if there is no start, return null if(fStartHigh == null) @@ -1194,7 +1194,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fStartLow; } - protected BigInteger getEnd() + public BigInteger getEnd() { // if there is no end, return null if(fEndHigh == null) From 39f6ca8ccc04b5b3fe5e00dbe6858bea2b2d492c Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 2 Mar 2008 19:14:50 +0000 Subject: [PATCH 061/118] [220842] S-Record export generates invalid checksums. --- .../actions/ExportMemoryAction.java | 14 ++++--- .../actions/ImportMemoryAction.java | 38 ++++++++++++++++--- .../TraditionalRenderingPlugin.java | 10 ++++- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java index a0994529168..d45c3ba2022 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java @@ -159,16 +159,20 @@ public class ExportMemoryAction implements IViewActionDelegate { buf.append(bString); } - BigInteger checksum = BigInteger.ZERO; + /* + * The least significant byte of the one's complement of the sum of the values + * represented by the pairs of characters making up the records length, address, + * and the code/data fields. + */ + byte checksum = 0; for(int i = 0; i < buf.length(); i+=2) { - BigInteger value = new BigInteger(buf.substring(i, i+1), 16); - checksum = checksum.add(value); + BigInteger value = new BigInteger(buf.substring(i, i+2), 16); + checksum += value.byteValue(); } - buf.append(BigInteger.valueOf(0xFF - checksum.byteValue()).and( - BigInteger.valueOf(0xFF)).toString(16)); + buf.append(BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16)); writer.write(buf.toString().toUpperCase()); writer.write("\n"); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java index 0f20900cd0c..d69b2f7fdd6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java @@ -21,9 +21,9 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; @@ -89,7 +89,7 @@ public class ImportMemoryAction implements IViewActionDelegate { BigInteger start = (BigInteger) results[2]; File file = (File) results[3]; - if("S-Record".equals(format)) + if("S-Record".equals(format)) //$NON-NLS-1$ { downloadSRecord(file, start, useCustomAddress.booleanValue(), (IMemoryBlockExtension) memBlock); // FIXME } @@ -101,6 +101,7 @@ public class ImportMemoryAction implements IViewActionDelegate { private void downloadSRecord(final File inputFile, final BigInteger startAddress, final boolean useCustomAddress, final IMemoryBlockExtension memblock) { Job job = new Job("Memory Download from S-Record File"){ //$NON-NLS-1$ + @Override public IStatus run(IProgressMonitor monitor) { try @@ -125,7 +126,7 @@ public class ImportMemoryAction implements IViewActionDelegate { jobs = jobs.divide(factor); } - monitor.beginTask("Transferring Data", jobs.intValue()); + monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$ BigInteger jobCount = BigInteger.ZERO; String line = reader.readLine(); @@ -139,11 +140,11 @@ public class ImportMemoryAction implements IViewActionDelegate { BigInteger recordAddress = null; - if("S3".equals(recordType)) + if("S3".equals(recordType)) //$NON-NLS-1$ addressSize = 4; - else if("S1".equals(recordType)) + else if("S1".equals(recordType)) //$NON-NLS-1$ addressSize = 2; - else if("S2".equals(recordType)) + else if("S2".equals(recordType)) //$NON-NLS-1$ addressSize = 3; recordAddress = new BigInteger(line.substring(position, position + addressSize * 2), 16); @@ -161,6 +162,31 @@ public class ImportMemoryAction implements IViewActionDelegate { data[i] = new BigInteger(line.substring(position++, position++ + 1), 16).byteValue(); } + /* + * The least significant byte of the one's complement of the sum of the values + * represented by the pairs of characters making up the records length, address, + * and the code/data fields. + */ + StringBuffer buf = new StringBuffer(line.substring(2)); + byte checksum = 0; + + for(int i = 0; i < buf.length(); i+=2) + { + BigInteger value = new BigInteger(buf.substring(i, i+2), 16); + checksum += value.byteValue(); + } + + /* + * Since we included the checksum in the checksum calculation the checksum + * ( if correct ) will always be 0xFF which is -1 using the signed byte size + * calculation here. + */ + if ( checksum != (byte) -1 ) { + reader.close(); + monitor.done(); + return new Status( IStatus.ERROR, TraditionalRenderingPlugin.getUniqueIdentifier(), "Checksum failure of line = " + line); //$NON-NLS-1$ + } + // FIXME error on incorrect checksum memblock.setValue(recordAddress.subtract(memblock.getBigBaseAddress()), data); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java index 0518366a1e8..2a4a46e55e4 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPlugin.java @@ -15,7 +15,8 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; public class TraditionalRenderingPlugin extends AbstractUIPlugin { - + private static final String PLUGIN_ID = "org.eclipse.dd.debug.memory.renderings.traditional"; //$NON-NLS-1$ + private static TraditionalRenderingPlugin plugin; public TraditionalRenderingPlugin() @@ -30,4 +31,11 @@ public class TraditionalRenderingPlugin extends AbstractUIPlugin public static TraditionalRenderingPlugin getDefault() { return plugin; } + + /** + * Returns the unique identifier for this plugin. + */ + public static String getUniqueIdentifier() { + return PLUGIN_ID; + } } From 6261ce70e5683d39d1b2d5c625b38ff75830256b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 2 Mar 2008 20:43:32 +0000 Subject: [PATCH 062/118] [215697] refactoring to allow better customization by adopters --- .../renderings/traditional/AbstractPane.java | 556 ++++++++++-------- .../renderings/traditional/IMemoryByte.java | 8 + .../traditional/IViewportCache.java | 19 + .../renderings/traditional/Rendering.java | 271 +++++---- .../traditional/TraditionalRendering.java | 9 +- 5 files changed, 502 insertions(+), 361 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemoryByte.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java index 2c882749109..1a555c1f2aa 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AbstractPane.java @@ -61,7 +61,184 @@ public abstract class AbstractPane extends Canvas protected int fRowCount = 0; protected boolean fPaneVisible = true; + + class AbstractPaneMouseListener implements MouseListener + { + public void mouseUp(MouseEvent me) + { + positionCaret(me.x, me.y); + fCaret.setVisible(true); + + if(fSelectionInProgress && me.button == 1) + { + endSelection(me.x, me.y); + } + + fSelectionInProgress = fSelectionStarted = false; + } + + public void mouseDown(MouseEvent me) + { + AbstractPane.this.forceFocus(); + + positionCaret(me.x, me.y); + + fCaret.setVisible(false); + + if(me.button == 1) + { + // if shift is down and we have an existing start address, + // append selection + if((me.stateMask & SWT.SHIFT) != 0 + && fRendering.getSelection().getStart() != null) + { + + // if the pane doesn't have a selection start (the + // selection was created in a different pane) + // then initialize the pane's selection start to the + // rendering's selection start + if(AbstractPane.this.fSelectionStartAddress == null) + AbstractPane.this.fSelectionStartAddress = fRendering + .getSelection().getStart(); + + AbstractPane.this.fSelectionStarted = true; + + AbstractPane.this.appendSelection(me.x, me.y); + + } + else + { + // start a new selection + + AbstractPane.this.startSelection(me.x, me.y); + } + } + } + + public void mouseDoubleClick(MouseEvent me) + { + handleMouseDoubleClick(me); + } + + } + + class AbstractPaneMouseMoveListener implements MouseMoveListener + { + public void mouseMove(MouseEvent me) + { + if(fSelectionStarted) + { + fSelectionInProgress = true; + appendSelection(me.x, me.y); + } + } + } + + class AbstractPaneKeyListener implements KeyListener + { + public void keyPressed(KeyEvent ke) + { + fOldSubCellCaretPosition = fSubCellCaretPosition; + if((ke.stateMask & SWT.SHIFT) != 0) + { + switch(ke.keyCode) + { + case SWT.ARROW_RIGHT: + case SWT.ARROW_LEFT: + case SWT.ARROW_UP: + case SWT.ARROW_DOWN: + case SWT.PAGE_DOWN: + case SWT.PAGE_UP: + if(fRendering.getSelection().getStart() == null) + { + fRendering.getSelection().setStart(fCaretAddress.add(BigInteger.valueOf( + fRendering.getAddressesPerColumn())), fCaretAddress); + } + break; + } + } + + if(ke.keyCode == SWT.ARROW_RIGHT) + { + handleRightArrowKey(); + } + else if(ke.keyCode == SWT.ARROW_LEFT || ke.keyCode == SWT.BS) + { + handleLeftArrowKey(); + } + else if(ke.keyCode == SWT.ARROW_DOWN) + { + handleDownArrowKey(); + } + else if(ke.keyCode == SWT.ARROW_UP) + { + handleUpArrowKey(); + } + else if(ke.keyCode == SWT.PAGE_DOWN) + { + handlePageDownKey(); + } + else if(ke.keyCode == SWT.PAGE_UP) + { + handlePageUpKey(); + } + else if(ke.keyCode == SWT.ESC) + { + fRendering.getViewportCache().clearEditBuffer(); + } + else if(ke.character == '\r') + { + fRendering.getViewportCache().writeEditBuffer(); + } + else if(Rendering.isValidEditCharacter(ke.character)) + { + if(fRendering.getSelection().hasSelection()) + { + setCaretAddress(fRendering.getSelection().getLow()); + fSubCellCaretPosition = 0; + } + + editCell(fCaretAddress, fSubCellCaretPosition, ke.character); + } + + if((ke.stateMask & SWT.SHIFT) != 0) + { + switch(ke.keyCode) + { + case SWT.ARROW_RIGHT: + case SWT.ARROW_LEFT: + case SWT.ARROW_UP: + case SWT.ARROW_DOWN: + case SWT.PAGE_DOWN: + case SWT.PAGE_UP: + fRendering.getSelection().setEnd(fCaretAddress.add(BigInteger.valueOf( + fRendering.getAddressesPerColumn())), + fCaretAddress); + break; + } + } + else if(ke.keyCode != SWT.SHIFT) + // if shift key, keep selection, we might add to it + { + fRendering.getSelection().clear(); + } + } + + public void keyReleased(KeyEvent ke) + { + // do nothing + } + } + + class AbstractPanePaintListener implements PaintListener + { + public void paintControl(PaintEvent pe) + { + AbstractPane.this.paint(pe); + } + } + public AbstractPane(Rendering rendering) { super(rendering, SWT.DOUBLE_BUFFERED); @@ -87,257 +264,13 @@ public abstract class AbstractPane extends Canvas fCaret.setSize(1, gc.stringExtent("|").y); //$NON-NLS-1$ gc.dispose(); - this.addPaintListener(new PaintListener() - { - public void paintControl(PaintEvent pe) - { - AbstractPane.this.paint(pe); - } - }); + this.addPaintListener(createPaintListener()); - this.addMouseListener(new MouseListener() - { - public void mouseUp(MouseEvent me) - { - positionCaret(me.x, me.y); + this.addMouseListener(createMouseListener()); - fCaret.setVisible(true); + this.addMouseMoveListener(createMouseMoveListener()); - if(fSelectionInProgress && me.button == 1) - { - endSelection(me.x, me.y); - } - - fSelectionInProgress = fSelectionStarted = false; - } - - public void mouseDown(MouseEvent me) - { - AbstractPane.this.forceFocus(); - - positionCaret(me.x, me.y); - - fCaret.setVisible(false); - - if(me.button == 1) - { - // if shift is down and we have an existing start address, - // append selection - if((me.stateMask & SWT.SHIFT) != 0 - && fRendering.getSelection().getStart() != null) - { - - // if the pane doesn't have a selection start (the - // selection was created in a different pane) - // then initialize the pane's selection start to the - // rendering's selection start - if(AbstractPane.this.fSelectionStartAddress == null) - AbstractPane.this.fSelectionStartAddress = fRendering - .getSelection().getStart(); - - AbstractPane.this.fSelectionStarted = true; - - AbstractPane.this.appendSelection(me.x, me.y); - - } - else - { - // start a new selection - - AbstractPane.this.startSelection(me.x, me.y); - } - } - } - - public void mouseDoubleClick(MouseEvent me) - { - try - { - BigInteger address = getViewportAddress(me.x / getCellWidth(), me.y - / getCellHeight()); - - fRendering.getSelection().clear(); - fRendering.getSelection().setStart(address.add(BigInteger - .valueOf(fRendering.getAddressesPerColumn())), address); - fRendering.getSelection().setEnd(address.add(BigInteger - .valueOf(fRendering.getAddressesPerColumn())), address); - } - catch(DebugException de) - { - // do nothing - } - } - }); - - this.addMouseMoveListener(new MouseMoveListener() - { - public void mouseMove(MouseEvent me) - { - if(fSelectionStarted) - { - fSelectionInProgress = true; - appendSelection(me.x, me.y); - } - } - }); - - this.addKeyListener(new KeyListener() - { - public void keyPressed(KeyEvent ke) - { - fOldSubCellCaretPosition = fSubCellCaretPosition; - if((ke.stateMask & SWT.SHIFT) != 0) - { - switch(ke.keyCode) - { - case SWT.ARROW_RIGHT: - case SWT.ARROW_LEFT: - case SWT.ARROW_UP: - case SWT.ARROW_DOWN: - case SWT.PAGE_DOWN: - case SWT.PAGE_UP: - if(fRendering.getSelection().getStart() == null) - { - fRendering.getSelection().setStart(fCaretAddress.add(BigInteger.valueOf( - fRendering.getAddressesPerColumn())), fCaretAddress); - } - break; - } - } - - if(ke.keyCode == SWT.ARROW_RIGHT) - { - fSubCellCaretPosition++; - if(fSubCellCaretPosition >= getCellCharacterCount()) - { - fSubCellCaretPosition = 0; - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.add(BigInteger - .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); - if(newCaretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0) - { - fSubCellCaretPosition = getCellCharacterCount(); - } - else - { - setCaretAddress(newCaretAddress); - } - } - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.ARROW_LEFT || ke.keyCode == SWT.BS) - { - fSubCellCaretPosition--; - if(fSubCellCaretPosition < 0) - { - fSubCellCaretPosition = getCellCharacterCount() - 1; - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger - .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); - if(newCaretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0) - { - fSubCellCaretPosition = 0; - } - else - { - setCaretAddress(newCaretAddress); - } - - } - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.ARROW_DOWN) - { - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.add(BigInteger - .valueOf(fRendering.getAddressableCellsPerRow())); - setCaretAddress(newCaretAddress); - - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.ARROW_UP) - { - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger - .valueOf(fRendering.getAddressableCellsPerRow())); - setCaretAddress(newCaretAddress); - - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.PAGE_DOWN) - { - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.add(BigInteger - .valueOf(fRendering.getAddressableCellsPerRow() - * (fRendering.getRowCount() - 1))); - - setCaretAddress(newCaretAddress); - - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.PAGE_UP) - { - // Ensure that caret is within the addressable range - BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger - .valueOf(fRendering.getAddressableCellsPerRow() - * (fRendering.getRowCount() - 1))); - setCaretAddress(newCaretAddress); - - updateCaret(); - ensureCaretWithinViewport(); - } - else if(ke.keyCode == SWT.ESC) - { - fRendering.getViewportCache().clearEditBuffer(); - } - else if(ke.character == '\r') - { - fRendering.getViewportCache().writeEditBuffer(); - } - else if(Rendering.isValidEditCharacter(ke.character)) - { - if(fRendering.getSelection().hasSelection()) - { - setCaretAddress(fRendering.getSelection().getLow()); - fSubCellCaretPosition = 0; - } - - editCell(fCaretAddress, fSubCellCaretPosition, ke.character); - } - - if((ke.stateMask & SWT.SHIFT) != 0) - { - switch(ke.keyCode) - { - case SWT.ARROW_RIGHT: - case SWT.ARROW_LEFT: - case SWT.ARROW_UP: - case SWT.ARROW_DOWN: - case SWT.PAGE_DOWN: - case SWT.PAGE_UP: - fRendering.getSelection().setEnd(fCaretAddress.add(BigInteger.valueOf( - fRendering.getAddressesPerColumn())), - fCaretAddress); - break; - } - } - else if(ke.keyCode != SWT.SHIFT) - // if shift key, keep selection, we might add to it - { - fRendering.getSelection().clear(); - } - } - - public void keyReleased(KeyEvent ke) - { - // do nothing - } - }); + this.addKeyListener(createKeyListener()); this.addFocusListener(new FocusListener() { @@ -364,6 +297,133 @@ public abstract class AbstractPane extends Canvas }); } + protected MouseListener createMouseListener(){ + return new AbstractPaneMouseListener(); + } + + protected MouseMoveListener createMouseMoveListener(){ + return new AbstractPaneMouseMoveListener(); + } + + protected KeyListener createKeyListener(){ + return new AbstractPaneKeyListener(); + } + + protected PaintListener createPaintListener(){ + return new AbstractPanePaintListener(); + } + + protected void handleRightArrowKey() + { + fSubCellCaretPosition++; + if(fSubCellCaretPosition >= getCellCharacterCount()) + { + fSubCellCaretPosition = 0; + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); + if(newCaretAddress.compareTo(fRendering.getMemoryBlockEndAddress()) > 0) + { + fSubCellCaretPosition = getCellCharacterCount(); + } + else + { + setCaretAddress(newCaretAddress); + } + } + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handleLeftArrowKey() + { + fSubCellCaretPosition--; + if(fSubCellCaretPosition < 0) + { + fSubCellCaretPosition = getCellCharacterCount() - 1; + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(getNumberOfBytesRepresentedByColumn() / fRendering.getAddressableSize())); + if(newCaretAddress.compareTo(fRendering.getMemoryBlockStartAddress()) < 0) + { + fSubCellCaretPosition = 0; + } + else + { + setCaretAddress(newCaretAddress); + } + + } + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handleDownArrowKey() + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow())); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handleUpArrowKey() + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow())); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handlePageDownKey() + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.add(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow() + * (fRendering.getRowCount() - 1))); + + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handlePageUpKey() + { + // Ensure that caret is within the addressable range + BigInteger newCaretAddress = fCaretAddress.subtract(BigInteger + .valueOf(fRendering.getAddressableCellsPerRow() + * (fRendering.getRowCount() - 1))); + setCaretAddress(newCaretAddress); + + updateCaret(); + ensureCaretWithinViewport(); + } + + protected void handleMouseDoubleClick(MouseEvent me) + { + try + { + BigInteger address = getViewportAddress(me.x / getCellWidth(), me.y + / getCellHeight()); + + fRendering.getSelection().clear(); + fRendering.getSelection().setStart(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + fRendering.getSelection().setEnd(address.add(BigInteger + .valueOf(fRendering.getAddressesPerColumn())), address); + } + catch(DebugException de) + { + // do nothing + } + } + protected boolean isPaneVisible() { return fPaneVisible; diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemoryByte.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemoryByte.java new file mode 100644 index 00000000000..9c0bb840508 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemoryByte.java @@ -0,0 +1,8 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +public interface IMemoryByte { + + public boolean isEdited(); + + public void setEdited(boolean edited); +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java new file mode 100644 index 00000000000..9f2e5d0bd48 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java @@ -0,0 +1,19 @@ +package org.eclipse.dd.debug.memory.renderings.traditional; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.MemoryByte; + +public interface IViewportCache { + + public void dispose(); + public void refresh(); + public MemoryByte[] getBytes(BigInteger address, int bytesRequested) throws DebugException; + public void archiveDeltas(); + public void setEditedValue(BigInteger address, MemoryByte[] bytes); + public void clearEditBuffer(); + public void writeEditBuffer(); + public boolean containsEditedCell(BigInteger address); + // private void queueRequest(BigInteger startAddress, BigInteger endAddress); +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 2f63034c75c..cc4fe61103f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -63,11 +63,11 @@ public class Rendering extends Composite implements IDebugEventSetListener // controls - private AddressPane fAddressPane; + protected AddressPane fAddressPane; - private DataPane fBinaryPane; + protected DataPane fBinaryPane; - private TextPane fTextPane; + protected TextPane fTextPane; private GoToAddressComposite fAddressBar; @@ -231,30 +231,16 @@ public class Rendering extends Composite implements IDebugEventSetListener switch(se.detail) { case SWT.ARROW_DOWN: - fViewportAddress = fViewportAddress.add(BigInteger - .valueOf(getAddressableCellsPerRow())); - ensureViewportAddressDisplayable(); - redrawPanes(); + handleDownArrow(); break; case SWT.PAGE_DOWN: - fViewportAddress = fViewportAddress.add(BigInteger - .valueOf(getAddressableCellsPerRow() - * (Rendering.this.getRowCount() - 1))); - ensureViewportAddressDisplayable(); - redrawPanes(); + handlePageDown(); break; case SWT.ARROW_UP: - fViewportAddress = fViewportAddress.subtract(BigInteger - .valueOf(getAddressableCellsPerRow())); - ensureViewportAddressDisplayable(); - redrawPanes(); + handleUpArrow(); break; case SWT.PAGE_UP: - fViewportAddress = fViewportAddress.subtract(BigInteger - .valueOf(getAddressableCellsPerRow() - * (Rendering.this.getRowCount() - 1))); - ensureViewportAddressDisplayable(); - redrawPanes(); + handlePageUp(); break; case SWT.SCROLL_LINE: if(getVerticalBar().getSelection() == getVerticalBar().getMinimum()) @@ -312,77 +298,8 @@ public class Rendering extends Composite implements IDebugEventSetListener } }); - this.setLayout(new Layout() - { - public void layout(Composite composite, boolean changed) - { - int xOffset = 0; - if(Rendering.this.getHorizontalBar().isVisible()) - xOffset = Rendering.this.getHorizontalBar().getSelection(); - - int x = xOffset * -1; - int y = 0; - - if(fAddressBarControl.isVisible()) - { - fAddressBarControl.setBounds(0, 0, - Rendering.this.getBounds().width, fAddressBarControl - .computeSize(100, 30).y); // FIXME - //y = fAddressBarControl.getBounds().height; - } - - if(fAddressPane.isPaneVisible()) - { - fAddressPane.setBounds(x, y, - fAddressPane.computeSize(0, 0).x, Rendering.this - .getBounds().height - - y); - x = fAddressPane.getBounds().x - + fAddressPane.getBounds().width; - } - - if(fBinaryPane.isPaneVisible()) - { - fBinaryPane.setBounds(x, y, - fBinaryPane.computeSize(0, 0).x, Rendering.this - .getBounds().height - - y); - x = fBinaryPane.getBounds().x - + fBinaryPane.getBounds().width; - } - - if(fTextPane.isPaneVisible()) - { - fTextPane.setBounds(x, y, - Math.max(fTextPane.computeSize(0, 0).x, Rendering.this.getClientArea().width - - x - xOffset), Rendering.this.getBounds().height - y); - } - - if(getClientArea().width >= fTextPane.getBounds().x + fTextPane.getBounds().width + xOffset) - { - Rendering.this.getHorizontalBar().setVisible(false); - } - else - { - ScrollBar horizontal = Rendering.this.getHorizontalBar(); - - horizontal.setVisible(true); - horizontal.setMinimum(0); - horizontal.setMaximum(fTextPane.getBounds().x - + fTextPane.getBounds().width + xOffset); - horizontal.setThumb(getClientArea().width); - horizontal.setPageIncrement(40); // TODO ? - horizontal.setIncrement(20); // TODO ? - } - } - - protected Point computeSize(Composite composite, int wHint, - int hHint, boolean flushCache) - { - return new Point(100, 100); // dummy data - } - }); - + setLayout(); + this.addControlListener(new ControlListener() { public void controlMoved(ControlEvent ce) @@ -398,6 +315,114 @@ public class Rendering extends Composite implements IDebugEventSetListener DebugPlugin.getDefault().addDebugEventListener(this); } + protected void setLayout() + { + this.setLayout(new Layout() + { + public void layout(Composite composite, boolean changed) + { + int xOffset = 0; + if(Rendering.this.getHorizontalBar().isVisible()) + xOffset = Rendering.this.getHorizontalBar().getSelection(); + + int x = xOffset * -1; + int y = 0; + + if(fAddressBarControl.isVisible()) + { + fAddressBarControl.setBounds(0, 0, + Rendering.this.getBounds().width, fAddressBarControl + .computeSize(100, 30).y); // FIXME + //y = fAddressBarControl.getBounds().height; + } + + if(fAddressPane.isPaneVisible()) + { + fAddressPane.setBounds(x, y, + fAddressPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fAddressPane.getBounds().x + + fAddressPane.getBounds().width; + } + + if(fBinaryPane.isPaneVisible()) + { + fBinaryPane.setBounds(x, y, + fBinaryPane.computeSize(0, 0).x, Rendering.this + .getBounds().height + - y); + x = fBinaryPane.getBounds().x + + fBinaryPane.getBounds().width; + } + + if(fTextPane.isPaneVisible()) + { + fTextPane.setBounds(x, y, + Math.max(fTextPane.computeSize(0, 0).x, Rendering.this.getClientArea().width + - x - xOffset), Rendering.this.getBounds().height - y); + } + + if(getClientArea().width >= fTextPane.getBounds().x + fTextPane.getBounds().width + xOffset) + { + Rendering.this.getHorizontalBar().setVisible(false); + } + else + { + ScrollBar horizontal = Rendering.this.getHorizontalBar(); + + horizontal.setVisible(true); + horizontal.setMinimum(0); + horizontal.setMaximum(fTextPane.getBounds().x + + fTextPane.getBounds().width + xOffset); + horizontal.setThumb(getClientArea().width); + horizontal.setPageIncrement(40); // TODO ? + horizontal.setIncrement(20); // TODO ? + } + } + + protected Point computeSize(Composite composite, int wHint, + int hHint, boolean flushCache) + { + return new Point(100, 100); // dummy data + } + }); + } + + protected void handleDownArrow() + { + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + } + + protected void handleUpArrow() + { + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow())); + ensureViewportAddressDisplayable(); + redrawPanes(); + } + + protected void handlePageDown() + { + fViewportAddress = fViewportAddress.add(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + } + + protected void handlePageUp() + { + fViewportAddress = fViewportAddress.subtract(BigInteger + .valueOf(getAddressableCellsPerRow() + * (Rendering.this.getRowCount() - 1))); + ensureViewportAddressDisplayable(); + redrawPanes(); + } + protected AddressPane createAddressPane() { return new AddressPane(this); @@ -561,7 +586,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return false; } - private IMemoryBlockExtension getMemoryBlock() + protected IMemoryBlockExtension getMemoryBlock() { IMemoryBlock block = fParent.getMemoryBlock(); if(block != null) @@ -576,12 +601,12 @@ public class Rendering extends Composite implements IDebugEventSetListener return fParent.getBigBaseAddress(); } - protected int getAddressableSize() + public int getAddressableSize() { return fParent.getAddressableSize(); } - protected ViewportCache getViewportCache() + protected IViewportCache getViewportCache() { return fViewportCache; } @@ -589,7 +614,7 @@ public class Rendering extends Composite implements IDebugEventSetListener public MemoryByte[] getBytes(BigInteger address, int bytes) throws DebugException { - return fViewportCache.getBytes(address, bytes); + return getViewportCache().getBytes(address, bytes); } // default visibility for performance @@ -599,7 +624,7 @@ public class Rendering extends Composite implements IDebugEventSetListener { } - class ViewportCache extends Thread + class ViewportCache extends Thread implements IViewportCache { class ArchiveDeltas implements Request { @@ -665,7 +690,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } } - protected void refresh() + public void refresh() { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -677,7 +702,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } } - protected void archiveDeltas() + public void archiveDeltas() { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -886,7 +911,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } // bytes will be fetched from cache - protected MemoryByte[] getBytes(BigInteger address, int bytesRequested) + public MemoryByte[] getBytes(BigInteger address, int bytesRequested) throws DebugException { assert Thread.currentThread().equals( @@ -933,7 +958,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return bytes; } - private boolean containsEditedCell(BigInteger address) + public boolean containsEditedCell(BigInteger address) { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -951,7 +976,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return (MemoryByte[]) fEditBuffer.get(address); } - protected void clearEditBuffer() + public void clearEditBuffer() { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -961,7 +986,7 @@ public class Rendering extends Composite implements IDebugEventSetListener Rendering.this.redrawPanes(); } - protected void writeEditBuffer() + public void writeEditBuffer() { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -997,7 +1022,7 @@ public class Rendering extends Composite implements IDebugEventSetListener clearEditBuffer(); } - protected void setEditedValue(BigInteger address, MemoryByte[] bytes) + public void setEditedValue(BigInteger address, MemoryByte[] bytes) { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages @@ -1334,9 +1359,9 @@ public class Rendering extends Composite implements IDebugEventSetListener { if(!this.isDisposed()) { - if(this.isVisible() && fViewportCache != null) + if(this.isVisible() && getViewportCache() != null) { - fViewportCache.refresh(); + getViewportCache().refresh(); } else { @@ -1348,7 +1373,7 @@ public class Rendering extends Composite implements IDebugEventSetListener protected void archiveDeltas() { - fViewportCache.archiveDeltas(); + this.getViewportCache().archiveDeltas(); } public void gotoAddress(BigInteger address) @@ -1364,7 +1389,7 @@ public class Rendering extends Composite implements IDebugEventSetListener redrawPanes(); } - protected void setViewportStartAddress(BigInteger newAddress) + public void setViewportStartAddress(BigInteger newAddress) { fViewportAddress = newAddress; } @@ -1615,6 +1640,36 @@ public class Rendering extends Composite implements IDebugEventSetListener } } + protected void redrawPane(int paneId) + { + if(!isDisposed() && this.isVisible()) + { + AbstractPane pane = null; + if(paneId == Rendering.PANE_ADDRESS) + { + pane = fAddressPane; + } + else if(paneId == Rendering.PANE_BINARY) + { + pane = fBinaryPane; + } + if(paneId == Rendering.PANE_TEXT) + { + pane = fTextPane; + } + if(pane != null && pane.isPaneVisible()) + { + pane.redraw(); + pane.setRowCount(); + if(pane.isFocusControl()) + pane.updateCaret(); + } + + } + + fParent.updateRenderingLabels(); + } + protected void redrawPanes() { if(!isDisposed() && this.isVisible()) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 5ea13b70c6b..e2a0bfb7333 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -95,10 +95,9 @@ import org.eclipse.ui.progress.UIJob; public class TraditionalRendering extends AbstractMemoryRendering implements IRepositionableMemoryRendering { - Rendering fRendering; - - private Action displayEndianBigAction; - private Action displayEndianLittleAction; + protected Rendering fRendering; + protected Action displayEndianBigAction; + protected Action displayEndianLittleAction; private IWorkbenchAdapter fWorkbenchAdapter; private IMemoryBlockConnection fConnection; @@ -1086,7 +1085,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe } -class TraditionalMemoryByte extends MemoryByte +class TraditionalMemoryByte extends MemoryByte implements IMemoryByte { private boolean isEdited = false; From 5d2e5b52e09ea3336b8e4521c616511beccbd1cb Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 11 Mar 2008 04:38:29 +0000 Subject: [PATCH 063/118] [208071] (performance) Traditional Memory Rendering: unnecessary populateCache --- .../renderings/traditional/Rendering.java | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index cc4fe61103f..c0618024446 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -636,6 +636,26 @@ public class Rendering extends Composite implements IDebugEventSetListener BigInteger startAddress; BigInteger endAddress; + + public AddressPair(BigInteger start, BigInteger end) + { + startAddress = start; + endAddress = end; + } + + @Override + public boolean equals(Object obj) { + if(obj == null) + return false; + if(obj instanceof AddressPair) + { + return ((AddressPair) obj).startAddress.equals(startAddress) + && ((AddressPair) obj).endAddress.equals(endAddress); + } + + return false; + } + } class MemoryUnit @@ -669,6 +689,8 @@ public class Rendering extends Composite implements IDebugEventSetListener private HashMap fEditBuffer = new HashMap(); private boolean fDisposed = false; + + private Object fLastQueued = null; private Vector fQueue = new Vector(); @@ -713,30 +735,26 @@ public class Rendering extends Composite implements IDebugEventSetListener queueRequestArchiveDeltas(); } } - - private void queueRequest(BigInteger startAddress, BigInteger endAddress) { - AddressPair pair = new AddressPair(); - pair.startAddress = startAddress; - pair.endAddress = endAddress; - synchronized(fQueue) - { - fQueue.addElement(pair); - } - synchronized(this) - { - this.notify(); - } + AddressPair pair = new AddressPair(startAddress, endAddress); + if(!pair.equals(fLastQueued)) + queue(pair); } private void queueRequestArchiveDeltas() { ArchiveDeltas archive = new ArchiveDeltas(); + queue(archive); + } + + private void queue(Object element) + { synchronized(fQueue) { - fQueue.addElement(archive); + fQueue.addElement(element); + fLastQueued = element; } synchronized(this) { @@ -777,7 +795,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } else if(pair != null) { - populateCache(pair.startAddress, pair.endAddress); + populateCache(pair.startAddress, pair.endAddress); } else { From 8f63cc5bbf123d1c6ac124383e851adf851a0b27 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 11 Mar 2008 05:02:05 +0000 Subject: [PATCH 064/118] [219009] TraditionalRendering.getSelectedBytes() ignores selection --- .../traditional/IMemorySelection.java | 2 ++ .../renderings/traditional/Rendering.java | 4 +++ .../traditional/TraditionalRendering.java | 36 ++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java index ac5c02995f9..697a1dc397a 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IMemorySelection.java @@ -12,6 +12,8 @@ public interface IMemorySelection public BigInteger getEnd(); + public BigInteger getStartLow(); + public void setStart(BigInteger high, BigInteger low); public void setEnd(BigInteger high, BigInteger low); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index c0618024446..abcda8d2324 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -1237,6 +1237,10 @@ public class Rendering extends Composite implements IDebugEventSetListener return fStartLow; } + public BigInteger getStartLow() { + return fStartLow; + } + public BigInteger getEnd() { // if there is no end, return null diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index e2a0bfb7333..63103ca8ee2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -20,6 +20,7 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.dd.debug.memory.renderings.traditional.Rendering.Selection; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; @@ -982,20 +983,45 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe // selection is terminology for caret position public BigInteger getSelectedAddress() { - return fRendering.getCaretAddress(); + IMemorySelection selection = fRendering.getSelection(); + if (selection == null || selection.getStart() == null) + return fRendering.getCaretAddress(); + + return selection.getStartLow(); } public MemoryByte[] getSelectedAsBytes() { - try + try { - return fRendering.getViewportCache().getBytes( - fRendering.getCaretAddress(), fRendering.getBytesPerColumn()); + // default to the caret address and the cell count size + BigInteger startAddr = fRendering.getCaretAddress(); + int byteCount = fRendering.getBytesPerColumn(); + + // Now see if there's a selection + IMemorySelection selection = fRendering.getSelection(); + if (selection != null && selection.getStart() != null) + { + // The implementation is such that just having a caret somewhere + // (without multiple cells being selected) constitutes a selection, + // except for when the rendering is in its initial state. I.e., + // just because we get here doesn't mean the user has selected more + // than one cell. + + startAddr = getSelectedAddress(); + + if (selection.getHigh() != null) + { + byteCount = selection.getHigh().subtract(selection.getLow()).intValue() * fRendering.getAddressableSize(); + } + } + return fRendering.getViewportCache().getBytes(startAddr, byteCount); + } catch(DebugException de) { // FIXME log? return null; - } + } } public void goToAddress(final BigInteger address) throws DebugException { From 33b938088170d6b6d4da1bebbc9006b4d5bb72e2 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 11 Mar 2008 05:10:29 +0000 Subject: [PATCH 065/118] [203068] (GTK workaround) Traditional Memory Rendering doesn't scroll --- .../dd/debug/memory/renderings/traditional/Rendering.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index abcda8d2324..f826065d252 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -243,6 +243,8 @@ public class Rendering extends Composite implements IDebugEventSetListener handlePageUp(); break; case SWT.SCROLL_LINE: + // See: BUG 203068 selection event details broken on GTK < 2.6 + default: if(getVerticalBar().getSelection() == getVerticalBar().getMinimum()) { // Set view port start address to the start address of the Memory Block @@ -268,14 +270,10 @@ public class Rendering extends Composite implements IDebugEventSetListener // getVerticalBar().setToolTipText(Rendering.this.getAddressString(fViewportAddress)); // Update the addresses on the Address pane. - // Do not update the Binary and Text panes until dragging of the thumb nail stops if(fAddressPane.isPaneVisible()) { fAddressPane.redraw(); } - break; - case SWT.NONE: - // Dragging of the thumb nail stops. Redraw the panes redrawPanes(); break; } From d8f5b3b91240d83cc2aafddfc8192696e709b6b1 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 15 Apr 2008 00:11:58 +0000 Subject: [PATCH 066/118] [227056] Traditional Rendering Context Menu Column Options are poor --- .../traditional/TraditionalRendering.java | 31 +++++++++++++------ .../TraditionalRendering_messages.properties | 8 ++--- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 63103ca8ee2..8b27dbdfd2f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -823,20 +823,20 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe displayColumnCountAuto.setChecked(fRendering.getColumnsSetting() == Rendering.COLUMNS_AUTO_SIZE_TO_FIT); final Action[] displayColumnCounts = new Action[MAX_MENU_COLUMN_COUNT]; - for(int i = 0; i < MAX_MENU_COLUMN_COUNT; i++) + for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT; i++, j*=2) { - final int finali = i; + final int finali = j; displayColumnCounts[i] = new Action( TraditionalRenderingMessages - .getString("TraditionalRendering.COLUMN_COUNT_" + (i + 1)), //$NON-NLS-1$ + .getString("TraditionalRendering.COLUMN_COUNT_" + finali), //$NON-NLS-1$ IAction.AS_RADIO_BUTTON) { public void run() { - TraditionalRendering.this.fRendering.setColumnsSetting(finali + 1); + TraditionalRendering.this.fRendering.setColumnsSetting(finali); } }; - displayColumnCounts[i].setChecked(fRendering.getColumnsSetting() == i + 1); + displayColumnCounts[i].setChecked(fRendering.getColumnsSetting() == finali); } final Action displayColumnCountCustomValue = new Action("", IAction.AS_RADIO_BUTTON) @@ -845,7 +845,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe { } }; - displayColumnCountCustomValue.setChecked(fRendering.getColumnsSetting() > 8); + boolean currentCountIsCustom = true; + for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT && currentCountIsCustom; i++, j*=2) + currentCountIsCustom = (j != fRendering.getColumnsSetting()); + displayColumnCountCustomValue.setChecked(currentCountIsCustom); final Action displayColumnCountCustom = new Action( @@ -883,11 +886,19 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe int currentColumnSetting = TraditionalRendering.this.fRendering.getColumnsSetting(); if(currentColumnSetting == Rendering.COLUMNS_AUTO_SIZE_TO_FIT) displayColumnCountAuto.setChecked(true); - else if(currentColumnSetting > 0 && currentColumnSetting <= MAX_MENU_COLUMN_COUNT) - displayColumnCounts[currentColumnSetting - 1].setChecked(true); else - displayColumnCountCustomValue.setChecked(true); - + { + boolean currentCountIsCustom = true; + for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT && currentCountIsCustom; i++, j*=2) + { + currentCountIsCustom = (j != fRendering.getColumnsSetting()); + if(j == fRendering.getColumnsSetting()) + displayColumnCounts[i].setChecked(true); + } + if(currentCountIsCustom) + displayColumnCountCustomValue.setChecked(true); + } + return; } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties index aeea82814a0..041aa4d356f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering_messages.properties @@ -39,11 +39,11 @@ TraditionalRendering.COLUMN_COUNT=Columns TraditionalRendering.COLUMN_COUNT_AUTO=Auto Size to Fill TraditionalRendering.COLUMN_COUNT_1=1 TraditionalRendering.COLUMN_COUNT_2=2 -TraditionalRendering.COLUMN_COUNT_3=3 TraditionalRendering.COLUMN_COUNT_4=4 -TraditionalRendering.COLUMN_COUNT_5=5 -TraditionalRendering.COLUMN_COUNT_6=6 -TraditionalRendering.COLUMN_COUNT_7=7 TraditionalRendering.COLUMN_COUNT_8=8 +TraditionalRendering.COLUMN_COUNT_16=16 +TraditionalRendering.COLUMN_COUNT_32=32 +TraditionalRendering.COLUMN_COUNT_64=64 +TraditionalRendering.COLUMN_COUNT_128=128 TraditionalRendering.COLUMN_COUNT_CUSTOM=Custom... TraditionalRendering.COPY_ADDRESS=Copy Address \ No newline at end of file From 7312a2b77838462824ca1492db51573236e81caa Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 15 Apr 2008 00:23:02 +0000 Subject: [PATCH 067/118] [227057] Memory Find/Replace Dialog does not allow binary value as 0b... --- .../debug/memory/renderings/actions/FindReplaceDialog.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index 08d74dcf52d..ccc5607cd16 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -135,7 +135,8 @@ public class FindReplaceDialog extends SelectionDialog } else if(formatBinaryButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 2), 2); + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().toUpperCase().startsWith("0B") + ? findText.getText().substring(2) : findText.getText(), 2), 2); } else if(formatDecimalButton.getSelection()) { @@ -187,7 +188,7 @@ public class FindReplaceDialog extends SelectionDialog else if(formatOctalButton.getSelection()) return removeZeroPrefixByte(new BigInteger(replaceText.getText().startsWith("0") ? replaceText.getText().substring(1) : replaceText.getText(), 8).toByteArray()); else if(formatBinaryButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(replaceText.getText(), 2).toByteArray()); + return removeZeroPrefixByte(new BigInteger(replaceText.getText().toUpperCase().startsWith("0B") ? replaceText.getText().substring(2) : replaceText.getText(), 2).toByteArray()); else if(formatDecimalButton.getSelection()) return removeZeroPrefixByte(new BigInteger(replaceText.getText(), 10).toByteArray()); else if(formatByteSequenceButton.getSelection()) From 62c695fba20141a39c4ffef614a3c47541428cb8 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 May 2008 05:32:03 +0000 Subject: [PATCH 068/118] [232003] Separate memory transport from traditional rendering plugin; support pluggable importers/exporters. --- .../feature.xml | 7 + .../actions/ExportMemoryAction.java | 206 -------- .../actions/ExportMemoryDialog.java | 400 --------------- .../renderings/actions/FindReplaceDialog.java | 230 ++++----- .../actions/ImportMemoryAction.java | 220 -------- .../actions/ImportMemoryDialog.java | 292 ----------- .../.classpath | 7 + .../.project | 28 + .../.settings/org.eclipse.jdt.core.prefs | 7 + .../META-INF/MANIFEST.MF | 16 + .../about.html | 24 + .../build.properties | 8 + .../icons/export.png | Bin 0 -> 227 bytes .../icons/import.png | Bin 0 -> 236 bytes .../plugin.properties | 2 + .../plugin.xml | 60 +++ .../schema/MemoryTransport.exsd | 160 ++++++ .../memory/transport/ExportMemoryDialog.java | 204 ++++++++ .../memory/transport/ImportMemoryDialog.java | 205 ++++++++ .../transport/MemoryTransportPlugin.java | 41 ++ .../debug/ui/memory/transport/Messages.java | 33 ++ .../memory/transport/PlainTextExporter.java | 467 +++++++++++++++++ .../memory/transport/PlainTextImporter.java | 347 +++++++++++++ .../ui/memory/transport/SRecordExporter.java | 479 ++++++++++++++++++ .../ui/memory/transport/SRecordImporter.java | 390 ++++++++++++++ .../transport/actions/ExportMemoryAction.java | 78 +++ .../transport/actions/ImportMemoryAction.java | 79 +++ .../ui/memory/transport/messages.properties | 0 .../transport/model/IMemoryExporter.java | 34 ++ .../transport/model/IMemoryImporter.java | 35 ++ 30 files changed, 2826 insertions(+), 1233 deletions(-) delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/.classpath create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/.project create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/about.html create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/icons/export.png create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/icons/import.png create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.properties create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/schema/MemoryTransport.exsd create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/Messages.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/messages.properties create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryExporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index d99f633af00..7eaf70ffb52 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -30,4 +30,11 @@ Memory Renderings version="0.0.0" unpack="false"/> + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java deleted file mode 100644 index d45c3ba2022..00000000000 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryAction.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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: - * Ted R Williams (Wind River Systems, Inc.) - initial implementation - *******************************************************************************/ - -package org.eclipse.dd.debug.memory.renderings.actions; - -import java.io.File; -import java.io.FileWriter; -import java.math.BigInteger; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.core.model.MemoryByte; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.views.memory.MemoryView; -import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.memory.IMemoryRendering; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * Action for exporting memory. - */ -public class ExportMemoryAction implements IViewActionDelegate { - - private MemoryView fView; - - public void init(IViewPart view) { - if (view instanceof MemoryView) - fView = (MemoryView) view; - } - - public void run(IAction action) { - - String secondaryId = MemoryViewIdRegistry - .getUniqueSecondaryId(IDebugUIConstants.ID_MEMORY_VIEW); - - ISelection selection = fView.getSite().getSelectionProvider() - .getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection strucSel = (IStructuredSelection) selection; - - // return if current selection is empty - if (strucSel.isEmpty()) - return; - - Object obj = strucSel.getFirstElement(); - - if (obj == null) - return; - - IMemoryBlock memBlock = null; - - if (obj instanceof IMemoryRendering) { - memBlock = ((IMemoryRendering) obj).getMemoryBlock(); - } else if (obj instanceof IMemoryBlock) { - memBlock = (IMemoryBlock) obj; - } - - Shell shell = DebugUIPlugin.getShell(); - ExportMemoryDialog dialog = new ExportMemoryDialog(shell, memBlock); - dialog.open(); - - Object results[] = dialog.getResult(); - - if(results != null && results.length == 5) - { - String format = (String) results[0]; - BigInteger start = (BigInteger) results[1]; - BigInteger end = (BigInteger) results[2]; - File file = (File) results[4]; - - if("S-Record".equals(format)) - { - exportSRecord(file, start, end, (IMemoryBlockExtension) memBlock); // FIXME - } - } - } - - } - - private void exportSRecord(final File outputFile, final BigInteger startAddress, final BigInteger endAddress, final IMemoryBlockExtension memblock) - { - Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$ - public IStatus run(IProgressMonitor monitor) { - - try - { - try - { - // FIXME 4 byte default - - BigInteger DATA_PER_RECORD = BigInteger.valueOf(16); - - BigInteger transferAddress = startAddress; - - FileWriter writer = new FileWriter(outputFile); - - BigInteger jobs = endAddress.subtract(transferAddress).divide(DATA_PER_RECORD); - BigInteger factor = BigInteger.ONE; - if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) - { - factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); - jobs = jobs.divide(factor); - } - - monitor.beginTask("Transferring Data", jobs.intValue()); - - BigInteger jobCount = BigInteger.ZERO; - while(transferAddress.compareTo(endAddress) < 0 && !monitor.isCanceled()) - { - BigInteger length = DATA_PER_RECORD; - if(endAddress.subtract(transferAddress).compareTo(length) < 0) - length = endAddress.subtract(transferAddress); - - writer.write("S3"); // FIXME 4 byte address - - StringBuffer buf = new StringBuffer(); - - BigInteger sRecordLength = BigInteger.valueOf(4); // address size - sRecordLength = sRecordLength.add(length); - sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum - - String transferAddressString = transferAddress.toString(16); - - String lengthString = sRecordLength.toString(16); - if(lengthString.length() == 1) - buf.append("0"); - buf.append(lengthString); - for(int i = 0; i < 8 - transferAddressString.length(); i++) - buf.append("0"); - buf.append(transferAddressString); - - // data - - MemoryByte bytes[] = memblock.getBytesFromAddress(transferAddress, - length.longValue() / memblock.getAddressableSize()); - for(MemoryByte b : bytes) - { - String bString = BigInteger.valueOf(0xFF & b.getValue()).toString(16); - if(bString.length() == 1) - buf.append("0"); - buf.append(bString); - } - - /* - * The least significant byte of the one's complement of the sum of the values - * represented by the pairs of characters making up the records length, address, - * and the code/data fields. - */ - byte checksum = 0; - - for(int i = 0; i < buf.length(); i+=2) - { - BigInteger value = new BigInteger(buf.substring(i, i+2), 16); - checksum += value.byteValue(); - } - - buf.append(BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16)); - - writer.write(buf.toString().toUpperCase()); - writer.write("\n"); - - transferAddress = transferAddress.add(length); - - jobCount = jobCount.add(BigInteger.ONE); - if(jobCount.compareTo(factor) == 0) - { - jobCount = BigInteger.ZERO; - monitor.worked(1); - } - } - - writer.close(); - monitor.done(); - } - catch(Exception e) { e.printStackTrace();} - } - catch(Exception e) {e.printStackTrace();} - return Status.OK_STATUS; - }}; - job.setUser(true); - job.schedule(); - } - - public void selectionChanged(IAction action, ISelection selection) { - - } - -} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java deleted file mode 100644 index 0df1a169e8c..00000000000 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ExportMemoryDialog.java +++ /dev/null @@ -1,400 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006-2007 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: - * Ted R Williams (Wind River Systems, Inc.) - initial implementation - *******************************************************************************/ - -package org.eclipse.dd.debug.memory.renderings.actions; - -import java.io.File; -import java.math.BigInteger; - -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; - -public class ExportMemoryDialog extends SelectionDialog -{ - - private Combo formatCombo; - - private IMemoryBlock fMemoryBlock; - - private Text startText; - private Text endText; - private Text lengthText; - private Text fileText; - - public ExportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) - { - super(parent); - super.setTitle("Export Memory"); - setShellStyle(getShellStyle() | SWT.RESIZE); - - fMemoryBlock = memoryBlock; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - validate(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() - */ - public Object[] getResult() { - - Object[] results = super.getResult(); - - if (results != null) - { - return results; - } - return new Object[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() - */ - protected void cancelPressed() { - - setResult(null); - - super.cancelPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - setSelectionResult(new Object[]{ getFormat(), getStartAddress(), getEndAddress(), getLength(), getFile() }); - - super.okPressed(); - } - - public String getFormat() - { - return formatCombo.getItem(formatCombo.getSelectionIndex()); - } - - public BigInteger getEndAddress() - { - String text = endText.getText(); - boolean hex = text.startsWith("0x"); - BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, - hex ? 16 : 10); - - return endAddress; - } - - public BigInteger getStartAddress() - { - String text = startText.getText(); - boolean hex = text.startsWith("0x"); - BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, - hex ? 16 : 10); - - return startAddress; - } - - public BigInteger getLength() - { - String text = lengthText.getText(); - boolean hex = text.startsWith("0x"); - BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, - hex ? 16 : 10); - - return lengthAddress; - } - - public File getFile() - { - return new File(fileText.getText()); - } - - private void validate() - { - boolean isValid = true; - - try - { - getEndAddress(); - - getStartAddress(); - - BigInteger length = getLength(); - - if(length.compareTo(BigInteger.ZERO) <= 0) - isValid = false; - - if(!getFile().getParentFile().exists()) - isValid = false; - } - catch(Exception e) - { - isValid = false; - } - - getButton(IDialogConstants.OK_ID).setEnabled(isValid); - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME - Composite composite = new Composite(parent, SWT.NONE); - FormLayout formLayout = new FormLayout(); - formLayout.spacing = 5; - formLayout.marginWidth = formLayout.marginHeight = 9; - composite.setLayout(formLayout); - - // format - - Label textLabel = new Label(composite, SWT.NONE); - textLabel.setText("Format: "); - - formatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); - - FormData data = new FormData(); - data.top = new FormAttachment(formatCombo, 0, SWT.CENTER); - textLabel.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(textLabel); - formatCombo.setLayoutData(data); - formatCombo.setItems( new String[] { "S-Record" }); // TODO offer extension point - formatCombo.select(0); - - // start address - - Label startLabel = new Label(composite, SWT.NONE); - startLabel.setText("Start address: "); - data = new FormData(); - data.top = new FormAttachment(formatCombo); - startLabel.setLayoutData(data); - - startText = new Text(composite, SWT.NONE); - data = new FormData(); - data.top = new FormAttachment(formatCombo); - data.left = new FormAttachment(startLabel); - data.width = 100; - startText.setLayoutData(data); - - // end address - - Label endLabel = new Label(composite, SWT.NONE); - endLabel.setText("End address: "); - data = new FormData(); - data.top = new FormAttachment(startText, 0, SWT.CENTER); - data.left = new FormAttachment(startText); - endLabel.setLayoutData(data); - - endText = new Text(composite, SWT.NONE); - data = new FormData(); - data.top = new FormAttachment(startText, 0, SWT.CENTER); - data.left = new FormAttachment(endLabel); - data.width = 100; - endText.setLayoutData(data); - - // length - - Label lengthLabel = new Label(composite, SWT.NONE); - lengthLabel.setText("Length: "); - data = new FormData(); - data.top = new FormAttachment(startText, 0, SWT.CENTER); - data.left = new FormAttachment(endText); - lengthLabel.setLayoutData(data); - - lengthText = new Text(composite, SWT.NONE); - data = new FormData(); - data.top = new FormAttachment(startText, 0, SWT.CENTER); - data.left = new FormAttachment(lengthLabel); - data.width = 100; - lengthText.setLayoutData(data); - - // file - - Label fileLabel = new Label(composite, SWT.NONE); - fileText = new Text(composite, SWT.NONE); - Button fileButton = new Button(composite, SWT.PUSH); - - fileLabel.setText("File name: "); - data = new FormData(); - data.top = new FormAttachment(fileButton, 0, SWT.CENTER); - fileLabel.setLayoutData(data); - - data = new FormData(); - data.top = new FormAttachment(fileButton, 0, SWT.CENTER); - data.left = new FormAttachment(fileLabel); - data.width = 300; - fileText.setLayoutData(data); - - fileButton.setText("Browse..."); - data = new FormData(); - data.top = new FormAttachment(lengthText); - data.left = new FormAttachment(fileText); - fileButton.setLayoutData(data); - - try - { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - startText.setText("0x" + startAddress.toString(16)); - endText.setText("0x" + startAddress.toString(16)); - lengthText.setText("0"); - } - catch(Exception e) - { - e.printStackTrace(); - // TODO - } - - fileButton.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(ExportMemoryDialog.this.getShell(), SWT.SAVE); - dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); - dialog.setFileName(fileText.getText()); - dialog.open(); - - if(dialog.getFileName() != null) - { - fileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); - } - - validate(); - } - - }); - - startText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - boolean valid = true; - try - { - getStartAddress(); - } - catch(Exception ex) - { - valid = false; - } - - startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : - Display.getDefault().getSystemColor(SWT.COLOR_RED)); - - // - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - lengthText.setText(endAddress.subtract(startAddress).toString()); - - validate(); - } - - }); - - endText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - try - { - getEndAddress(); - endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - - BigInteger endAddress = getEndAddress(); - BigInteger startAddress = getStartAddress(); - - String lengthString = endAddress.subtract(startAddress).toString(); - - if(!lengthText.getText().equals(lengthString)) - lengthText.setText(lengthString); - } - catch(Exception ex) - { - endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - } - - validate(); - } - - }); - - lengthText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - try - { - BigInteger length = getLength(); - lengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger startAddress = getStartAddress(); - String endString = "0x" + startAddress.add(length).toString(16); - if(!endText.getText().equals(endString)) - endText.setText(endString); - } - catch(Exception ex) - { - lengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); - } - - validate(); - } - - }); - - fileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validate(); - } - }); - - return composite; - } - - -} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java index ccc5607cd16..de0a9d3232f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java @@ -58,30 +58,30 @@ public class FindReplaceDialog extends SelectionDialog final static int preFetchSize = 10 * 1024; - private Text findText; - private Text replaceText; + private Text fFindText; + private Text fReplaceText; - private Combo startText; - private Combo endText; + private Combo fStartText; + private Combo fEndText; - private Button findButton; - private Button replaceButton; - private Button replaceFindButton; - private Button replaceAllButton; - private Button closeButton; + private Button fFindButton; + private Button fReplaceButton; + private Button fReplaceFindButton; + private Button fReplaceAllButton; + private Button fCloseButton; private MemoryView fMemoryView; - Button formatAsciiButton; - Button formatHexButton; - Button formatOctalButton; - Button formatBinaryButton; - Button formatDecimalButton; - Button formatByteSequenceButton; + Button fFormatAsciiButton; + Button fFormatHexButton; + Button fFormatOctalButton; + Button fFormatBinaryButton; + Button fFormatDecimalButton; + Button fFormatByteSequenceButton; - Button caseInSensitiveCheckbox; + Button fCaseInSensitiveCheckbox; - Button forwardButton; + Button fForwardButton; public FindReplaceDialog(Shell parent, IMemoryBlockExtension memoryBlock, MemoryView memoryView) { @@ -96,7 +96,7 @@ public class FindReplaceDialog extends SelectionDialog private BigInteger getUserStart() { - String start = startText.getText(); + String start = fStartText.getText(); if(start.toUpperCase().startsWith("0X")) //$NON-NLS-1$ start = start.substring(2); return new BigInteger(start, 16); @@ -104,7 +104,7 @@ public class FindReplaceDialog extends SelectionDialog private BigInteger getUserEnd() { - String end = endText.getText(); + String end = fEndText.getText(); if(end.toUpperCase().startsWith("0X")) //$NON-NLS-1$ end = end.substring(2); return new BigInteger(end, 16); @@ -112,39 +112,39 @@ public class FindReplaceDialog extends SelectionDialog private boolean getIsDirectionForward() { - return forwardButton.getSelection(); + return fForwardButton.getSelection(); } private SearchPhrase getSearchPhrase() { SearchPhrase phrase = null; - if(formatAsciiButton.getSelection()) + if(fFormatAsciiButton.getSelection()) { - phrase = new AsciiSearchPhrase(findText.getText(), caseInSensitiveCheckbox.getSelection()); + phrase = new AsciiSearchPhrase(fFindText.getText(), fCaseInSensitiveCheckbox.getSelection()); } - else if(formatHexButton.getSelection()) + else if(fFormatHexButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().toUpperCase().startsWith("0X") - ? findText.getText().substring(2) : findText.getText(), 16), 16); + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0X") + ? fFindText.getText().substring(2) : fFindText.getText(), 16), 16); } - else if(formatOctalButton.getSelection()) + else if(fFormatOctalButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().startsWith("0") - ? findText.getText().substring(1) : findText.getText(), 8), 8); + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().startsWith("0") + ? fFindText.getText().substring(1) : fFindText.getText(), 8), 8); } - else if(formatBinaryButton.getSelection()) + else if(fFormatBinaryButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText().toUpperCase().startsWith("0B") - ? findText.getText().substring(2) : findText.getText(), 2), 2); + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0B") + ? fFindText.getText().substring(2) : fFindText.getText(), 2), 2); } - else if(formatDecimalButton.getSelection()) + else if(fFormatDecimalButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(findText.getText(), 10), 10); + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText(), 10), 10); } - else if(formatByteSequenceButton.getSelection()) + else if(fFormatByteSequenceButton.getSelection()) { - phrase = new ByteSequenceSearchPhrase(findText.getText()); + phrase = new ByteSequenceSearchPhrase(fFindText.getText()); } return phrase; @@ -181,18 +181,18 @@ public class FindReplaceDialog extends SelectionDialog private byte[] getReplaceData() { - if(formatAsciiButton.getSelection()) - return replaceText.getText().getBytes(); - else if(formatHexButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(replaceText.getText().toUpperCase().startsWith("0X") ? replaceText.getText().substring(2) : replaceText.getText(), 16).toByteArray()); - else if(formatOctalButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(replaceText.getText().startsWith("0") ? replaceText.getText().substring(1) : replaceText.getText(), 8).toByteArray()); - else if(formatBinaryButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(replaceText.getText().toUpperCase().startsWith("0B") ? replaceText.getText().substring(2) : replaceText.getText(), 2).toByteArray()); - else if(formatDecimalButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(replaceText.getText(), 10).toByteArray()); - else if(formatByteSequenceButton.getSelection()) - return parseByteSequence(replaceText.getText()); + if(fFormatAsciiButton.getSelection()) + return fReplaceText.getText().getBytes(); + else if(fFormatHexButton.getSelection()) + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0X") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 16).toByteArray()); + else if(fFormatOctalButton.getSelection()) + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().startsWith("0") ? fReplaceText.getText().substring(1) : fReplaceText.getText(), 8).toByteArray()); + else if(fFormatBinaryButton.getSelection()) + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0B") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 2).toByteArray()); + else if(fFormatDecimalButton.getSelection()) + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText(), 10).toByteArray()); + else if(fFormatByteSequenceButton.getSelection()) + return parseByteSequence(fReplaceText.getText()); return new byte[0]; } @@ -201,8 +201,8 @@ public class FindReplaceDialog extends SelectionDialog * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { - findButton = createButton(parent, 10, Messages.getString("FindReplaceDialog.ButtonFind"), true); //$NON-NLS-1$ - findButton.addSelectionListener(new SelectionListener() + fFindButton = createButton(parent, 10, Messages.getString("FindReplaceDialog.ButtonFind"), true); //$NON-NLS-1$ + fFindButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } @@ -212,8 +212,8 @@ public class FindReplaceDialog extends SelectionDialog } }); - replaceFindButton = createButton(parent, 11, Messages.getString("FindReplaceDialog.ButtonReplaceFind"), false); //$NON-NLS-1$ - replaceFindButton.addSelectionListener(new SelectionListener() + fReplaceFindButton = createButton(parent, 11, Messages.getString("FindReplaceDialog.ButtonReplaceFind"), false); //$NON-NLS-1$ + fReplaceFindButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } @@ -223,8 +223,8 @@ public class FindReplaceDialog extends SelectionDialog } }); - replaceButton = createButton(parent, 12, Messages.getString("FindReplaceDialog.ButtonReplace"), false); //$NON-NLS-1$ - replaceButton.addSelectionListener(new SelectionListener() + fReplaceButton = createButton(parent, 12, Messages.getString("FindReplaceDialog.ButtonReplace"), false); //$NON-NLS-1$ + fReplaceButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } @@ -234,8 +234,8 @@ public class FindReplaceDialog extends SelectionDialog } }); - replaceAllButton = createButton(parent, 13, Messages.getString("FindReplaceDialog.ButtonReplaceAll"), false); //$NON-NLS-1$ - replaceAllButton.addSelectionListener(new SelectionListener() + fReplaceAllButton = createButton(parent, 13, Messages.getString("FindReplaceDialog.ButtonReplaceAll"), false); //$NON-NLS-1$ + fReplaceAllButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } @@ -245,7 +245,7 @@ public class FindReplaceDialog extends SelectionDialog } }); - closeButton = createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("FindReplaceDialog.Close"), false); //$NON-NLS-1$ + fCloseButton = createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("FindReplaceDialog.Close"), false); //$NON-NLS-1$ ((GridLayout) parent.getLayout()).numColumns = 2; @@ -287,7 +287,7 @@ public class FindReplaceDialog extends SelectionDialog public BigInteger getEndAddress() { - String text = endText.getText(); + String text = fEndText.getText(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -297,7 +297,7 @@ public class FindReplaceDialog extends SelectionDialog public BigInteger getStartAddress() { - String text = startText.getText(); + String text = fStartText.getText(); boolean hex = text.startsWith("0x"); //$NON-NLS-1$ BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, hex ? 16 : 10); @@ -325,10 +325,10 @@ public class FindReplaceDialog extends SelectionDialog } - findButton.setEnabled(valid); - replaceButton.setEnabled(replaceValid); - replaceFindButton.setEnabled(replaceValid); - replaceAllButton.setEnabled(replaceValid); + fFindButton.setEnabled(valid); + fReplaceButton.setEnabled(replaceValid); + fReplaceFindButton.setEnabled(replaceValid); + fReplaceAllButton.setEnabled(replaceValid); } private String pad(int characterCount, String value) @@ -451,32 +451,32 @@ public class FindReplaceDialog extends SelectionDialog Label findLabel = new Label(composite, SWT.NONE); Label replaceLabel = new Label(composite, SWT.NONE); - replaceText = new Text(composite, SWT.BORDER); + fReplaceText = new Text(composite, SWT.BORDER); findLabel.setText(Messages.getString("FindReplaceDialog.LabelFind")); //$NON-NLS-1$ - findText = new Text(composite, SWT.BORDER); + fFindText = new Text(composite, SWT.BORDER); FormData data = new FormData(); - data.left = new FormAttachment(replaceText, 0, SWT.LEFT); + data.left = new FormAttachment(fReplaceText, 0, SWT.LEFT); data.width = 260; - findText.setLayoutData(data); + fFindText.setLayoutData(data); data = new FormData(); - data.top = new FormAttachment(findText, 0, SWT.CENTER); + data.top = new FormAttachment(fFindText, 0, SWT.CENTER); findLabel.setLayoutData(data); // replace replaceLabel.setText(Messages.getString("FindReplaceDialog.LabelReplaceWith")); //$NON-NLS-1$ data = new FormData(); - data.top = new FormAttachment(findText); + data.top = new FormAttachment(fFindText); replaceLabel.setLayoutData(data); data = new FormData(); data.top = new FormAttachment(replaceLabel, 0, SWT.CENTER); data.left = new FormAttachment(replaceLabel); data.width = 260; - replaceText.setLayoutData(data); + fReplaceText.setLayoutData(data); // group direction @@ -489,13 +489,13 @@ public class FindReplaceDialog extends SelectionDialog layout.numColumns = 1; directionGroup.setLayout(layout); - forwardButton = new Button(directionGroup, SWT.RADIO); - forwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ + fForwardButton = new Button(directionGroup, SWT.RADIO); + fForwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ data = new FormData(); - data.top = new FormAttachment(replaceText); + data.top = new FormAttachment(fReplaceText); data.right = new FormAttachment(formatGroup, 0, SWT.RIGHT); data.left = new FormAttachment(formatGroup, 0, SWT.LEFT); data.bottom = new FormAttachment(rangeGroup, 0, SWT.BOTTOM); @@ -515,32 +515,32 @@ public class FindReplaceDialog extends SelectionDialog Label startLabel = new Label(rangeGroup, SWT.NONE); startLabel.setText(Messages.getString("FindReplaceDialog.LabelStartAddress")); //$NON-NLS-1$ - startText = new Combo(rangeGroup, SWT.BORDER); + fStartText = new Combo(rangeGroup, SWT.BORDER); GridData gridData = new GridData(); gridData.widthHint = 200; gridData.grabExcessHorizontalSpace = true; - startText.setLayoutData(gridData); + fStartText.setLayoutData(gridData); // group range - end address Label endLabel = new Label(rangeGroup, SWT.NONE); endLabel.setText(Messages.getString("FindReplaceDialog.LabelEndAddress")); //$NON-NLS-1$ - endText = new Combo(rangeGroup, SWT.BORDER); + fEndText = new Combo(rangeGroup, SWT.BORDER); gridData = new GridData(); gridData.widthHint = 200; gridData.grabExcessHorizontalSpace = true; - endText.setLayoutData(gridData); + fEndText.setLayoutData(gridData); data = new FormData(); data.left = new FormAttachment(directionGroup); data.top = new FormAttachment(directionGroup, 0, SWT.TOP); - data.right = new FormAttachment(findText, 0, SWT.RIGHT); + data.right = new FormAttachment(fFindText, 0, SWT.RIGHT); rangeGroup.setLayoutData(data); - startText.setItems(removeNullElements(new String[] { getViewportStart(), getStart(), getEnd(), getMemoryBlockBaseAddress() })); - endText.setItems(removeNullElements(new String[] { getEnd(), getStart(), getMemoryBlockBaseAddress(), getViewportStart() })); - startText.select(0); - endText.select(0); + fStartText.setItems(removeNullElements(new String[] { getViewportStart(), getStart(), getEnd(), getMemoryBlockBaseAddress() })); + fEndText.setItems(removeNullElements(new String[] { getEnd(), getStart(), getMemoryBlockBaseAddress(), getViewportStart() })); + fStartText.select(0); + fEndText.select(0); // format group @@ -549,23 +549,23 @@ public class FindReplaceDialog extends SelectionDialog layout.numColumns = 1; formatGroup.setLayout(layout); - formatAsciiButton = new Button(formatGroup, SWT.RADIO); - formatAsciiButton.setText(Messages.getString("FindReplaceDialog.ButtonASCII")); //$NON-NLS-1$ + fFormatAsciiButton = new Button(formatGroup, SWT.RADIO); + fFormatAsciiButton.setText(Messages.getString("FindReplaceDialog.ButtonASCII")); //$NON-NLS-1$ - formatHexButton = new Button(formatGroup, SWT.RADIO); - formatHexButton.setText(Messages.getString("FindReplaceDialog.ButtonHexadecimal")); //$NON-NLS-1$ + fFormatHexButton = new Button(formatGroup, SWT.RADIO); + fFormatHexButton.setText(Messages.getString("FindReplaceDialog.ButtonHexadecimal")); //$NON-NLS-1$ - formatOctalButton = new Button(formatGroup, SWT.RADIO); - formatOctalButton.setText(Messages.getString("FindReplaceDialog.ButtonOctal")); //$NON-NLS-1$ + fFormatOctalButton = new Button(formatGroup, SWT.RADIO); + fFormatOctalButton.setText(Messages.getString("FindReplaceDialog.ButtonOctal")); //$NON-NLS-1$ - formatBinaryButton = new Button(formatGroup, SWT.RADIO); - formatBinaryButton.setText(Messages.getString("FindReplaceDialog.ButtonBinary")); //$NON-NLS-1$ + fFormatBinaryButton = new Button(formatGroup, SWT.RADIO); + fFormatBinaryButton.setText(Messages.getString("FindReplaceDialog.ButtonBinary")); //$NON-NLS-1$ - formatDecimalButton = new Button(formatGroup, SWT.RADIO); - formatDecimalButton.setText(Messages.getString("FindReplaceDialog.ButtonDecimal")); //$NON-NLS-1$ + fFormatDecimalButton = new Button(formatGroup, SWT.RADIO); + fFormatDecimalButton.setText(Messages.getString("FindReplaceDialog.ButtonDecimal")); //$NON-NLS-1$ - formatByteSequenceButton = new Button(formatGroup, SWT.RADIO); - formatByteSequenceButton.setText(Messages.getString("FindReplaceDialog.ButtonByteSequence")); //$NON-NLS-1$ + fFormatByteSequenceButton = new Button(formatGroup, SWT.RADIO); + fFormatByteSequenceButton.setText(Messages.getString("FindReplaceDialog.ButtonByteSequence")); //$NON-NLS-1$ data = new FormData(); data.top = new FormAttachment(rangeGroup); @@ -594,15 +594,15 @@ public class FindReplaceDialog extends SelectionDialog wrapCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonWrapSearch")); //$NON-NLS-1$ wrapCheckbox.setEnabled(false); // TODO implement wrap - caseInSensitiveCheckbox = new Button(optionsGroup, SWT.CHECK); - caseInSensitiveCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonCaseInsensitive")); //$NON-NLS-1$ + fCaseInSensitiveCheckbox = new Button(optionsGroup, SWT.CHECK); + fCaseInSensitiveCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonCaseInsensitive")); //$NON-NLS-1$ - formatAsciiButton.addSelectionListener(new SelectionListener() + fFormatAsciiButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { - caseInSensitiveCheckbox.setEnabled(true); + fCaseInSensitiveCheckbox.setEnabled(true); } }); @@ -611,16 +611,16 @@ public class FindReplaceDialog extends SelectionDialog public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { - caseInSensitiveCheckbox.setEnabled(false); + fCaseInSensitiveCheckbox.setEnabled(false); } }; - formatHexButton.addSelectionListener(nonAsciiListener); - formatOctalButton.addSelectionListener(nonAsciiListener); - formatBinaryButton.addSelectionListener(nonAsciiListener); - formatDecimalButton.addSelectionListener(nonAsciiListener); - formatByteSequenceButton.addSelectionListener(nonAsciiListener); + fFormatHexButton.addSelectionListener(nonAsciiListener); + fFormatOctalButton.addSelectionListener(nonAsciiListener); + fFormatBinaryButton.addSelectionListener(nonAsciiListener); + fFormatDecimalButton.addSelectionListener(nonAsciiListener); + fFormatByteSequenceButton.addSelectionListener(nonAsciiListener); - startText.addModifyListener(new ModifyListener() { + fStartText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { boolean valid = true; try @@ -632,7 +632,7 @@ public class FindReplaceDialog extends SelectionDialog valid = false; } - startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : Display.getDefault().getSystemColor(SWT.COLOR_RED)); validate(); @@ -640,16 +640,16 @@ public class FindReplaceDialog extends SelectionDialog }); - endText.addModifyListener(new ModifyListener() { + fEndText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { try { getEndAddress(); - endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); } catch(Exception ex) { - endText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } validate(); @@ -657,33 +657,33 @@ public class FindReplaceDialog extends SelectionDialog }); - findText.addModifyListener(new ModifyListener() { + fFindText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); - replaceText.addModifyListener(new ModifyListener() { + fReplaceText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validate(); } }); - forwardButton.setSelection(true); - formatAsciiButton.setSelection(true); + fForwardButton.setSelection(true); + fFormatAsciiButton.setSelection(true); composite.setTabList(new Control[] { - findText, - replaceText, + fFindText, + fReplaceText, directionGroup, rangeGroup, formatGroup, optionsGroup, }); - findText.setFocus(); + fFindText.setFocus(); return composite; } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java deleted file mode 100644 index d69b2f7fdd6..00000000000 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryAction.java +++ /dev/null @@ -1,220 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 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: - * Ted R Williams (Wind River Systems, Inc.) - initial implementation - *******************************************************************************/ - -package org.eclipse.dd.debug.memory.renderings.actions; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.math.BigInteger; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.views.memory.MemoryView; -import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.memory.IMemoryRendering; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; - -/** - * Action for downloading memory. - */ -public class ImportMemoryAction implements IViewActionDelegate { - - - private MemoryView fView; - - public void init(IViewPart view) { - if (view instanceof MemoryView) - fView = (MemoryView) view; - } - - public void run(IAction action) { - - String secondaryId = MemoryViewIdRegistry - .getUniqueSecondaryId(IDebugUIConstants.ID_MEMORY_VIEW); - - ISelection selection = fView.getSite().getSelectionProvider() - .getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection strucSel = (IStructuredSelection) selection; - - // return if current selection is empty - if (strucSel.isEmpty()) - return; - - Object obj = strucSel.getFirstElement(); - - if (obj == null) - return; - - IMemoryBlock memBlock = null; - - if (obj instanceof IMemoryRendering) { - memBlock = ((IMemoryRendering) obj).getMemoryBlock(); - } else if (obj instanceof IMemoryBlock) { - memBlock = (IMemoryBlock) obj; - } - - Shell shell = DebugUIPlugin.getShell(); - ImportMemoryDialog dialog = new ImportMemoryDialog(shell, memBlock); - dialog.open(); - - Object results[] = dialog.getResult(); - - if(results != null && results.length == 4) - { - String format = (String) results[0]; - Boolean useCustomAddress = (Boolean) results[1]; - BigInteger start = (BigInteger) results[2]; - File file = (File) results[3]; - - if("S-Record".equals(format)) //$NON-NLS-1$ - { - downloadSRecord(file, start, useCustomAddress.booleanValue(), (IMemoryBlockExtension) memBlock); // FIXME - } - } - } - - } - - private void downloadSRecord(final File inputFile, final BigInteger startAddress, final boolean useCustomAddress, final IMemoryBlockExtension memblock) - { - Job job = new Job("Memory Download from S-Record File"){ //$NON-NLS-1$ - @Override - public IStatus run(IProgressMonitor monitor) { - - try - { - try - { - // FIXME 4 byte default - - final int CHECKSUM_LENGTH = 1; - - BigInteger offset = null; - if(!useCustomAddress) - offset = BigInteger.ZERO; - - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))); - - BigInteger jobs = BigInteger.valueOf(inputFile.length()); - BigInteger factor = BigInteger.ONE; - if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) - { - factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); - jobs = jobs.divide(factor); - } - - monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$ - - BigInteger jobCount = BigInteger.ZERO; - String line = reader.readLine(); - while(line != null && !monitor.isCanceled()) - { - String recordType = line.substring(0, 2); - int recordCount = Integer.parseInt(line.substring(2, 4), 16); - int bytesRead = 4 + recordCount; - int position = 4; - int addressSize = 0; - - BigInteger recordAddress = null; - - if("S3".equals(recordType)) //$NON-NLS-1$ - addressSize = 4; - else if("S1".equals(recordType)) //$NON-NLS-1$ - addressSize = 2; - else if("S2".equals(recordType)) //$NON-NLS-1$ - addressSize = 3; - - recordAddress = new BigInteger(line.substring(position, position + addressSize * 2), 16); - recordCount -= addressSize; - position += addressSize * 2; - - if(offset == null) - offset = startAddress.subtract(recordAddress); - - recordAddress = recordAddress.add(offset); - - byte data[] = new byte[recordCount - CHECKSUM_LENGTH]; - for(int i = 0; i < data.length; i++) - { - data[i] = new BigInteger(line.substring(position++, position++ + 1), 16).byteValue(); - } - - /* - * The least significant byte of the one's complement of the sum of the values - * represented by the pairs of characters making up the records length, address, - * and the code/data fields. - */ - StringBuffer buf = new StringBuffer(line.substring(2)); - byte checksum = 0; - - for(int i = 0; i < buf.length(); i+=2) - { - BigInteger value = new BigInteger(buf.substring(i, i+2), 16); - checksum += value.byteValue(); - } - - /* - * Since we included the checksum in the checksum calculation the checksum - * ( if correct ) will always be 0xFF which is -1 using the signed byte size - * calculation here. - */ - if ( checksum != (byte) -1 ) { - reader.close(); - monitor.done(); - return new Status( IStatus.ERROR, TraditionalRenderingPlugin.getUniqueIdentifier(), "Checksum failure of line = " + line); //$NON-NLS-1$ - } - - // FIXME error on incorrect checksum - - memblock.setValue(recordAddress.subtract(memblock.getBigBaseAddress()), data); - - jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); - while(jobCount.compareTo(factor) >= 0) - { - jobCount = jobCount.subtract(factor); - monitor.worked(1); - } - - line = reader.readLine(); - } - - reader.close(); - monitor.done(); - } - catch(Exception e) { e.printStackTrace();} - } - catch(Exception e) {e.printStackTrace();} - return Status.OK_STATUS; - }}; - job.setUser(true); - job.schedule(); - } - - public void selectionChanged(IAction action, ISelection selection) { - - } - -} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java deleted file mode 100644 index bfbf83a9d11..00000000000 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/ImportMemoryDialog.java +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006-2007 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: - * Ted R Williams (Wind River Systems, Inc.) - initial implementation - *******************************************************************************/ - -package org.eclipse.dd.debug.memory.renderings.actions; - -import java.io.File; -import java.math.BigInteger; - -import javax.swing.ButtonGroup; - -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; - -public class ImportMemoryDialog extends SelectionDialog -{ - - private Combo formatCombo; - - private IMemoryBlock fMemoryBlock; - - private Text startText; - private Text fileText; - - private Button comboRestoreToThisAddress; - private Button comboRestoreToFileAddress; - - public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) - { - super(parent); - super.setTitle("Download to Memory"); - setShellStyle(getShellStyle() | SWT.RESIZE); - - fMemoryBlock = memoryBlock; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) - */ - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - validate(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() - */ - public Object[] getResult() { - - Object[] results = super.getResult(); - - if (results != null) - { - return results; - } - return new Object[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() - */ - protected void cancelPressed() { - - setResult(null); - - super.cancelPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - setSelectionResult(new Object[]{ getFormat(), new Boolean(comboRestoreToThisAddress.getSelection()), - getStartAddress(), getFile() }); - - super.okPressed(); - } - - public String getFormat() - { - return formatCombo.getItem(formatCombo.getSelectionIndex()); - } - - public BigInteger getStartAddress() - { - String text = startText.getText(); - boolean hex = text.startsWith("0x"); - BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, - hex ? 16 : 10); - - return startAddress; - } - - public File getFile() - { - return new File(fileText.getText()); - } - - private void validate() - { - boolean isValid = true; - - try - { - getStartAddress(); - } - catch(Exception e) - { - isValid = false; - } - - getButton(IDialogConstants.OK_ID).setEnabled(isValid); - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME - Composite composite = new Composite(parent, SWT.NONE); - FormLayout formLayout = new FormLayout(); - formLayout.spacing = 5; - formLayout.marginWidth = formLayout.marginHeight = 9; - composite.setLayout(formLayout); - - // format - - Label textLabel = new Label(composite, SWT.NONE); - textLabel.setText("Format: "); - - formatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); - - FormData data = new FormData(); - data.top = new FormAttachment(formatCombo, 0, SWT.CENTER); - textLabel.setLayoutData(data); - - data = new FormData(); - data.left = new FormAttachment(textLabel); - formatCombo.setLayoutData(data); - formatCombo.setItems( new String[] { "S-Record" }); // TODO offer extension point - formatCombo.select(0); - - // restore to file address - - comboRestoreToFileAddress = new Button(composite, SWT.RADIO); - comboRestoreToFileAddress.setText("Restore to address specified in the file"); - data = new FormData(); - data.top = new FormAttachment(formatCombo); - comboRestoreToFileAddress.setLayoutData(data); - - // restore to this address - - comboRestoreToThisAddress = new Button(composite, SWT.RADIO); - comboRestoreToThisAddress.setText("Restore to this address: "); - data = new FormData(); - data.top = new FormAttachment(comboRestoreToFileAddress); - comboRestoreToThisAddress.setLayoutData(data); - - startText = new Text(composite, SWT.NONE); - data = new FormData(); - data.top = new FormAttachment(comboRestoreToFileAddress); - data.left = new FormAttachment(comboRestoreToThisAddress); - data.width = 100; - startText.setLayoutData(data); - - // file - - Label fileLabel = new Label(composite, SWT.NONE); - fileText = new Text(composite, SWT.NONE); - Button fileButton = new Button(composite, SWT.PUSH); - - fileLabel.setText("File name: "); - data = new FormData(); - data.top = new FormAttachment(fileButton, 0, SWT.CENTER); - fileLabel.setLayoutData(data); - - data = new FormData(); - data.top = new FormAttachment(fileButton, 0, SWT.CENTER); - data.left = new FormAttachment(fileLabel); - data.width = 300; - fileText.setLayoutData(data); - - fileButton.setText("Browse..."); - data = new FormData(); - data.top = new FormAttachment(startText); - data.left = new FormAttachment(fileText); - fileButton.setLayoutData(data); - - try - { - BigInteger startAddress = null; - if(fMemoryBlock instanceof IMemoryBlockExtension) - startAddress = ((IMemoryBlockExtension) fMemoryBlock) - .getBigBaseAddress(); // FIXME use selection/caret address? - else - startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); - - startText.setText("0x" + startAddress.toString(16)); - } - catch(Exception e) - { - e.printStackTrace(); - // TODO - } - - fileButton.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - // TODO Auto-generated method stub - - } - - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(ImportMemoryDialog.this.getShell(), SWT.SAVE); - dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); - dialog.setFileName(fileText.getText()); - dialog.open(); - - if(dialog.getFileName() != null) - { - fileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); - } - - validate(); - } - - }); - - startText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - boolean valid = true; - try - { - getStartAddress(); - } - catch(Exception ex) - { - valid = false; - } - - startText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : - Display.getDefault().getSystemColor(SWT.COLOR_RED)); - - // - - validate(); - } - - }); - fileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - validate(); - } - }); - - return composite; - } - - -} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/.classpath b/plugins/org.eclipse.dd.debug.ui.memory.transport/.classpath new file mode 100644 index 00000000000..2fbb7a23e12 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/.project b/plugins/org.eclipse.dd.debug.ui.memory.transport/.project new file mode 100644 index 00000000000..b1da30811d6 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/.project @@ -0,0 +1,28 @@ + + + org.eclipse.dd.debug.ui.memory.transport + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.dd.debug.ui.memory.transport/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..b51d4342d8d --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +#Fri May 09 21:44:48 PDT 2008 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..457f0bad69f --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Memory Transport Plug-in +Bundle-SymbolicName: org.eclipse.dd.debug.ui.memory.transport;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Localization: plugin +Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.debug.core, + org.eclipse.debug.ui, + org.eclipse.core.runtime, + org.eclipse.swt, + org.eclipse.jface, + org.eclipse.ui +Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.dd.debug.ui.memory.transport.MemoryTransportPlugin diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html b/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html new file mode 100644 index 00000000000..cb740ae8bc8 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html @@ -0,0 +1,24 @@ + + + + +About +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties b/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties new file mode 100644 index 00000000000..e14f8a09223 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + schema/,\ + plugin.xml,\ + build.properties,\ + plugin.properties diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/icons/export.png b/plugins/org.eclipse.dd.debug.ui.memory.transport/icons/export.png new file mode 100644 index 0000000000000000000000000000000000000000..91b2198825cb30c5498bfd5a951713caefbe04d3 GIT binary patch literal 227 zcmV<90382`P)B1hhOleLjth?YXxAtRKKxtaeGO33r}+Be&TkS#r) z$NEy2d!zQO8vtmlp{)kR12rL5j6y_26!Z1WT+Z|O9Cagw7IFJu8LpH;RtUhU4(2XC d&PY=I4-2;7ZC}Rka$5iZ002ovPDHLkV1oJvTulG~ literal 0 HcmV?d00001 diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/icons/import.png b/plugins/org.eclipse.dd.debug.ui.memory.transport/icons/import.png new file mode 100644 index 0000000000000000000000000000000000000000..fa02317c7fd36390f9430f68cc5b02e379a9dc94 GIT binary patch literal 236 zcmVk0E<+)KSc5@Yl?tim;9`~XE}6D+WCDT>HjjulUd@M)ln#zKv* + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/schema/MemoryTransport.exsd b/plugins/org.eclipse.dd.debug.ui.memory.transport/schema/MemoryTransport.exsd new file mode 100644 index 00000000000..341130f5831 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/schema/MemoryTransport.exsd @@ -0,0 +1,160 @@ + + + + + + + + + Allows plug-ins to contribute arbitrary memory importers and exporters. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /******************************************************************************* + * Copyright (c) 2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + + + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java new file mode 100644 index 00000000000..f0f45a56c94 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.util.Properties; +import java.util.Vector; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +public class ExportMemoryDialog extends SelectionDialog +{ + + private Combo fFormatCombo; + + private IMemoryBlock fMemoryBlock; + + private Control fCurrentControl = null; + + private IMemoryExporter fFormatExporters[]; + private String fFormatNames[]; + + private Properties fProperties = new Properties(); + + public ExportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + { + super(parent); + super.setTitle("Export Memory"); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fMemoryBlock = memoryBlock; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + super.createButtonsForButtonBar(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() + */ + public Object[] getResult() { + + Object[] results = super.getResult(); + + if (results != null) + { + return results; + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + protected void cancelPressed() { + + setResult(null); + + super.cancelPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + if(fCurrentControl != null) + fCurrentControl.dispose(); + fFormatExporters[fFormatCombo.getSelectionIndex()].exportMemory(); + + super.okPressed(); + } + + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME + Composite composite = new Composite(parent, SWT.NONE); + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // format + + Label textLabel = new Label(composite, SWT.NONE); + textLabel.setText("Format: "); + + fFormatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); + + FormData data = new FormData(); + data.top = new FormAttachment(fFormatCombo, 0, SWT.CENTER); + textLabel.setLayoutData(data); + + data = new FormData(); + data.left = new FormAttachment(textLabel); + fFormatCombo.setLayoutData(data); + + Vector exporters = new Vector(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = + registry.getExtensionPoint("org.eclipse.dd.debug.ui.memory.transport.memoryTransport"); + IConfigurationElement points[] = + extensionPoint.getConfigurationElements(); + + for (int i = 0; i < points.length; i++) + { + IConfigurationElement element = points[i]; + if("exporter".equals(element.getName())) + { + try + { + exporters.addElement((IMemoryExporter) element.createExecutableExtension("class")); + } + catch(Exception e) { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + } + + fFormatExporters = new IMemoryExporter[exporters.size()]; + fFormatNames = new String[exporters.size()]; + for(int i = 0; i < fFormatExporters.length; i++) + { + fFormatExporters[i] = (IMemoryExporter) exporters.elementAt(i); + fFormatNames[i] = ((IMemoryExporter) exporters.elementAt(i)).getName(); + } + + final Composite container = new Composite(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fFormatCombo); + data.left = new FormAttachment(0); + container.setLayoutData(data); + + fFormatCombo.setItems(fFormatNames); + + fFormatCombo.addSelectionListener(new SelectionListener(){ + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + if(fCurrentControl != null) + fCurrentControl.dispose(); + fCurrentControl = fFormatExporters[fFormatCombo.getSelectionIndex()].createControl(container, + fMemoryBlock, fProperties, ExportMemoryDialog.this); + } + }); + + + fFormatCombo.select(0); + fCurrentControl = fFormatExporters[0].createControl(container, + fMemoryBlock, fProperties, ExportMemoryDialog.this); + + return composite; + } + + public void setValid(boolean isValid) + { + getButton(IDialogConstants.OK_ID).setEnabled(isValid); + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java new file mode 100644 index 00000000000..392e2dc6a14 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java @@ -0,0 +1,205 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.util.Properties; +import java.util.Vector; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; + +public class ImportMemoryDialog extends SelectionDialog +{ + + private Combo fFormatCombo; + + private IMemoryBlock fMemoryBlock; + + private Control fCurrentControl = null; + + private IMemoryImporter fFormatImporters[]; + private String fFormatNames[]; + + private Properties fProperties = new Properties(); + + public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + { + super(parent); + super.setTitle("Download to Memory"); + setShellStyle(getShellStyle() | SWT.RESIZE); + + fMemoryBlock = memoryBlock; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) + */ + protected void createButtonsForButtonBar(Composite parent) { + super.createButtonsForButtonBar(parent); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.dialogs.SelectionDialog#getResult() + */ + public Object[] getResult() { + + Object[] results = super.getResult(); + + if (results != null) + { + return results; + } + return new Object[0]; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#cancelPressed() + */ + protected void cancelPressed() { + + setResult(null); + + super.cancelPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + if(fCurrentControl != null) + fCurrentControl.dispose(); + fFormatImporters[fFormatCombo.getSelectionIndex()].importMemory(); + + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + + PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, DebugUIPlugin.getUniqueIdentifier() + ".AddMemoryRenderingDialog_context"); //$NON-NLS-1$ // FIXME + Composite composite = new Composite(parent, SWT.NONE); + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // format + + Label textLabel = new Label(composite, SWT.NONE); + textLabel.setText("Format: "); + + fFormatCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); + + FormData data = new FormData(); + data.top = new FormAttachment(fFormatCombo, 0, SWT.CENTER); + textLabel.setLayoutData(data); + + data = new FormData(); + data.left = new FormAttachment(textLabel); + fFormatCombo.setLayoutData(data); + + Vector importers = new Vector(); + + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extensionPoint = + registry.getExtensionPoint("org.eclipse.dd.debug.ui.memory.transport.memoryTransport"); + IConfigurationElement points[] = + extensionPoint.getConfigurationElements(); + + for (int i = 0; i < points.length; i++) + { + IConfigurationElement element = points[i]; + if("importer".equals(element.getName())) + { + try + { + importers.addElement((IMemoryImporter) element.createExecutableExtension("class")); + } + catch(Exception e) { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + } + + fFormatImporters = new IMemoryImporter[importers.size()]; + fFormatNames = new String[importers.size()]; + for(int i = 0; i < fFormatImporters.length; i++) + { + fFormatImporters[i] = (IMemoryImporter) importers.elementAt(i); + fFormatNames[i] = ((IMemoryImporter) importers.elementAt(i)).getName(); + } + + final Composite container = new Composite(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fFormatCombo); + data.left = new FormAttachment(0); + container.setLayoutData(data); + + fFormatCombo.setItems(fFormatNames); + + fFormatCombo.addSelectionListener(new SelectionListener(){ + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + if(fCurrentControl != null) + fCurrentControl.dispose(); + fCurrentControl = fFormatImporters[fFormatCombo.getSelectionIndex()].createControl(container, + fMemoryBlock, fProperties, ImportMemoryDialog.this); + } + }); + + + fFormatCombo.select(0); + fCurrentControl = fFormatImporters[0].createControl(container, + fMemoryBlock, fProperties, ImportMemoryDialog.this); + + return composite; + } + + public void setValid(boolean isValid) + { + getButton(IDialogConstants.OK_ID).setEnabled(isValid); + } + + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java new file mode 100644 index 00000000000..10f6c6e0ea0 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class MemoryTransportPlugin extends AbstractUIPlugin +{ + private static final String PLUGIN_ID = "org.eclipse.dd.debug.ui.memory.transport"; //$NON-NLS-1$ + + private static MemoryTransportPlugin plugin; + + public MemoryTransportPlugin() + { + super(); + plugin = this; + } + + /** + * Returns the shared instance. + */ + public static MemoryTransportPlugin getDefault() { + return plugin; + } + + /** + * Returns the unique identifier for this plugin. + */ + public static String getUniqueIdentifier() { + return PLUGIN_ID; + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/Messages.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/Messages.java new file mode 100644 index 00000000000..d10158d2367 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2007-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.dd.debug.ui.memory.transport.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java new file mode 100644 index 00000000000..d4f5191448c --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -0,0 +1,467 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.File; +import java.io.FileWriter; +import java.math.BigInteger; +import java.util.Properties; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class PlainTextExporter implements IMemoryExporter { + + File fOutputFile; + BigInteger fStartAddress; + BigInteger fEndAddress; + + private Text fStartText; + private Text fEndText; + private Text fLengthText; + private Text fFileText; + + private IMemoryBlock fMemoryBlock; + + private ExportMemoryDialog fParentDialog; + + private Properties fProperties; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ExportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_END, fEndText.getText()); + + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + + super.dispose(); + } + }; + + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // start address + + Label startLabel = new Label(composite, SWT.NONE); + startLabel.setText("Start address: "); + FormData data = new FormData(); + startLabel.setLayoutData(data); + + fStartText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(startLabel); + data.left = new FormAttachment(startLabel); + data.width = 100; + fStartText.setLayoutData(data); + + // end address + + Label endLabel = new Label(composite, SWT.NONE); + endLabel.setText("End address: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fStartText); + endLabel.setLayoutData(data); + + fEndText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(endLabel); + data.width = 100; + fEndText.setLayoutData(data); + + // length + + Label lengthLabel = new Label(composite, SWT.NONE); + lengthLabel.setText("Length: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fEndText); + lengthLabel.setLayoutData(data); + + fLengthText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(lengthLabel); + data.width = 100; + fLengthText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fLengthText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + if(properties.getProperty(TRANSFER_END) != null) + fEndText.setText(properties.getProperty(TRANSFER_END)); + else + fEndText.setText("0x" + startAddress.toString(16)); + + fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + fStartText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + fLengthText.setText(endAddress.subtract(startAddress).toString()); + + validate(); + } + + }); + + fEndText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + getEndAddress(); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + String lengthString = endAddress.subtract(startAddress).toString(); + + if(!fLengthText.getText().equals(lengthString)) + fLengthText.setText(lengthString); + } + catch(Exception ex) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + fLengthText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + BigInteger length = getLength(); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + BigInteger startAddress = getStartAddress(); + String endString = "0x" + startAddress.add(length).toString(16); + if(!fEndText.getText().equals(endString)) + fEndText.setText(endString); + } + catch(Exception ex) + { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + fFileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + composite.pack(); + + return composite; + } + + public BigInteger getEndAddress() + { + String text = fEndText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return endAddress; + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public BigInteger getLength() + { + String text = fLengthText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return lengthAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + private void validate() + { + boolean isValid = true; + + try + { + getEndAddress(); + + getStartAddress(); + + BigInteger length = getLength(); + + if(length.compareTo(BigInteger.ZERO) <= 0) + isValid = false; + + if(!getFile().getParentFile().exists()) + isValid = false; + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + + } + + public String getId() + { + return "PlainTextExporter"; + } + + public String getName() + { + return "Plain Text"; + } + + public void exportMemory() { + Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + // FIXME 4 byte default + + BigInteger CELLSIZE = BigInteger.valueOf(4); + + BigInteger COLUMNS = BigInteger.valueOf(5); // FIXME + + BigInteger DATA_PER_LINE = CELLSIZE.multiply(COLUMNS); + + BigInteger transferAddress = fStartAddress; + + FileWriter writer = new FileWriter(fOutputFile); + + BigInteger jobs = fEndAddress.subtract(transferAddress).divide(DATA_PER_LINE); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); + + BigInteger jobCount = BigInteger.ZERO; + while(transferAddress.compareTo(fEndAddress) < 0 && !monitor.isCanceled()) + { + BigInteger length = DATA_PER_LINE; + if(fEndAddress.subtract(transferAddress).compareTo(length) < 0) + length = fEndAddress.subtract(transferAddress); + + StringBuffer buf = new StringBuffer(); + +// String transferAddressString = transferAddress.toString(16); + + // future option +// for(int i = 0; i < 8 - transferAddressString.length(); i++) +// buf.append("0"); +// buf.append(transferAddressString); +// buf.append(" "); // TODO tab? + + // data + + for(int i = 0; i < length.divide(CELLSIZE).intValue(); i++) + { + if(i != 0) + buf.append(" "); + MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress( + transferAddress.add(CELLSIZE.multiply(BigInteger.valueOf(i))), + CELLSIZE.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize()); + for(int byteIndex = 0; byteIndex < bytes.length; byteIndex++) + { + String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16); + if(bString.length() == 1) + buf.append("0"); + buf.append(bString); + } + } + + writer.write(buf.toString().toUpperCase()); + writer.write("\n"); + + transferAddress = transferAddress.add(length); + + jobCount = jobCount.add(BigInteger.ONE); + if(jobCount.compareTo(factor) == 0) + { + jobCount = BigInteger.ZERO; + monitor.worked(1); + } + } + + writer.close(); + monitor.done(); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java new file mode 100644 index 00000000000..23692b72e83 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -0,0 +1,347 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.math.BigInteger; +import java.util.Properties; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class PlainTextImporter implements IMemoryImporter { + + File fInputFile; + BigInteger fStartAddress; + boolean fUseCustomAddress; + Boolean fScrollToStart; + + private Text fStartText; + private Text fFileText; + +// private Button fComboRestoreToThisAddress; +// private Button fComboRestoreToFileAddress; + + private Button fScrollToBeginningOnImportComplete; + + private IMemoryBlock fMemoryBlock; + + private ImportMemoryDialog fParentDialog; + + private Properties fProperties; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + fUseCustomAddress = true; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_SCROLL_TO_START, fScrollToStart.toString()); + + fStartAddress = getStartAddress(); + fInputFile = getFile(); + + super.dispose(); + } + }; + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + +// // restore to file address +// +// fComboRestoreToFileAddress = new Button(composite, SWT.RADIO); +// fComboRestoreToFileAddress.setText("Restore to address specified in the file"); +// //comboRestoreToFileAddress.setLayoutData(data); +// +// // restore to this address +// +// fComboRestoreToThisAddress = new Button(composite, SWT.RADIO); +// fComboRestoreToThisAddress.setText("Restore to this address: "); + FormData data = new FormData(); +// data.top = new FormAttachment(fComboRestoreToFileAddress); +// fComboRestoreToThisAddress.setLayoutData(data); + + fStartText = new Text(composite, SWT.NONE); + data = new FormData(); +// data.top = new FormAttachment(fComboRestoreToFileAddress); +// data.left = new FormAttachment(fComboRestoreToThisAddress); + data.width = 100; + fStartText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fStartText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + fStartText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + validate(); + } + + }); + fFileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + fScrollToBeginningOnImportComplete = new Button(composite, SWT.CHECK); + fScrollToBeginningOnImportComplete.setText("Scroll to File Start Address"); + data = new FormData(); + data.top = new FormAttachment(fileButton); + fScrollToBeginningOnImportComplete.setLayoutData(data); + + composite.pack(); + parent.pack(); + + return composite; + } + + private void validate() + { + boolean isValid = true; + + try + { + getStartAddress(); + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + } + + public boolean getScrollToStart() + { + return fScrollToBeginningOnImportComplete.getSelection(); + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + public String getId() + { + return "PlainTextImporter"; + } + + public String getName() + { + return "Plain Text"; + } + + public void importMemory() { + Job job = new Job("Memory Download from Plain Text File"){ //$NON-NLS-1$ + + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + BigInteger offset = null; + if(!fUseCustomAddress) + offset = BigInteger.ZERO; + + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); + + BigInteger jobs = BigInteger.valueOf(fInputFile.length()); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$ + + BigInteger jobCount = BigInteger.ZERO; + BigInteger recordAddress = fStartAddress; + String line = reader.readLine(); + while(line != null && !monitor.isCanceled()) + { + StringTokenizer st = new StringTokenizer(line, " "); + int bytesRead = 0; + while(st.hasMoreElements()) + { + String valueString = (String) st.nextElement(); + int position = 0; + byte data[] = new byte[valueString.length() / 2]; + for(int i = 0; i < data.length; i++) + { + data[i] = new BigInteger(valueString.substring(position++, position++ + 1), 16).byteValue(); + } + + ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) + fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data); + + bytesRead += data.length; + } + + recordAddress = recordAddress.and(BigInteger.valueOf(bytesRead)); + + jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); + while(jobCount.compareTo(factor) >= 0) + { + jobCount = jobCount.subtract(factor); + monitor.worked(1); + } + + line = reader.readLine(); + } + + reader.close(); + monitor.done(); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) {e.printStackTrace();} + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java new file mode 100644 index 00000000000..ba1c44cc3d5 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -0,0 +1,479 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.File; +import java.io.FileWriter; +import java.math.BigInteger; +import java.util.Properties; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class SRecordExporter implements IMemoryExporter +{ + File fOutputFile; + BigInteger fStartAddress; + BigInteger fEndAddress; + + private Text fStartText; + private Text fEndText; + private Text fLengthText; + private Text fFileText; + + private IMemoryBlock fMemoryBlock; + + private ExportMemoryDialog fParentDialog; + + private Properties fProperties; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ExportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_END, fEndText.getText()); + + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + + super.dispose(); + } + }; + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // start address + + Label startLabel = new Label(composite, SWT.NONE); + startLabel.setText("Start address: "); + FormData data = new FormData(); + startLabel.setLayoutData(data); + + fStartText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(startLabel); + data.left = new FormAttachment(startLabel); + data.width = 100; + fStartText.setLayoutData(data); + + // end address + + Label endLabel = new Label(composite, SWT.NONE); + endLabel.setText("End address: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fStartText); + endLabel.setLayoutData(data); + + fEndText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(endLabel); + data.width = 100; + fEndText.setLayoutData(data); + + // length + + Label lengthLabel = new Label(composite, SWT.NONE); + lengthLabel.setText("Length: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fEndText); + lengthLabel.setLayoutData(data); + + fLengthText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(lengthLabel); + data.width = 100; + fLengthText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fLengthText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + if(properties.getProperty(TRANSFER_END) != null) + fEndText.setText(properties.getProperty(TRANSFER_END)); + else + fEndText.setText("0x" + startAddress.toString(16)); + + fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + fStartText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + fLengthText.setText(endAddress.subtract(startAddress).toString()); + + validate(); + } + + }); + + fEndText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + getEndAddress(); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + String lengthString = endAddress.subtract(startAddress).toString(); + + if(!fLengthText.getText().equals(lengthString)) + fLengthText.setText(lengthString); + } + catch(Exception ex) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + fLengthText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + try + { + BigInteger length = getLength(); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + BigInteger startAddress = getStartAddress(); + String endString = "0x" + startAddress.add(length).toString(16); + if(!fEndText.getText().equals(endString)) + fEndText.setText(endString); + } + catch(Exception ex) + { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + }); + + fFileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + composite.pack(); + + return composite; + } + + public BigInteger getEndAddress() + { + String text = fEndText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return endAddress; + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public BigInteger getLength() + { + String text = fLengthText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return lengthAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + private void validate() + { + boolean isValid = true; + + try + { + getEndAddress(); + + getStartAddress(); + + BigInteger length = getLength(); + + if(length.compareTo(BigInteger.ZERO) <= 0) + isValid = false; + + if(!getFile().getParentFile().exists()) + isValid = false; + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + + } + + + public String getId() + { + return "srecord"; + } + + public String getName() + { + return "SRecord"; + } + + public void exportMemory() + { + Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + // FIXME 4 byte default + + BigInteger DATA_PER_RECORD = BigInteger.valueOf(16); + + BigInteger transferAddress = fStartAddress; + + FileWriter writer = new FileWriter(fOutputFile); + + BigInteger jobs = fEndAddress.subtract(transferAddress).divide(DATA_PER_RECORD); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); + + BigInteger jobCount = BigInteger.ZERO; + while(transferAddress.compareTo(fEndAddress) < 0 && !monitor.isCanceled()) + { + BigInteger length = DATA_PER_RECORD; + if(fEndAddress.subtract(transferAddress).compareTo(length) < 0) + length = fEndAddress.subtract(transferAddress); + + writer.write("S3"); // FIXME 4 byte address + + StringBuffer buf = new StringBuffer(); + + BigInteger sRecordLength = BigInteger.valueOf(4); // address size + sRecordLength = sRecordLength.add(length); + sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum + + String transferAddressString = transferAddress.toString(16); + + String lengthString = sRecordLength.toString(16); + if(lengthString.length() == 1) + buf.append("0"); + buf.append(lengthString); + for(int i = 0; i < 8 - transferAddressString.length(); i++) + buf.append("0"); + buf.append(transferAddressString); + + // data + + MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress, + length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize()); + for(int byteIndex = 0; byteIndex < bytes.length; byteIndex++) + { + String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16); + if(bString.length() == 1) + buf.append("0"); + buf.append(bString); + } + + /* + * The least significant byte of the one's complement of the sum of the values + * represented by the pairs of characters making up the records length, address, + * and the code/data fields. + */ + byte checksum = 0; + + for(int i = 0; i < buf.length(); i+=2) + { + BigInteger value = new BigInteger(buf.substring(i, i+2), 16); + checksum += value.byteValue(); + } + + buf.append(BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16)); + + writer.write(buf.toString().toUpperCase()); + writer.write("\n"); + + transferAddress = transferAddress.add(length); + + jobCount = jobCount.add(BigInteger.ONE); + if(jobCount.compareTo(factor) == 0) + { + jobCount = BigInteger.ZERO; + monitor.worked(1); + } + } + + writer.close(); + monitor.done(); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java new file mode 100644 index 00000000000..965cbe2e1e0 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -0,0 +1,390 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.math.BigInteger; +import java.util.Properties; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class SRecordImporter implements IMemoryImporter { + + File fInputFile; + BigInteger fStartAddress; + boolean fUseCustomAddress; + Boolean fScrollToStart; + + private Text fStartText; + private Text fFileText; + + private Button fComboRestoreToThisAddress; + private Button fComboRestoreToFileAddress; + + private Button fScrollToBeginningOnImportComplete; + + private IMemoryBlock fMemoryBlock; + + private ImportMemoryDialog fParentDialog; + + private Properties fProperties; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_SCROLL_TO_START, fScrollToStart.toString()); + + fStartAddress = getStartAddress(); + fInputFile = getFile(); + + super.dispose(); + } + }; + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // restore to file address + + fComboRestoreToFileAddress = new Button(composite, SWT.RADIO); + fComboRestoreToFileAddress.setText("Restore to address specified in the file"); + //comboRestoreToFileAddress.setLayoutData(data); + + // restore to this address + + fComboRestoreToThisAddress = new Button(composite, SWT.RADIO); + fComboRestoreToThisAddress.setText("Restore to this address: "); + FormData data = new FormData(); + data.top = new FormAttachment(fComboRestoreToFileAddress); + fComboRestoreToThisAddress.setLayoutData(data); + + fStartText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fComboRestoreToFileAddress); + data.left = new FormAttachment(fComboRestoreToThisAddress); + data.width = 100; + fStartText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fStartText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock) + .getBigBaseAddress(); // FIXME use selection/caret address? + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*" } ); + dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + if(dialog.getFileName() != null) + { + fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + } + + validate(); + } + + }); + + fStartText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + validate(); + } + + }); + fFileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + fScrollToBeginningOnImportComplete = new Button(composite, SWT.CHECK); + fScrollToBeginningOnImportComplete.setText("Scroll to File Start Address"); + data = new FormData(); + data.top = new FormAttachment(fileButton); + fScrollToBeginningOnImportComplete.setLayoutData(data); + + composite.pack(); + parent.pack(); + + return composite; + } + + private void validate() + { + boolean isValid = true; + + try + { + getStartAddress(); + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + } + + public boolean getScrollToStart() + { + return fScrollToBeginningOnImportComplete.getSelection(); + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + public String getId() + { + return "snfimporter"; + } + + public String getName() + { + return "SRecord"; + } + + public void importMemory() { + Job job = new Job("Memory Download from S-Record File"){ //$NON-NLS-1$ + + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + // FIXME 4 byte default + + final int CHECKSUM_LENGTH = 1; + + BigInteger offset = null; + if(!fUseCustomAddress) + offset = BigInteger.ZERO; + + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); + + BigInteger jobs = BigInteger.valueOf(fInputFile.length()); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$ + + BigInteger jobCount = BigInteger.ZERO; + String line = reader.readLine(); + while(line != null && !monitor.isCanceled()) + { + String recordType = line.substring(0, 2); + int recordCount = Integer.parseInt(line.substring(2, 4), 16); + int bytesRead = 4 + recordCount; + int position = 4; + int addressSize = 0; + + BigInteger recordAddress = null; + + if("S3".equals(recordType)) //$NON-NLS-1$ + addressSize = 4; + else if("S1".equals(recordType)) //$NON-NLS-1$ + addressSize = 2; + else if("S2".equals(recordType)) //$NON-NLS-1$ + addressSize = 3; + + recordAddress = new BigInteger(line.substring(position, position + addressSize * 2), 16); + recordCount -= addressSize; + position += addressSize * 2; + + if(offset == null) + offset = fStartAddress.subtract(recordAddress); + + recordAddress = recordAddress.add(offset); + + byte data[] = new byte[recordCount - CHECKSUM_LENGTH]; + for(int i = 0; i < data.length; i++) + { + data[i] = new BigInteger(line.substring(position++, position++ + 1), 16).byteValue(); + } + + /* + * The least significant byte of the one's complement of the sum of the values + * represented by the pairs of characters making up the records length, address, + * and the code/data fields. + */ + StringBuffer buf = new StringBuffer(line.substring(2)); + byte checksum = 0; + + for(int i = 0; i < buf.length(); i+=2) + { + BigInteger value = new BigInteger(buf.substring(i, i+2), 16); + checksum += value.byteValue(); + } + + /* + * Since we included the checksum in the checksum calculation the checksum + * ( if correct ) will always be 0xFF which is -1 using the signed byte size + * calculation here. + */ + if ( checksum != (byte) -1 ) { + reader.close(); + monitor.done(); + return new Status( IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), "Checksum failure of line = " + line); //$NON-NLS-1$ + } + + // FIXME error on incorrect checksum + + ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data); + + jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); + while(jobCount.compareTo(factor) >= 0) + { + jobCount = jobCount.subtract(factor); + monitor.worked(1); + } + + line = reader.readLine(); + } + + reader.close(); + monitor.done(); + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) + { + DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java new file mode 100644 index 00000000000..3ad72347562 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport.actions; + +import org.eclipse.dd.debug.ui.memory.transport.ExportMemoryDialog; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Action for exporting memory. + */ +public class ExportMemoryAction implements IViewActionDelegate { + + private MemoryView fView; + + public void init(IViewPart view) { + if (view instanceof MemoryView) + fView = (MemoryView) view; + } + + public void run(IAction action) { + + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection strucSel = (IStructuredSelection) selection; + + // return if current selection is empty + if (strucSel.isEmpty()) + return; + + Object obj = strucSel.getFirstElement(); + + if (obj == null) + return; + + IMemoryBlock memBlock = null; + + if (obj instanceof IMemoryRendering) { + memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + } else if (obj instanceof IMemoryBlock) { + memBlock = (IMemoryBlock) obj; + } + if(memBlock == null) + return; + + ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + dialog.open(); + + dialog.getResult(); + } + + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java new file mode 100644 index 00000000000..4c87cd3bf4e --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport.actions; + +import org.eclipse.dd.debug.ui.memory.transport.ImportMemoryDialog; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; + +/** + * Action for downloading memory. + */ +public class ImportMemoryAction implements IViewActionDelegate { + + + private MemoryView fView; + + public void init(IViewPart view) { + if (view instanceof MemoryView) + fView = (MemoryView) view; + } + + public void run(IAction action) { + + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + if (selection instanceof IStructuredSelection) { + IStructuredSelection strucSel = (IStructuredSelection) selection; + + // return if current selection is empty + if (strucSel.isEmpty()) + return; + + Object obj = strucSel.getFirstElement(); + + if (obj == null) + return; + + IMemoryBlock memBlock = null; + + if (obj instanceof IMemoryRendering) { + memBlock = ((IMemoryRendering) obj).getMemoryBlock(); + } else if (obj instanceof IMemoryBlock) { + memBlock = (IMemoryBlock) obj; + } + if(memBlock == null) + return; + + ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + dialog.open(); + + dialog.getResult(); + } + + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/messages.properties b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/messages.properties new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryExporter.java new file mode 100644 index 00000000000..262cb4ca42f --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryExporter.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport.model; + +import java.util.Properties; + +import org.eclipse.dd.debug.ui.memory.transport.ExportMemoryDialog; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +public interface IMemoryExporter +{ + public static final String TRANSFER_FILE = "File"; + public static final String TRANSFER_START = "Start"; + public static final String TRANSFER_END = "End"; + + public Control createControl(Composite parent, IMemoryBlock memBlock, Properties properties, ExportMemoryDialog parentDialog); + + public void exportMemory(); + + public String getId(); + + public String getName(); +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java new file mode 100644 index 00000000000..cf494524772 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport.model; + +import java.util.Properties; + +import org.eclipse.dd.debug.ui.memory.transport.ImportMemoryDialog; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +public interface IMemoryImporter +{ + public static final String TRANSFER_FILE = "File"; + public static final String TRANSFER_START = "Start"; + public static final String TRANSFER_END = "End"; + public static final String TRANSFER_SCROLL_TO_START = "ScrollToStart"; + + public Control createControl(Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog); + + public void importMemory(); + + public String getId(); + + public String getName(); +} From 321f3cdcff3d421bde5bf51f50c7b4673a2ac0c8 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 14 May 2008 06:15:54 +0000 Subject: [PATCH 069/118] [232003] Separate memory transport from traditional rendering plugin; support pluggable importers/exporters. --- .../plugin.xml | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index e6d2d7755f6..8a21f92e37a 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -1,6 +1,6 @@ - + - - - - @@ -64,5 +40,4 @@ - From 237bb0270617d6e40a049c47d5c9371d56a5545c Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Wed, 14 May 2008 17:33:07 +0000 Subject: [PATCH 070/118] Updated data in about file. --- plugins/org.eclipse.dd.debug.ui.memory.transport/about.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html b/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html index cb740ae8bc8..04492dd7e1b 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/about.html @@ -5,7 +5,7 @@ About

About This Content

-

June 5, 2007

+

May 14, 2008

License

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise From c289fa0b9b14a0c4f15b41f2dbd7d24babc41407 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 21 May 2008 05:11:09 +0000 Subject: [PATCH 071/118] [230262] Implement Memory Change Trails --- .../renderings/traditional/DataPane.java | 61 +++++--- .../traditional/IViewportCache.java | 4 +- .../renderings/traditional/Rendering.java | 140 +++++++++++------- .../renderings/traditional/TextPane.java | 65 ++++---- .../traditional/TraditionalRendering.java | 75 ++++++++++ ...aditionalRenderingPreferenceConstants.java | 2 + ...itionalRenderingPreferenceInitializer.java | 2 + .../TraditionalRenderingPreferencePage.java | 3 + 8 files changed, 248 insertions(+), 104 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java index b1668d63bea..9307063fcf0 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/DataPane.java @@ -17,6 +17,7 @@ import java.math.BigInteger; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; @@ -102,8 +103,8 @@ public class DataPane extends AbstractPane } //else { - if(bytes[i] instanceof TraditionalMemoryByte) - bytesToSet[i].setEdited(((TraditionalMemoryByte) bytes[i]).isEdited()); +// if(bytes[i] instanceof TraditionalMemoryByte) +// bytesToSet[i].setEdited(((TraditionalMemoryByte) bytes[i]).isEdited()); bytesToSet[i].setChanged(bytes[i].isChanged()); } } @@ -272,7 +273,7 @@ public class DataPane extends AbstractPane * fRendering.getColumnCount() + col) * fRendering.getAddressesPerColumn())); - MemoryByte bytes[] = fRendering.getBytes(cellAddress, + TraditionalMemoryByte bytes[] = fRendering.getBytes(cellAddress, fRendering.getBytesPerColumn()); if(fRendering.getSelection().isSelected(cellAddress)) @@ -293,7 +294,6 @@ public class DataPane extends AbstractPane // Allow subclasses to override this method to do their own coloring applyCustomColor(gc, bytes, col); - } gc.drawText(getCellText(bytes), cellWidth * col @@ -337,31 +337,46 @@ public class DataPane extends AbstractPane } // Allow subclasses to override this method to do their own coloring - protected void applyCustomColor(GC gc, MemoryByte bytes[], int col) + protected void applyCustomColor(GC gc, TraditionalMemoryByte bytes[], int col) { - // TODO consider adding finer granularity? - boolean anyByteChanged = false; - for(int n = 0; n < bytes.length && !anyByteChanged; n++) - if(bytes[n].isChanged()) - anyByteChanged = true; + // TODO consider adding finer granularity? + boolean anyByteEditing = false; + for(int n = 0; n < bytes.length && !anyByteEditing; n++) + if(bytes[n] instanceof TraditionalMemoryByte) + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; - // TODO consider adding finer granularity? - boolean anyByteEditing = false; - for(int n = 0; n < bytes.length && !anyByteEditing; n++) - if(bytes[n] instanceof TraditionalMemoryByte) - if(((TraditionalMemoryByte) bytes[n]).isEdited()) - anyByteEditing = true; - - if(anyByteEditing) - gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); - else if(anyByteChanged) - gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); - else if(isOdd(col)) + if(isOdd(col)) gc.setForeground(fRendering.getTraditionalRendering().getColorText()); else gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); - gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + + if(anyByteEditing) + { + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + } + else + { + boolean isColored = false; + for(int i = 0; i < fRendering.getHistoryDepth() && !isColored; i++) + { + // TODO consider adding finer granularity? + for(int n = 0; n < bytes.length; n++) + { + if(bytes[n].isChanged(i)) + { + if(i == 0) + gc.setForeground(fRendering.getTraditionalRendering().getColorsChanged()[i]); + else + gc.setBackground(fRendering.getTraditionalRendering().getColorsChanged()[i]); + isColored = true; + break; + } + } + } + } + } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java index 9f2e5d0bd48..af0f4f0c732 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/IViewportCache.java @@ -9,9 +9,9 @@ public interface IViewportCache { public void dispose(); public void refresh(); - public MemoryByte[] getBytes(BigInteger address, int bytesRequested) throws DebugException; + public TraditionalMemoryByte[] getBytes(BigInteger address, int bytesRequested) throws DebugException; public void archiveDeltas(); - public void setEditedValue(BigInteger address, MemoryByte[] bytes); + public void setEditedValue(BigInteger address, TraditionalMemoryByte[] bytes); public void clearEditBuffer(); public void writeEditBuffer(); public boolean containsEditedCell(BigInteger address); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index f826065d252..16154a7a68e 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -32,6 +32,7 @@ import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; @@ -106,7 +107,7 @@ public class Rendering extends Composite implements IDebugEventSetListener private boolean fIsTargetLittleEndian = false; private boolean fIsDisplayLittleEndian = false; - + // constants used to identify radix public final static int RADIX_HEX = 1; @@ -482,6 +483,16 @@ public class Rendering extends Composite implements IDebugEventSetListener { return fSelection; } + + protected int getHistoryDepth() + { + return fViewportCache.getHistoryDepth(); + } + + protected void setHistoryDepth(int depth) + { + fViewportCache.setHistoryDepth(depth); + } public void logError(String message, Exception e) { @@ -609,7 +620,7 @@ public class Rendering extends Composite implements IDebugEventSetListener return fViewportCache; } - public MemoryByte[] getBytes(BigInteger address, int bytes) + public TraditionalMemoryByte[] getBytes(BigInteger address, int bytes) throws DebugException { return getViewportCache().getBytes(address, bytes); @@ -652,7 +663,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } return false; - } + } } @@ -662,7 +673,7 @@ public class Rendering extends Composite implements IDebugEventSetListener BigInteger end; - MemoryByte[] bytes; + TraditionalMemoryByte[] bytes; public MemoryUnit clone() { @@ -670,9 +681,9 @@ public class Rendering extends Composite implements IDebugEventSetListener b.start = this.start; b.end = this.end; - b.bytes = new MemoryByte[this.bytes.length]; + b.bytes = new TraditionalMemoryByte[this.bytes.length]; for(int i = 0; i < this.bytes.length; i++) - b.bytes[i] = new MemoryByte(this.bytes[i].getValue()); + b.bytes[i] = new TraditionalMemoryByte(this.bytes[i].getValue()); return b; } @@ -694,8 +705,10 @@ public class Rendering extends Composite implements IDebugEventSetListener protected MemoryUnit fCache = null; - protected MemoryUnit fHistoryCache = null; + protected MemoryUnit fHistoryCache[] = new MemoryUnit[0]; + protected int fHistoryDepth = 0; + public ViewportCache() { start(); @@ -709,6 +722,17 @@ public class Rendering extends Composite implements IDebugEventSetListener this.notify(); } } + + public int getHistoryDepth() + { + return fHistoryDepth; + } + + public void setHistoryDepth(int depth) + { + fHistoryDepth = depth; + fHistoryCache = new MemoryUnit[fHistoryDepth]; + } public void refresh() { @@ -737,8 +761,7 @@ public class Rendering extends Composite implements IDebugEventSetListener private void queueRequest(BigInteger startAddress, BigInteger endAddress) { AddressPair pair = new AddressPair(startAddress, endAddress); - if(!pair.equals(fLastQueued)) - queue(pair); + queue(pair); } private void queueRequestArchiveDeltas() @@ -751,8 +774,11 @@ public class Rendering extends Composite implements IDebugEventSetListener { synchronized(fQueue) { - fQueue.addElement(element); - fLastQueued = element; + if(!(fQueue.size() > 0 && element.equals(fLastQueued))) + { + fQueue.addElement(element); + fLastQueued = element; + } } synchronized(this) { @@ -789,7 +815,10 @@ public class Rendering extends Composite implements IDebugEventSetListener } if(archiveDeltas) { - fHistoryCache = fCache.clone(); + for(int i = fViewportCache.getHistoryDepth() - 1; i > 0; i--) + fHistoryCache[i] = fHistoryCache[i - 1]; + + fHistoryCache[0] = fCache.clone(); } else if(pair != null) { @@ -837,9 +866,9 @@ public class Rendering extends Composite implements IDebugEventSetListener final MemoryByte readBytes[] = memoryBlock .getBytesFromAddress(startAddress, units); - MemoryByte cachedBytes[] = new MemoryByte[readBytes.length]; + TraditionalMemoryByte cachedBytes[] = new TraditionalMemoryByte[readBytes.length]; for(int i = 0; i < readBytes.length; i++) - cachedBytes[i] = new MemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); + cachedBytes[i] = new TraditionalMemoryByte(readBytes[i].getValue(), readBytes[i].getFlags()); // derive the target endian from the read MemoryBytes. if (cachedBytes.length > 0) { @@ -855,7 +884,7 @@ public class Rendering extends Composite implements IDebugEventSetListener if(addressableSize.compareTo(BigInteger.ONE) != 0) { int unitSize = addressableSize.intValue(); - MemoryByte cachedBytesAsByteSequence[] = new MemoryByte[cachedBytes.length]; + TraditionalMemoryByte cachedBytesAsByteSequence[] = new TraditionalMemoryByte[cachedBytes.length]; for(int unit = 0; unit < units; unit++) { for(int unitbyte = 0; unitbyte < unitSize; unitbyte++) @@ -867,40 +896,43 @@ public class Rendering extends Composite implements IDebugEventSetListener } } - final MemoryByte[] cachedBytesFinal = cachedBytes; + final TraditionalMemoryByte[] cachedBytesFinal = cachedBytes; Display.getDefault().asyncExec(new Runnable() { public void run() { // generate deltas - if(fHistoryCache != null && fHistoryCache.isValid()) - { - BigInteger maxStart = startAddress - .max(fHistoryCache.start); - BigInteger minEnd = endAddress - .min(fHistoryCache.end).subtract( - BigInteger.valueOf(1)); - - BigInteger overlapLength = minEnd - .subtract(maxStart); - if(overlapLength.compareTo(BigInteger.valueOf(0)) > 0) - { - // there is overlap - - int offsetIntoOld = maxStart.subtract( - fHistoryCache.start).intValue(); - int offsetIntoNew = maxStart.subtract( - startAddress).intValue(); - - for(int i = overlapLength.intValue(); i >= 0; i--) - { - cachedBytesFinal[offsetIntoNew + i] - .setChanged(cachedBytesFinal[offsetIntoNew - + i].getValue() != fHistoryCache.bytes[offsetIntoOld - + i].getValue()); - } - } - } + for(int historyIndex = 0; historyIndex < getHistoryDepth(); historyIndex++) + { + if(fHistoryCache[historyIndex] != null && fHistoryCache[historyIndex].isValid()) + { + BigInteger maxStart = startAddress + .max(fHistoryCache[historyIndex].start); + BigInteger minEnd = endAddress + .min(fHistoryCache[historyIndex].end).subtract( + BigInteger.valueOf(1)); + + BigInteger overlapLength = minEnd + .subtract(maxStart); + if(overlapLength.compareTo(BigInteger.valueOf(0)) > 0) + { + // there is overlap + + int offsetIntoOld = maxStart.subtract( + fHistoryCache[historyIndex].start).intValue(); + int offsetIntoNew = maxStart.subtract( + startAddress).intValue(); + + for(int i = overlapLength.intValue(); i >= 0; i--) + { + cachedBytesFinal[offsetIntoNew + i] + .setChanged(historyIndex, cachedBytesFinal[offsetIntoNew + + i].getValue() != fHistoryCache[historyIndex].bytes[offsetIntoOld + + i].getValue()); + } + } + } + } fCache = new MemoryUnit(); fCache.start = startAddress; @@ -910,8 +942,8 @@ public class Rendering extends Composite implements IDebugEventSetListener // If the history does not exist, populate the history with the just populated cache. This solves the // use case of 1) connect to target; 2) edit memory before the first suspend debug event; 3) paint // differences in changed color. - if(fHistoryCache == null) - fHistoryCache = fCache.clone(); + if(fHistoryCache[0] == null) + fHistoryCache[0] = fCache.clone(); Rendering.this.redrawPanes(); } @@ -927,7 +959,7 @@ public class Rendering extends Composite implements IDebugEventSetListener } // bytes will be fetched from cache - public MemoryByte[] getBytes(BigInteger address, int bytesRequested) + public TraditionalMemoryByte[] getBytes(BigInteger address, int bytesRequested) throws DebugException { assert Thread.currentThread().equals( @@ -952,7 +984,7 @@ public class Rendering extends Composite implements IDebugEventSetListener if(contains) { int offset = address.subtract(fCache.start).intValue(); - MemoryByte bytes[] = new MemoryByte[bytesRequested]; + TraditionalMemoryByte bytes[] = new TraditionalMemoryByte[bytesRequested]; for(int i = 0; i < bytes.length; i++) { bytes[i] = fCache.bytes[offset + i]; @@ -961,10 +993,10 @@ public class Rendering extends Composite implements IDebugEventSetListener return bytes; } - MemoryByte bytes[] = new MemoryByte[bytesRequested]; + TraditionalMemoryByte bytes[] = new TraditionalMemoryByte[bytesRequested]; for(int i = 0; i < bytes.length; i++) { - bytes[i] = new MemoryByte(); + bytes[i] = new TraditionalMemoryByte(); bytes[i].setReadable(false); } @@ -983,13 +1015,13 @@ public class Rendering extends Composite implements IDebugEventSetListener return fEditBuffer.containsKey(address); } - private MemoryByte[] getEditedMemory(BigInteger address) + private TraditionalMemoryByte[] getEditedMemory(BigInteger address) { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages .getString("TraditionalRendering.CALLED_ON_NON_DISPATCH_THREAD"); //$NON-NLS-1$ - return (MemoryByte[]) fEditBuffer.get(address); + return (TraditionalMemoryByte[]) fEditBuffer.get(address); } public void clearEditBuffer() @@ -1014,7 +1046,7 @@ public class Rendering extends Composite implements IDebugEventSetListener while(iterator.hasNext()) { BigInteger address = (BigInteger) iterator.next(); - MemoryByte[] bytes = (MemoryByte[]) fEditBuffer + TraditionalMemoryByte[] bytes = (TraditionalMemoryByte[]) fEditBuffer .get(address); byte byteValue[] = new byte[bytes.length]; @@ -1038,7 +1070,7 @@ public class Rendering extends Composite implements IDebugEventSetListener clearEditBuffer(); } - public void setEditedValue(BigInteger address, MemoryByte[] bytes) + public void setEditedValue(BigInteger address, TraditionalMemoryByte[] bytes) { assert Thread.currentThread().equals( Display.getDefault().getThread()) : TraditionalRenderingMessages diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java index 799e43c7be9..d6c0cf48f57 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TextPane.java @@ -242,7 +242,7 @@ public class TextPane extends AbstractPane * columns + col) * fRendering.getAddressesPerColumn())); - MemoryByte bytes[] = fRendering.getBytes(cellAddress, + TraditionalMemoryByte bytes[] = fRendering.getBytes(cellAddress, fRendering.getBytesPerColumn()); if(fRendering.getSelection().isSelected(cellAddress)) @@ -281,31 +281,46 @@ public class TextPane extends AbstractPane } - protected void applyCustomColor(GC gc, MemoryByte bytes[], int col) - { - // TODO reuse, this could be in the abstract base - // TODO consider adding finer granularity? - boolean anyByteChanged = false; - for(int n = 0; n < bytes.length && !anyByteChanged; n++) - if(bytes[n].isChanged()) - anyByteChanged = true; - - // TODO consider adding finer granularity? + // Allow subclasses to override this method to do their own coloring + protected void applyCustomColor(GC gc, TraditionalMemoryByte bytes[], int col) + { + // TODO consider adding finer granularity? boolean anyByteEditing = false; for(int n = 0; n < bytes.length && !anyByteEditing; n++) if(bytes[n] instanceof TraditionalMemoryByte) - if(((TraditionalMemoryByte) bytes[n]).isEdited()) - anyByteEditing = true; - - if(anyByteEditing) - gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); - else if(anyByteChanged) - gc.setForeground(fRendering.getTraditionalRendering().getColorChanged()); - else if(isOdd(col)) - gc.setForeground(fRendering.getTraditionalRendering().getColorText()); - else - gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); - - gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); - } + if(((TraditionalMemoryByte) bytes[n]).isEdited()) + anyByteEditing = true; + + if(isOdd(col)) + gc.setForeground(fRendering.getTraditionalRendering().getColorText()); + else + gc.setForeground(fRendering.getTraditionalRendering().getColorTextAlternate()); + gc.setBackground(fRendering.getTraditionalRendering().getColorBackground()); + + if(anyByteEditing) + { + gc.setForeground(fRendering.getTraditionalRendering().getColorEdit()); + } + else + { + boolean isColored = false; + for(int i = 0; i < fRendering.getHistoryDepth() && !isColored; i++) + { + // TODO consider adding finer granularity? + for(int n = 0; n < bytes.length; n++) + { + if(bytes[n].isChanged(i)) + { + if(i == 0) + gc.setForeground(fRendering.getTraditionalRendering().getColorsChanged()[i]); + else + gc.setBackground(fRendering.getTraditionalRendering().getColorsChanged()[i]); + isColored = true; + break; + } + } + } + + } + } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 8b27dbdfd2f..945df88dc9e 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -352,6 +352,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe private Color colorBackground; private Color colorChanged; + private Color colorsChanged[] = null; private Color colorEdit; private Color colorSelection; private Color colorText; @@ -417,12 +418,18 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe if(colorTextAlternate != null) colorTextAlternate.dispose(); colorTextAlternate = null; + + disposeChangedColors(); } public void applyPreferences() { if(!fRendering.isDisposed()) { + IPreferenceStore store = TraditionalRenderingPlugin.getDefault().getPreferenceStore(); + + fRendering.setHistoryDepth(store.getInt(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT)); + fRendering.setBackground(getColorBackground()); AbstractPane panes[] = fRendering.getRenderingPanes(); @@ -448,6 +455,41 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe return colorChanged; } + private void disposeChangedColors() + { + if(colorsChanged != null) + for(int i = 0; i < colorsChanged.length; i++) + colorsChanged[i].dispose(); + colorsChanged = null; + } + + public Color[] getColorsChanged() + { + if(colorsChanged != null && colorsChanged.length != fRendering.getHistoryDepth()) + { + disposeChangedColors(); + } + + if(colorsChanged == null) + { + colorsChanged = new Color[fRendering.getHistoryDepth()]; + colorsChanged[0] = colorChanged; + int shades = fRendering.getHistoryDepth() + 4; + int red = (255 - colorChanged.getRed()) / shades; + int green = (255 - colorChanged.getGreen()) / shades; + int blue = (255 - colorChanged.getBlue()) / shades; + for(int i = 1; i < fRendering.getHistoryDepth(); i++) + { + colorsChanged[i] = new Color(colorChanged.getDevice(), + colorChanged.getRed() + ((shades - i) * red), + colorChanged.getGreen() + ((shades - i) * green), + colorChanged.getBlue() + ((shades - i) * blue)); + } + } + + return colorsChanged; + } + public Color getColorEdit() { return colorEdit; @@ -1060,6 +1102,7 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe { if(this.fRendering != null) this.fRendering.dispose(); + disposeColors(); super.dispose(); } @@ -1126,11 +1169,23 @@ class TraditionalMemoryByte extends MemoryByte implements IMemoryByte { private boolean isEdited = false; + private boolean[] changeHistory = new boolean[0]; + + public TraditionalMemoryByte() + { + super(); + } + public TraditionalMemoryByte(byte byteValue) { super(byteValue); } + public TraditionalMemoryByte(byte byteValue, byte byteFlags) + { + super(byteValue, byteFlags); + } + public boolean isEdited() { return isEdited; @@ -1140,6 +1195,26 @@ class TraditionalMemoryByte extends MemoryByte implements IMemoryByte { isEdited = edited; } + + public boolean isChanged(int historyDepth) + { + return changeHistory.length > historyDepth && changeHistory[historyDepth]; + } + + public void setChanged(int historyDepth, boolean changed) + { + if(historyDepth >= changeHistory.length) + { + boolean newChangeHistory[] = new boolean[historyDepth + 1]; + System.arraycopy(changeHistory, 0, newChangeHistory, 0, changeHistory.length); + changeHistory = newChangeHistory; + } + + changeHistory[historyDepth] = changed; + + if(historyDepth == 0) + this.setChanged(changed); + } } class CopyAction extends Action diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java index c6be1afd5db..b68cb17102b 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceConstants.java @@ -40,4 +40,6 @@ public class TraditionalRenderingPreferenceConstants { public static final String MEM_EDIT_BUFFER_SAVE_ON_ENTER_OR_FOCUS_LOST = "saveOnEnterOrFocusLost"; + public static final String MEM_HISTORY_TRAILS_COUNT = "memoryHistoryTrailsCount"; + } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java index d41e0bb1363..4bb0eea8e48 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceInitializer.java @@ -56,6 +56,8 @@ public class TraditionalRenderingPreferenceInitializer extends AbstractPreferenc store.setDefault(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE, TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE_ON_ENTER_ONLY); + + store.setDefault(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT, "1"); } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java index 1d58cb08055..d90cd43f38a 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java @@ -80,6 +80,9 @@ public class TraditionalRenderingPreferencePage addField(new RadioGroupFieldEditor(TraditionalRenderingPreferenceConstants.MEM_EDIT_BUFFER_SAVE, "Edit Buffer", 1, new String[][] { { "Save on E&nter, Cancel on Focus Lost", "saveOnEnterCancelOnFocusLost" }, { "Save on Enter or Focus L&ost", "saveOnEnterOrFocusLost" } }, getFieldEditorParent())); + + addField(new ScaleFieldEditor(TraditionalRenderingPreferenceConstants.MEM_HISTORY_TRAILS_COUNT, + "History &Trail Levels", getFieldEditorParent(), 1, 10, 1, 1)); } /* (non-Javadoc) From e5ae2a94a7a64a52110a892a7ed16ea53f8e8f10 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 23 Jun 2008 23:33:55 +0000 Subject: [PATCH 072/118] [238189] memory search should be promoted to its own plugin --- .../META-INF/MANIFEST.MF | 3 +- .../icons/export.png | Bin 227 -> 0 bytes .../icons/import.png | Bin 236 -> 0 bytes .../plugin.properties | 2 - .../plugin.xml | 14 +- .../.classpath | 7 + .../.project | 17 + .../META-INF/MANIFEST.MF | 17 + .../about.html | 24 ++ .../build.properties | 9 + .../plugin.xml | 39 ++ .../debug/ui/memory/search}/FindAction.java | 34 +- .../ui/memory/search}/FindReplaceDialog.java | 397 +++++++++++++----- .../ui/memory/search/MemorySearchPlugin.java | 53 +++ .../ui/memory/search/MemorySearchResult.java | 86 ++++ .../search/MemorySearchResultsPage.java | 285 +++++++++++++ .../dd/debug/ui/memory/search}/Messages.java | 6 +- .../ui/memory/search}/messages.properties | 6 + 18 files changed, 867 insertions(+), 132 deletions(-) delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png delete mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/.classpath create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/.project create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/about.html create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/build.properties create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml rename plugins/{org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions => org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search}/FindAction.java (72%) rename plugins/{org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions => org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search}/FindReplaceDialog.java (68%) create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchPlugin.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java rename plugins/{org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions => org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search}/Messages.java (85%) rename plugins/{org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions => org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search}/messages.properties (74%) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index ee4f0610be2..10cfe9cdfd3 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Require-Bundle: org.eclipse.debug.core, org.eclipse.core.runtime, org.eclipse.swt, org.eclipse.jface, - org.eclipse.ui + org.eclipse.ui, + org.eclipse.search;bundle-version="3.4.0" Eclipse-LazyStart: true Bundle-Activator: org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPlugin Bundle-Vendor: Eclipse.org diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/export.png deleted file mode 100644 index 91b2198825cb30c5498bfd5a951713caefbe04d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmV<90382`P)B1hhOleLjth?YXxAtRKKxtaeGO33r}+Be&TkS#r) z$NEy2d!zQO8vtmlp{)kR12rL5j6y_26!Z1WT+Z|O9Cagw7IFJu8LpH;RtUhU4(2XC d&PY=I4-2;7ZC}Rka$5iZ002ovPDHLkV1oJvTulG~ diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/icons/import.png deleted file mode 100644 index fa02317c7fd36390f9430f68cc5b02e379a9dc94..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmVk0E<+)KSc5@Yl?tim;9`~XE}6D+WCDT>HjjulUd@M)ln#zKv* - - - - - - + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/.classpath b/plugins/org.eclipse.dd.debug.ui.memory.search/.classpath new file mode 100644 index 00000000000..751c8f2e504 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/.project b/plugins/org.eclipse.dd.debug.ui.memory.search/.project new file mode 100644 index 00000000000..acc37f5d819 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/.project @@ -0,0 +1,17 @@ + + + org.eclipse.dd.debug.ui.memory.search + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..f8cd624315b --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Memory Search +Bundle-SymbolicName: org.eclipse.dd.debug.ui.memory.search;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Localization: plugin +Require-Bundle: org.eclipse.debug.core, + org.eclipse.debug.ui, + org.eclipse.core.runtime, + org.eclipse.swt, + org.eclipse.jface, + org.eclipse.ui, + org.eclipse.search;bundle-version="3.4.0" +Eclipse-LazyStart: true +Bundle-Activator: org.eclipse.dd.debug.ui.memory.search.MemorySearchPlugin +Bundle-Vendor: Eclipse.org +Import-Package: org.eclipse.debug.ui.memory diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/about.html b/plugins/org.eclipse.dd.debug.ui.memory.search/about.html new file mode 100644 index 00000000000..cb740ae8bc8 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/about.html @@ -0,0 +1,24 @@ + + + + +About +

About This Content

+ +

June 5, 2007

+

License

+ +

The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.

+ +

If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.

+ + \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/build.properties b/plugins/org.eclipse.dd.debug.ui.memory.search/build.properties new file mode 100644 index 00000000000..bbc45d3cdc8 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/build.properties @@ -0,0 +1,9 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + plugin.properties,\ + .,\ + plugin.xml,\ + about.html,\ + icons/ + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml new file mode 100644 index 00000000000..53860b0f809 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindAction.java similarity index 72% rename from plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java rename to plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindAction.java index 6d06fc17f61..fe6f3f5d7cf 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2008 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 @@ -9,7 +9,9 @@ * Ted R Williams (Wind River Systems, Inc.) - initial implementation *******************************************************************************/ -package org.eclipse.dd.debug.memory.renderings.actions; +package org.eclipse.dd.debug.ui.memory.search; + +import java.util.Properties; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; @@ -26,6 +28,8 @@ import org.eclipse.ui.IViewPart; public class FindAction implements IViewActionDelegate { private MemoryView fView; + + private static Properties fSearchDialogProperties = new Properties(); public void init(IViewPart view) { if (view instanceof MemoryView) @@ -57,16 +61,32 @@ public class FindAction implements IViewActionDelegate { } Shell shell = DebugUIPlugin.getShell(); - FindReplaceDialog dialog = new FindReplaceDialog(shell, (IMemoryBlockExtension) memBlock, fView); - dialog.open(); - - Object results[] = dialog.getResult(); + FindReplaceDialog dialog = new FindReplaceDialog(shell, (IMemoryBlockExtension) memBlock, + fView, (Properties) fSearchDialogProperties); + if(action.getText().equalsIgnoreCase("Find Next")) + { + if(fSearchDialogProperties.getProperty(FindReplaceDialog.SEARCH_ENABLE_FIND_NEXT, "false").equals("true")) + { + dialog.performFindNext(); + } + return; + } + else + { + dialog.open(); + + Object results[] = dialog.getResult(); + } } } public void selectionChanged(IAction action, ISelection selection) { - + if(action.getText().equalsIgnoreCase("Find Next")) + { + action.setEnabled(fSearchDialogProperties.getProperty(FindReplaceDialog.SEARCH_ENABLE_FIND_NEXT, "false") + .equals("true")); + } } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java similarity index 68% rename from plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java rename to plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index de0a9d3232f..6b822ab54a3 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2008 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 @@ -9,14 +9,16 @@ * Ted R Williams (Wind River Systems, Inc.) - initial implementation *******************************************************************************/ -package org.eclipse.dd.debug.memory.renderings.actions; +package org.eclipse.dd.debug.ui.memory.search; import java.math.BigInteger; +import java.util.Properties; import java.util.StringTokenizer; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.DebugException; @@ -25,10 +27,15 @@ import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.search.ui.ISearchQuery; +import org.eclipse.search.ui.ISearchResult; +import org.eclipse.search.ui.NewSearchUI; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -65,6 +72,7 @@ public class FindReplaceDialog extends SelectionDialog private Combo fEndText; private Button fFindButton; + private Button fFindAllButton; private Button fReplaceButton; private Button fReplaceFindButton; private Button fReplaceAllButton; @@ -72,18 +80,39 @@ public class FindReplaceDialog extends SelectionDialog private MemoryView fMemoryView; - Button fFormatAsciiButton; - Button fFormatHexButton; - Button fFormatOctalButton; - Button fFormatBinaryButton; - Button fFormatDecimalButton; - Button fFormatByteSequenceButton; + private Button fFormatAsciiButton; + private Button fFormatHexButton; + private Button fFormatOctalButton; + private Button fFormatBinaryButton; + private Button fFormatDecimalButton; + private Button fFormatByteSequenceButton; - Button fCaseInSensitiveCheckbox; + private Button fCaseInSensitiveCheckbox; - Button fForwardButton; + private Button fWrapCheckbox; - public FindReplaceDialog(Shell parent, IMemoryBlockExtension memoryBlock, MemoryView memoryView) + private Button fForwardButton; + + private Properties fProperties; + + protected final static String SEARCH_FIND = "SEARCH_FIND"; //$NON-NLS-1$ + protected final static String SEARCH_REPLACE = "SEARCH_REPLACE"; //$NON-NLS-1$ + protected final static String SEARCH_START = "SEARCH_START"; //$NON-NLS-1$ + protected final static String SEARCH_END = "SEARCH_END"; //$NON-NLS-1$ + protected final static String SEARCH_LAST_FOUND = "SEARCH_LAST_FOUND"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT = "SEARCH_FORMAT"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_ASCII = "SEARCH_FORMAT_ASCII"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_HEX = "SEARCH_FORMAT_HEX"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_OCTAL = "SEARCH_FORMAT_OCTAL"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_BINARY = "SEARCH_FORMAT_BINARY"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_DECIMAL = "SEARCH_FORMAT_DECIMAL"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_BYTESEQUENCE = "SEARCH_FORMAT_BYTESEQUENCE"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_CASEINSENSTIVE = "SEARCH_FORMAT_CASEINSENSTIVE"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_FORWARD = "SEARCH_FORMAT_FORWARD"; //$NON-NLS-1$ + protected final static String SEARCH_FORMAT_WRAP = "SEARCH_FORMAT_WRAP"; //$NON-NLS-1$ + protected final static String SEARCH_ENABLE_FIND_NEXT = "SEARCH_ENABLE_FIND_NEXT"; //$NON-NLS-1$ + + public FindReplaceDialog(Shell parent, IMemoryBlockExtension memoryBlock, MemoryView memoryView, Properties properties) { super(parent); super.setTitle(Messages.getString("FindReplaceDialog.Title")); //$NON-NLS-1$ @@ -91,6 +120,7 @@ public class FindReplaceDialog extends SelectionDialog fMemoryBlock = memoryBlock; fMemoryView = memoryView; + fProperties = properties; this.setBlockOnOpen(false); } @@ -125,17 +155,17 @@ public class FindReplaceDialog extends SelectionDialog } else if(fFormatHexButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0X") + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0X") //$NON-NLS-1$ ? fFindText.getText().substring(2) : fFindText.getText(), 16), 16); } else if(fFormatOctalButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().startsWith("0") + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().startsWith("0") //$NON-NLS-1$ ? fFindText.getText().substring(1) : fFindText.getText(), 8), 8); } else if(fFormatBinaryButton.getSelection()) { - phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0B") + phrase = new BigIntegerSearchPhrase(new BigInteger(fFindText.getText().toUpperCase().startsWith("0B") //$NON-NLS-1$ ? fFindText.getText().substring(2) : fFindText.getText(), 2), 2); } else if(fFormatDecimalButton.getSelection()) @@ -153,14 +183,14 @@ public class FindReplaceDialog extends SelectionDialog protected byte[] parseByteSequence(String s) { Vector sequence = new Vector(); - StringTokenizer st = new StringTokenizer(s, " "); + StringTokenizer st = new StringTokenizer(s, " "); //$NON-NLS-1$ while(st.hasMoreElements()) { String element = ((String) st.nextElement()).trim(); if(element.length() > 0) { BigInteger value; - if(element.toUpperCase().startsWith("0X")) + if(element.toUpperCase().startsWith("0X")) //$NON-NLS-1$ value = new BigInteger(element.substring(2), 16); else value = new BigInteger(element, 10); @@ -184,11 +214,11 @@ public class FindReplaceDialog extends SelectionDialog if(fFormatAsciiButton.getSelection()) return fReplaceText.getText().getBytes(); else if(fFormatHexButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0X") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 16).toByteArray()); + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0X") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 16).toByteArray()); //$NON-NLS-1$ else if(fFormatOctalButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().startsWith("0") ? fReplaceText.getText().substring(1) : fReplaceText.getText(), 8).toByteArray()); + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().startsWith("0") ? fReplaceText.getText().substring(1) : fReplaceText.getText(), 8).toByteArray()); //$NON-NLS-1$ else if(fFormatBinaryButton.getSelection()) - return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0B") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 2).toByteArray()); + return removeZeroPrefixByte(new BigInteger(fReplaceText.getText().toUpperCase().startsWith("0B") ? fReplaceText.getText().substring(2) : fReplaceText.getText(), 2).toByteArray()); //$NON-NLS-1$ else if(fFormatDecimalButton.getSelection()) return removeZeroPrefixByte(new BigInteger(fReplaceText.getText(), 10).toByteArray()); else if(fFormatByteSequenceButton.getSelection()) @@ -201,6 +231,7 @@ public class FindReplaceDialog extends SelectionDialog * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { + fFindButton = createButton(parent, 10, Messages.getString("FindReplaceDialog.ButtonFind"), true); //$NON-NLS-1$ fFindButton.addSelectionListener(new SelectionListener() { @@ -212,6 +243,17 @@ public class FindReplaceDialog extends SelectionDialog } }); + fFindAllButton = createButton(parent, 10, Messages.getString("FindReplaceDialog.ButtonFindAll"), true); //$NON-NLS-1$ + fFindAllButton.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) { } + + public void widgetSelected(SelectionEvent e) { + performFind(getUserStart(), getUserEnd(), getSearchPhrase(), getIsDirectionForward(), null, true, false); + cancelPressed(); + } + }); + fReplaceFindButton = createButton(parent, 11, Messages.getString("FindReplaceDialog.ButtonReplaceFind"), false); //$NON-NLS-1$ fReplaceFindButton.addSelectionListener(new SelectionListener() { @@ -271,6 +313,31 @@ public class FindReplaceDialog extends SelectionDialog */ protected void cancelPressed() { + fProperties.setProperty(SEARCH_FIND, fFindText.getText()); + fProperties.setProperty(SEARCH_REPLACE, fReplaceText.getText()); + fProperties.setProperty(SEARCH_START, fStartText.getText()); + fProperties.setProperty(SEARCH_END, fEndText.getText()); + if(fFormatAsciiButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_ASCII); + else if(fFormatBinaryButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_BINARY); + else if(fFormatByteSequenceButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_BYTESEQUENCE); + else if(fFormatDecimalButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_DECIMAL); + else if(fFormatHexButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_HEX); + else if(fFormatOctalButton.getSelection()) + fProperties.setProperty(SEARCH_FORMAT, SEARCH_FORMAT_OCTAL); + + fProperties.setProperty(SEARCH_FORMAT_FORWARD, "" + fForwardButton.getSelection()); + + fProperties.setProperty(FindReplaceDialog.SEARCH_FORMAT_CASEINSENSTIVE, "" + fCaseInSensitiveCheckbox.getSelection()); + + fProperties.setProperty(FindReplaceDialog.SEARCH_FORMAT_WRAP, "" + fWrapCheckbox.getSelection()); + + fProperties.setProperty(SEARCH_ENABLE_FIND_NEXT, "false"); + setResult(null); super.cancelPressed(); @@ -280,7 +347,7 @@ public class FindReplaceDialog extends SelectionDialog * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { - setSelectionResult(new Object[]{ }); + setSelectionResult(new Object[]{ fProperties }); super.okPressed(); } @@ -322,7 +389,7 @@ public class FindReplaceDialog extends SelectionDialog } catch(Throwable ex) { - + // do nothing } fFindButton.setEnabled(valid); @@ -357,6 +424,7 @@ public class FindReplaceDialog extends SelectionDialog } catch(DebugException de) { + // do nothing } if(base == null) @@ -387,6 +455,7 @@ public class FindReplaceDialog extends SelectionDialog } catch(DebugException de) { + // do nothing } if(start == null) @@ -405,6 +474,7 @@ public class FindReplaceDialog extends SelectionDialog } catch(DebugException de) { + // do nothing } if(end == null) @@ -460,6 +530,7 @@ public class FindReplaceDialog extends SelectionDialog data.left = new FormAttachment(fReplaceText, 0, SWT.LEFT); data.width = 260; fFindText.setLayoutData(data); + fFindText.setText(fProperties.getProperty(FindReplaceDialog.SEARCH_FIND, "")); data = new FormData(); data.top = new FormAttachment(fFindText, 0, SWT.CENTER); @@ -477,6 +548,7 @@ public class FindReplaceDialog extends SelectionDialog data.left = new FormAttachment(replaceLabel); data.width = 260; fReplaceText.setLayoutData(data); + fReplaceText.setText(fProperties.getProperty(FindReplaceDialog.SEARCH_REPLACE, "")); // group direction @@ -493,6 +565,8 @@ public class FindReplaceDialog extends SelectionDialog fForwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ + fForwardButton.setSelection(fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true")); + backwardButton.setSelection(!fForwardButton.getSelection()); data = new FormData(); data.top = new FormAttachment(fReplaceText); @@ -539,6 +613,10 @@ public class FindReplaceDialog extends SelectionDialog fStartText.setItems(removeNullElements(new String[] { getViewportStart(), getStart(), getEnd(), getMemoryBlockBaseAddress() })); fEndText.setItems(removeNullElements(new String[] { getEnd(), getStart(), getMemoryBlockBaseAddress(), getViewportStart() })); + if(fProperties.getProperty(FindReplaceDialog.SEARCH_START) != null) + fStartText.add(fProperties.getProperty(FindReplaceDialog.SEARCH_START), 0); + if(fProperties.getProperty(FindReplaceDialog.SEARCH_END) != null) + fEndText.add(fProperties.getProperty(FindReplaceDialog.SEARCH_END), 0); fStartText.select(0); fEndText.select(0); @@ -551,7 +629,7 @@ public class FindReplaceDialog extends SelectionDialog fFormatAsciiButton = new Button(formatGroup, SWT.RADIO); fFormatAsciiButton.setText(Messages.getString("FindReplaceDialog.ButtonASCII")); //$NON-NLS-1$ - + fFormatHexButton = new Button(formatGroup, SWT.RADIO); fFormatHexButton.setText(Messages.getString("FindReplaceDialog.ButtonHexadecimal")); //$NON-NLS-1$ @@ -567,6 +645,19 @@ public class FindReplaceDialog extends SelectionDialog fFormatByteSequenceButton = new Button(formatGroup, SWT.RADIO); fFormatByteSequenceButton.setText(Messages.getString("FindReplaceDialog.ButtonByteSequence")); //$NON-NLS-1$ + final String format = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT, FindReplaceDialog.SEARCH_FORMAT_ASCII); + + Display.getDefault().asyncExec(new Runnable(){ + public void run() { + fFormatAsciiButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_ASCII)); + fFormatOctalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_OCTAL)); + fFormatBinaryButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BINARY)); + fFormatDecimalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_DECIMAL)); + fFormatHexButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_HEX)); + fFormatByteSequenceButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BYTESEQUENCE)); + } + }); + data = new FormData(); data.top = new FormAttachment(rangeGroup); formatGroup.setLayoutData(data); @@ -590,9 +681,9 @@ public class FindReplaceDialog extends SelectionDialog // wrap - Button wrapCheckbox = new Button(optionsGroup, SWT.CHECK); - wrapCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonWrapSearch")); //$NON-NLS-1$ - wrapCheckbox.setEnabled(false); // TODO implement wrap + fWrapCheckbox = new Button(optionsGroup, SWT.CHECK); + fWrapCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonWrapSearch")); //$NON-NLS-1$ + fWrapCheckbox.setEnabled(false); // TODO implement wrap fCaseInSensitiveCheckbox = new Button(optionsGroup, SWT.CHECK); fCaseInSensitiveCheckbox.setText(Messages.getString("FindReplaceDialog.ButtonCaseInsensitive")); //$NON-NLS-1$ @@ -718,16 +809,86 @@ public class FindReplaceDialog extends SelectionDialog return bytes; } - private void performFind(final BigInteger start, final BigInteger end, final SearchPhrase searchPhrase, - final boolean searchForward, final byte[] replaceData, final boolean isReplaceAll, final boolean replaceThenFind) + private BigInteger parseHexBigInteger(String s) { - Job job = new Job("Searching memory for " + searchPhrase){ //$NON-NLS-1$ - public IStatus run(IProgressMonitor monitor) { + if(s.toUpperCase().startsWith("0X")) + return new BigInteger(s.substring(2), 16); + else + return new BigInteger(s, 16); + } + + protected void performFindNext() + { + try + { + BigInteger start = parseHexBigInteger(fProperties.getProperty(SEARCH_LAST_FOUND)); + BigInteger end = parseHexBigInteger(fProperties.getProperty(SEARCH_END)); + boolean searchForward = fProperties.getProperty(SEARCH_FORMAT_FORWARD, "false").equals("true"); + boolean caseInSensitive = fProperties.getProperty(SEARCH_FORMAT_CASEINSENSTIVE, "false").equals("true"); + if(searchForward) + start = start.add(BigInteger.ONE); + else + start = start.subtract(BigInteger.ONE); + SearchPhrase phrase = null; + String findText = fProperties.getProperty(SEARCH_FIND); + + if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_ASCII)) + phrase = new AsciiSearchPhrase(findText, caseInSensitive); + else if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_HEX)) + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.toUpperCase().startsWith("0X") //$NON-NLS-1$ + ? findText.substring(2) : findText, 16), 16); + else if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_OCTAL)) + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.startsWith("0") //$NON-NLS-1$ + ? findText.substring(1) : findText, 8), 8); + else if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_BINARY)) + phrase = new BigIntegerSearchPhrase(new BigInteger(findText.toUpperCase().startsWith("0B") //$NON-NLS-1$ + ? findText.substring(2) : findText, 2), 2); + else if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_DECIMAL)) + phrase = new BigIntegerSearchPhrase(new BigInteger(findText, 10), 10); + else if(fProperties.getProperty(SEARCH_FORMAT).equals(SEARCH_FORMAT_BYTESEQUENCE)) + phrase = new ByteSequenceSearchPhrase(findText); + + performFind(start, end, phrase, searchForward, null, false, false); + + } + catch(Exception e) + { + MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.MemorySearchFailure"), e); + } + } + + private void performFind(final BigInteger start, final BigInteger end, final SearchPhrase searchPhrase, + final boolean searchForward, final byte[] replaceData, final boolean all, final boolean replaceThenFind) + { + final ISearchQuery query = new IMemorySearchQuery() + { + private ISearchResult fSearchResult = null; + + public boolean canRerun() { + return false; + } + + public boolean canRunInBackground() { + return true; + } + + public String getLabel() { + return Messages.getString("FindReplaceDialog.SearchingMemoryFor") + searchPhrase; //$NON-NLS-1$ + } + + public ISearchResult getSearchResult() { + if(fSearchResult == null) + fSearchResult = new MemorySearchResult(this, Messages.getString("FindReplaceDialog.SearchingMemoryFor") + searchPhrase); //$NON-NLS-1$ + return fSearchResult; + } + + public IStatus run(IProgressMonitor monitor) + throws OperationCanceledException { + BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); BigInteger currentPosition = start; - - + boolean isReplace = replaceData != null; BigInteger jobs = range.subtract(searchPhraseLength); @@ -745,31 +906,81 @@ public class FindReplaceDialog extends SelectionDialog FindReplaceMemoryCache cache = new FindReplaceMemoryCache(); monitor.beginTask(Messages.getString("FindReplaceDialog.SearchingMemoryFor") + searchPhrase, jobs.intValue()); //$NON-NLS-1$ - + boolean matched = false; - while(!matched && - ((searchForward && currentPosition.compareTo(end.subtract(searchPhraseLength)) < 0) - || (!searchForward && currentPosition.compareTo(end) > 0)) - && !monitor.isCanceled()) + while(((searchForward && currentPosition.compareTo(end.subtract(searchPhraseLength)) < 0) + || (!searchForward && currentPosition.compareTo(end) > 0)) && !monitor.isCanceled()) { try { - // TODO cache and reuse previously read bytes? MemoryByte bytes[] = getBytesFromAddress(currentPosition, searchPhraseLength.intValue(), cache); matched = searchPhrase.isMatch(bytes); - } - catch(DebugException e) - { - // TODO log ? - // stop search? preference? - } - - if(!matched) - { + if(matched) + { + if(all && !isReplace) + ((MemorySearchResult) getSearchResult()).addMatch("0x" + currentPosition.toString(16)); //$NON-NLS-1$ + + if(isReplace) + { + try + { + fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), replaceData); + } + catch(DebugException de) + { + MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.MemoryReadFailed"), de); //$NON-NLS-1$ + } + + replaceCount = replaceCount.add(BigInteger.ONE); + } + + if(isReplace && replaceThenFind && replaceCount.compareTo(BigInteger.ONE) == 0) + { + isReplace = false; + matched = false; + } + + if(matched && !all) + { + final BigInteger finalCurrentPosition = currentPosition; + Display.getDefault().asyncExec(new Runnable(){ + + public void run() { + IMemoryRenderingContainer containers[] = getMemoryView().getMemoryRenderingContainers(); + for(int i = 0; i < containers.length; i++) + { + IMemoryRendering rendering = containers[i].getActiveRendering(); + if(rendering instanceof IRepositionableMemoryRendering) + { + try { + ((IRepositionableMemoryRendering) rendering).goToAddress(finalCurrentPosition); + } catch (DebugException e) { + MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ + } + } + } + } + + }); + + fProperties.setProperty(SEARCH_ENABLE_FIND_NEXT, "true"); + fProperties.setProperty(SEARCH_LAST_FOUND, "0x" + finalCurrentPosition.toString(16)); + return Status.OK_STATUS; + } + } + + matched = false; + if(searchForward) currentPosition = currentPosition.add(BigInteger.ONE); else currentPosition = currentPosition.subtract(BigInteger.ONE); + + } + catch(DebugException e) + { + MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.MemorySearchFailure"), e); //$NON-NLS-1$ + return Status.CANCEL_STATUS; } jobCount = jobCount.add(BigInteger.ONE); @@ -777,73 +988,40 @@ public class FindReplaceDialog extends SelectionDialog { jobCount = BigInteger.ZERO; monitor.worked(1); - } - - if(matched) - { - if(isReplace) - { - try - { - fMemoryBlock.setValue(currentPosition.subtract(fMemoryBlock.getBigBaseAddress()), replaceData); - } - catch(DebugException de) - { - // TODO log? - } - - replaceCount = replaceCount.add(BigInteger.ONE); - } - - if(isReplace && replaceThenFind && replaceCount.compareTo(BigInteger.ONE) == 0) - { - isReplace = false; - matched = false; - - if(searchForward) - currentPosition = currentPosition.add(BigInteger.ONE); - else - currentPosition = currentPosition.subtract(BigInteger.ONE); - } - - if(isReplaceAll) - { - matched = false; - - if(searchForward) - currentPosition = currentPosition.add(BigInteger.ONE); - else - currentPosition = currentPosition.subtract(BigInteger.ONE); - } - } + } } if(monitor.isCanceled()) return Status.CANCEL_STATUS; - if(matched) - { - ISelection selection = fMemoryView.getViewPane(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1).getSelectionProvider().getSelection(); - if(selection instanceof StructuredSelection) - { - if(((StructuredSelection) selection).getFirstElement() instanceof IRepositionableMemoryRendering) - { - try - { - ((IRepositionableMemoryRendering) ((StructuredSelection) selection).getFirstElement()).goToAddress(currentPosition); - } - catch(DebugException de) - { - // log - } - } - } - } - return Status.OK_STATUS; } + + public MemoryView getMemoryView() { + return fMemoryView; + } }; - job.schedule(); + + if(all && replaceData == null) + { + Display.getDefault().asyncExec(new Runnable() { + public void run() + { + NewSearchUI.activateSearchResultView(); + NewSearchUI.runQueryInBackground(query); + } + }); + } + else + { + Job job = new Job("Searching memory for " + searchPhrase){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + return query.run(monitor); + } + }; + job.schedule(); + } + } interface SearchPhrase @@ -910,10 +1088,10 @@ public class FindReplaceDialog extends SelectionDialog public String toString() { if(fBytes == null) - return ""; + return ""; //$NON-NLS-1$ StringBuffer buf = new StringBuffer(); for(int i = 0; i < fBytes.length; i++) - buf.append(BigInteger.valueOf(fBytes[i]).toString(16) + " "); + buf.append(BigInteger.valueOf(fBytes[i]).toString(16) + " "); //$NON-NLS-1$ return buf.toString(); } @@ -971,4 +1149,9 @@ public class FindReplaceDialog extends SelectionDialog return processedBytes; } + interface IMemorySearchQuery extends ISearchQuery + { + public MemoryView getMemoryView(); + }; + } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchPlugin.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchPlugin.java new file mode 100644 index 00000000000..f875089e353 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchPlugin.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2007-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.search; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +public class MemorySearchPlugin extends AbstractUIPlugin +{ + private static final String PLUGIN_ID = "org.eclipse.dd.debug.memory.renderings.traditional"; //$NON-NLS-1$ + + private static MemorySearchPlugin plugin; + + public MemorySearchPlugin() + { + super(); + plugin = this; + } + + /** + * Returns the shared instance. + */ + public static MemorySearchPlugin getDefault() { + return plugin; + } + + /** + * Returns the unique identifier for this plugin. + */ + public static String getUniqueIdentifier() { + return PLUGIN_ID; + } + + protected static void logError(String message, Exception e) + { + Status status = new Status(IStatus.ERROR, PLUGIN_ID, + DebugException.INTERNAL_ERROR, message, e); + + getDefault().getLog().log(status); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java new file mode 100644 index 00000000000..32f7fa08958 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2007-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.search; + +import java.util.Enumeration; +import java.util.Vector; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.search.ui.ISearchQuery; +import org.eclipse.search.ui.ISearchResult; +import org.eclipse.search.ui.ISearchResultListener; +import org.eclipse.search.ui.SearchResultEvent; + +public class MemorySearchResult implements ISearchResult +{ + private ISearchQuery fQuery; + private String fLabel; + + private Vector listeners = new Vector(); + + private Vector fMatches = new Vector(); + + public MemorySearchResult(ISearchQuery query, String label) + { + fQuery = query; + fLabel = label; + } + + public ImageDescriptor getImageDescriptor() { + + return null; + } + + public String getLabel() { + return fLabel; + } + + public ISearchQuery getQuery() { + return fQuery; + } + + public String getTooltip() { + + return fLabel; + } + + public String[] getMatches() + { + String matches[] = new String[fMatches.size()]; + for(int i = 0; i < matches.length; i++) + matches[i] = (String) fMatches.elementAt(i); + return matches; + } + + public void addMatch(String address) + { + fMatches.addElement(address); + fireChange(); + } + + private void fireChange() + { + Enumeration en = listeners.elements(); + while(en.hasMoreElements()) + ((ISearchResultListener) en.nextElement()).searchResultChanged(new SearchResultEvent(this) {} ); + } + + public void addListener(ISearchResultListener l) { + listeners.addElement(l); + + } + + public void removeListener(ISearchResultListener l) { + listeners.removeElement(l); + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java new file mode 100644 index 00000000000..4a3cb184fd3 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java @@ -0,0 +1,285 @@ +/******************************************************************************* + * Copyright (c) 2007-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.search; + +import java.math.BigInteger; + +import org.eclipse.dd.debug.ui.memory.search.FindReplaceDialog.IMemorySearchQuery; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.search.ui.IQueryListener; +import org.eclipse.search.ui.ISearchQuery; +import org.eclipse.search.ui.ISearchResult; +import org.eclipse.search.ui.ISearchResultListener; +import org.eclipse.search.ui.ISearchResultPage; +import org.eclipse.search.ui.ISearchResultViewPart; +import org.eclipse.search.ui.NewSearchUI; +import org.eclipse.search.ui.SearchResultEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IMemento; +import org.eclipse.ui.part.Page; +import org.eclipse.ui.part.PageBook; + +public class MemorySearchResultsPage extends Page implements ISearchResultPage, IQueryListener { + + private TreeViewer fTreeViewer; + private PageBook fPagebook; + private Composite fViewerContainer; + private IQueryListener fQueryListener; + + private ISearchResultViewPart fPart; + + public void queryAdded(ISearchQuery query) { + + } + + public void queryFinished(ISearchQuery query) { + + } + + public void queryRemoved(ISearchQuery query) { + + } + + public void queryStarting(ISearchQuery query) { + + } + + public String getID() { + + return MemorySearchPlugin.getUniqueIdentifier(); + } + + public String getLabel() { + if(fQuery == null) + return Messages.getString("MemorySearchResultsPage.LabelMemorySearch"); //$NON-NLS-1$ + else + return fQuery.getLabel(); + } + + public Object getUIState() { + + return fTreeViewer.getSelection(); + } + + public void restoreState(IMemento memento) { + + + } + + public void saveState(IMemento memento) { + + + } + + public void setID(String id) { + + + } + + public void setInput(ISearchResult search, Object uiState) { + if(search instanceof MemorySearchResult) + ((MemorySearchResult) search).addListener(new ISearchResultListener() + { + + public void searchResultChanged(SearchResultEvent e) { + Display.getDefault().asyncExec(new Runnable() { + public void run() + { + fTreeViewer.refresh(); + } + }); + + } + + }); + + } + + public void setViewPart(ISearchResultViewPart part) { + fPart = part; + } + + public void createControl(Composite parent) { + fViewerContainer = new Composite(parent, SWT.NULL); + fViewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); + fViewerContainer.setSize(100, 100); + fViewerContainer.setLayout(new FillLayout()); + + fTreeViewer = new TreeViewer(fViewerContainer, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + + fTreeViewer.setContentProvider(new ITreeContentProvider() { + + public void dispose() { + + + } + + public void inputChanged(Viewer viewer, Object oldInput, + Object newInput) { + viewer.refresh(); + } + + public Object[] getChildren(Object parentElement) { + return new Object[0]; + } + + public Object getParent(Object element) { + return null; + } + + public boolean hasChildren(Object element) { + return false; + } + + public Object[] getElements(Object inputElement) { + + if(fQuery == null) + return new Object[0]; + else + { + return ((MemorySearchResult) fQuery.getSearchResult()).getMatches(); + } + } + + }); + + fTreeViewer.setInput(new Object()); + fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener(){ + + public void selectionChanged(final SelectionChangedEvent event) { + if( event.getSelection() instanceof StructuredSelection) + { + IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView().getMemoryRenderingContainers(); + for(int i = 0; i < containers.length; i++) + { + IMemoryRendering rendering = containers[i].getActiveRendering(); + if(rendering instanceof IRepositionableMemoryRendering) + { + try { + ((IRepositionableMemoryRendering) rendering).goToAddress(new BigInteger(((StructuredSelection) event.getSelection()).getFirstElement().toString().substring(2), 16)); + } catch (DebugException e) { + MemorySearchPlugin.logError(Messages.getString("MemorySearchResultsPage.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ + } + } + } + } + } + + }); + fTreeViewer.setLabelProvider(new ILabelProvider() { + + public Image getImage(Object element) { + + return null; + } + + public String getText(Object element) { + return element.toString(); + } + + public void addListener(ILabelProviderListener listener) { + + + } + + public void dispose() { + + + } + + public boolean isLabelProperty(Object element, String property) { + + return false; + } + + public void removeListener(ILabelProviderListener listener) { + + + } + + }); + + fQueryListener = createQueryListener(); + + NewSearchUI.addQueryListener(fQueryListener); + } + + private ISearchQuery fQuery; + + private IQueryListener createQueryListener() { + return new IQueryListener() { + public void queryAdded(ISearchQuery query) { + // ignore + } + + public void queryRemoved(ISearchQuery query) { + queryStarting(query); + } + + public void queryStarting(final ISearchQuery query) { + fQuery = query; + + Display.getDefault().asyncExec(new Runnable() { + public void run() + { + fPart.updateLabel(); + + if(!fTreeViewer.getControl().isDisposed()) + fTreeViewer.refresh(); + } + }); + } + + public void queryFinished(final ISearchQuery query) { + + } + }; + } + + public void dispose() { + fTreeViewer.getControl().dispose(); + fViewerContainer.dispose(); + } + + public Control getControl() { + return fViewerContainer; + } + + public void setActionBars(IActionBars actionBars) { + + + } + + public void setFocus() { + + + } + +} diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/Messages.java similarity index 85% rename from plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java rename to plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/Messages.java index c3317f44bda..58c91e68226 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/Messages.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/Messages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2008 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 @@ -9,13 +9,13 @@ * Ted R Williams (Wind River Systems, Inc.) - initial implementation *******************************************************************************/ -package org.eclipse.dd.debug.memory.renderings.actions; +package org.eclipse.dd.debug.ui.memory.search; import java.util.MissingResourceException; import java.util.ResourceBundle; public class Messages { - private static final String BUNDLE_NAME = "org.eclipse.dd.debug.memory.renderings.actions.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.dd.debug.ui.memory.search.messages"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(BUNDLE_NAME); diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/messages.properties similarity index 74% rename from plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties rename to plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/messages.properties index 8f9bd5d5c47..e6a16833af8 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/actions/messages.properties +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/messages.properties @@ -1,5 +1,6 @@ FindReplaceDialog.Title=Find / Replace Memory FindReplaceDialog.ButtonFind=Find +FindReplaceDialog.ButtonFindAll=Find All FindReplaceDialog.ButtonReplaceFind=Replace/Find FindReplaceDialog.ButtonReplace=Replace FindReplaceDialog.ButtonReplaceAll=Replace All @@ -22,4 +23,9 @@ FindReplaceDialog.ButtonByteSequence=Byte Sequence FindReplaceDialog.LabelOptions=Options FindReplaceDialog.ButtonWrapSearch=Wrap Search FindReplaceDialog.ButtonCaseInsensitive=Case Insensitive +FindReplaceDialog.MemoryReadFailed=Memory Read Failed +FindReplaceDialog.MemorySearchFailure=Memory Search Failure +FindReplaceDialog.RepositioningMemoryViewFailed=Repositioning Memory View Failed FindReplaceDialog.SearchingMemoryFor=Searching memory for +MemorySearchResultsPage.LabelMemorySearch=Memory Search +MemorySearchResultsPage.RepositioningMemoryViewFailed=Repositioning Memory View Failed From 48efefa297e4f25d0589b5b3e8eb635e87951b8f Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 1 Jul 2008 18:03:45 +0000 Subject: [PATCH 073/118] [239153] bump versions on HEAD, 1.0 -> 1.1 --- .../org.eclipse.dd.debug.memory.renderings-feature/feature.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index 7eaf70ffb52..13fc0178cff 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF index 10cfe9cdfd3..00e40b60cfd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Traditional Memory Rendering Bundle-SymbolicName: org.eclipse.dd.debug.memory.renderings.traditional;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.debug.core, org.eclipse.debug.ui, diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF index f8cd624315b..91786cd9cac 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Memory Search Bundle-SymbolicName: org.eclipse.dd.debug.ui.memory.search;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Require-Bundle: org.eclipse.debug.core, org.eclipse.debug.ui, diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF b/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF index 457f0bad69f..22ac449edff 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Memory Transport Plug-in Bundle-SymbolicName: org.eclipse.dd.debug.ui.memory.transport;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Bundle-Vendor: Eclipse.org Require-Bundle: org.eclipse.debug.core, From 646f793f1f12cbdcaee1559ec053d1d926be9227 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 17 Jul 2008 04:26:50 +0000 Subject: [PATCH 074/118] [241182] source build for all device debug plugins --- .../build.properties | 2 ++ .../org.eclipse.dd.debug.memory.renderings-feature/feature.xml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties index 66d3261e69c..4d2a80b5a61 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/build.properties @@ -1,3 +1,5 @@ bin.includes = feature.xml,\ feature.properties,\ license.html + +generate.feature@org.eclipse.dd.debug.memory.renderings.source=org.eclipse.dd.debug.memory.renderings \ No newline at end of file diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index 13fc0178cff..4370ac01ac0 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -37,4 +37,6 @@ Memory Renderings version="0.0.0" unpack="false"/> + + From 08017c93cd53089140e7a175d702c08861884be8 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 30 Jul 2008 14:15:32 +0000 Subject: [PATCH 075/118] [242571] memory search plugin is missing from memory feature --- .../feature.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml index 4370ac01ac0..145627e5f29 100644 --- a/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml +++ b/features/org.eclipse.dd.debug.memory.renderings-feature/feature.xml @@ -23,6 +23,10 @@ Memory Renderings
+ + - - + + From 1bb7c8e3b6192a7746c4394161c04fbcff655168 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Fri, 1 Aug 2008 21:17:38 +0000 Subject: [PATCH 076/118] [242932] [memory] Import/Export icons missing --- .../org.eclipse.dd.debug.ui.memory.transport/build.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties b/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties index e14f8a09223..835e763df2c 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/build.properties @@ -5,4 +5,5 @@ bin.includes = META-INF/,\ schema/,\ plugin.xml,\ build.properties,\ - plugin.properties + plugin.properties,\ + icons/ From 800c9730a22c4c3c9d0576d44ff86e5c65ad3d4f Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 12 Aug 2008 17:05:27 +0000 Subject: [PATCH 077/118] [243910] [Traditional Rendering] DebugEvent processing inflexible --- .../renderings/traditional/Rendering.java | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 16154a7a68e..28e1eba6f85 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -521,8 +521,11 @@ public class Rendering extends Composite implements IDebugEventSetListener if(this.isDisposed()) return; + boolean isChangeOnly = false; + boolean isSuspend = false; + for(int i = 0; i < events.length; i++) - { + { if(events[0].getSource() instanceof IDebugElement) { final int kind = events[i].getKind(); @@ -530,46 +533,44 @@ public class Rendering extends Composite implements IDebugEventSetListener final IDebugElement source = (IDebugElement) events[i] .getSource(); - // TODO allow extensible customization of event handling; - // integration with user configurable update policies should happen here. if(source.getDebugTarget() == getMemoryBlock() .getDebugTarget()) { if(kind == DebugEvent.SUSPEND) { handleSuspendEvent(detail); + isSuspend = true; } else if(kind == DebugEvent.CHANGE) { handleChangeEvent(); + isChangeOnly = true; } -// else if(kind == DebugEvent.RESUME) -// { -// handleResumeEvent(); -// } } } } - } - - protected void handleSuspendEvent(int detail) - { - if(detail == 0) - { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { - archiveDeltas(); - refresh(); - } - }); - } + + if(isSuspend) + handleSuspend(); + else if(isChangeOnly) + handleChange(); } - protected void handleChangeEvent() + protected void handleSuspend() { - Display.getDefault().asyncExec(new Runnable() + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + archiveDeltas(); + refresh(); + } + }); + } + + protected void handleChange() + { + Display.getDefault().asyncExec(new Runnable() { public void run() { @@ -577,16 +578,13 @@ public class Rendering extends Composite implements IDebugEventSetListener } }); } - - protected void handleResumeEvent() + + protected void handleSuspendEvent(int detail) + { + } + + protected void handleChangeEvent() { - Display.getDefault().asyncExec(new Runnable() - { - public void run() - { -// archiveDeltas(); - } - }); } // return true to enable development debug print statements From 1a8fe002955f50773b3d7ca6b0e8793ed2df01e2 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 19 Aug 2008 20:09:35 +0000 Subject: [PATCH 078/118] [244608] [memory] import dialog needs better validation --- .../debug/ui/memory/transport/PlainTextImporter.java | 9 +++++++++ .../dd/debug/ui/memory/transport/SRecordImporter.java | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 23692b72e83..8e5f953b1b8 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -219,6 +219,13 @@ public class PlainTextImporter implements IMemoryImporter { composite.pack(); parent.pack(); + + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); return composite; } @@ -230,6 +237,8 @@ public class PlainTextImporter implements IMemoryImporter { try { getStartAddress(); + if(!getFile().exists()) + isValid = false; } catch(Exception e) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 965cbe2e1e0..9fcef67f40c 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -92,6 +92,7 @@ public class SRecordImporter implements IMemoryImporter { // restore to file address fComboRestoreToFileAddress = new Button(composite, SWT.RADIO); + fComboRestoreToFileAddress.setSelection(true); fComboRestoreToFileAddress.setText("Restore to address specified in the file"); //comboRestoreToFileAddress.setLayoutData(data); @@ -217,6 +218,13 @@ public class SRecordImporter implements IMemoryImporter { composite.pack(); parent.pack(); + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); + return composite; } @@ -227,6 +235,8 @@ public class SRecordImporter implements IMemoryImporter { try { getStartAddress(); + if(!getFile().exists()) + isValid = false; } catch(Exception e) { From 83c242076128f145b7387ea496ef8e7e60c9158d Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 24 Aug 2008 03:22:57 +0000 Subject: [PATCH 079/118] [244012] Memory Rendering Transport export SRecord Exporter should zero pad the checksum --- .../dd/debug/ui/memory/transport/SRecordExporter.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index ba1c44cc3d5..b6807db518f 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -441,8 +441,11 @@ public class SRecordExporter implements IMemoryExporter checksum += value.byteValue(); } - buf.append(BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16)); - + String bString = BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16); + if(bString.length() == 1) + buf.append("0"); + buf.append(bString); + writer.write(buf.toString().toUpperCase()); writer.write("\n"); From 7174e4d974d0db9e824ce99dae3dea103dd4d8f9 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Sun, 24 Aug 2008 17:04:27 +0000 Subject: [PATCH 080/118] [245043] import/export toolbar actions enabled without valid selection --- .../plugin.xml | 2 - .../transport/actions/ExportMemoryAction.java | 36 +++++++++-------- .../transport/actions/ImportMemoryAction.java | 39 +++++++++++-------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml index 27317e78ac8..57dd55080dc 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml @@ -41,7 +41,6 @@ icon="icons/export.png" id="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction" label="%ExportMemoryAction.label" - state="false" style="push" toolbarPath="additions" tooltip="%ExportMemoryAction.label"/> @@ -51,7 +50,6 @@ icon="icons/import.png" id="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction" label="%ImportMemoryAction.label" - state="false" style="push" toolbarPath="additions" tooltip="%ImportMemoryAction.label"/> diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java index 3ad72347562..fdfb490745e 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java @@ -37,42 +37,46 @@ public class ExportMemoryAction implements IViewActionDelegate { fView = (MemoryView) view; } - public void run(IAction action) { - - ISelection selection = fView.getSite().getSelectionProvider() - .getSelection(); + private IMemoryBlock getMemoryBlock(ISelection selection) + { + IMemoryBlock memBlock = null; + if (selection instanceof IStructuredSelection) { IStructuredSelection strucSel = (IStructuredSelection) selection; // return if current selection is empty if (strucSel.isEmpty()) - return; + return null; Object obj = strucSel.getFirstElement(); if (obj == null) - return; - - IMemoryBlock memBlock = null; + return null; if (obj instanceof IMemoryRendering) { memBlock = ((IMemoryRendering) obj).getMemoryBlock(); } else if (obj instanceof IMemoryBlock) { memBlock = (IMemoryBlock) obj; } - if(memBlock == null) - return; - - ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock); - dialog.open(); - - dialog.getResult(); } + return memBlock; + } + + public void run(IAction action) { + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + IMemoryBlock memBlock = getMemoryBlock(selection); + if(memBlock == null) + return; + ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + dialog.open(); + + dialog.getResult(); } public void selectionChanged(IAction action, ISelection selection) { - + action.setEnabled(getMemoryBlock(selection) != null); } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java index 4c87cd3bf4e..cc3bc9cd4a1 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java @@ -37,43 +37,48 @@ public class ImportMemoryAction implements IViewActionDelegate { if (view instanceof MemoryView) fView = (MemoryView) view; } - - public void run(IAction action) { - - ISelection selection = fView.getSite().getSelectionProvider() - .getSelection(); + + private IMemoryBlock getMemoryBlock(ISelection selection) + { + IMemoryBlock memBlock = null; + if (selection instanceof IStructuredSelection) { IStructuredSelection strucSel = (IStructuredSelection) selection; // return if current selection is empty if (strucSel.isEmpty()) - return; + return null; Object obj = strucSel.getFirstElement(); if (obj == null) - return; - - IMemoryBlock memBlock = null; + return null; if (obj instanceof IMemoryRendering) { memBlock = ((IMemoryRendering) obj).getMemoryBlock(); } else if (obj instanceof IMemoryBlock) { memBlock = (IMemoryBlock) obj; } - if(memBlock == null) - return; - - ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock); - dialog.open(); - - dialog.getResult(); } + return memBlock; + } + public void run(IAction action) { + + ISelection selection = fView.getSite().getSelectionProvider() + .getSelection(); + IMemoryBlock memBlock = getMemoryBlock(selection); + if(memBlock == null) + return; + + ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + dialog.open(); + + dialog.getResult(); } public void selectionChanged(IAction action, ISelection selection) { - + action.setEnabled(getMemoryBlock(selection) != null); } } From c28276e43bd8d9d3df881663067c361b9909b6eb Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 25 Aug 2008 16:29:56 +0000 Subject: [PATCH 081/118] [244608] [memory] import dialog needs better validation --- .../eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java | 1 - .../eclipse/dd/debug/ui/memory/transport/SRecordExporter.java | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index d4f5191448c..ac17ae335f8 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -97,7 +97,6 @@ public class PlainTextExporter implements IMemoryExporter { fStartText = new Text(composite, SWT.NONE); data = new FormData(); - data.top = new FormAttachment(startLabel); data.left = new FormAttachment(startLabel); data.width = 100; fStartText.setLayoutData(data); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index b6807db518f..d3daba247c6 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -94,7 +94,6 @@ public class SRecordExporter implements IMemoryExporter fStartText = new Text(composite, SWT.NONE); data = new FormData(); - data.top = new FormAttachment(startLabel); data.left = new FormAttachment(startLabel); data.width = 100; fStartText.setLayoutData(data); From 6f7abc24696f03017e024ea320b599e04e54c62e Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 25 Aug 2008 19:50:25 +0000 Subject: [PATCH 082/118] [244608] [memory] import dialog needs better validation --- .../dd/debug/ui/memory/transport/PlainTextImporter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 8e5f953b1b8..2913d266eac 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -106,10 +106,13 @@ public class PlainTextImporter implements IMemoryImporter { // data.top = new FormAttachment(fComboRestoreToFileAddress); // fComboRestoreToThisAddress.setLayoutData(data); + Label labelStartText = new Label(composite, SWT.NONE); + labelStartText.setText("Restore to address: "); + fStartText = new Text(composite, SWT.NONE); data = new FormData(); // data.top = new FormAttachment(fComboRestoreToFileAddress); -// data.left = new FormAttachment(fComboRestoreToThisAddress); + data.left = new FormAttachment(labelStartText); data.width = 100; fStartText.setLayoutData(data); From 8fa4117cae2786a40749b83ee7eff03eae3e3236 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 25 Aug 2008 20:07:17 +0000 Subject: [PATCH 083/118] [245169] [traditional memory] divide by zero --- .../dd/debug/memory/renderings/traditional/AddressPane.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java index 402eff0139b..61e2b5787b6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/AddressPane.java @@ -125,6 +125,9 @@ public class AddressPane extends AbstractPane cellOffset *= fRendering.getAddressableSize(); + if(fRendering.getColumnCount() == 0) // avoid divide by zero + return new Point(0,0); + int row = cellOffset / (fRendering.getColumnCount() * fRendering.getBytesPerColumn() / fRendering .getBytesPerCharacter()); From eb4710fccffd7af9408aaa6d082d0260ccb4440b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 26 Aug 2008 00:52:02 +0000 Subject: [PATCH 084/118] [245195] [traditional memory] Add preference action to memory view action menu --- .../plugin.properties | 1 + .../plugin.xml | 16 +++++ .../TraditionalRenderingPreferenceAction.java | 62 +++++++++++++++++++ .../TraditionalRenderingPreferencePage.java | 2 +- 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceAction.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties new file mode 100644 index 00000000000..3f960bac63c --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.properties @@ -0,0 +1 @@ +TraditionalRenderingPreferenceActionName=Traditional Rendering Preferences... \ No newline at end of file diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index 6ae4bc7a1c2..5ae6224678e 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -15,6 +15,7 @@
+ + + + + + + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceAction.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceAction.java new file mode 100644 index 00000000000..5feb6cd9115 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferenceAction.java @@ -0,0 +1,62 @@ + +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation 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: + * Ted Williams - Wind River - initial API and implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.memory.renderings.traditional; + + +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.preference.IPreferenceNode; +import org.eclipse.jface.preference.IPreferencePage; +import org.eclipse.jface.preference.PreferenceDialog; +import org.eclipse.jface.preference.PreferenceManager; +import org.eclipse.jface.preference.PreferenceNode; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.ui.IViewActionDelegate; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.actions.ActionDelegate; + +public class TraditionalRenderingPreferenceAction extends ActionDelegate implements IViewActionDelegate { + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + IPreferencePage page = new TraditionalRenderingPreferencePage(); + showPreferencePage("org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferencePage", page); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init(IViewPart view) { + } + + protected void showPreferencePage(String id, IPreferencePage page) { + final IPreferenceNode targetNode = new PreferenceNode(id, page); + + PreferenceManager manager = new PreferenceManager(); + manager.addToRoot(targetNode); + final PreferenceDialog dialog = new PreferenceDialog(DebugUIPlugin.getShell(), manager); + final boolean [] result = new boolean[] { false }; + BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), new Runnable() { + public void run() { + dialog.create(); + dialog.setMessage(targetNode.getLabelText()); + result[0]= (dialog.open() == Window.OK); + } + }); + } + +} + diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java index d90cd43f38a..05d65eab55f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRenderingPreferencePage.java @@ -40,7 +40,7 @@ public class TraditionalRenderingPreferencePage public TraditionalRenderingPreferencePage() { super(GRID); setPreferenceStore(TraditionalRenderingPlugin.getDefault().getPreferenceStore()); - //setDescription("Traditional Memory Rendering"); + setDescription("Traditional Memory Rendering"); } /** From db563baeb9f5664207a4353d0135a5ff038167a7 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 28 Aug 2008 21:05:06 +0000 Subject: [PATCH 085/118] [214956] support for platform request --- .../plugin.xml | 8 + .../TraditionalGoToAddressRendering.java | 238 ++++++++++++++++++ ...ionalGoToAddressRenderingTypeDelegate.java | 28 +++ 3 files changed, 274 insertions(+) create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java create mode 100644 plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRenderingTypeDelegate.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index 5ae6224678e..1189c5ee62e 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -16,6 +16,14 @@ + + + + + Date: Fri, 29 Aug 2008 21:40:29 +0000 Subject: [PATCH 086/118] [245752] [memory] Search results should be highlighted --- .../traditional/TraditionalRendering.java | 6 +++ .../ui/memory/search/FindReplaceDialog.java | 17 ++++++- .../debug/ui/memory/search/MemoryMatch.java | 48 +++++++++++++++++++ .../ui/memory/search/MemorySearchResult.java | 8 ++-- .../search/MemorySearchResultsPage.java | 19 +++++++- 5 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 945df88dc9e..028943ab1d2 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -328,6 +328,12 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe super.deactivated(); } + + public void setSelection(BigInteger start, BigInteger end) + { + fRendering.getSelection().setStart(start, start); + fRendering.getSelection().setEnd(end, end); + } public void gotoAddress(final BigInteger address) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 6b822ab54a3..621ce9ee792 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -11,6 +11,8 @@ package org.eclipse.dd.debug.ui.memory.search; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigInteger; import java.util.Properties; import java.util.StringTokenizer; @@ -885,7 +887,7 @@ public class FindReplaceDialog extends SelectionDialog public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { - BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); + final BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); BigInteger currentPosition = start; @@ -918,7 +920,7 @@ public class FindReplaceDialog extends SelectionDialog if(matched) { if(all && !isReplace) - ((MemorySearchResult) getSearchResult()).addMatch("0x" + currentPosition.toString(16)); //$NON-NLS-1$ + ((MemorySearchResult) getSearchResult()).addMatch(new MemoryMatch(currentPosition, searchPhraseLength)); if(isReplace) { @@ -958,6 +960,17 @@ public class FindReplaceDialog extends SelectionDialog MemorySearchPlugin.logError(Messages.getString("FindReplaceDialog.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ } } + if(rendering != null) + { + // Temporary, until platform accepts/adds new interface for setting the selection + try { + Method m = rendering.getClass().getMethod("setSelection", new Class[] { BigInteger.class, BigInteger.class } ); + if(m != null) + m.invoke(rendering, finalCurrentPosition, finalCurrentPosition.add(searchPhraseLength)); + } catch (Exception e) { + // do nothing + } + } } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java new file mode 100644 index 00000000000..596547bb622 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemoryMatch.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.search; + +import java.math.BigInteger; + +public class MemoryMatch +{ + BigInteger fStartAddress; + + public BigInteger getStartAddress() { + return fStartAddress; + } + + public void setStartAddress(BigInteger startAddress) { + fStartAddress = startAddress; + } + + public BigInteger getLength() { + return fLength; + } + + public void setLength(BigInteger length) { + fLength = length; + } + + BigInteger fLength; + + public MemoryMatch(BigInteger startAddress, BigInteger length) + { + fStartAddress = startAddress; + fLength = length; + } + + public BigInteger getEndAddress() + { + return getStartAddress().add(getLength()); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java index 32f7fa08958..41f040bbe79 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResult.java @@ -53,15 +53,15 @@ public class MemorySearchResult implements ISearchResult return fLabel; } - public String[] getMatches() + public MemoryMatch[] getMatches() { - String matches[] = new String[fMatches.size()]; + MemoryMatch matches[] = new MemoryMatch[fMatches.size()]; for(int i = 0; i < matches.length; i++) - matches[i] = (String) fMatches.elementAt(i); + matches[i] = (MemoryMatch) fMatches.elementAt(i); return matches; } - public void addMatch(String address) + public void addMatch(MemoryMatch address) { fMatches.addElement(address); fireChange(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java index 4a3cb184fd3..2dc4a1e83fd 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/MemorySearchResultsPage.java @@ -11,6 +11,7 @@ package org.eclipse.dd.debug.ui.memory.search; +import java.lang.reflect.Method; import java.math.BigInteger; import org.eclipse.dd.debug.ui.memory.search.FindReplaceDialog.IMemorySearchQuery; @@ -177,17 +178,30 @@ public class MemorySearchResultsPage extends Page implements ISearchResultPage, if( event.getSelection() instanceof StructuredSelection) { IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView().getMemoryRenderingContainers(); + MemoryMatch match = (MemoryMatch) ((StructuredSelection) event.getSelection()).getFirstElement(); for(int i = 0; i < containers.length; i++) { IMemoryRendering rendering = containers[i].getActiveRendering(); if(rendering instanceof IRepositionableMemoryRendering) { try { - ((IRepositionableMemoryRendering) rendering).goToAddress(new BigInteger(((StructuredSelection) event.getSelection()).getFirstElement().toString().substring(2), 16)); + ((IRepositionableMemoryRendering) rendering).goToAddress(match.getStartAddress()); } catch (DebugException e) { MemorySearchPlugin.logError(Messages.getString("MemorySearchResultsPage.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ } } + + if(rendering != null) + { + // Temporary, until platform accepts/adds new interface for setting the selection + try { + Method m = rendering.getClass().getMethod("setSelection", new Class[] { BigInteger.class, BigInteger.class } ); //$NON-NLS-1$ + if(m != null) + m.invoke(rendering, match.getStartAddress(), match.getEndAddress()); + } catch (Exception e) { + // do nothing + } + } } } } @@ -201,6 +215,9 @@ public class MemorySearchResultsPage extends Page implements ISearchResultPage, } public String getText(Object element) { + if(element instanceof MemoryMatch) + return "0x" + ((MemoryMatch) element).getStartAddress().toString(16); //$NON-NLS-1$ + return element.toString(); } From 2ad6225eb4133603a8446567d2f0e4138472b3b5 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 1 Sep 2008 02:27:55 +0000 Subject: [PATCH 087/118] [214956] [Memory View] Memory View workflow enhancements: quick address navigation; simplified use defaults; fewer clicks --- .../TraditionalGoToAddressRendering.java | 143 ++++++------------ 1 file changed, 45 insertions(+), 98 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java index 89d39fe01bf..00bb7adaa94 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java @@ -96,116 +96,63 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { } IMemoryRenderingContainer containers[] = fSite.getMemoryRenderingContainers(); - IMemoryRenderingContainer firstRenderingViewPane = null; for(int i = 0; i < containers.length; i++) { if(containers[i] instanceof RenderingViewPane) { - firstRenderingViewPane = containers[i]; - break; - } - } - - BigInteger absoluteAddress = null; - if(fGotoAddress.isGoToAddress()) - absoluteAddress = address; - - IMemoryBlock activeMemoryBlock = null; - - if(address != null && firstRenderingViewPane != null) - { - IMemoryRendering activeRendering = firstRenderingViewPane.getActiveRendering(); - if(activeRendering != null) - { - activeMemoryBlock = activeRendering.getMemoryBlock(); - IMemoryBlockExtension blockExtension = (IMemoryBlockExtension) activeMemoryBlock.getAdapter(IMemoryBlockExtension.class); - if(blockExtension != null) - { - BigInteger baseAddress = null; - BigInteger addressableSize = null; - try - { - baseAddress = blockExtension.getBigBaseAddress(); - addressableSize = BigInteger.valueOf(blockExtension.getAddressableSize()); - } - catch(DebugException de) - { - // TODO - } - - if(baseAddress != null) - { - if(fGotoAddress.isOffset()) - absoluteAddress = baseAddress.add(address); - else if(fGotoAddress.isJump() && addressableSize != null) - absoluteAddress = baseAddress.add(address.multiply(addressableSize)); - } - } + BigInteger absoluteAddress = null; + if(fGotoAddress.isGoToAddress()) + absoluteAddress = address; - // 1) Try to reposition the renderings using the IRepositionableMemoryRendering interface - if(absoluteAddress != null && activeRendering instanceof IRepositionableMemoryRendering) + IMemoryBlock activeMemoryBlock = null; + + if(address != null && containers[i] != null) { - try + IMemoryRendering activeRendering = containers[i].getActiveRendering(); + if(activeRendering != null) { - ((IRepositionableMemoryRendering) activeRendering).goToAddress(absoluteAddress); - return; - } - catch(DebugException de) - { - // TODO ? + activeMemoryBlock = activeRendering.getMemoryBlock(); + IMemoryBlockExtension blockExtension = (IMemoryBlockExtension) activeMemoryBlock.getAdapter(IMemoryBlockExtension.class); + if(blockExtension != null) + { + BigInteger baseAddress = null; + BigInteger addressableSize = null; + try + { + baseAddress = blockExtension.getBigBaseAddress(); + addressableSize = BigInteger.valueOf(blockExtension.getAddressableSize()); + } + catch(DebugException de) + { + // TODO + } + + if(baseAddress != null) + { + if(fGotoAddress.isOffset()) + absoluteAddress = baseAddress.add(address); + else if(fGotoAddress.isJump() && addressableSize != null) + absoluteAddress = baseAddress.add(address.multiply(addressableSize)); + } + } + + // 1) Try to reposition the renderings using the IRepositionableMemoryRendering interface + if(absoluteAddress != null && activeRendering instanceof IRepositionableMemoryRendering) + { + try + { + ((IRepositionableMemoryRendering) activeRendering).goToAddress(absoluteAddress); + } + catch(DebugException de) + { + // do nothing + } + } } } } } - - // 2) Fallback: Remove existing memory block; Add new memory block - IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(DebugUITools.getDebugContext()); - final BigInteger absoluteAddressFinal = absoluteAddress; - final IMemoryBlock activeMemoryBlockFinal = activeMemoryBlock; - final IMemoryBlockRetrieval retrievalFinal = retrieval; - if(retrieval instanceof IMemoryBlockRetrievalExtension) - { - String absoluteAddressExpression = fGotoAddress.getExpressionText(); - if(absoluteAddressFinal != null) - absoluteAddressExpression = (radix == 16 ? "0x" : "") + absoluteAddressFinal.toString(radix); - final String absoluteAddressExpressionFinal = absoluteAddressExpression; - - new Thread() { // upgrade to Job ? - public void run() - { - try - { - final IMemoryBlockExtension memBlock = ((IMemoryBlockRetrievalExtension) retrievalFinal) - .getExtendedMemoryBlock(absoluteAddressExpressionFinal, DebugUITools.getDebugContext()); - - if (memBlock != null) - { - Display.getDefault().asyncExec(new Runnable(){ - public void run() - { - IMemoryRenderingContainer container = fSite.getContainer(IDebugUIConstants.ID_RENDERING_VIEW_PANE_1); - IMemoryRendering createRendering = new CreateRendering(container); - createRendering.init(container, memBlock); - container.addMemoryRendering(createRendering); - } - }); - } - else - { - // open error if it failed to retrieve a memory block - MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, null); - } - } - catch(DebugException de) - { - MemoryViewUtil.openError(DebugUIMessages.AddMemoryBlockAction_title, DebugUIMessages.AddMemoryBlockAction_noMemoryBlock, de); - } - } - }.start(); - - - } } }; From d099bf7482036155849be225df52181e100799e8 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 16 Sep 2008 20:33:07 +0000 Subject: [PATCH 088/118] [247559] [traditional memory] Padding preference should be respected --- .../renderings/traditional/Rendering.java | 22 +++++++++++--- .../traditional/TraditionalRendering.java | 30 +++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index 28e1eba6f85..e47500e5df5 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006-2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006-2008 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 @@ -140,6 +140,8 @@ public class Rendering extends Composite implements IDebugEventSetListener private int fPaneSpacing = 16; + private String fPaddingString = "?"; //$NON-NLS-1$ + // flag whether the memory cache is dirty private boolean fCacheDirty = false; @@ -514,6 +516,18 @@ public class Rendering extends Composite implements IDebugEventSetListener layout(true); } + public void setPaddingString(String padding) + { + fPaddingString = padding; + + refresh(); + } + + public char getPaddingCharacter() + { + return fPaddingString.charAt(0); // use only the first character + } + static int suspendCount = 0; public void handleDebugEvents(DebugEvent[] events) @@ -1933,7 +1947,7 @@ public class Rendering extends Composite implements IDebugEventSetListener StringBuffer errorText = new StringBuffer(); for(int i = getRadixCharacterCount(radix, bytes.length); i > 0; i--) - errorText.append('?'); + errorText.append(getPaddingCharacter()); return errorText.toString(); } @@ -2015,7 +2029,7 @@ public class Rendering extends Composite implements IDebugEventSetListener { StringBuffer errorText = new StringBuffer(); for(int i = memoryBytes.length; i > 0; i--) - errorText.append('?'); + errorText.append(getPaddingCharacter()); return errorText.toString(); } @@ -2077,7 +2091,7 @@ public class Rendering extends Composite implements IDebugEventSetListener // return ?s the length of byte count StringBuffer buf = new StringBuffer(); for(int i = 0; i < memoryBytes.length - buf.length(); i++) - buf.append('?'); + buf.append(getPaddingCharacter()); return buf.toString(); } } diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 028943ab1d2..4e51b4b1edd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2006-2008 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 @@ -20,7 +20,6 @@ import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.dd.debug.memory.renderings.traditional.Rendering.Selection; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; @@ -31,6 +30,7 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.memory.IMemoryBlockConnection; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; +import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; @@ -156,6 +156,30 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe } }); + + DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener( + new IPropertyChangeListener() + { + public void propertyChange(PropertyChangeEvent event) + { + if(event.getProperty().equals(IDebugUIConstants.PREF_PADDED_STR)) + { + if(TraditionalRendering.this.fRendering != null) + { + setRenderingPadding((String) event.getNewValue()); + TraditionalRendering.this.fRendering.redrawPanes(); + } + } + } + }); + + } + + private void setRenderingPadding(String padding) + { + if(padding == null || padding.length() == 0) + padding = "?"; + TraditionalRendering.this.fRendering.setPaddingString(padding); } protected void logError(String message, Exception e) @@ -442,6 +466,8 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe for(int i = 0; i < panes.length; i++) panes[i].setBackground(getColorBackground()); + setRenderingPadding(DebugUIPlugin.getDefault().getPreferenceStore().getString(IDebugUIConstants.PREF_PADDED_STR)); + fRendering.redrawPanes(); } } From 461838f7a2c6990207c16e2d066b8248c533d411 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 17 Sep 2008 20:58:06 +0000 Subject: [PATCH 089/118] [247734] [Memory] Find, Find Next, Import, Export, Refresh enable without valid selection --- .../plugin.xml | 8 +++-- .../plugin.xml | 36 ++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml index 53860b0f809..d3e28970f1e 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml @@ -7,9 +7,11 @@ targetID="org.eclipse.debug.ui.MemoryView"> + menubarPath="additions" + state="false"> + menubarPath="additions" + state="false"> diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml index 57dd55080dc..19aab13dbd4 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml @@ -36,23 +36,27 @@ targetID="org.eclipse.debug.ui.MemoryView" id="org.eclipse.debug.ui.memoryView.toolbar"> + class="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction" + enablesFor="1" + helpContextId="ExportMemoryAction_context" + icon="icons/export.png" + id="org.eclipse.dd.debug.ui.memory.transport.actions.ExportMemoryAction" + label="%ExportMemoryAction.label" + state="false" + style="push" + toolbarPath="additions" + tooltip="%ExportMemoryAction.label"/> + class="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction" + enablesFor="1" + helpContextId="ExportMemoryAction_context" + icon="icons/import.png" + id="org.eclipse.dd.debug.ui.memory.transport.actions.ImportMemoryAction" + label="%ImportMemoryAction.label" + state="false" + style="push" + toolbarPath="additions" + tooltip="%ImportMemoryAction.label"/> From 13adefb692f60a942642cfc2bacc46ce1e286bac Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 18 Sep 2008 00:00:15 +0000 Subject: [PATCH 090/118] [247762] [memory] TraditionalGoToAddressRendering should report expression evaluation failure to user --- .../traditional/TraditionalGoToAddressRendering.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java index 00bb7adaa94..e3e8efd57f0 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java @@ -92,7 +92,8 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { } catch(NumberFormatException nfe) { - + MemoryViewUtil.openError(DebugUIMessages.GoToAddressAction_Go_to_address_failed, + DebugUIMessages.GoToAddressAction_Address_is_invalid, nfe); } IMemoryRenderingContainer containers[] = fSite.getMemoryRenderingContainers(); From a26d5d664293740b96fb3cb15b5bdfa995d95f05 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 18 Sep 2008 00:16:00 +0000 Subject: [PATCH 091/118] [247763] [traditional memory rendering] column count popup menus include blank item --- .../traditional/TraditionalRendering.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 4e51b4b1edd..80e921e1c8f 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006-2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006 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 @@ -919,11 +919,6 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe { } }; - boolean currentCountIsCustom = true; - for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT && currentCountIsCustom; i++, j*=2) - currentCountIsCustom = (j != fRendering.getColumnsSetting()); - displayColumnCountCustomValue.setChecked(currentCountIsCustom); - final Action displayColumnCountCustom = new Action( TraditionalRenderingMessages @@ -1040,8 +1035,13 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe sub.add(displayColumnCountAuto); for(int i = 0; i < displayColumnCounts.length; i++) sub.add(displayColumnCounts[i]); - if(displayColumnCountCustomValue.isChecked()) + + boolean currentCountIsCustom = fRendering.getColumnsSetting() != 0; + for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT && currentCountIsCustom; i++, j*=2) + currentCountIsCustom = (j != fRendering.getColumnsSetting()); + if(currentCountIsCustom) sub.add(displayColumnCountCustomValue); + sub.add(displayColumnCountCustom); manager.add(sub); manager.add(new Separator()); From fb9f3b039c441e2965ba73c3fec216af516c636a Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 18 Sep 2008 01:16:41 +0000 Subject: [PATCH 092/118] [247765] [memory] implement "scroll to start address" for memory importers --- .../memory/transport/ImportMemoryDialog.java | 50 +++++++++++++++++-- .../memory/transport/PlainTextImporter.java | 8 +++ .../ui/memory/transport/SRecordImporter.java | 8 +++ .../transport/actions/ImportMemoryAction.java | 8 ++- 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java index 392e2dc6a14..6ffa7b5b7f5 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java @@ -11,21 +11,26 @@ package org.eclipse.dd.debug.ui.memory.transport; +import java.math.BigInteger; import java.util.Properties; import java.util.Vector; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.views.memory.MemoryView; +import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane; +import org.eclipse.debug.ui.memory.IMemoryRendering; +import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -36,10 +41,12 @@ import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.SelectionDialog; +import org.eclipse.ui.progress.UIJob; public class ImportMemoryDialog extends SelectionDialog { @@ -55,13 +62,50 @@ public class ImportMemoryDialog extends SelectionDialog private Properties fProperties = new Properties(); - public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock) + private MemoryView fMemoryView; + + public ImportMemoryDialog(Shell parent, IMemoryBlock memoryBlock, MemoryView view) { super(parent); super.setTitle("Download to Memory"); setShellStyle(getShellStyle() | SWT.RESIZE); fMemoryBlock = memoryBlock; + fMemoryView = view; + } + + protected void scrollRenderings(final BigInteger address) + { + UIJob job = new UIJob("repositionRenderings"){ //$NON-NLS-1$ + public IStatus runInUIThread(IProgressMonitor monitor) { + final IMemoryRenderingContainer containers[] = fMemoryView.getMemoryRenderingContainers(); + for(int i = 0; i < containers.length; i++) + { + if(containers[i] instanceof RenderingViewPane) + { + IMemoryRendering rendering = containers[i].getActiveRendering(); + + if(rendering instanceof IRepositionableMemoryRendering) + { + try + { + ((IRepositionableMemoryRendering) rendering).goToAddress(address); + } + catch (DebugException e) + { + // do nothing + } + } + } + } + + return Status.OK_STATUS; + }}; + job.setSystem(true); + job.setThread(Display.getDefault().getThread()); + job.schedule(); + + } /* (non-Javadoc) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 2913d266eac..dc0443691c6 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -294,6 +294,8 @@ public class PlainTextImporter implements IMemoryImporter { if(!fUseCustomAddress) offset = BigInteger.ZERO; + BigInteger scrollToAddress = null; + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); BigInteger jobs = BigInteger.valueOf(fInputFile.length()); @@ -323,6 +325,9 @@ public class PlainTextImporter implements IMemoryImporter { data[i] = new BigInteger(valueString.substring(position++, position++ + 1), 16).byteValue(); } + if(scrollToAddress == null) + scrollToAddress = recordAddress; + ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data); @@ -343,6 +348,9 @@ public class PlainTextImporter implements IMemoryImporter { reader.close(); monitor.done(); + + if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true")) + fParentDialog.scrollRenderings(scrollToAddress); } catch(Exception e) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 9fcef67f40c..a0de0236109 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -289,6 +289,8 @@ public class SRecordImporter implements IMemoryImporter { final int CHECKSUM_LENGTH = 1; + BigInteger scrollToAddress = null; + BigInteger offset = null; if(!fUseCustomAddress) offset = BigInteger.ZERO; @@ -364,6 +366,9 @@ public class SRecordImporter implements IMemoryImporter { return new Status( IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), "Checksum failure of line = " + line); //$NON-NLS-1$ } + if(scrollToAddress == null) + scrollToAddress = recordAddress; + // FIXME error on incorrect checksum ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data); @@ -380,6 +385,9 @@ public class SRecordImporter implements IMemoryImporter { reader.close(); monitor.done(); + + if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true")) + fParentDialog.scrollRenderings(scrollToAddress); } catch(Exception e) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java index cc3bc9cd4a1..b2c3f34aa16 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java @@ -16,7 +16,9 @@ import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.contexts.IDebugContextService; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; @@ -36,6 +38,10 @@ public class ImportMemoryAction implements IViewActionDelegate { public void init(IViewPart view) { if (view instanceof MemoryView) fView = (MemoryView) view; + +// IDebugContextService debugContextService = DebugUITools.getDebugContextManager().getContextService(view.getSite().getWorkbenchWindow()); +// this. +// debugContextService.getActiveContext(); } private IMemoryBlock getMemoryBlock(ISelection selection) @@ -71,7 +77,7 @@ public class ImportMemoryAction implements IViewActionDelegate { if(memBlock == null) return; - ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock, fView); dialog.open(); dialog.getResult(); From 2160dbc2d367cd9b1f2f988d27ed0189484d8e6a Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 22 Sep 2008 04:25:38 +0000 Subject: [PATCH 093/118] [248084] [traditional memory rendering] IMemoryBlockConnection adapter should track BigBaseAddress --- .../debug/memory/renderings/traditional/Rendering.java | 7 ++++++- .../renderings/traditional/TraditionalRendering.java | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java index e47500e5df5..426e5f0714e 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/Rendering.java @@ -1691,7 +1691,12 @@ public class Rendering extends Composite implements IDebugEventSetListener fIsDisplayLittleEndian = littleEndian; fireSettingsChanged(); - layoutPanes(); + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + layoutPanes(); + } + }); } public void setBytesPerColumn(int byteCount) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 80e921e1c8f..cfb2a4f4683 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1183,7 +1183,15 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe Display display = DebugUIPlugin.getDefault().getWorkbench().getDisplay(); display.asyncExec(new Runnable() { public void run() { - TraditionalRendering.this.fRendering.refresh(); + try + { + fBigBaseAddress = TraditionalRendering.this.fRendering.getMemoryBlock().getBigBaseAddress(); + TraditionalRendering.this.fRendering.gotoAddress(fBigBaseAddress); + TraditionalRendering.this.fRendering.refresh(); + } + catch (DebugException e) + { + } } }); } From 6d1a5f77db2e4ddbb17e108fa28e090bab943f86 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 1 Oct 2008 21:56:25 +0000 Subject: [PATCH 094/118] [249407] Memory Exporters should use KeyListener instead of ModifyListener for validation --- .../memory/transport/PlainTextExporter.java | 30 ++++++++++++++----- .../ui/memory/transport/SRecordExporter.java | 30 ++++++++++++++----- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index ac17ae335f8..dfd27de2900 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -29,6 +29,8 @@ import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; @@ -210,8 +212,8 @@ public class PlainTextExporter implements IMemoryExporter { }); - fStartText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fStartText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { boolean valid = true; try { @@ -235,10 +237,11 @@ public class PlainTextExporter implements IMemoryExporter { validate(); } + public void keyPressed(KeyEvent e) {} }); - fEndText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fEndText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { try { getEndAddress(); @@ -260,10 +263,12 @@ public class PlainTextExporter implements IMemoryExporter { validate(); } + public void keyPressed(KeyEvent e) {} + }); - fLengthText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fLengthText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { try { BigInteger length = getLength(); @@ -281,12 +286,21 @@ public class PlainTextExporter implements IMemoryExporter { validate(); } + + + public void keyPressed(KeyEvent e) { + + } }); - fFileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fFileText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { validate(); } + + public void keyPressed(KeyEvent e) { + + } }); composite.pack(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index d3daba247c6..466ad9af35d 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -27,6 +27,8 @@ import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; @@ -206,8 +208,8 @@ public class SRecordExporter implements IMemoryExporter }); - fStartText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fStartText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { boolean valid = true; try { @@ -231,10 +233,11 @@ public class SRecordExporter implements IMemoryExporter validate(); } + public void keyPressed(KeyEvent e) {} }); - fEndText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fEndText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { try { getEndAddress(); @@ -256,10 +259,12 @@ public class SRecordExporter implements IMemoryExporter validate(); } + public void keyPressed(KeyEvent e) {} + }); - fLengthText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fLengthText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { try { BigInteger length = getLength(); @@ -277,12 +282,21 @@ public class SRecordExporter implements IMemoryExporter validate(); } + + + public void keyPressed(KeyEvent e) { + + } }); - fFileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { + fFileText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { validate(); } + + public void keyPressed(KeyEvent e) { + + } }); composite.pack(); From 26a457e6d68cf062fafbe253195cb03f17b8ac0f Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 6 Oct 2008 23:49:06 +0000 Subject: [PATCH 095/118] [158601] Copy To Clipboard in Memory window always shows 5 cells per row --- .../traditional/TraditionalRendering.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index cfb2a4f4683..ac369c97bbc 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1287,8 +1287,7 @@ class CopyAction extends Action public void run() { - final int COLUMNS = 80; // FIXME user preference - final String PANE_SPACING = " "; // preference also ? //$NON-NLS-1$ + final String PANE_SPACING = " "; //$NON-NLS-1$ Clipboard clip = null; try @@ -1329,23 +1328,7 @@ class CopyAction extends Action + (fRendering.getPaneVisible(Rendering.PANE_TEXT) ? asciiCellWidth : 0); - int availableWidth = COLUMNS; - - if(fRendering.getPaneVisible(Rendering.PANE_ADDRESS)) - { - availableWidth -= addressWidth; - availableWidth -= PANE_SPACING.length(); // between address - // and next - } - - if(fRendering.getPaneVisible(Rendering.PANE_BINARY) - && fRendering.getPaneVisible(Rendering.PANE_TEXT)) - { - availableWidth -= PANE_SPACING.length(); // between binary - // and text - } - - final int columns = availableWidth / combindCellWidths; + final int columns = fRendering.getColumnCount(); BigInteger lengthToRead = end.subtract(start); From 21661960b44c6477ea117ac844cc5ce454f385ea Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 14 Oct 2008 18:07:11 +0000 Subject: [PATCH 096/118] [250822] Import/Export file dialog missing "*" filter --- .../dd/debug/ui/memory/transport/PlainTextExporter.java | 4 ++-- .../dd/debug/ui/memory/transport/PlainTextImporter.java | 4 ++-- .../eclipse/dd/debug/ui/memory/transport/SRecordExporter.java | 4 ++-- .../eclipse/dd/debug/ui/memory/transport/SRecordImporter.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index dfd27de2900..c73b92a261f 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -197,8 +197,8 @@ public class PlainTextExporter implements IMemoryExporter { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); dialog.open(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index dc0443691c6..44648ec7368 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -172,8 +172,8 @@ public class PlainTextImporter implements IMemoryImporter { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); dialog.open(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index 466ad9af35d..dfd253ee40b 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -193,8 +193,8 @@ public class SRecordExporter implements IMemoryExporter public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); dialog.open(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index a0de0236109..631a12576c9 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -167,8 +167,8 @@ public class SRecordImporter implements IMemoryImporter { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); dialog.setText("Choose memory export file"); - dialog.setFilterExtensions(new String[] { "*.*" } ); - dialog.setFilterNames(new String[] { "All Files (*.*)" } ); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); dialog.open(); From 351ab621de653ea0a8513bdfcc35521c9b64bc6b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 23 Oct 2008 16:52:21 +0000 Subject: [PATCH 097/118] [214956] [Memory View] Memory View workflow enhancements: quick address navigation; simplified use defaults; fewer clicks --- .../TraditionalGoToAddressRendering.java | 258 ++++++++++++------ 1 file changed, 171 insertions(+), 87 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java index e3e8efd57f0..7f93ae65415 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalGoToAddressRendering.java @@ -17,15 +17,12 @@ import java.math.BigInteger; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.core.model.IMemoryBlockRetrieval; import org.eclipse.debug.core.model.IMemoryBlockRetrievalExtension; import org.eclipse.debug.internal.ui.DebugUIMessages; +import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane; import org.eclipse.debug.internal.ui.views.memory.renderings.CreateRendering; -import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressComposite; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; @@ -37,10 +34,14 @@ import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { @@ -64,7 +65,7 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { Composite fGotoAddressContainer = parent; - final GoToAddressComposite fGotoAddress = new GoToAddressComposite(); + final GoToAddressWidget fGotoAddress = new GoToAddressWidget(); Control fGotoAddressControl = fGotoAddress.createControl(fGotoAddressContainer); fControl = fGotoAddressControl; @@ -73,87 +74,7 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { { public void run() { - String expression = fGotoAddress.getExpressionText(); - int radix = 10; - if(expression.toUpperCase().startsWith("0X")) - { - expression = expression.substring(2); - radix = 16; - } - else if(fGotoAddress.isHex()) - { - radix = 16; - } - - BigInteger address = null; - try - { - address = new BigInteger(expression, radix); - } - catch(NumberFormatException nfe) - { - MemoryViewUtil.openError(DebugUIMessages.GoToAddressAction_Go_to_address_failed, - DebugUIMessages.GoToAddressAction_Address_is_invalid, nfe); - } - - IMemoryRenderingContainer containers[] = fSite.getMemoryRenderingContainers(); - for(int i = 0; i < containers.length; i++) - { - if(containers[i] instanceof RenderingViewPane) - { - BigInteger absoluteAddress = null; - if(fGotoAddress.isGoToAddress()) - absoluteAddress = address; - - IMemoryBlock activeMemoryBlock = null; - - if(address != null && containers[i] != null) - { - IMemoryRendering activeRendering = containers[i].getActiveRendering(); - if(activeRendering != null) - { - activeMemoryBlock = activeRendering.getMemoryBlock(); - IMemoryBlockExtension blockExtension = (IMemoryBlockExtension) activeMemoryBlock.getAdapter(IMemoryBlockExtension.class); - if(blockExtension != null) - { - BigInteger baseAddress = null; - BigInteger addressableSize = null; - try - { - baseAddress = blockExtension.getBigBaseAddress(); - addressableSize = BigInteger.valueOf(blockExtension.getAddressableSize()); - } - catch(DebugException de) - { - // TODO - } - - if(baseAddress != null) - { - if(fGotoAddress.isOffset()) - absoluteAddress = baseAddress.add(address); - else if(fGotoAddress.isJump() && addressableSize != null) - absoluteAddress = baseAddress.add(address.multiply(addressableSize)); - } - } - - // 1) Try to reposition the renderings using the IRepositionableMemoryRendering interface - if(absoluteAddress != null && activeRendering instanceof IRepositionableMemoryRendering) - { - try - { - ((IRepositionableMemoryRendering) activeRendering).goToAddress(absoluteAddress); - } - catch(DebugException de) - { - // do nothing - } - } - } - } - } - } - + go(fGotoAddress.getExpressionText(), false); } }; @@ -167,6 +88,16 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { }); } + button = fGotoAddress.getButton(GoToAddressWidget.ID_GO_NEW_TAB); + if (button != null) + { + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + go(fGotoAddress.getExpressionText(), true); + } + }); + } + fGotoAddress.getExpressionWidget().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.CR) @@ -182,5 +113,158 @@ public class TraditionalGoToAddressRendering extends AbstractMemoryRendering { public Control getControl() { return fControl; } - + + private void go(final String expression, final boolean inNewTab) + { + IMemoryRenderingContainer containers[] = fSite.getMemoryRenderingContainers(); + for(int i = 0; i < containers.length; i++) + { + if(containers[i] instanceof RenderingViewPane) + { + final IMemoryRenderingContainer container = containers[i]; + if(containers[i] != null) + { + final IMemoryRendering activeRendering = containers[i].getActiveRendering(); + if(activeRendering != null) + { + new Thread() { + public void run() + { + IMemoryBlock activeMemoryBlock = activeRendering.getMemoryBlock(); + IMemoryBlockExtension blockExtension = (IMemoryBlockExtension) activeMemoryBlock.getAdapter(IMemoryBlockExtension.class); + + if(inNewTab) + { + try { + final IMemoryRendering rendering = new CreateRendering(container); + IMemoryBlock newBlock = null; + if(activeMemoryBlock.getDebugTarget() instanceof IMemoryBlockRetrievalExtension) + { + newBlock = ((IMemoryBlockRetrievalExtension) activeMemoryBlock.getDebugTarget()) + .getExtendedMemoryBlock(expression, activeMemoryBlock.getDebugTarget()); + + } + else + { + BigInteger newAddress; + if(expression.toUpperCase().startsWith("0X")) + newAddress = new BigInteger(expression.substring(2), 16); + else + newAddress = new BigInteger(expression, 16); + + newBlock = activeMemoryBlock.getDebugTarget().getMemoryBlock(newAddress.longValue(), + activeMemoryBlock.getLength()); + } + + final IMemoryBlock finalNewBlock = newBlock; + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + rendering.init(container, finalNewBlock); + container.addMemoryRendering(rendering); + } + }); + + } catch (DebugException e) { + MemoryViewUtil.openError(DebugUIMessages.GoToAddressAction_Go_to_address_failed, + DebugUIMessages.GoToAddressAction_Address_is_invalid, e); + } + } + else if(activeRendering instanceof IRepositionableMemoryRendering) + { + try + { + if(activeMemoryBlock.getDebugTarget() instanceof IMemoryBlockRetrievalExtension) + { + IMemoryBlockExtension resolveExpressionBlock = ((IMemoryBlockRetrievalExtension) activeMemoryBlock.getDebugTarget()) + .getExtendedMemoryBlock(expression, activeMemoryBlock.getDebugTarget()); + ((IRepositionableMemoryRendering) activeRendering).goToAddress(resolveExpressionBlock.getBigBaseAddress()); + } + else + { + BigInteger newAddress; + if(expression.toUpperCase().startsWith("0X")) + newAddress = new BigInteger(expression.substring(2), 16); + else + newAddress = new BigInteger(expression, 16); + + ((IRepositionableMemoryRendering) activeRendering).goToAddress(newAddress); + } + } + catch(DebugException de) + { + MemoryViewUtil.openError(DebugUIMessages.GoToAddressAction_Go_to_address_failed, + DebugUIMessages.GoToAddressAction_Address_is_invalid, de); + } + } + + } + }.start(); + } + } + } + } + } +} + +class GoToAddressWidget { + + private Text fExpression; + private Button fOKButton; + private Button fOKNewTabButton; + private Composite fComposite; + + protected static int ID_GO_NEW_TAB = 2000; + + /** + * @param parent + * @return + */ + public Control createControl(Composite parent) + { + fComposite = new Composite(parent, SWT.NONE); + PlatformUI.getWorkbench().getHelpSystem().setHelp(fComposite, DebugUIPlugin.getUniqueIdentifier() + ".GoToAddressComposite_context"); //$NON-NLS-1$ + GridLayout layout = new GridLayout(); + layout.numColumns = 6; + layout.makeColumnsEqualWidth = false; + layout.marginHeight = 0; + layout.marginLeft = 0; + fComposite.setLayout(layout); + + fExpression = new Text(fComposite, SWT.SINGLE | SWT.BORDER); + fExpression.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + fOKButton = new Button(fComposite, SWT.NONE); + fOKButton.setText("Go"); + +// fOKNewTabButton = new Button(fComposite, SWT.NONE); +// fOKNewTabButton.setText("New Tab"); + + return fComposite; + } + + public int getHeight() + { + int height = fComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; + return height; + } + + public Button getButton(int id) + { + if (id == IDialogConstants.OK_ID) + return fOKButton; + if (id == ID_GO_NEW_TAB) + return fOKNewTabButton; + return null; + } + + public String getExpressionText() + { + return fExpression.getText().trim(); + } + + public Text getExpressionWidget() + { + return fExpression; + } } From 899c96ac5b800d3c9c12fbb42a77118ea135a2f4 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 23 Oct 2008 17:33:45 +0000 Subject: [PATCH 098/118] [251877] Find/Replace dialog incorrectly restores Forward/Backward button states --- .../dd/debug/ui/memory/search/FindReplaceDialog.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 621ce9ee792..6f043f4cbf1 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -565,10 +565,13 @@ public class FindReplaceDialog extends SelectionDialog fForwardButton = new Button(directionGroup, SWT.RADIO); fForwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ - Button backwardButton = new Button(directionGroup, SWT.RADIO); + final Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ - fForwardButton.setSelection(fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true")); - backwardButton.setSelection(!fForwardButton.getSelection()); + final boolean isForward = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true"); + Display.getDefault().asyncExec(new Runnable() { public void run() { + fForwardButton.setSelection(isForward); + backwardButton.setSelection(!isForward); + }}); data = new FormData(); data.top = new FormAttachment(fReplaceText); From 3c61232e71f0a284d81b7d09179d6ded7aa0c4d5 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 23 Oct 2008 19:51:20 +0000 Subject: [PATCH 099/118] [251877] Find/Replace dialog incorrectly restores Forward/Backward button states --- .../ui/memory/search/FindReplaceDialog.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 6f043f4cbf1..eb0cb7f600c 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -568,10 +568,8 @@ public class FindReplaceDialog extends SelectionDialog final Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ final boolean isForward = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true"); - Display.getDefault().asyncExec(new Runnable() { public void run() { - fForwardButton.setSelection(isForward); - backwardButton.setSelection(!isForward); - }}); + fForwardButton.setSelection(isForward); + backwardButton.setSelection(!isForward); data = new FormData(); data.top = new FormAttachment(fReplaceText); @@ -652,16 +650,13 @@ public class FindReplaceDialog extends SelectionDialog final String format = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT, FindReplaceDialog.SEARCH_FORMAT_ASCII); - Display.getDefault().asyncExec(new Runnable(){ - public void run() { - fFormatAsciiButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_ASCII)); - fFormatOctalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_OCTAL)); - fFormatBinaryButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BINARY)); - fFormatDecimalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_DECIMAL)); - fFormatHexButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_HEX)); - fFormatByteSequenceButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BYTESEQUENCE)); - } - }); + fFormatAsciiButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_ASCII)); + fFormatOctalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_OCTAL)); + fFormatBinaryButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BINARY)); + fFormatDecimalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_DECIMAL)); + fFormatHexButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_HEX)); + fFormatByteSequenceButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BYTESEQUENCE)); + data = new FormData(); data.top = new FormAttachment(rangeGroup); @@ -767,9 +762,6 @@ public class FindReplaceDialog extends SelectionDialog } }); - fForwardButton.setSelection(true); - fFormatAsciiButton.setSelection(true); - composite.setTabList(new Control[] { fFindText, fReplaceText, From 4f5ce5c6ebb33b7940a0bd8d64f63074ba7e49d6 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Thu, 23 Oct 2008 20:35:43 +0000 Subject: [PATCH 100/118] [251877] Find/Replace dialog incorrectly restores Forward/Backward button states --- .../ui/memory/search/FindReplaceDialog.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index eb0cb7f600c..1db62399547 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -334,9 +334,9 @@ public class FindReplaceDialog extends SelectionDialog fProperties.setProperty(SEARCH_FORMAT_FORWARD, "" + fForwardButton.getSelection()); - fProperties.setProperty(FindReplaceDialog.SEARCH_FORMAT_CASEINSENSTIVE, "" + fCaseInSensitiveCheckbox.getSelection()); + fProperties.setProperty(SEARCH_FORMAT_CASEINSENSTIVE, "" + fCaseInSensitiveCheckbox.getSelection()); - fProperties.setProperty(FindReplaceDialog.SEARCH_FORMAT_WRAP, "" + fWrapCheckbox.getSelection()); + fProperties.setProperty(SEARCH_FORMAT_WRAP, "" + fWrapCheckbox.getSelection()); fProperties.setProperty(SEARCH_ENABLE_FIND_NEXT, "false"); @@ -532,7 +532,7 @@ public class FindReplaceDialog extends SelectionDialog data.left = new FormAttachment(fReplaceText, 0, SWT.LEFT); data.width = 260; fFindText.setLayoutData(data); - fFindText.setText(fProperties.getProperty(FindReplaceDialog.SEARCH_FIND, "")); + fFindText.setText(fProperties.getProperty(SEARCH_FIND, "")); data = new FormData(); data.top = new FormAttachment(fFindText, 0, SWT.CENTER); @@ -550,7 +550,7 @@ public class FindReplaceDialog extends SelectionDialog data.left = new FormAttachment(replaceLabel); data.width = 260; fReplaceText.setLayoutData(data); - fReplaceText.setText(fProperties.getProperty(FindReplaceDialog.SEARCH_REPLACE, "")); + fReplaceText.setText(fProperties.getProperty(SEARCH_REPLACE, "")); // group direction @@ -567,7 +567,7 @@ public class FindReplaceDialog extends SelectionDialog fForwardButton.setText(Messages.getString("FindReplaceDialog.ButtonForward")); //$NON-NLS-1$ final Button backwardButton = new Button(directionGroup, SWT.RADIO); backwardButton.setText(Messages.getString("FindReplaceDialog.ButtonBackward")); //$NON-NLS-1$ - final boolean isForward = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true"); + final boolean isForward = fProperties.getProperty(SEARCH_FORMAT_FORWARD, "true").equalsIgnoreCase("true"); fForwardButton.setSelection(isForward); backwardButton.setSelection(!isForward); @@ -616,10 +616,10 @@ public class FindReplaceDialog extends SelectionDialog fStartText.setItems(removeNullElements(new String[] { getViewportStart(), getStart(), getEnd(), getMemoryBlockBaseAddress() })); fEndText.setItems(removeNullElements(new String[] { getEnd(), getStart(), getMemoryBlockBaseAddress(), getViewportStart() })); - if(fProperties.getProperty(FindReplaceDialog.SEARCH_START) != null) - fStartText.add(fProperties.getProperty(FindReplaceDialog.SEARCH_START), 0); - if(fProperties.getProperty(FindReplaceDialog.SEARCH_END) != null) - fEndText.add(fProperties.getProperty(FindReplaceDialog.SEARCH_END), 0); + if(fProperties.getProperty(SEARCH_START) != null) + fStartText.add(fProperties.getProperty(SEARCH_START), 0); + if(fProperties.getProperty(SEARCH_END) != null) + fEndText.add(fProperties.getProperty(SEARCH_END), 0); fStartText.select(0); fEndText.select(0); @@ -648,14 +648,14 @@ public class FindReplaceDialog extends SelectionDialog fFormatByteSequenceButton = new Button(formatGroup, SWT.RADIO); fFormatByteSequenceButton.setText(Messages.getString("FindReplaceDialog.ButtonByteSequence")); //$NON-NLS-1$ - final String format = fProperties.getProperty(FindReplaceDialog.SEARCH_FORMAT, FindReplaceDialog.SEARCH_FORMAT_ASCII); + final String format = fProperties.getProperty(SEARCH_FORMAT, FindReplaceDialog.SEARCH_FORMAT_ASCII); - fFormatAsciiButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_ASCII)); - fFormatOctalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_OCTAL)); - fFormatBinaryButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BINARY)); - fFormatDecimalButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_DECIMAL)); - fFormatHexButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_HEX)); - fFormatByteSequenceButton.setSelection(format.equals(FindReplaceDialog.SEARCH_FORMAT_BYTESEQUENCE)); + fFormatAsciiButton.setSelection(format.equals(SEARCH_FORMAT_ASCII)); + fFormatOctalButton.setSelection(format.equals(SEARCH_FORMAT_OCTAL)); + fFormatBinaryButton.setSelection(format.equals(SEARCH_FORMAT_BINARY)); + fFormatDecimalButton.setSelection(format.equals(SEARCH_FORMAT_DECIMAL)); + fFormatHexButton.setSelection(format.equals(SEARCH_FORMAT_HEX)); + fFormatByteSequenceButton.setSelection(format.equals(SEARCH_FORMAT_BYTESEQUENCE)); data = new FormData(); From 129d6e5f36b7d508e2bfcdc200291da17eb159b3 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Thu, 23 Oct 2008 21:09:59 +0000 Subject: [PATCH 101/118] Bugzilla 251925 --- plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml index d3e28970f1e..036231eda44 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/plugin.xml @@ -10,8 +10,7 @@ enablesFor="1" id="org.eclipse.dd.debug.ui.memory.search.FindAction" label="Find Next" - menubarPath="additions" - state="false"> + menubarPath="additions"> + menubarPath="additions"> From 3d8b28336af6ea1b1830a597222f7bbff70b6f39 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Thu, 23 Oct 2008 21:14:04 +0000 Subject: [PATCH 102/118] Bugzilla 251927. --- .../dd/debug/ui/memory/transport/PlainTextExporter.java | 2 +- .../dd/debug/ui/memory/transport/PlainTextImporter.java | 4 ++-- .../dd/debug/ui/memory/transport/SRecordImporter.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index c73b92a261f..2f8369c118c 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -381,7 +381,7 @@ public class PlainTextExporter implements IMemoryExporter { } public void exportMemory() { - Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$ + Job job = new Job("Memory Export to Plain Text File"){ //$NON-NLS-1$ public IStatus run(IProgressMonitor monitor) { try diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 44648ec7368..417f79b46d3 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -171,7 +171,7 @@ public class PlainTextImporter implements IMemoryImporter { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); - dialog.setText("Choose memory export file"); + dialog.setText("Choose memory import file"); dialog.setFilterExtensions(new String[] { "*.*;*" } ); dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); @@ -282,7 +282,7 @@ public class PlainTextImporter implements IMemoryImporter { } public void importMemory() { - Job job = new Job("Memory Download from Plain Text File"){ //$NON-NLS-1$ + Job job = new Job("Memory Import from Plain Text File"){ //$NON-NLS-1$ public IStatus run(IProgressMonitor monitor) { diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 631a12576c9..3d09177cd80 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -166,7 +166,7 @@ public class SRecordImporter implements IMemoryImporter { public void widgetSelected(SelectionEvent e) { FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); - dialog.setText("Choose memory export file"); + dialog.setText("Choose memory import file"); dialog.setFilterExtensions(new String[] { "*.*;*" } ); dialog.setFilterNames(new String[] { "All Files" } ); dialog.setFileName(fFileText.getText()); @@ -268,7 +268,7 @@ public class SRecordImporter implements IMemoryImporter { public String getId() { - return "snfimporter"; + return "srecord"; } public String getName() @@ -277,7 +277,7 @@ public class SRecordImporter implements IMemoryImporter { } public void importMemory() { - Job job = new Job("Memory Download from S-Record File"){ //$NON-NLS-1$ + Job job = new Job("Memory Import from S-Record File"){ //$NON-NLS-1$ public IStatus run(IProgressMonitor monitor) { From 6ee11bc77b9ecb6d9f41f2164c62100ba6fb3729 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Sun, 26 Oct 2008 01:37:28 +0000 Subject: [PATCH 103/118] Bugzilla 252106 --- .../dd/debug/ui/memory/transport/PlainTextExporter.java | 5 +++-- .../dd/debug/ui/memory/transport/PlainTextImporter.java | 5 +++-- .../dd/debug/ui/memory/transport/SRecordExporter.java | 5 +++-- .../dd/debug/ui/memory/transport/SRecordImporter.java | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index 2f8369c118c..bf6ef75b2a2 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -202,9 +202,10 @@ public class PlainTextExporter implements IMemoryExporter { dialog.setFileName(fFileText.getText()); dialog.open(); - if(dialog.getFileName() != null) + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) { - fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + fFileText.setText(dialog.getFilterPath() + File.separator + filename); } validate(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 417f79b46d3..9b676a5f2f1 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -177,9 +177,10 @@ public class PlainTextImporter implements IMemoryImporter { dialog.setFileName(fFileText.getText()); dialog.open(); - if(dialog.getFileName() != null) + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) { - fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + fFileText.setText(dialog.getFilterPath() + File.separator + filename); } validate(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index dfd253ee40b..9f13f1be043 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -198,9 +198,10 @@ public class SRecordExporter implements IMemoryExporter dialog.setFileName(fFileText.getText()); dialog.open(); - if(dialog.getFileName() != null) + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) { - fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + fFileText.setText(dialog.getFilterPath() + File.separator + filename); } validate(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 3d09177cd80..5e4c8b4e6df 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -172,9 +172,10 @@ public class SRecordImporter implements IMemoryImporter { dialog.setFileName(fFileText.getText()); dialog.open(); - if(dialog.getFileName() != null) + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) { - fFileText.setText(dialog.getFilterPath() + File.separator + dialog.getFileName()); + fFileText.setText(dialog.getFilterPath() + File.separator + filename); } validate(); From 4b0daf25c053584db6c767dd288f80feed81bae2 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Oct 2008 05:26:10 +0000 Subject: [PATCH 104/118] [252130] Memory Import should buffer writes to improve performance --- .../transport/BufferedMemoryWriter.java | 83 +++++++++++++++++++ .../memory/transport/PlainTextImporter.java | 7 +- .../ui/memory/transport/SRecordImporter.java | 13 ++- .../transport/model/IMemoryImporter.java | 1 + 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/BufferedMemoryWriter.java diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/BufferedMemoryWriter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/BufferedMemoryWriter.java new file mode 100644 index 00000000000..4b0a50ef216 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/BufferedMemoryWriter.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.math.BigInteger; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlockExtension; + +public class BufferedMemoryWriter +{ + private IMemoryBlockExtension fBlock; + private byte[] fBuffer; + private int fBufferPosition = 0; + private BigInteger fBufferStart = null; + + public BufferedMemoryWriter(IMemoryBlockExtension block, int bufferLength) + { + fBlock = block; + fBuffer = new byte[bufferLength]; + } + + public void write(BigInteger address, byte[] data) throws DebugException + { + while(data.length > 0) + { + if(fBufferStart == null) + { + fBufferStart = address; + int length = data.length <= fBuffer.length ? data.length : fBuffer.length; + System.arraycopy(data, 0, fBuffer, 0, length); + fBufferPosition = length; + byte[] dataRemainder = new byte[data.length - length]; + System.arraycopy(data, length, dataRemainder, 0, data.length - length); + data = dataRemainder; + address = fBufferStart.add(BigInteger.valueOf(length)); + } + else if(fBufferStart.add(BigInteger.valueOf(fBufferPosition)).compareTo(address) != 0) + { + flush(); + } + else + { + int availableBufferLength = fBuffer.length - fBufferPosition; + int length = data.length <= fBuffer.length - availableBufferLength + ? data.length : fBuffer.length - availableBufferLength; + System.arraycopy(data, 0, fBuffer, fBufferPosition, length); + fBufferPosition += length; + + byte[] dataRemainder = new byte[data.length - length]; + System.arraycopy(data, length, dataRemainder, 0, data.length - length); + data = dataRemainder; + address = fBufferStart.add(BigInteger.valueOf(length)); + } + + if(fBufferPosition == fBuffer.length) + flush(); + } + } + + public void flush() throws DebugException + { + if(fBufferStart != null) + { + byte data[] = new byte[fBufferPosition]; + System.arraycopy(fBuffer, 0, data, 0, fBufferPosition); + fBlock.setValue(fBufferStart, data); + fBufferStart = null; + } + } + +} + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 9b676a5f2f1..71f38295918 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -65,6 +65,8 @@ public class PlainTextImporter implements IMemoryImporter { private Properties fProperties; + private static final int BUFFER_LENGTH = 64 * 1024; + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog) { fMemoryBlock = memBlock; @@ -291,6 +293,8 @@ public class PlainTextImporter implements IMemoryImporter { { try { + BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH); + BigInteger offset = null; if(!fUseCustomAddress) offset = BigInteger.ZERO; @@ -329,7 +333,7 @@ public class PlainTextImporter implements IMemoryImporter { if(scrollToAddress == null) scrollToAddress = recordAddress; - ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) + memoryWriter.write(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data); bytesRead += data.length; @@ -347,6 +351,7 @@ public class PlainTextImporter implements IMemoryImporter { line = reader.readLine(); } + memoryWriter.flush(); reader.close(); monitor.done(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 5e4c8b4e6df..601d2135d97 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -47,7 +47,6 @@ public class SRecordImporter implements IMemoryImporter { File fInputFile; BigInteger fStartAddress; - boolean fUseCustomAddress; Boolean fScrollToStart; private Text fStartText; @@ -64,6 +63,8 @@ public class SRecordImporter implements IMemoryImporter { private Properties fProperties; + private static final int BUFFER_LENGTH = 64 * 1024; + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog) { fMemoryBlock = memBlock; @@ -77,6 +78,7 @@ public class SRecordImporter implements IMemoryImporter { fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); fProperties.setProperty(TRANSFER_START, fStartText.getText()); fProperties.setProperty(TRANSFER_SCROLL_TO_START, fScrollToStart.toString()); + fProperties.setProperty(TRANSFER_CUSTOM_START_ADDRESS, "" + fComboRestoreToThisAddress.getSelection()); fStartAddress = getStartAddress(); fInputFile = getFile(); @@ -94,12 +96,14 @@ public class SRecordImporter implements IMemoryImporter { fComboRestoreToFileAddress = new Button(composite, SWT.RADIO); fComboRestoreToFileAddress.setSelection(true); fComboRestoreToFileAddress.setText("Restore to address specified in the file"); + fComboRestoreToFileAddress.setSelection(!new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "true")).booleanValue()); //comboRestoreToFileAddress.setLayoutData(data); // restore to this address fComboRestoreToThisAddress = new Button(composite, SWT.RADIO); fComboRestoreToThisAddress.setText("Restore to this address: "); + fComboRestoreToThisAddress.setSelection(new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "true")).booleanValue()); FormData data = new FormData(); data.top = new FormAttachment(fComboRestoreToFileAddress); fComboRestoreToThisAddress.setLayoutData(data); @@ -286,6 +290,8 @@ public class SRecordImporter implements IMemoryImporter { { try { + BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH); + // FIXME 4 byte default final int CHECKSUM_LENGTH = 1; @@ -293,7 +299,7 @@ public class SRecordImporter implements IMemoryImporter { BigInteger scrollToAddress = null; BigInteger offset = null; - if(!fUseCustomAddress) + if(!fProperties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "false").equals("true")) offset = BigInteger.ZERO; BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); @@ -372,7 +378,7 @@ public class SRecordImporter implements IMemoryImporter { // FIXME error on incorrect checksum - ((IMemoryBlockExtension) fMemoryBlock).setValue(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data); + memoryWriter.write(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data); jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); while(jobCount.compareTo(factor) >= 0) @@ -384,6 +390,7 @@ public class SRecordImporter implements IMemoryImporter { line = reader.readLine(); } + memoryWriter.flush(); reader.close(); monitor.done(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java index cf494524772..ba78776afcc 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/model/IMemoryImporter.java @@ -23,6 +23,7 @@ public interface IMemoryImporter public static final String TRANSFER_FILE = "File"; public static final String TRANSFER_START = "Start"; public static final String TRANSFER_END = "End"; + public static final String TRANSFER_CUSTOM_START_ADDRESS = "CustomStartAddress"; public static final String TRANSFER_SCROLL_TO_START = "ScrollToStart"; public Control createControl(Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog); From be8328b09a7559fd2469fb994576f29b20565468 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 27 Oct 2008 15:45:10 +0000 Subject: [PATCH 105/118] [252130] Memory Import should buffer writes to improve performance --- .../eclipse/dd/debug/ui/memory/transport/SRecordImporter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 601d2135d97..649a881bb1e 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -96,14 +96,14 @@ public class SRecordImporter implements IMemoryImporter { fComboRestoreToFileAddress = new Button(composite, SWT.RADIO); fComboRestoreToFileAddress.setSelection(true); fComboRestoreToFileAddress.setText("Restore to address specified in the file"); - fComboRestoreToFileAddress.setSelection(!new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "true")).booleanValue()); + fComboRestoreToFileAddress.setSelection(!new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "false")).booleanValue()); //comboRestoreToFileAddress.setLayoutData(data); // restore to this address fComboRestoreToThisAddress = new Button(composite, SWT.RADIO); fComboRestoreToThisAddress.setText("Restore to this address: "); - fComboRestoreToThisAddress.setSelection(new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "true")).booleanValue()); + fComboRestoreToThisAddress.setSelection(new Boolean(properties.getProperty(TRANSFER_CUSTOM_START_ADDRESS, "false")).booleanValue()); FormData data = new FormData(); data.top = new FormAttachment(fComboRestoreToFileAddress); fComboRestoreToThisAddress.setLayoutData(data); From 27fd234e78c4989dffae078d4a31389c9f30eb90 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Wed, 29 Oct 2008 19:47:56 +0000 Subject: [PATCH 106/118] [252651] Traditional Rendering should implement IResettableMemoryRendering --- .../renderings/traditional/TraditionalRendering.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index ac369c97bbc..358044b28b6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -36,6 +36,7 @@ import org.eclipse.debug.ui.memory.AbstractTableRendering; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRenderingContainer; import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; +import org.eclipse.debug.ui.memory.IResettableMemoryRendering; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; @@ -94,7 +95,7 @@ import org.eclipse.ui.progress.UIJob; *

*/ -public class TraditionalRendering extends AbstractMemoryRendering implements IRepositionableMemoryRendering +public class TraditionalRendering extends AbstractMemoryRendering implements IRepositionableMemoryRendering, IResettableMemoryRendering { protected Rendering fRendering; protected Action displayEndianBigAction; @@ -1202,6 +1203,10 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe return super.getAdapter(adapter); } + + public void resetRendering() throws DebugException { + fRendering.gotoAddress(fRendering.fBaseAddress); + } } From 4e2105bd6a3c6a5df27c916baaa8f8b6c72f9367 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Sun, 2 Nov 2008 02:27:20 +0000 Subject: [PATCH 107/118] Bugzilla 253087 --- .../traditional/TraditionalRendering.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 358044b28b6..b54b0f0ed02 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -977,12 +977,27 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe newColumnCount = Integer.parseInt(inputDialog.getValue()); } catch (NumberFormatException x) { assert false; } - TraditionalRendering.this.fRendering.setColumnsSetting(newColumnCount); - this.setChecked(false); - - displayColumnCountCustomValue.setChecked(true); - displayColumnCountCustomValue.setText(Integer.valueOf( - fRendering.getColumnsSetting()).toString()); + boolean customIsOneOfStandardListChoices = false; + + for(int i = 0, j = 1; i < MAX_MENU_COLUMN_COUNT; i++, j*=2) { + if ( newColumnCount == j ) { + customIsOneOfStandardListChoices = true; + TraditionalRendering.this.fRendering.setColumnsSetting(newColumnCount); + this.setChecked(false); + displayColumnCountCustomValue.setChecked(false); + displayColumnCounts[i].setChecked(true); + break; + } + } + + if ( ! customIsOneOfStandardListChoices ) { + TraditionalRendering.this.fRendering.setColumnsSetting(newColumnCount); + this.setChecked(false); + + displayColumnCountCustomValue.setChecked(true); + displayColumnCountCustomValue.setText(Integer.valueOf( + fRendering.getColumnsSetting()).toString()); + } } }; From 77b28bc8d7a3c16521463cd91cfa6ebafbd4ce93 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Sun, 2 Nov 2008 03:50:04 +0000 Subject: [PATCH 108/118] Bugzilla 253090. --- .../ui/memory/search/FindReplaceDialog.java | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 1db62399547..53596b904c5 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -194,6 +194,10 @@ public class FindReplaceDialog extends SelectionDialog BigInteger value; if(element.toUpperCase().startsWith("0X")) //$NON-NLS-1$ value = new BigInteger(element.substring(2), 16); + else if(element.toUpperCase().startsWith("0B")) //$NON-NLS-1$ + value = new BigInteger(element.substring(2), 2); + else if(element.toUpperCase().startsWith("0")) //$NON-NLS-1$ + value = new BigInteger(element.substring(1), 8); else value = new BigInteger(element, 10); Byte b = new Byte(value.byteValue()); @@ -383,11 +387,25 @@ public class FindReplaceDialog extends SelectionDialog { BigInteger endAddress = getEndAddress(); BigInteger startAddress = getStartAddress(); - if(getSearchPhrase() != null && getSearchPhrase().getByteLength() > 0) - valid = true; - if(getReplaceData() != null && getReplaceData().length > 0) - replaceValid = true; + /* + * The end-address must be larger that the start-address. + */ + if ( startAddress.compareTo(endAddress) == -1 ) { + /* + * Validate the search phrase. + */ + if(getSearchPhrase() != null && getSearchPhrase().getByteLength() > 0) { + valid = true; + } + + /* + * Validate the replacement phrase. + */ + if(getReplaceData() != null && getReplaceData().length > 0) { + replaceValid = true; + } + } } catch(Throwable ex) { @@ -703,6 +721,7 @@ public class FindReplaceDialog extends SelectionDialog public void widgetSelected(SelectionEvent e) { fCaseInSensitiveCheckbox.setEnabled(false); + validate(); } }; fFormatHexButton.addSelectionListener(nonAsciiListener); @@ -1090,7 +1109,12 @@ public class FindReplaceDialog extends SelectionDialog public int getByteLength() { - return fBytes.length; + if ( fBytes != null ) { + return fBytes.length; + } + else { + return 0; + } } public String toString() @@ -1105,6 +1129,8 @@ public class FindReplaceDialog extends SelectionDialog public boolean isMatch(MemoryByte[] bytes) { + if ( fBytes == null ) + return false; for(int i = 0; i < bytes.length; i++) if(bytes[i].getValue() != fBytes[i]) return false; From e5cff7aaeb46fd49db3d2d7edd7604d7894229b5 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 3 Nov 2008 23:13:44 +0000 Subject: [PATCH 109/118] [253405] Traditional Rendering should support DSF IMemoryBlockUpdatePolicyProvider clearCache API --- .../traditional/TraditionalRendering.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index b54b0f0ed02..2bc1f5a79d6 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -11,6 +11,8 @@ package org.eclipse.dd.debug.memory.renderings.traditional; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.math.BigInteger; import org.eclipse.core.commands.AbstractHandler; @@ -625,6 +627,17 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe { public void run() { + // For compatibility with DSF update modes (hopefully this will either be replaced by an enhanced + // platform interface or the caching will move out of the data layer + try { + Method m = fRendering.getMemoryBlock().getClass().getMethod("clearCache", new Class[0]); + if(m != null) + m.invoke(fRendering.getMemoryBlock(), new Object[0]); + } + catch (Exception e) + { + } + TraditionalRendering.this.fRendering.refresh(); } }); From d80ad003f2084eb687102c957be5a166c2b639cf Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Mon, 17 Nov 2008 19:49:57 +0000 Subject: [PATCH 110/118] Bugzilla 255550 --- .../ui/memory/transport/SRecordExporter.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index 9f13f1be043..689c4ecdcb0 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -301,6 +301,22 @@ public class SRecordExporter implements IMemoryExporter }); composite.pack(); + parent.pack(); + + /* + * We need to perform a validation. If we do it immediately we will get an exception + * because things are not totally setup. So we schedule an immediate running of the + * validation. For a very brief time the view logically may show a state which does + * not reflect the true state of affairs. But the validate immediately corrects the + * info. In practice the user never sees the invalid state displayed, because of the + * speed of the draw of the dialog. + */ + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); return composite; } @@ -364,7 +380,6 @@ public class SRecordExporter implements IMemoryExporter } fParentDialog.setValid(isValid); - } From a259b9f9000ff558d609fb3b70ad587ce6ca691b Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 18 Nov 2008 04:56:37 +0000 Subject: [PATCH 111/118] [255591] [Traditional Memory Rendering] IMemoryBlockConnection adapter forces scroll to base address on update() --- .../renderings/traditional/TraditionalRendering.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 2bc1f5a79d6..94e146a66cd 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -1214,8 +1214,11 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe public void run() { try { - fBigBaseAddress = TraditionalRendering.this.fRendering.getMemoryBlock().getBigBaseAddress(); - TraditionalRendering.this.fRendering.gotoAddress(fBigBaseAddress); + if(fBigBaseAddress != TraditionalRendering.this.fRendering.getMemoryBlock().getBigBaseAddress()) + { + fBigBaseAddress = TraditionalRendering.this.fRendering.getMemoryBlock().getBigBaseAddress(); + TraditionalRendering.this.fRendering.gotoAddress(fBigBaseAddress); + } TraditionalRendering.this.fRendering.refresh(); } catch (DebugException e) From b254ebb961b73b3d7e61337190023253fd1f0ad1 Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Tue, 18 Nov 2008 05:22:56 +0000 Subject: [PATCH 112/118] [255593] [Traditional Rendering] Goto Context Action redundant if experimental Goto Address bar is present --- .../traditional/TraditionalRendering.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java index 94e146a66cd..ed6979e4ad9 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/src/org/eclipse/dd/debug/memory/renderings/traditional/TraditionalRendering.java @@ -25,12 +25,14 @@ import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.IMemoryBlockRetrieval; import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.internal.ui.DebugPluginImages; import org.eclipse.debug.internal.ui.DebugUIMessages; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; import org.eclipse.debug.internal.ui.memory.IMemoryBlockConnection; +import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil; import org.eclipse.debug.internal.ui.views.memory.renderings.GoToAddressAction; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.AbstractMemoryRendering; @@ -1078,7 +1080,28 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe manager.add(copyAction); manager.add(copyAddressAction); - manager.add(gotoAddressAction); + // IMemoryGoToAddressProvider interface, called using reflection, waiting on platform acceptance of patch + final IMemoryBlockRetrieval retrieve = MemoryViewUtil.getMemoryBlockRetrieval(TraditionalRendering.this.getMemoryBlock()); + if (retrieve != null) + { + try + { + Method m = retrieve.getClass().getMethod("getGoToAddressRenderingId", new Class[] {}); + m.setAccessible(true); + + if(m != null) + { + String id = (String) m.invoke(retrieve, new Object[] {}); + if(id == null) + manager.add(gotoAddressAction); + } + } + catch(Exception e) + { + // do nothing + } + } + manager.add(gotoBaseAddressAction); manager.add(refreshAction); manager.add(new Separator()); From 5780c5059bbe0d0c264ffb7f774d447fe0a9cfaa Mon Sep 17 00:00:00 2001 From: Ted Williams Date: Mon, 8 Dec 2008 06:24:29 +0000 Subject: [PATCH 113/118] [257857] [Memory] Review and fix help context for memory search, transport and traditional rendering --- .../plugin.xml | 1 + .../TraditionalRenderingPreferencePage.java | 10 ++++++++++ .../dd/debug/ui/memory/search/FindReplaceDialog.java | 2 +- .../dd/debug/ui/memory/search/MemorySearchPlugin.java | 2 +- .../plugin.xml | 2 +- .../debug/ui/memory/transport/ExportMemoryDialog.java | 2 +- .../debug/ui/memory/transport/ImportMemoryDialog.java | 2 +- 7 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml index 1189c5ee62e..6f0d32931db 100644 --- a/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml +++ b/plugins/org.eclipse.dd.debug.memory.renderings.traditional/plugin.xml @@ -30,6 +30,7 @@ category="org.eclipse.debug.ui.DebugPreferencePage" class="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferencePage" id="org.eclipse.dd.debug.memory.renderings.traditional.TraditionalRenderingPreferencePage" + helpContextId="TraditionalRenderingPreferencePage_context" name="Traditional Memory Rendering"/> Date: Thu, 18 Dec 2008 16:14:39 +0000 Subject: [PATCH 114/118] Bugzilla 257634 - checked in to 1.1.1 branch and now to HEAD. --- .../ui/memory/transport/SRecordImporter.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 649a881bb1e..87c4ac407dc 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -115,6 +115,24 @@ public class SRecordImporter implements IMemoryImporter { data.width = 100; fStartText.setLayoutData(data); + fComboRestoreToFileAddress.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) {} + + public void widgetSelected(SelectionEvent e) { + validate(); + } + }); + + fComboRestoreToThisAddress.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) {} + + public void widgetSelected(SelectionEvent e) { + validate(); + } + }); + // file Label fileLabel = new Label(composite, SWT.NONE); @@ -239,9 +257,17 @@ public class SRecordImporter implements IMemoryImporter { try { - getStartAddress(); - if(!getFile().exists()) - isValid = false; + boolean restoreToAddress = fComboRestoreToThisAddress.getSelection(); + if ( restoreToAddress ) { + getStartAddress(); + } + + boolean restoreToAddressFromFile = fComboRestoreToFileAddress.getSelection(); + if ( restoreToAddressFromFile ) { + if(!getFile().exists()) { + isValid = false; + } + } } catch(Exception e) { From f389aad1d7fa10ed8823ad0dc65d02c30570eda4 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Thu, 22 Jan 2009 17:11:59 +0000 Subject: [PATCH 115/118] Bugzilla 262048 --- .../plugin.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml index 03e31faa3fa..540250d6bb2 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml @@ -6,29 +6,30 @@ id="org.eclipse.dd.debug.ui.memory.transport.dd" name="org.eclipse.dd.debug.ui.memory.transport.dd" point="org.eclipse.dd.debug.ui.memory.transport.memoryTransport"> + - + + - - + From 26eb1a0f20750526b4f2223e14c6845c0aa68098 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Fri, 23 Jan 2009 18:09:57 +0000 Subject: [PATCH 116/118] Bugzillas 262193 , 262196 , 262197 Randy --- .../plugin.xml | 10 + .../memory/transport/ExportMemoryDialog.java | 4 +- .../memory/transport/ImportMemoryDialog.java | 10 +- .../transport/MemoryTransportPlugin.java | 23 + .../memory/transport/PlainTextExporter.java | 11 +- .../memory/transport/PlainTextImporter.java | 18 +- .../memory/transport/RAWBinaryExporter.java | 465 ++++++++++++++++++ .../memory/transport/RAWBinaryImporter.java | 344 +++++++++++++ .../ui/memory/transport/SRecordExporter.java | 9 +- .../ui/memory/transport/SRecordImporter.java | 7 +- .../transport/actions/ExportMemoryAction.java | 7 +- .../transport/actions/ImportMemoryAction.java | 9 +- 12 files changed, 867 insertions(+), 50 deletions(-) create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryExporter.java create mode 100644 plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryImporter.java diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml index 540250d6bb2..ac8db50b99c 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/plugin.xml @@ -29,6 +29,16 @@ class="org.eclipse.dd.debug.ui.memory.transport.PlainTextExporter"> + + + + diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java index 3714645c9a8..8c9bba4fcb3 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ExportMemoryDialog.java @@ -14,7 +14,6 @@ package org.eclipse.dd.debug.ui.memory.transport; import java.util.Properties; import java.util.Vector; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionRegistry; @@ -24,7 +23,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -151,7 +149,7 @@ public class ExportMemoryDialog extends SelectionDialog exporters.addElement((IMemoryExporter) element.createExecutableExtension("class")); } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java index cab3b068518..ae3dd1e519d 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/ImportMemoryDialog.java @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.Status; import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane; import org.eclipse.debug.ui.memory.IMemoryRendering; @@ -195,7 +194,7 @@ public class ImportMemoryDialog extends SelectionDialog importers.addElement((IMemoryImporter) element.createExecutableExtension("class")); } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } @@ -232,10 +231,9 @@ public class ImportMemoryDialog extends SelectionDialog } }); - fFormatCombo.select(0); - fCurrentControl = fFormatImporters[0].createControl(container, - fMemoryBlock, fProperties, ImportMemoryDialog.this); + fCurrentControl = + fFormatImporters[0].createControl(container,fMemoryBlock, fProperties, ImportMemoryDialog.this); return composite; } @@ -244,6 +242,4 @@ public class ImportMemoryDialog extends SelectionDialog { getButton(IDialogConstants.OK_ID).setEnabled(isValid); } - - } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java index 10f6c6e0ea0..212c2c75352 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/MemoryTransportPlugin.java @@ -11,6 +11,9 @@ package org.eclipse.dd.debug.ui.memory.transport; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; public class MemoryTransportPlugin extends AbstractUIPlugin @@ -38,4 +41,24 @@ public class MemoryTransportPlugin extends AbstractUIPlugin public static String getUniqueIdentifier() { return PLUGIN_ID; } + + /** + * Returns the currently active workbench window shell or null + * if none. + * + * @return the currently active workbench window shell or null + */ + public static Shell getShell() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window == null) { + IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); + if (windows.length > 0) { + return windows[0].getShell(); + } + } + else { + return window.getShell(); + } + return null; + } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java index bf6ef75b2a2..5a0b24f481e 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextExporter.java @@ -25,14 +25,9 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FormAttachment; @@ -183,7 +178,7 @@ public class PlainTextExporter implements IMemoryExporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } @@ -464,13 +459,13 @@ public class PlainTextExporter implements IMemoryExporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } return Status.OK_STATUS; diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java index 71f38295918..fdad4521a4d 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/PlainTextImporter.java @@ -27,7 +27,6 @@ import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -160,7 +159,7 @@ public class PlainTextImporter implements IMemoryImporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } @@ -295,10 +294,6 @@ public class PlainTextImporter implements IMemoryImporter { { BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH); - BigInteger offset = null; - if(!fUseCustomAddress) - offset = BigInteger.ZERO; - BigInteger scrollToAddress = null; BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); @@ -333,13 +328,16 @@ public class PlainTextImporter implements IMemoryImporter { if(scrollToAddress == null) scrollToAddress = recordAddress; - memoryWriter.write(recordAddress.subtract(((IMemoryBlockExtension) - fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data); + BigInteger writeAddress = + + recordAddress.subtract(((IMemoryBlockExtension)fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)); + + memoryWriter.write(writeAddress, data); bytesRead += data.length; } - recordAddress = recordAddress.and(BigInteger.valueOf(bytesRead)); + recordAddress = recordAddress.add(BigInteger.valueOf(bytesRead)); jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); while(jobCount.compareTo(factor) >= 0) @@ -360,7 +358,7 @@ public class PlainTextImporter implements IMemoryImporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryExporter.java new file mode 100644 index 00000000000..5d4552c9cd6 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryExporter.java @@ -0,0 +1,465 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.File; +import java.io.FileOutputStream; +import java.math.BigInteger; +import java.util.Properties; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryExporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class RAWBinaryExporter implements IMemoryExporter +{ + File fOutputFile; + BigInteger fStartAddress; + BigInteger fEndAddress; + + private Text fStartText; + private Text fEndText; + private Text fLengthText; + private Text fFileText; + + private IMemoryBlock fMemoryBlock; + + private ExportMemoryDialog fParentDialog; + + private Properties fProperties; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ExportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_END, fEndText.getText()); + + fStartAddress = getStartAddress(); + fEndAddress = getEndAddress(); + fOutputFile = getFile(); + + super.dispose(); + } + }; + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // start address + + Label startLabel = new Label(composite, SWT.NONE); + startLabel.setText("Start address: "); + FormData data = new FormData(); + startLabel.setLayoutData(data); + + fStartText = new Text(composite, SWT.NONE); + data = new FormData(); + data.left = new FormAttachment(startLabel); + data.width = 100; + fStartText.setLayoutData(data); + + // end address + + Label endLabel = new Label(composite, SWT.NONE); + endLabel.setText("End address: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fStartText); + endLabel.setLayoutData(data); + + fEndText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(endLabel); + data.width = 100; + fEndText.setLayoutData(data); + + // length + + Label lengthLabel = new Label(composite, SWT.NONE); + lengthLabel.setText("Length: "); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(fEndText); + lengthLabel.setLayoutData(data); + + fLengthText = new Text(composite, SWT.NONE); + data = new FormData(); + data.top = new FormAttachment(fStartText, 0, SWT.CENTER); + data.left = new FormAttachment(lengthLabel); + data.width = 100; + fLengthText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fLengthText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress(); + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + if(properties.getProperty(TRANSFER_END) != null) + fEndText.setText(properties.getProperty(TRANSFER_END)); + else + fEndText.setText("0x" + startAddress.toString(16)); + + fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory export file"); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) + { + fFileText.setText(dialog.getFilterPath() + File.separator + filename); + } + + validate(); + } + + }); + + fStartText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + fLengthText.setText(endAddress.subtract(startAddress).toString()); + + validate(); + } + + public void keyPressed(KeyEvent e) {} + }); + + fEndText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { + try + { + getEndAddress(); + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + + BigInteger endAddress = getEndAddress(); + BigInteger startAddress = getStartAddress(); + + String lengthString = endAddress.subtract(startAddress).toString(); + + if(!fLengthText.getText().equals(lengthString)) + fLengthText.setText(lengthString); + } + catch(Exception ex) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + public void keyPressed(KeyEvent e) {} + + }); + + fLengthText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { + try + { + BigInteger length = getLength(); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + BigInteger startAddress = getStartAddress(); + String endString = "0x" + startAddress.add(length).toString(16); + if(!fEndText.getText().equals(endString)) + fEndText.setText(endString); + } + catch(Exception ex) + { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + validate(); + } + + + + public void keyPressed(KeyEvent e) { + + } + }); + + fFileText.addKeyListener(new KeyListener() { + public void keyReleased(KeyEvent e) { + validate(); + } + + public void keyPressed(KeyEvent e) { + + } + }); + + composite.pack(); + parent.pack(); + + /* + * We need to perform a validation. If we do it immediately we will get an exception + * because things are not totally setup. So we schedule an immediate running of the + * validation. For a very brief time the view logically may show a state which does + * not reflect the true state of affairs. But the validate immediately corrects the + * info. In practice the user never sees the invalid state displayed, because of the + * speed of the draw of the dialog. + */ + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); + + return composite; + } + + public BigInteger getEndAddress() + { + String text = fEndText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return endAddress; + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public BigInteger getLength() + { + String text = fLengthText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return lengthAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + private void validate() + { + boolean isValid = true; + + try + { + getEndAddress(); + + getStartAddress(); + + BigInteger length = getLength(); + + if(length.compareTo(BigInteger.ZERO) <= 0) + isValid = false; + + if(!getFile().getParentFile().exists()) + isValid = false; + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + } + + + public String getId() + { + return "rawbinary"; + } + + public String getName() + { + return "RAW Binary"; + } + + public void exportMemory() + { + Job job = new Job("Memory Export to RAW Binary File"){ //$NON-NLS-1$ + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + BigInteger DATA_PER_RECORD = BigInteger.valueOf(1024); + + BigInteger transferAddress = fStartAddress; + + FileOutputStream writer = new FileOutputStream(fOutputFile); + + BigInteger jobs = fEndAddress.subtract(transferAddress).divide(DATA_PER_RECORD); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + monitor.beginTask("Transferring Data", jobs.intValue()); + + BigInteger jobCount = BigInteger.ZERO; + while(transferAddress.compareTo(fEndAddress) < 0 && !monitor.isCanceled()) + { + BigInteger length = DATA_PER_RECORD; + if(fEndAddress.subtract(transferAddress).compareTo(length) < 0) + length = fEndAddress.subtract(transferAddress); + + // data + byte[] byteValues = new byte[length.intValue()]; + + MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress, + length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize()); + for(int byteIndex = 0; byteIndex < bytes.length; byteIndex++) + { + byteValues[byteIndex] = bytes[byteIndex].getValue(); + } + + + writer.write(byteValues); + + transferAddress = transferAddress.add(length); + + jobCount = jobCount.add(BigInteger.ONE); + if(jobCount.compareTo(factor) == 0) + { + jobCount = BigInteger.ZERO; + monitor.worked(1); + } + } + + writer.close(); + monitor.done(); + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } + +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryImporter.java new file mode 100644 index 00000000000..298d5751bd1 --- /dev/null +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/RAWBinaryImporter.java @@ -0,0 +1,344 @@ +/******************************************************************************* + * Copyright (c) 2006-2008 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: + * Ted R Williams (Wind River Systems, Inc.) - initial implementation + *******************************************************************************/ + +package org.eclipse.dd.debug.ui.memory.transport; + +import java.io.File; +import java.io.FileInputStream; +import java.math.BigInteger; +import java.util.Properties; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +public class RAWBinaryImporter implements IMemoryImporter { + + File fInputFile; + BigInteger fStartAddress; + Boolean fScrollToStart; + + private Text fStartText; + private Text fFileText; + + private Button fScrollToBeginningOnImportComplete; + + private IMemoryBlock fMemoryBlock; + + private ImportMemoryDialog fParentDialog; + + private Properties fProperties; + + private static final int BUFFER_LENGTH = 64 * 1024; + + public Control createControl(final Composite parent, IMemoryBlock memBlock, Properties properties, ImportMemoryDialog parentDialog) + { + fMemoryBlock = memBlock; + fParentDialog = parentDialog; + fProperties = properties; + + Composite composite = new Composite(parent, SWT.NONE) + { + public void dispose() + { + fProperties.setProperty(TRANSFER_FILE, fFileText.getText()); + fProperties.setProperty(TRANSFER_START, fStartText.getText()); + fProperties.setProperty(TRANSFER_SCROLL_TO_START, fScrollToStart.toString()); + fStartAddress = getStartAddress(); + fInputFile = getFile(); + + super.dispose(); + } + }; + FormLayout formLayout = new FormLayout(); + formLayout.spacing = 5; + formLayout.marginWidth = formLayout.marginHeight = 9; + composite.setLayout(formLayout); + + // restore to this address + + Label labelStartText = new Label(composite, SWT.NONE); + labelStartText.setText("Restore to address: "); + + fStartText = new Text(composite, SWT.NONE); + FormData data = new FormData(); + data.left = new FormAttachment(labelStartText); + data.width = 100; + fStartText.setLayoutData(data); + + // file + + Label fileLabel = new Label(composite, SWT.NONE); + fFileText = new Text(composite, SWT.NONE); + Button fileButton = new Button(composite, SWT.PUSH); + + fileLabel.setText("File name: "); + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + fileLabel.setLayoutData(data); + + data = new FormData(); + data.top = new FormAttachment(fileButton, 0, SWT.CENTER); + data.left = new FormAttachment(fileLabel); + data.width = 300; + fFileText.setLayoutData(data); + + fileButton.setText("Browse..."); + data = new FormData(); + data.top = new FormAttachment(fStartText); + data.left = new FormAttachment(fFileText); + fileButton.setLayoutData(data); + + fFileText.setText(properties.getProperty(TRANSFER_FILE, "")); + fScrollToStart = new Boolean(properties.getProperty(TRANSFER_SCROLL_TO_START, "true")); + try + { + BigInteger startAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + startAddress = ((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress(); + else + startAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + if(properties.getProperty(TRANSFER_START) != null) + fStartText.setText(properties.getProperty(TRANSFER_START)); + else + fStartText.setText("0x" + startAddress.toString(16)); + + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + + fileButton.addSelectionListener(new SelectionListener() { + + public void widgetDefaultSelected(SelectionEvent e) { + } + + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setText("Choose memory import file"); + dialog.setFilterExtensions(new String[] { "*.*;*" } ); + dialog.setFilterNames(new String[] { "All Files" } ); + dialog.setFileName(fFileText.getText()); + dialog.open(); + + String filename = dialog.getFileName(); + if(filename != null && filename.length() != 0 ) + { + fFileText.setText(dialog.getFilterPath() + File.separator + filename); + } + + validate(); + } + + }); + + fStartText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + boolean valid = true; + try + { + getStartAddress(); + } + catch(Exception ex) + { + valid = false; + } + + fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : + Display.getDefault().getSystemColor(SWT.COLOR_RED)); + + // + + validate(); + } + + }); + fFileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + fScrollToBeginningOnImportComplete = new Button(composite, SWT.CHECK); + fScrollToBeginningOnImportComplete.setText("Scroll to File Start Address"); + data = new FormData(); + data.top = new FormAttachment(fileButton); + fScrollToBeginningOnImportComplete.setLayoutData(data); + + composite.pack(); + parent.pack(); + + Display.getDefault().asyncExec(new Runnable(){ + public void run() + { + validate(); + } + }); + + return composite; + } + + private void validate() + { + boolean isValid = true; + + try + { + getStartAddress(); + if(!getFile().exists()) + isValid = false; + } + catch(Exception e) + { + isValid = false; + } + + fParentDialog.setValid(isValid); + } + + public boolean getScrollToStart() + { + return fScrollToBeginningOnImportComplete.getSelection(); + } + + public BigInteger getStartAddress() + { + String text = fStartText.getText(); + boolean hex = text.startsWith("0x"); + BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text, + hex ? 16 : 10); + + return startAddress; + } + + public File getFile() + { + return new File(fFileText.getText()); + } + + public String getId() + { + return "rawbinary"; + } + + public String getName() + { + return "RAW Binary"; + } + + public void importMemory() { + Job job = new Job("Memory Import from RAW Binary File"){ //$NON-NLS-1$ + + public IStatus run(IProgressMonitor monitor) { + + try + { + try + { + BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH); + + BigInteger scrollToAddress = null; + + FileInputStream reader = new FileInputStream(fInputFile); + + BigInteger jobs = BigInteger.valueOf(fInputFile.length()); + BigInteger factor = BigInteger.ONE; + if(jobs.compareTo(BigInteger.valueOf(0x7FFFFFFF)) > 0) + { + factor = jobs.divide(BigInteger.valueOf(0x7FFFFFFF)); + jobs = jobs.divide(factor); + } + + byte[] byteValues = new byte[1024]; + + monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$ + + BigInteger jobCount = BigInteger.ZERO; + int actualByteCount = reader.read(byteValues); + BigInteger recordAddress = fStartAddress; + + while(actualByteCount != -1 && !monitor.isCanceled()) + { + byte data[] = new byte[actualByteCount]; + for(int i = 0; i < data.length; i++) + { + data[i] = byteValues[i]; + } + + if(scrollToAddress == null) + scrollToAddress = recordAddress; + + BigInteger baseAddress = null; + if(fMemoryBlock instanceof IMemoryBlockExtension) + baseAddress = ((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress(); + else + baseAddress = BigInteger.valueOf(fMemoryBlock.getStartAddress()); + + memoryWriter.write(recordAddress.subtract(baseAddress), data); + + jobCount = jobCount.add(BigInteger.valueOf(actualByteCount)); + while(jobCount.compareTo(factor) >= 0) + { + jobCount = jobCount.subtract(factor); + monitor.worked(1); + } + + recordAddress.add(BigInteger.valueOf(actualByteCount)); + actualByteCount = reader.read(byteValues); + } + + memoryWriter.flush(); + reader.close(); + monitor.done(); + + if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true")) + fParentDialog.scrollRenderings(scrollToAddress); + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + } + catch(Exception e) + { + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + DebugException.INTERNAL_ERROR, "Failure", e)); + } + return Status.OK_STATUS; + }}; + job.setUser(true); + job.schedule(); + } +} diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java index 689c4ecdcb0..44f648f8ee7 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordExporter.java @@ -25,12 +25,9 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.MemoryByte; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FormAttachment; @@ -179,7 +176,7 @@ public class SRecordExporter implements IMemoryExporter } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } @@ -493,13 +490,13 @@ public class SRecordExporter implements IMemoryExporter } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } return Status.OK_STATUS; diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java index 87c4ac407dc..83a715bdbb8 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/SRecordImporter.java @@ -26,7 +26,6 @@ import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -175,7 +174,7 @@ public class SRecordImporter implements IMemoryImporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } @@ -425,13 +424,13 @@ public class SRecordImporter implements IMemoryImporter { } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } } catch(Exception e) { - DebugUIPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), + MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(), DebugException.INTERNAL_ERROR, "Failure", e)); } return Status.OK_STATUS; diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java index fdfb490745e..4dcb0f23cbf 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ExportMemoryAction.java @@ -12,16 +12,13 @@ package org.eclipse.dd.debug.ui.memory.transport.actions; import org.eclipse.dd.debug.ui.memory.transport.ExportMemoryDialog; +import org.eclipse.dd.debug.ui.memory.transport.MemoryTransportPlugin; import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; -import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; -import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; @@ -69,7 +66,7 @@ public class ExportMemoryAction implements IViewActionDelegate { IMemoryBlock memBlock = getMemoryBlock(selection); if(memBlock == null) return; - ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock); + ExportMemoryDialog dialog = new ExportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock); dialog.open(); dialog.getResult(); diff --git a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java index b2c3f34aa16..a60553feab9 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.transport/src/org/eclipse/dd/debug/ui/memory/transport/actions/ImportMemoryAction.java @@ -12,18 +12,13 @@ package org.eclipse.dd.debug.ui.memory.transport.actions; import org.eclipse.dd.debug.ui.memory.transport.ImportMemoryDialog; +import org.eclipse.dd.debug.ui.memory.transport.MemoryTransportPlugin; import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.views.memory.MemoryView; -import org.eclipse.debug.internal.ui.views.memory.MemoryViewIdRegistry; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.contexts.IDebugContextService; import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; @@ -77,7 +72,7 @@ public class ImportMemoryAction implements IViewActionDelegate { if(memBlock == null) return; - ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock, fView); + ImportMemoryDialog dialog = new ImportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock, fView); dialog.open(); dialog.getResult(); From e87b55fc2c3ed2755c49531c3131dc05ffcc1361 Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Fri, 23 Jan 2009 18:41:08 +0000 Subject: [PATCH 117/118] Bugzilla 262213 --- .../org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index 1a69bdb0019..b36fc46a9fd 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -413,6 +413,7 @@ public class FindReplaceDialog extends SelectionDialog } fFindButton.setEnabled(valid); + fFindAllButton.setEnabled(valid); fReplaceButton.setEnabled(replaceValid); fReplaceFindButton.setEnabled(replaceValid); fReplaceAllButton.setEnabled(replaceValid); From 8a526a1b6d440e8078cb51f345dfa914615b6a6c Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Thu, 5 Feb 2009 20:05:17 +0000 Subject: [PATCH 118/118] Bugzilla 263854 --- .../debug/ui/memory/search/FindReplaceDialog.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java index b36fc46a9fd..772e1426de3 100644 --- a/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java +++ b/plugins/org.eclipse.dd.debug.ui.memory.search/src/org/eclipse/dd/debug/ui/memory/search/FindReplaceDialog.java @@ -903,12 +903,18 @@ public class FindReplaceDialog extends SelectionDialog throws OperationCanceledException { final BigInteger searchPhraseLength = BigInteger.valueOf(searchPhrase.getByteLength()); - BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); - BigInteger currentPosition = start; + BigInteger range = start.subtract(end); + //BigInteger range = searchForward ? end.subtract(start) : start.subtract(end); + //BigInteger currentPosition = start; + BigInteger currentPosition = searchForward ? start : end.subtract(searchPhraseLength); + if ( range.compareTo(searchPhraseLength) >= 0 ) { + return Status.OK_STATUS; + } + boolean isReplace = replaceData != null; - BigInteger jobs = range.subtract(searchPhraseLength); + BigInteger jobs = range; BigInteger factor = BigInteger.ONE; if(jobs.compareTo(BigInteger.valueOf(0x07FFFFFF)) > 0) { @@ -926,7 +932,7 @@ public class FindReplaceDialog extends SelectionDialog boolean matched = false; while(((searchForward && currentPosition.compareTo(end.subtract(searchPhraseLength)) < 0) - || (!searchForward && currentPosition.compareTo(end) > 0)) && !monitor.isCanceled()) + || (!searchForward && currentPosition.compareTo(start) > 0)) && !monitor.isCanceled()) { try {