mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 568513: Scroll to correct address on memory file import
The CDT 9.x code scrolled once, to the start address of the import when the import finished. The refactoring done early in the CDT 10.x cycle (Bug 562164) instead scrolled repeatedly, generally once per line of the input file, until finally scrolling one last time to the byte right after the last imported byte. Change-Id: I79f2a17c7a5feb19a463002ce19dec9d22afc90f
This commit is contained in:
parent
725ff665e7
commit
bb6f318a79
7 changed files with 20 additions and 10 deletions
|
@ -18,8 +18,8 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ExportRequest;
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ImportRequest;
|
||||
|
@ -60,7 +60,7 @@ public final class PlainTextTransportTest {
|
|||
|
||||
private void transport(String name, BigInteger end) throws CoreException, IOException {
|
||||
EmulateMemory memory = new EmulateMemory(BigInteger.valueOf(1), base);
|
||||
Consumer<BigInteger> scroll = new CollectScrolls();
|
||||
CollectScrolls scroll = new CollectScrolls();
|
||||
File input = new InputFile(name).get();
|
||||
new PlainTextImport(input, new ImportRequest(base, start, memory), scroll)//
|
||||
.run(new NullProgressMonitor());
|
||||
|
@ -68,6 +68,7 @@ public final class PlainTextTransportTest {
|
|||
new PlainTextExport(output, new ExportRequest(start, end, BigInteger.ONE, memory))//
|
||||
.run(new NullProgressMonitor());
|
||||
Assert.assertEquals(read(input), read(output));
|
||||
Assert.assertEquals(Arrays.asList(start), scroll.collected());
|
||||
}
|
||||
|
||||
private List<String> read(File file) throws IOException {
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ExportRequest;
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ImportRequest;
|
||||
|
@ -59,7 +59,7 @@ public final class RAWBinaryTransportTest {
|
|||
|
||||
private void transport(String name, BigInteger end) throws CoreException, IOException {
|
||||
EmulateMemory memory = new EmulateMemory(BigInteger.valueOf(1), base);
|
||||
Consumer<BigInteger> scroll = new CollectScrolls();
|
||||
CollectScrolls scroll = new CollectScrolls();
|
||||
File input = new InputFile(name).get();
|
||||
new RAWBinaryImport(input, new ImportRequest(base, start, memory), scroll)//
|
||||
.run(new NullProgressMonitor());
|
||||
|
@ -67,6 +67,7 @@ public final class RAWBinaryTransportTest {
|
|||
new RAWBinaryExport(output, new ExportRequest(start, end, BigInteger.ONE, memory))//
|
||||
.run(new NullProgressMonitor());
|
||||
Assert.assertArrayEquals(read(input), read(output));
|
||||
Assert.assertEquals(Arrays.asList(start), scroll.collected());
|
||||
}
|
||||
|
||||
private byte[] read(File file) throws IOException {
|
||||
|
|
|
@ -18,8 +18,8 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ExportRequest;
|
||||
import org.eclipse.cdt.debug.core.memory.transport.ImportRequest;
|
||||
|
@ -60,7 +60,7 @@ public final class SRecordTransportTest {
|
|||
|
||||
private void transport(String name, BigInteger end) throws CoreException, IOException {
|
||||
EmulateMemory memory = new EmulateMemory(BigInteger.valueOf(1), base);
|
||||
Consumer<BigInteger> scroll = new CollectScrolls();
|
||||
CollectScrolls scroll = new CollectScrolls();
|
||||
File input = new InputFile(name).get();
|
||||
File output = new OutputFile(name).get();
|
||||
new SRecordImport(input, new ImportRequest(base, start, memory), scroll, true)//
|
||||
|
@ -68,11 +68,15 @@ public final class SRecordTransportTest {
|
|||
new SRecordExport(output, new ExportRequest(start, end, BigInteger.ONE, memory))//
|
||||
.run(new NullProgressMonitor());
|
||||
Assert.assertArrayEquals(read(input), read(output));
|
||||
Assert.assertEquals(Arrays.asList(start), scroll.collected());
|
||||
|
||||
scroll = new CollectScrolls();
|
||||
new SRecordImport(input, new ImportRequest(base, start, memory), scroll, false)//
|
||||
.run(new NullProgressMonitor());
|
||||
new SRecordExport(output, new ExportRequest(start, end, BigInteger.ONE, memory))//
|
||||
.run(new NullProgressMonitor());
|
||||
Assert.assertArrayEquals(read(input), read(output));
|
||||
Assert.assertEquals(Arrays.asList(start), scroll.collected());
|
||||
}
|
||||
|
||||
private String[] read(File file) throws IOException {
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Automatic-Module-Name: org.eclipse.cdt.debug.core.memory
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: org.eclipse.cdt.debug.core.memory
|
||||
Bundle-Version: 0.1.0.qualifier
|
||||
Bundle-Version: 0.1.100.qualifier
|
||||
Bundle-Name: %Bundle-Name
|
||||
Bundle-Vendor: %Bundle-Vendor
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
|
|
|
@ -70,11 +70,11 @@ public final class PlainTextImport extends FileImport<BufferedReader> {
|
|||
bytesRead += data.length;
|
||||
}
|
||||
recordAddress = recordAddress.add(BigInteger.valueOf(bytesRead));
|
||||
scroll.accept(recordAddress);
|
||||
BigInteger jobCount = BigInteger.valueOf(bytesRead).divide(factor);
|
||||
monitor.worked(jobCount.intValue());
|
||||
line = reader.readLine();
|
||||
lineNo++;
|
||||
}
|
||||
scroll.accept(start);
|
||||
}
|
||||
}
|
|
@ -52,9 +52,9 @@ public final class RAWBinaryImport extends FileImport<FileInputStream> {
|
|||
BigInteger jobCount = BigInteger.valueOf(actualByteCount).divide(factor);
|
||||
monitor.worked(jobCount.intValue());
|
||||
recordAddress = recordAddress.add(BigInteger.valueOf(actualByteCount));
|
||||
scroll.accept(recordAddress);
|
||||
actualByteCount = input.read(byteValues);
|
||||
}
|
||||
scroll.accept(start);
|
||||
}
|
||||
|
||||
}
|
|
@ -50,6 +50,7 @@ public class SRecordImport extends FileImport<BufferedReader> {
|
|||
throws IOException, DebugException {
|
||||
// FIXME 4 byte default
|
||||
final int CHECKSUM_LENGTH = 1;
|
||||
BigInteger scrollToAddress = null;
|
||||
BigInteger offset = null;
|
||||
if (!transfer) {
|
||||
offset = BigInteger.ZERO;
|
||||
|
@ -135,7 +136,9 @@ public class SRecordImport extends FileImport<BufferedReader> {
|
|||
new Status(IStatus.ERROR, FrameworkUtil.getBundle(getClass()).getSymbolicName(),
|
||||
String.format(Messages.SRecordImport_e_checksum_failure, line)));
|
||||
}
|
||||
scroll.accept(recordAddress);
|
||||
if (scrollToAddress == null) {
|
||||
scrollToAddress = recordAddress;
|
||||
}
|
||||
// FIXME error on incorrect checksum
|
||||
write.to(recordAddress.subtract(base), data);
|
||||
BigInteger jobCount = BigInteger.valueOf(bytesRead).divide(factor);
|
||||
|
@ -143,6 +146,7 @@ public class SRecordImport extends FileImport<BufferedReader> {
|
|||
line = reader.readLine();
|
||||
lineNo++;
|
||||
}
|
||||
scroll.accept(scrollToAddress);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue