1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 390897: Data buffering for SRecord export

Change-Id: I52cb28cd7fbbf19a9d2bc39754e0ea6fd8582aa3
This commit is contained in:
John Dallaway 2020-04-13 17:16:48 +01:00
parent 794a7e2339
commit cab5fc1752
2 changed files with 66 additions and 51 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.debug.ui.memory.transport;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.debug.ui.memory.transport;singleton:=true
Bundle-Version: 2.1.100.qualifier Bundle-Version: 2.1.200.qualifier
Bundle-Localization: plugin Bundle-Localization: plugin
Bundle-Vendor: %providerName Bundle-Vendor: %providerName
Require-Bundle: org.eclipse.debug.core, Require-Bundle: org.eclipse.debug.core,

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. * Copyright (c) 2006, 2020 Wind River Systems, Inc. and others.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -10,6 +10,7 @@
* *
* Contributors: * Contributors:
* Ted R Williams (Wind River Systems, Inc.) - initial implementation * Ted R Williams (Wind River Systems, Inc.) - initial implementation
* John Dallaway - Enhanced data buffering for performance (bug 390897)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.ui.memory.transport; package org.eclipse.cdt.debug.ui.memory.transport;
@ -497,6 +498,7 @@ public class SRecordExporter implements IMemoryExporter {
// FIXME 4 byte default // FIXME 4 byte default
BigInteger DATA_PER_RECORD = BigInteger.valueOf(16); BigInteger DATA_PER_RECORD = BigInteger.valueOf(16);
BigInteger DATA_PER_TRANSFER = BigInteger.valueOf(4096).multiply(DATA_PER_RECORD);
BigInteger transferAddress = fStartAddress; BigInteger transferAddress = fStartAddress;
@ -513,22 +515,33 @@ public class SRecordExporter implements IMemoryExporter {
BigInteger jobCount = BigInteger.ZERO; BigInteger jobCount = BigInteger.ZERO;
while (transferAddress.compareTo(fEndAddress) < 0 && !monitor.isCanceled()) { while (transferAddress.compareTo(fEndAddress) < 0 && !monitor.isCanceled()) {
BigInteger length = DATA_PER_RECORD; BigInteger length = DATA_PER_TRANSFER;
if (fEndAddress.subtract(transferAddress).compareTo(length) < 0) if (fEndAddress.subtract(transferAddress).compareTo(length) < 0)
length = fEndAddress.subtract(transferAddress); length = fEndAddress.subtract(transferAddress);
monitor.subTask(String.format(Messages.getString("Exporter.Progress"), length.toString(10), //$NON-NLS-1$ monitor.subTask(String.format(Messages.getString("Exporter.Progress"), length.toString(10), //$NON-NLS-1$
transferAddress.toString(16))); transferAddress.toString(16)));
MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress,
length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize());
BigInteger sRecordAddress = transferAddress;
BigInteger sRecordEndAddress = transferAddress.add(length);
while (sRecordAddress.compareTo(sRecordEndAddress) < 0 && !monitor.isCanceled()) {
BigInteger sRecordDataLength = DATA_PER_RECORD;
if (sRecordEndAddress.subtract(sRecordAddress).compareTo(sRecordDataLength) < 0) {
sRecordDataLength = fEndAddress.subtract(sRecordAddress);
}
writer.write("S3"); // FIXME 4 byte address //$NON-NLS-1$ writer.write("S3"); // FIXME 4 byte address //$NON-NLS-1$
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
BigInteger sRecordLength = BigInteger.valueOf(4); // address size BigInteger sRecordLength = BigInteger.valueOf(4); // address size
sRecordLength = sRecordLength.add(length); sRecordLength = sRecordLength.add(sRecordDataLength);
sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum
String transferAddressString = transferAddress.toString(16); String transferAddressString = sRecordAddress.toString(16);
String lengthString = sRecordLength.toString(16); String lengthString = sRecordLength.toString(16);
if (lengthString.length() == 1) if (lengthString.length() == 1)
@ -538,11 +551,9 @@ public class SRecordExporter implements IMemoryExporter {
buf.append("0"); //$NON-NLS-1$ buf.append("0"); //$NON-NLS-1$
buf.append(transferAddressString); buf.append(transferAddressString);
// data final int byteOffset = sRecordAddress.subtract(transferAddress).intValue();
final int byteLength = byteOffset + sRecordDataLength.intValue();
MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress, for (int byteIndex = byteOffset; byteIndex < byteLength; byteIndex++) {
length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize());
for (int byteIndex = 0; byteIndex < bytes.length; byteIndex++) {
String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16); String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16);
if (bString.length() == 1) if (bString.length() == 1)
buf.append("0"); //$NON-NLS-1$ buf.append("0"); //$NON-NLS-1$
@ -561,7 +572,8 @@ public class SRecordExporter implements IMemoryExporter {
checksum += value.byteValue(); checksum += value.byteValue();
} }
String bString = BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16); String bString = BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF))
.toString(16);
if (bString.length() == 1) if (bString.length() == 1)
buf.append("0"); //$NON-NLS-1$ buf.append("0"); //$NON-NLS-1$
buf.append(bString); buf.append(bString);
@ -569,7 +581,7 @@ public class SRecordExporter implements IMemoryExporter {
writer.write(buf.toString().toUpperCase()); writer.write(buf.toString().toUpperCase());
writer.write("\n"); //$NON-NLS-1$ writer.write("\n"); //$NON-NLS-1$
transferAddress = transferAddress.add(length); sRecordAddress = sRecordAddress.add(sRecordDataLength);
jobCount = jobCount.add(BigInteger.ONE); jobCount = jobCount.add(BigInteger.ONE);
if (jobCount.compareTo(factor) == 0) { if (jobCount.compareTo(factor) == 0) {
@ -578,6 +590,9 @@ public class SRecordExporter implements IMemoryExporter {
} }
} }
transferAddress = transferAddress.add(length);
}
writer.close(); writer.close();
monitor.done(); monitor.done();
} catch (IOException ex) { } catch (IOException ex) {