mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +02:00
Bug 378294 : The SRecord importer/exporter dialogs allow entry of
addresses that are more than 32-bits Change-Id: I529b9a85d25327c4a48d809f52fd2d87d80a80fd Reviewed-on: https://git.eclipse.org/r/5787 Reviewed-by: Randy Rohrbach <Randy.Rohrbach@Windriver.com> IP-Clean: Randy Rohrbach <Randy.Rohrbach@Windriver.com> Tested-by: Randy Rohrbach <Randy.Rohrbach@Windriver.com>
This commit is contained in:
parent
6091c93f7b
commit
d768c30d0c
2 changed files with 84 additions and 49 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -66,7 +66,6 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
|
|
||||||
Composite composite = new Composite(parent, SWT.NONE)
|
Composite composite = new Composite(parent, SWT.NONE)
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
fProperties.put(TRANSFER_FILE, fFileText.getText());
|
fProperties.put(TRANSFER_FILE, fFileText.getText());
|
||||||
|
@ -192,27 +191,25 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
|
|
||||||
fStartText.addKeyListener(new KeyListener() {
|
fStartText.addKeyListener(new KeyListener() {
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
boolean valid = true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getStartAddress();
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
|
||||||
|
String lengthString = actualLength.toString();
|
||||||
|
|
||||||
|
if(!fLengthText.getText().equals(lengthString)) {
|
||||||
|
if ( ! actualLength.equals( BigInteger.ZERO ) ) {
|
||||||
|
fLengthText.setText(lengthString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
valid = false;
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
validate();
|
||||||
|
//fParentDialog.setValid(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) {}
|
public void keyPressed(KeyEvent e) {}
|
||||||
|
@ -222,23 +219,25 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getEndAddress();
|
|
||||||
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
|
||||||
BigInteger endAddress = getEndAddress();
|
BigInteger actualLength = getEndAddress().subtract(getStartAddress());
|
||||||
BigInteger startAddress = getStartAddress();
|
String lengthString = actualLength.toString();
|
||||||
|
|
||||||
String lengthString = endAddress.subtract(startAddress).toString();
|
|
||||||
|
|
||||||
if(!fLengthText.getText().equals(lengthString))
|
if(!fLengthText.getText().equals(lengthString)) {
|
||||||
fLengthText.setText(lengthString);
|
if ( ! actualLength.equals( BigInteger.ZERO ) ) {
|
||||||
|
fLengthText.setText(lengthString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
fEndText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
validate();
|
||||||
|
//fParentDialog.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e) {}
|
public void keyPressed(KeyEvent e) {}
|
||||||
|
@ -251,20 +250,22 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
{
|
{
|
||||||
BigInteger length = getLength();
|
BigInteger length = getLength();
|
||||||
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
BigInteger startAddress = getStartAddress();
|
String endString = "0x" + getStartAddress().add(length).toString(16); //$NON-NLS-1$
|
||||||
String endString = "0x" + startAddress.add(length).toString(16); //$NON-NLS-1$
|
if(!fEndText.getText().equals(endString)) {
|
||||||
if(!fEndText.getText().equals(endString))
|
if ( ! length.equals( BigInteger.ZERO ) ) {
|
||||||
|
fLengthText.setText(endString);
|
||||||
|
}
|
||||||
fEndText.setText(endString);
|
fEndText.setText(endString);
|
||||||
|
}
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
fLengthText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
validate();
|
||||||
|
//fParentDialog.setValid(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
|
|
||||||
|
@ -309,6 +310,10 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
|
BigInteger endAddress = new BigInteger(hex ? text.substring(2) : text,
|
||||||
hex ? 16 : 10);
|
hex ? 16 : 10);
|
||||||
|
|
||||||
|
if ( endAddress.bitLength() > 32 ) {
|
||||||
|
throw(new NumberFormatException("End Address is larger than 32 bits"));
|
||||||
|
}
|
||||||
|
|
||||||
return endAddress;
|
return endAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,6 +324,10 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
|
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
|
||||||
hex ? 16 : 10);
|
hex ? 16 : 10);
|
||||||
|
|
||||||
|
if ( startAddress.bitLength() > 32 ) {
|
||||||
|
throw(new NumberFormatException("Start Address is larger than 32 bits"));
|
||||||
|
}
|
||||||
|
|
||||||
return startAddress;
|
return startAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,6 +338,7 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
|
BigInteger lengthAddress = new BigInteger(hex ? text.substring(2) : text,
|
||||||
hex ? 16 : 10);
|
hex ? 16 : 10);
|
||||||
|
|
||||||
|
|
||||||
return lengthAddress;
|
return lengthAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +387,6 @@ public class SRecordExporter implements IMemoryExporter
|
||||||
public void exportMemory()
|
public void exportMemory()
|
||||||
{
|
{
|
||||||
Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$
|
Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$
|
||||||
@Override
|
|
||||||
public IStatus run(IProgressMonitor monitor) {
|
public IStatus run(IProgressMonitor monitor) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.eclipse.debug.core.model.IMemoryBlock;
|
||||||
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
import org.eclipse.debug.core.model.IMemoryBlockExtension;
|
||||||
import org.eclipse.jface.dialogs.IDialogSettings;
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.swt.SWT;
|
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.ModifyEvent;
|
||||||
import org.eclipse.swt.events.ModifyListener;
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -73,7 +75,6 @@ public class SRecordImporter implements IMemoryImporter {
|
||||||
|
|
||||||
Composite composite = new Composite(parent, SWT.NONE)
|
Composite composite = new Composite(parent, SWT.NONE)
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
fProperties.put(TRANSFER_FILE, fFileText.getText());
|
fProperties.put(TRANSFER_FILE, fFileText.getText());
|
||||||
|
@ -131,7 +132,17 @@ public class SRecordImporter implements IMemoryImporter {
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {}
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
||||||
|
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
validate();
|
try
|
||||||
|
{
|
||||||
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
getStartAddress();
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
fParentDialog.setValid(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -190,27 +201,38 @@ public class SRecordImporter implements IMemoryImporter {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
fStartText.addModifyListener(new ModifyListener() {
|
fStartText.addKeyListener(new KeyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
boolean valid = true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getStartAddress();
|
boolean restoreToAddress = fComboRestoreToThisAddress.getSelection();
|
||||||
|
if ( restoreToAddress ) {
|
||||||
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
getStartAddress();
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getStartAddress();
|
||||||
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
valid = false;
|
fStartText.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
fStartText.setForeground(valid ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) :
|
|
||||||
Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
validate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void keyPressed(KeyEvent e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
fFileText.addModifyListener(new ModifyListener() {
|
fFileText.addModifyListener(new ModifyListener() {
|
||||||
public void modifyText(ModifyEvent e) {
|
public void modifyText(ModifyEvent e) {
|
||||||
validate();
|
validate();
|
||||||
|
@ -276,6 +298,11 @@ public class SRecordImporter implements IMemoryImporter {
|
||||||
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
|
BigInteger startAddress = new BigInteger(hex ? text.substring(2) : text,
|
||||||
hex ? 16 : 10);
|
hex ? 16 : 10);
|
||||||
|
|
||||||
|
|
||||||
|
if ( startAddress.bitLength() > 32 ) {
|
||||||
|
throw(new NumberFormatException("Start Address is larger than 32 bits"));
|
||||||
|
}
|
||||||
|
|
||||||
return startAddress;
|
return startAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +324,6 @@ public class SRecordImporter implements IMemoryImporter {
|
||||||
public void importMemory() {
|
public void importMemory() {
|
||||||
Job job = new Job("Memory Import from S-Record File"){ //$NON-NLS-1$
|
Job job = new Job("Memory Import from S-Record File"){ //$NON-NLS-1$
|
||||||
|
|
||||||
@Override
|
|
||||||
public IStatus run(IProgressMonitor monitor) {
|
public IStatus run(IProgressMonitor monitor) {
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
Loading…
Add table
Reference in a new issue