diff --git a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java index b26235a224a..21c1584aae9 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.memorybrowser/src/org/eclipse/cdt/debug/ui/memory/memorybrowser/MemoryBrowser.java @@ -995,7 +995,9 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IM if(tabFolder != null) { fStackLayout.topControl = tabFolder; CTabItem tabItem = (CTabItem) tabFolder.getSelection(); - getSite().getSelectionProvider().setSelection(new StructuredSelection(tabItem.getData(KEY_RENDERING))); + if ( tabItem != null ) { + getSite().getSelectionProvider().setSelection(new StructuredSelection(tabItem.getData(KEY_RENDERING))); + } handleTabActivated(tabItem); } else { diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java index 35766ded478..ffeb18f5788 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/PlainTextExporter.java @@ -159,11 +159,41 @@ public class PlainTextExporter implements IMemoryExporter { textValue = fProperties.get(TRANSFER_START); fStartText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ + + try + { + getStartAddress(); + } + catch(Exception e) + { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ - - fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + + try + { + getEndAddress(); + } + catch(Exception e) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + try + { + BigInteger length = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(length.toString()); + if(length.compareTo(BigInteger.ZERO) <= 0) { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + } + catch(Exception e) + { + fLengthText.setText("0"); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fileButton.addSelectionListener(new SelectionAdapter() { @@ -195,13 +225,25 @@ public class PlainTextExporter implements IMemoryExporter { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger actualLength = getEndAddress().subtract(getStartAddress()); + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); fLengthText.setText(actualLength.toString()); if(actualLength.compareTo(BigInteger.ZERO) <= 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -230,6 +272,18 @@ public class PlainTextExporter implements IMemoryExporter { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -252,15 +306,39 @@ public class PlainTextExporter implements IMemoryExporter { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger length = getLength(); - String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$ fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; + BigInteger startAddress = getStartAddress(); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + fEndText.setText(endString); if(length.compareTo(BigInteger.ZERO) <= 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java index 0a622e17333..1f4190cafbd 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/RAWBinaryExporter.java @@ -158,11 +158,41 @@ public class RAWBinaryExporter implements IMemoryExporter textValue = fProperties.get(TRANSFER_START); fStartText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ + + try + { + getStartAddress(); + } + catch(Exception e) + { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } textValue = fProperties.get(TRANSFER_END); fEndText.setText(textValue != null ? textValue : "0x0"); //$NON-NLS-1$ - - fLengthText.setText(getEndAddress().subtract(getStartAddress()).toString()); + + try + { + getEndAddress(); + } + catch(Exception e) + { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + try + { + BigInteger length = getEndAddress().subtract(getStartAddress()); + fLengthText.setText(length.toString()); + if(length.compareTo(BigInteger.ZERO) <= 0) { + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + } + catch(Exception e) + { + fLengthText.setText("0"); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } fileButton.addSelectionListener(new SelectionListener() { @@ -196,13 +226,25 @@ public class RAWBinaryExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger actualLength = getEndAddress().subtract(getStartAddress()); + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); fLengthText.setText(actualLength.toString()); if(actualLength.compareTo(BigInteger.ZERO) <= 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -231,6 +273,18 @@ public class RAWBinaryExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -253,15 +307,39 @@ public class RAWBinaryExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger length = getLength(); - String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$ fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; + BigInteger startAddress = getStartAddress(); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + fEndText.setText(endString); if(length.compareTo(BigInteger.ZERO) <= 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { diff --git a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java index c76326874f8..9484110a842 100644 --- a/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java +++ b/memory/org.eclipse.cdt.debug.ui.memory.transport/src/org/eclipse/cdt/debug/ui/memory/transport/SRecordExporter.java @@ -249,13 +249,25 @@ public class SRecordExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger actualLength = getEndAddress().subtract(getStartAddress()); + BigInteger startAddress = getStartAddress(); + BigInteger actualLength = getEndAddress().subtract(startAddress); fLengthText.setText(actualLength.toString()); if(actualLength.compareTo(BigInteger.ZERO) <= 0) { fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -284,6 +296,18 @@ public class SRecordExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + BigInteger startAddress = getStartAddress(); + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + BigInteger endAddress = getEndAddress(); + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) { @@ -306,15 +330,39 @@ public class SRecordExporter implements IMemoryExporter fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); - BigInteger length = getLength(); - String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$ fStartText.setText(fStartText.getText().trim()); + + BigInteger length = getLength(); + String endString; + BigInteger startAddress = getStartAddress(); + BigInteger endAddress = startAddress.add(length); + + if(length.compareTo(BigInteger.ZERO) <= 0) { + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + endString = endAddress.toString(16); //$NON-NLS-1$ + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + } + else { + endString = "0x" + endAddress.toString(16); //$NON-NLS-1$ + } + fEndText.setText(endString); if(length.compareTo(BigInteger.ZERO) <= 0) { fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); } + + if(startAddress.compareTo(BigInteger.ZERO) < 0) { + fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } + + if(endAddress.compareTo(BigInteger.ZERO) < 0) { + fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED)); + } } catch(Exception ex) {