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,69 +515,82 @@ 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)));
writer.write("S3"); // FIXME 4 byte address //$NON-NLS-1$
StringBuilder buf = new StringBuilder();
BigInteger sRecordLength = BigInteger.valueOf(4); // address size
sRecordLength = sRecordLength.add(length);
sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum
String transferAddressString = transferAddress.toString(16);
String lengthString = sRecordLength.toString(16);
if (lengthString.length() == 1)
buf.append("0"); //$NON-NLS-1$
buf.append(lengthString);
for (int i = 0; i < 8 - transferAddressString.length(); i++)
buf.append("0"); //$NON-NLS-1$
buf.append(transferAddressString);
// data
MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress, MemoryByte bytes[] = ((IMemoryBlockExtension) fMemoryBlock).getBytesFromAddress(transferAddress,
length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize()); length.longValue() / ((IMemoryBlockExtension) fMemoryBlock).getAddressableSize());
for (int byteIndex = 0; byteIndex < bytes.length; byteIndex++) {
String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16); 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$
StringBuilder buf = new StringBuilder();
BigInteger sRecordLength = BigInteger.valueOf(4); // address size
sRecordLength = sRecordLength.add(sRecordDataLength);
sRecordLength = sRecordLength.add(BigInteger.ONE); // checksum
String transferAddressString = sRecordAddress.toString(16);
String lengthString = sRecordLength.toString(16);
if (lengthString.length() == 1)
buf.append("0"); //$NON-NLS-1$
buf.append(lengthString);
for (int i = 0; i < 8 - transferAddressString.length(); i++)
buf.append("0"); //$NON-NLS-1$
buf.append(transferAddressString);
final int byteOffset = sRecordAddress.subtract(transferAddress).intValue();
final int byteLength = byteOffset + sRecordDataLength.intValue();
for (int byteIndex = byteOffset; byteIndex < byteLength; byteIndex++) {
String bString = BigInteger.valueOf(0xFF & bytes[byteIndex].getValue()).toString(16);
if (bString.length() == 1)
buf.append("0"); //$NON-NLS-1$
buf.append(bString);
}
/*
* The least significant byte of the one's complement of the sum of the values
* represented by the pairs of characters making up the records length, address,
* and the code/data fields.
*/
byte checksum = 0;
for (int i = 0; i < buf.length(); i += 2) {
BigInteger value = new BigInteger(buf.substring(i, i + 2), 16);
checksum += value.byteValue();
}
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);
writer.write(buf.toString().toUpperCase());
writer.write("\n"); //$NON-NLS-1$
sRecordAddress = sRecordAddress.add(sRecordDataLength);
jobCount = jobCount.add(BigInteger.ONE);
if (jobCount.compareTo(factor) == 0) {
jobCount = BigInteger.ZERO;
monitor.worked(1);
}
} }
/*
* The least significant byte of the one's complement of the sum of the values
* represented by the pairs of characters making up the records length, address,
* and the code/data fields.
*/
byte checksum = 0;
for (int i = 0; i < buf.length(); i += 2) {
BigInteger value = new BigInteger(buf.substring(i, i + 2), 16);
checksum += value.byteValue();
}
String bString = BigInteger.valueOf(0xFF - checksum).and(BigInteger.valueOf(0xFF)).toString(16);
if (bString.length() == 1)
buf.append("0"); //$NON-NLS-1$
buf.append(bString);
writer.write(buf.toString().toUpperCase());
writer.write("\n"); //$NON-NLS-1$
transferAddress = transferAddress.add(length); transferAddress = transferAddress.add(length);
jobCount = jobCount.add(BigInteger.ONE);
if (jobCount.compareTo(factor) == 0) {
jobCount = BigInteger.ZERO;
monitor.worked(1);
}
} }
writer.close(); writer.close();