1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bugzillas

262193 , 262196 , 262197

   Randy
This commit is contained in:
Randy Rohrbach 2009-01-23 18:09:57 +00:00
parent f389aad1d7
commit 26eb1a0f20
12 changed files with 867 additions and 50 deletions

View file

@ -29,6 +29,16 @@
class="org.eclipse.dd.debug.ui.memory.transport.PlainTextExporter"> class="org.eclipse.dd.debug.ui.memory.transport.PlainTextExporter">
</exporter> </exporter>
<importer
name="RAWBinaryImporter"
id="org.eclipse.dd.debug.ui.memory.transport.RAWBinaryImporter"
class="org.eclipse.dd.debug.ui.memory.transport.RAWBinaryImporter">
</importer>
<exporter
name="RAWBInaryExporter"
id="org.eclipse.dd.debug.ui.memory.transport.RAWBinaryExporter"
class="org.eclipse.dd.debug.ui.memory.transport.RAWBinaryExporter">
</exporter>
</extension> </extension>

View file

@ -14,7 +14,6 @@ package org.eclipse.dd.debug.ui.memory.transport;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry; 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.dd.debug.ui.memory.transport.model.IMemoryExporter;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
@ -151,7 +149,7 @@ public class ExportMemoryDialog extends SelectionDialog
exporters.addElement((IMemoryExporter) element.createExecutableExtension("class")); exporters.addElement((IMemoryExporter) element.createExecutableExtension("class"));
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }

View file

@ -25,7 +25,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter; import org.eclipse.dd.debug.ui.memory.transport.model.IMemoryImporter;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; 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.MemoryView;
import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane; import org.eclipse.debug.internal.ui.views.memory.RenderingViewPane;
import org.eclipse.debug.ui.memory.IMemoryRendering; import org.eclipse.debug.ui.memory.IMemoryRendering;
@ -195,7 +194,7 @@ public class ImportMemoryDialog extends SelectionDialog
importers.addElement((IMemoryImporter) element.createExecutableExtension("class")); importers.addElement((IMemoryImporter) element.createExecutableExtension("class"));
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }
@ -232,10 +231,9 @@ public class ImportMemoryDialog extends SelectionDialog
} }
}); });
fFormatCombo.select(0); fFormatCombo.select(0);
fCurrentControl = fFormatImporters[0].createControl(container, fCurrentControl =
fMemoryBlock, fProperties, ImportMemoryDialog.this); fFormatImporters[0].createControl(container,fMemoryBlock, fProperties, ImportMemoryDialog.this);
return composite; return composite;
} }
@ -244,6 +242,4 @@ public class ImportMemoryDialog extends SelectionDialog
{ {
getButton(IDialogConstants.OK_ID).setEnabled(isValid); getButton(IDialogConstants.OK_ID).setEnabled(isValid);
} }
} }

View file

@ -11,6 +11,9 @@
package org.eclipse.dd.debug.ui.memory.transport; 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; import org.eclipse.ui.plugin.AbstractUIPlugin;
public class MemoryTransportPlugin extends AbstractUIPlugin public class MemoryTransportPlugin extends AbstractUIPlugin
@ -38,4 +41,24 @@ public class MemoryTransportPlugin extends AbstractUIPlugin
public static String getUniqueIdentifier() { public static String getUniqueIdentifier() {
return PLUGIN_ID; return PLUGIN_ID;
} }
/**
* Returns the currently active workbench window shell or <code>null</code>
* if none.
*
* @return the currently active workbench window shell or <code>null</code>
*/
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;
}
} }

View file

@ -25,14 +25,9 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.swt.SWT; 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.KeyEvent;
import org.eclipse.swt.events.KeyListener; 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.SelectionEvent;
import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormAttachment;
@ -183,7 +178,7 @@ public class PlainTextExporter implements IMemoryExporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
@ -464,13 +459,13 @@ public class PlainTextExporter implements IMemoryExporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
return Status.OK_STATUS; return Status.OK_STATUS;

View file

@ -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.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -160,7 +159,7 @@ public class PlainTextImporter implements IMemoryImporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
@ -295,10 +294,6 @@ public class PlainTextImporter implements IMemoryImporter {
{ {
BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH); BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH);
BigInteger offset = null;
if(!fUseCustomAddress)
offset = BigInteger.ZERO;
BigInteger scrollToAddress = null; BigInteger scrollToAddress = null;
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile))); BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(fInputFile)));
@ -333,13 +328,16 @@ public class PlainTextImporter implements IMemoryImporter {
if(scrollToAddress == null) if(scrollToAddress == null)
scrollToAddress = recordAddress; scrollToAddress = recordAddress;
memoryWriter.write(recordAddress.subtract(((IMemoryBlockExtension) BigInteger writeAddress =
fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead)), data);
recordAddress.subtract(((IMemoryBlockExtension)fMemoryBlock).getBigBaseAddress()).add(BigInteger.valueOf(bytesRead));
memoryWriter.write(writeAddress, data);
bytesRead += data.length; bytesRead += data.length;
} }
recordAddress = recordAddress.and(BigInteger.valueOf(bytesRead)); recordAddress = recordAddress.add(BigInteger.valueOf(bytesRead));
jobCount = jobCount.add(BigInteger.valueOf(bytesRead)); jobCount = jobCount.add(BigInteger.valueOf(bytesRead));
while(jobCount.compareTo(factor) >= 0) while(jobCount.compareTo(factor) >= 0)
@ -360,7 +358,7 @@ public class PlainTextImporter implements IMemoryImporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -25,12 +25,9 @@ import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener; 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.SelectionEvent;
import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormAttachment;
@ -179,7 +176,7 @@ public class SRecordExporter implements IMemoryExporter
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
@ -493,13 +490,13 @@ public class SRecordExporter implements IMemoryExporter
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
return Status.OK_STATUS; return Status.OK_STATUS;

View file

@ -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.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension; import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
@ -175,7 +174,7 @@ public class SRecordImporter implements IMemoryImporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
@ -425,13 +424,13 @@ public class SRecordImporter implements IMemoryImporter {
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
} }
catch(Exception 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)); DebugException.INTERNAL_ERROR, "Failure", e));
} }
return Status.OK_STATUS; return Status.OK_STATUS;

View file

@ -12,16 +12,13 @@
package org.eclipse.dd.debug.ui.memory.transport.actions; 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.ExportMemoryDialog;
import org.eclipse.dd.debug.ui.memory.transport.MemoryTransportPlugin;
import org.eclipse.debug.core.model.IMemoryBlock; 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.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.debug.ui.memory.IMemoryRendering;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
@ -69,7 +66,7 @@ public class ExportMemoryAction implements IViewActionDelegate {
IMemoryBlock memBlock = getMemoryBlock(selection); IMemoryBlock memBlock = getMemoryBlock(selection);
if(memBlock == null) if(memBlock == null)
return; return;
ExportMemoryDialog dialog = new ExportMemoryDialog(DebugUIPlugin.getShell(), memBlock); ExportMemoryDialog dialog = new ExportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock);
dialog.open(); dialog.open();
dialog.getResult(); dialog.getResult();

View file

@ -12,18 +12,13 @@
package org.eclipse.dd.debug.ui.memory.transport.actions; 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.ImportMemoryDialog;
import org.eclipse.dd.debug.ui.memory.transport.MemoryTransportPlugin;
import org.eclipse.debug.core.model.IMemoryBlock; 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.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.debug.ui.memory.IMemoryRendering;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
@ -77,7 +72,7 @@ public class ImportMemoryAction implements IViewActionDelegate {
if(memBlock == null) if(memBlock == null)
return; return;
ImportMemoryDialog dialog = new ImportMemoryDialog(DebugUIPlugin.getShell(), memBlock, fView); ImportMemoryDialog dialog = new ImportMemoryDialog(MemoryTransportPlugin.getShell(), memBlock, fView);
dialog.open(); dialog.open();
dialog.getResult(); dialog.getResult();