1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bugzilla defects

256775
283586
287540
290710
292059
292120
292293
This commit is contained in:
Randy Rohrbach 2009-10-18 04:53:48 +00:00
parent 6cb229669e
commit 0d66821cc1
14 changed files with 643 additions and 532 deletions

View file

@ -516,7 +516,7 @@
</extension>
<!-- memory update policy -->
<!-- memory update policy
<extension
point="org.eclipse.ui.viewActions">
<viewContribution
@ -557,6 +557,7 @@
</action>
</viewContribution>
</extension>
-->
<!-- Debug view context menu contributions -->
<extension point="org.eclipse.ui.popupMenus">

View file

@ -70,8 +70,8 @@ import org.eclipse.swt.custom.CTabFolder2Adapter;
import org.eclipse.swt.custom.CTabFolderEvent;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
@ -103,6 +103,7 @@ import org.eclipse.ui.progress.WorkbenchJob;
*
*/
@SuppressWarnings("restriction")
public class MemoryBrowser extends ViewPart implements IDebugContextListener, ILaunchListener, IMemoryRenderingSite
{
public static final String ID = "org.eclipse.cdt.debug.ui.memory.memorybrowser.MemoryBrowser"; //$NON-NLS-1$
@ -120,6 +121,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
private final static String KEY_RENDERING = "RENDERING"; //$NON-NLS-1$
private final static String KEY_CONTEXT = "CONTEXT"; //$NON-NLS-1$
private final static String KEY_MEMORY_BLOCK = "MEMORY"; //$NON-NLS-1$
private final static String KEY_RETRIEVAL = "RETRIEVAL"; //$NON-NLS-1$
private final static String KEY_CONTAINER = "CONTAINER"; //$NON-NLS-1$
@ -175,10 +177,9 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
}
});
fGotoAddressBar.getExpressionWidget().addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent e) {}
public void keyReleased(KeyEvent e) {
if(e.keyCode == SWT.CR)
fGotoAddressBar.getExpressionWidget().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {}
public void widgetDefaultSelected(SelectionEvent e) {
performGo(false);
}
});
@ -270,10 +271,13 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
public void launchChanged(ILaunch launch) {}
public void launchRemoved(ILaunch launch) {
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) launch.getAdapter(IMemoryBlockRetrieval.class));
// For CDT launch is not adaptable to memory rendering, but the debug targets do.
for (IDebugTarget target : launch.getDebugTargets()) {
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) target.getAdapter(IMemoryBlockRetrieval.class));
if(retrieval != null)
releaseTabFolder(retrieval);
}
}
public IMemoryRenderingContainer getContainer(String id) {
return null;
@ -323,10 +327,8 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
{
public void run()
{
IMemoryBlockRetrievalExtension retrievalExtension = (IMemoryBlockRetrievalExtension) retrieval;
try {
IMemoryBlockExtension newBlock = retrievalExtension.getExtendedMemoryBlock(expression, context);
BigInteger newBase = newBlock.getBigBaseAddress();
BigInteger newBase = getExpressionAddress(retrieval, expression, context);
if(((IMemoryBlockExtension) rendering.getMemoryBlock()).supportBaseAddressModification())
((IMemoryBlockExtension) rendering.getMemoryBlock()).setBaseAddress(newBase);
rendering.goToAddress(newBase);
@ -366,7 +368,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
private CTabFolder createTabFolder(Composite parent)
{
CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT);
final CTabFolder folder = new CTabFolder(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.FLAT);
ColorRegistry reg = JFaceResources.getColorRegistry();
Color c1 = reg.get("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"), //$NON-NLS-1$
@ -376,17 +378,51 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
folder.setSimple(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS));
folder.setBorderVisible(true);
// listener to dispose rendering resources for each closed tab
folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void close(CTabFolderEvent event) {
event.doit = false;
event.doit = true;
CTabItem item = (CTabItem) event.item;
IMemoryRenderingContainer container = (IMemoryRenderingContainer) item.getData(KEY_CONTAINER);
fCurrentContainers.remove( container );
disposeTab(item);
}
});
// listener to dispose rendering resources for all tab items when view part is closed
folder.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
for(CTabItem tab : folder.getItems()) {
disposeTab(tab);
}
folder.removeDisposeListener(this);
}
});
return folder;
}
/**
* dispose rendering resources associated with the tab item
* @param item
*/
private void disposeTab(CTabItem item ) {
if (item.isDisposed())
return;
IMemoryRenderingContainer container = (IMemoryRenderingContainer) item.getData(KEY_CONTAINER);
fCurrentContainers.remove( container );
IMemoryRendering rendering = (IMemoryRendering) item.getData(KEY_RENDERING);
// always deactivate rendering before disposing it.
if ( rendering != null ) {
rendering.deactivated();
rendering.dispose();
}
IMemoryBlockExtension block = (IMemoryBlockExtension) item.getData(KEY_MEMORY_BLOCK);
try {
block.dispose();
} catch (DebugException e) {
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Could not dispose memory block", e)); //$NON-NLS-1$
}
}
private CTabItem createTab(CTabFolder tabFolder, int index) {
int swtStyle = SWT.CLOSE;
CTabItem tab = new CTabItem(tabFolder, swtStyle, index);
@ -496,42 +532,36 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
if(context instanceof IAdaptable)
{
IMemoryBlockRetrieval retrieval = ((IMemoryBlockRetrieval) ((IAdaptable) context).getAdapter(IMemoryBlockRetrieval.class));
if(retrieval != null)
{
fGotoAddressBarControl.setVisible(true);
if(getTabFolder(retrieval) != null)
CTabFolder tabFolder = getTabFolder(retrieval);
if(tabFolder != null)
{
fStackLayout.topControl = getTabFolder(retrieval);
fStackLayout.topControl = tabFolder;
}
else
{
CTabFolder newFolder = this.createTabFolder(fRenderingsComposite);
newFolder.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void close(CTabFolderEvent event) {
event.doit = true;
CTabItem item = (CTabItem) event.item;
IMemoryRenderingContainer container = (IMemoryRenderingContainer) item.getData(KEY_CONTAINER);
fCurrentContainers.remove( container );
}
});
newFolder.addSelectionListener(new SelectionListener()
tabFolder = this.createTabFolder(fRenderingsComposite);
tabFolder.addSelectionListener(new SelectionListener()
{
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
getSite().getSelectionProvider().setSelection(new StructuredSelection(((CTabItem) e.item).getData(KEY_RENDERING)));
}
});
newFolder.setData(KEY_CONTEXT, context);
newFolder.setData(KEY_RETRIEVAL, retrieval);
tabFolder.setData(KEY_RETRIEVAL, retrieval);
CTabItem item = createTab(newFolder, 0);
CTabItem item = createTab(tabFolder, 0);
populateTabWithRendering(item, retrieval, context);
setTabFolder(retrieval, newFolder);
setTabFolder(retrieval, tabFolder);
fStackLayout.topControl = getTabFolder(retrieval);
}
// update debug context to the new selection
tabFolder.setData(KEY_CONTEXT, context);
}
else
{
@ -585,19 +615,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
};
IMemoryBlock block = null;
if(retrieval instanceof IAdaptable)
{
IMemoryBlockRetrievalExtension retrievalExtension = (IMemoryBlockRetrievalExtension)
((IAdaptable) retrieval).getAdapter(IMemoryBlockRetrievalExtension.class);
if(retrievalExtension != null)
block = retrievalExtension.getExtendedMemoryBlock("0", context); //$NON-NLS-1$
}
if ( block == null ) {
MemoryBrowserPlugin.getDefault().getLog().log(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Extended Memory Block could not be obtained")); //$NON-NLS-1$
return;
}
IMemoryBlock block = createMemoryBlock(retrieval, "0", context);
fCurrentContainers.add(container);
rendering.init(container, block);
@ -606,6 +624,7 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
tab.getParent().setSelection(0);
tab.setData(KEY_RENDERING, rendering);
tab.setData(KEY_CONTAINER, container);
tab.setData(KEY_MEMORY_BLOCK, block);
getSite().getSelectionProvider().setSelection(new StructuredSelection(tab.getData(KEY_RENDERING)));
updateLabel(tab, rendering);
@ -648,12 +667,15 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
if(folder != null)
{
for(CTabItem tab : folder.getItems()) {
IMemoryRenderingContainer container = (IMemoryRenderingContainer) tab.getData(KEY_CONTAINER);
fCurrentContainers.remove( container );
tab.dispose();
disposeTab(tab);
}
}
fContextFolders.remove(context);
folder.dispose();
if (fStackLayout.topControl.equals(folder)) {
handleUnsupportedSelection();
}
}
class SelectionProviderAdapter implements ISelectionProvider {
@ -689,7 +711,46 @@ public class MemoryBrowser extends ViewPart implements IDebugContextListener, IL
});
}
}
}
/**
* create a memory block
* @param retrieval memory block retrieval.
* @param expression expression to be evaluated to an addressL
* @param context context for evaluating the expression. This is typically
* a debug element.
* @return a memory block based on the given expression and context
* @throws DebugException if unable to retrieve the specified memory
*/
private IMemoryBlockExtension createMemoryBlock(IMemoryBlockRetrieval retrieval, String expression, Object context) throws DebugException {
IMemoryBlockExtension block = null;
if(retrieval instanceof IAdaptable)
{
IMemoryBlockRetrievalExtension retrievalExtension = (IMemoryBlockRetrievalExtension)
((IAdaptable) retrieval).getAdapter(IMemoryBlockRetrievalExtension.class);
if(retrievalExtension != null)
block = retrievalExtension.getExtendedMemoryBlock(expression, context); //$NON-NLS-1$
}
if ( block == null ) {
throw new DebugException(new Status(Status.ERROR, MemoryBrowserPlugin.PLUGIN_ID, "Extended Memory Block could not be obtained")); //$NON-NLS-1$
}
return block;
}
/**
* Get a memory address for an expression in a given context.
* @param retrieval
* @param expression
* @param context
* @return BigInteger address of the expression
* @throws DebugException
*/
private BigInteger getExpressionAddress(IMemoryBlockRetrieval retrieval, String expression, Object context) throws DebugException {
// Until 257842 issue is solved this is done via IMemoryBlockRetrievalExtension API.
IMemoryBlockExtension newBlock = createMemoryBlock(retrieval, expression, context);
BigInteger address = newBlock.getBigBaseAddress();
newBlock.dispose();
return address;
}
}

View file

@ -9,6 +9,7 @@
class="org.eclipse.cdt.debug.ui.memory.search.FindAction"
enablesFor="1"
id="org.eclipse.cdt.debug.ui.memory.search.FindAction"
helpContextId="FindNextAction_context"
label="%action.label.0"
menubarPath="additions">
</action>
@ -20,6 +21,7 @@
class="org.eclipse.cdt.debug.ui.memory.search.FindAction"
enablesFor="1"
id="org.eclipse.cdt.debug.ui.memory.search.FindAction"
helpContextId="FindReplaceAction_context"
label="%action.label.1"
menubarPath="additions">
</action>
@ -32,6 +34,7 @@
class="org.eclipse.cdt.debug.ui.memory.search.FindAction"
enablesFor="1"
id="org.eclipse.cdt.debug.ui.memory.search.FindAction"
helpContextId="FindNextAction_context"
label="%action.label.2"
menubarPath="additions">
</action>
@ -43,6 +46,7 @@
class="org.eclipse.cdt.debug.ui.memory.search.FindAction"
enablesFor="1"
id="org.eclipse.cdt.debug.ui.memory.search.FindAction"
helpContextId="FindReplaceAction_context"
label="%action.label.3"
menubarPath="additions">
</action>

View file

@ -75,7 +75,6 @@ public class FindReplaceDialog extends SelectionDialog
private Button fReplaceButton;
private Button fReplaceFindButton;
private Button fReplaceAllButton;
private Button fCloseButton;
private IMemoryRenderingSite fMemoryView;
@ -290,7 +289,7 @@ public class FindReplaceDialog extends SelectionDialog
}
});
fCloseButton = createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("FindReplaceDialog.Close"), false); //$NON-NLS-1$
createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("FindReplaceDialog.Close"), false); //$NON-NLS-1$
((GridLayout) parent.getLayout()).numColumns = 2;
@ -528,7 +527,7 @@ public class FindReplaceDialog extends SelectionDialog
*/
protected Control createDialogArea(Composite parent) {
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, MemorySearchPlugin.getUniqueIdentifier() + ".MemorySearchDialog_context"); //$NON-NLS-1$
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, MemorySearchPlugin.getUniqueIdentifier() + ".FindReplaceDialog_context"); //$NON-NLS-1$
Composite composite = new Composite(parent, SWT.NONE);
FormLayout formLayout = new FormLayout();
formLayout.spacing = 5;

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>

View file

@ -1,7 +0,0 @@
#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

View file

@ -11,6 +11,6 @@ Require-Bundle: org.eclipse.debug.core,
org.eclipse.swt,
org.eclipse.jface,
org.eclipse.ui
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.cdt.debug.ui.memory.transport.MemoryTransportPlugin

View file

@ -47,6 +47,7 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.progress.UIJob;
@SuppressWarnings("restriction")
public class ImportMemoryDialog extends SelectionDialog
{
@ -179,7 +180,7 @@ public class ImportMemoryDialog extends SelectionDialog
data.left = new FormAttachment(textLabel);
fFormatCombo.setLayoutData(data);
Vector importers = new Vector();
Vector<Object> importers = new Vector<Object>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint =
@ -194,7 +195,7 @@ public class ImportMemoryDialog extends SelectionDialog
{
try
{
importers.addElement((IMemoryImporter) element.createExecutableExtension("class"));
importers.addElement(element.createExecutableExtension("class"));
}
catch(Exception e) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Properties;
@ -364,9 +365,6 @@ public class PlainTextExporter implements IMemoryExporter {
public void exportMemory() {
Job job = new Job("Memory Export to Plain Text File"){ //$NON-NLS-1$
public IStatus run(IProgressMonitor monitor) {
try
{
try
{
// FIXME 4 byte default
@ -398,6 +396,8 @@ public class PlainTextExporter implements IMemoryExporter {
if(fEndAddress.subtract(transferAddress).compareTo(length) < 0)
length = fEndAddress.subtract(transferAddress);
monitor.subTask(String.format("Transfering %s bytes at address 0x%s", length.toString(10), transferAddress.toString(16)));
StringBuffer buf = new StringBuffer();
// String transferAddressString = transferAddress.toString(16);
@ -441,17 +441,22 @@ public class PlainTextExporter implements IMemoryExporter {
writer.close();
monitor.done();
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
}
}
catch(Exception e)
{
DebugException.REQUEST_FAILED, "Could not write to file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could read from target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could read from target.", ex);
} catch (Exception ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", ex);
}
return Status.OK_STATUS;
}};

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Properties;
@ -276,9 +277,6 @@ public class PlainTextImporter implements IMemoryImporter {
Job job = new Job("Memory Import from Plain Text File"){ //$NON-NLS-1$
public IStatus run(IProgressMonitor monitor) {
try
{
try
{
BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH);
@ -297,9 +295,9 @@ public class PlainTextImporter implements IMemoryImporter {
monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$
BigInteger jobCount = BigInteger.ZERO;
BigInteger recordAddress = fStartAddress;
String line = reader.readLine();
int lineNo = 1; // line error reporting
while(line != null && !monitor.isCanceled())
{
StringTokenizer st = new StringTokenizer(line, " ");
@ -311,7 +309,12 @@ public class PlainTextImporter implements IMemoryImporter {
byte data[] = new byte[valueString.length() / 2];
for(int i = 0; i < data.length; i++)
{
try {
data[i] = new BigInteger(valueString.substring(position++, position++ + 1), 16).byteValue();
} catch (NumberFormatException ex) {
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, String.format("Invalid file format. Expected integer at line %d", lineNo ), ex);
}
}
if(scrollToAddress == null)
@ -328,30 +331,38 @@ public class PlainTextImporter implements IMemoryImporter {
recordAddress = recordAddress.add(BigInteger.valueOf(bytesRead));
jobCount = jobCount.add(BigInteger.valueOf(bytesRead));
while(jobCount.compareTo(factor) >= 0)
{
jobCount = jobCount.subtract(factor);
monitor.worked(1);
}
BigInteger jobCount = BigInteger.valueOf(bytesRead).divide(factor);
monitor.worked(jobCount.intValue());
line = reader.readLine();
lineNo++;
}
if (!monitor.isCanceled())
memoryWriter.flush();
reader.close();
monitor.done();
if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true"))
fParentDialog.scrollRenderings(scrollToAddress);
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could not read from file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not read from file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to target.", ex);
} catch (Exception ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex);
}
}
catch(Exception e) {e.printStackTrace();}
return Status.OK_STATUS;
}};
job.setUser(true);

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Properties;
@ -377,9 +378,6 @@ public class RAWBinaryExporter implements IMemoryExporter
{
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);
@ -405,6 +403,8 @@ public class RAWBinaryExporter implements IMemoryExporter
if(fEndAddress.subtract(transferAddress).compareTo(length) < 0)
length = fEndAddress.subtract(transferAddress);
monitor.subTask(String.format("Transfering %s bytes at address 0x%s", length.toString(10), transferAddress.toString(16)));
// data
byte[] byteValues = new byte[length.intValue()];
@ -430,17 +430,22 @@ public class RAWBinaryExporter implements IMemoryExporter
writer.close();
monitor.done();
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
}
}
catch(Exception e)
{
DebugException.REQUEST_FAILED, "Could not write to file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could not read from target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not read from target.", ex);
} catch (Exception e) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", e));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", e);
}
return Status.OK_STATUS;
}};

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Properties;
@ -251,9 +252,6 @@ public class RAWBinaryImporter implements IMemoryImporter {
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);
@ -274,7 +272,6 @@ public class RAWBinaryImporter implements IMemoryImporter {
monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$
BigInteger jobCount = BigInteger.ZERO;
int actualByteCount = reader.read(byteValues);
BigInteger recordAddress = fStartAddress;
@ -297,34 +294,37 @@ public class RAWBinaryImporter implements IMemoryImporter {
memoryWriter.write(recordAddress.subtract(baseAddress), data);
jobCount = jobCount.add(BigInteger.valueOf(actualByteCount));
while(jobCount.compareTo(factor) >= 0)
{
jobCount = jobCount.subtract(factor);
monitor.worked(1);
}
BigInteger jobCount = BigInteger.valueOf(actualByteCount).divide(factor);
monitor.worked(jobCount.intValue());
recordAddress.add(BigInteger.valueOf(actualByteCount));
actualByteCount = reader.read(byteValues);
}
if (!monitor.isCanceled())
memoryWriter.flush();
reader.close();
monitor.done();
if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true"))
fParentDialog.scrollRenderings(scrollToAddress);
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
}
}
catch(Exception e)
{
DebugException.REQUEST_FAILED, "Could not read from file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not read from file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could not write to target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to target.", ex);
} catch (Exception ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex);
}
return Status.OK_STATUS;
}};

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Properties;
@ -379,9 +380,6 @@ public class SRecordExporter implements IMemoryExporter
{
Job job = new Job("Memory Export to S-Record File"){ //$NON-NLS-1$
public IStatus run(IProgressMonitor monitor) {
try
{
try
{
// FIXME 4 byte default
@ -409,6 +407,8 @@ public class SRecordExporter implements IMemoryExporter
if(fEndAddress.subtract(transferAddress).compareTo(length) < 0)
length = fEndAddress.subtract(transferAddress);
monitor.subTask(String.format("Transfering %s bytes at address 0x%s", length.toString(10), transferAddress.toString(16)));
writer.write("S3"); // FIXME 4 byte address
StringBuffer buf = new StringBuffer();
@ -472,17 +472,22 @@ public class SRecordExporter implements IMemoryExporter
writer.close();
monitor.done();
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
}
}
catch(Exception e)
{
DebugException.REQUEST_FAILED, "Could not write to file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could not read from target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not read from target.", ex);
} catch (Exception ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure exporting memory", ex);
}
return Status.OK_STATUS;
}};

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.debug.ui.memory.transport;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Properties;
@ -300,8 +301,6 @@ public class SRecordImporter implements IMemoryImporter {
public IStatus run(IProgressMonitor monitor) {
try
{
try
{
BufferedMemoryWriter memoryWriter = new BufferedMemoryWriter((IMemoryBlockExtension) fMemoryBlock, BUFFER_LENGTH);
@ -328,12 +327,19 @@ public class SRecordImporter implements IMemoryImporter {
monitor.beginTask("Transferring Data", jobs.intValue()); //$NON-NLS-1$
BigInteger jobCount = BigInteger.ZERO;
String line = reader.readLine();
int lineNo = 1; // line error reporting
while(line != null && !monitor.isCanceled())
{
String recordType = line.substring(0, 2);
int recordCount = Integer.parseInt(line.substring(2, 4), 16);
int recordCount = 0;
try {
recordCount = Integer.parseInt(line.substring(2, 4), 16);
} catch (NumberFormatException ex) {
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, String.format("Invalid file format. Invalid line length at line %d", lineNo ), ex);
}
int bytesRead = 4 + recordCount;
int position = 4;
int addressSize = 0;
@ -347,7 +353,12 @@ public class SRecordImporter implements IMemoryImporter {
else if("S2".equals(recordType)) //$NON-NLS-1$
addressSize = 3;
try {
recordAddress = new BigInteger(line.substring(position, position + addressSize * 2), 16);
} catch (NumberFormatException ex) {
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, String.format("Invalid file format. Invalid address at line %d", lineNo ), ex);
}
recordCount -= addressSize;
position += addressSize * 2;
@ -359,7 +370,12 @@ public class SRecordImporter implements IMemoryImporter {
byte data[] = new byte[recordCount - CHECKSUM_LENGTH];
for(int i = 0; i < data.length; i++)
{
try {
data[i] = new BigInteger(line.substring(position++, position++ + 1), 16).byteValue();
} catch (NumberFormatException ex) {
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, String.format("Invalid file format. Invalid data at line %d", lineNo ), ex);
}
}
/*
@ -372,7 +388,13 @@ public class SRecordImporter implements IMemoryImporter {
for(int i = 0; i < buf.length(); i+=2)
{
BigInteger value = new BigInteger(buf.substring(i, i+2), 16);
BigInteger value = null;
try {
value = new BigInteger(buf.substring(i, i+2), 16);
} catch (NumberFormatException ex) {
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, String.format("Invalid file format. Invalid checksum format at line %d", lineNo ), ex);
}
checksum += value.byteValue();
}
@ -394,33 +416,37 @@ public class SRecordImporter implements IMemoryImporter {
memoryWriter.write(recordAddress.subtract(((IMemoryBlockExtension) fMemoryBlock).getBigBaseAddress()), data);
jobCount = jobCount.add(BigInteger.valueOf(bytesRead));
while(jobCount.compareTo(factor) >= 0)
{
jobCount = jobCount.subtract(factor);
monitor.worked(1);
}
BigInteger jobCount = BigInteger.valueOf(bytesRead).divide(factor);
monitor.worked(jobCount.intValue());
line = reader.readLine();
lineNo++;
}
if (!monitor.isCanceled())
memoryWriter.flush();
reader.close();
monitor.done();
if(fProperties.getProperty(TRANSFER_SCROLL_TO_START, "false").equals("true"))
fParentDialog.scrollRenderings(scrollToAddress);
}
catch(Exception e)
{
} catch (IOException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
}
}
catch(Exception e)
{
DebugException.REQUEST_FAILED, "Could not read from file.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not read from file.", ex);
} catch (DebugException ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure", e));
DebugException.REQUEST_FAILED, "Could not write to target.", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.REQUEST_FAILED, "Could not write to target.", ex);
} catch (Exception ex) {
MemoryTransportPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex));
return new Status(IStatus.ERROR, MemoryTransportPlugin.getUniqueIdentifier(),
DebugException.INTERNAL_ERROR, "Failure importing from file", ex);
}
return Status.OK_STATUS;
}};