Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2020-12-01 20:10:31 +0000
committerJonah Graham2020-12-01 23:15:35 +0000
commitbb6f318a79876001e00a4ff047050f77ef8d7083 (patch)
tree1dcc297b91f1734d02e9e9ed20bbc1ec0509249f
parent725ff665e781762925ef89d3f6f74315eccbbf3d (diff)
downloadorg.eclipse.cdt-bb6f318a79876001e00a4ff047050f77ef8d7083.tar.gz
org.eclipse.cdt-bb6f318a79876001e00a4ff047050f77ef8d7083.tar.xz
org.eclipse.cdt-bb6f318a79876001e00a4ff047050f77ef8d7083.zip
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
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/PlainTextTransportTest.java5
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/RAWBinaryTransportTest.java5
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/SRecordTransportTest.java8
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory/META-INF/MANIFEST.MF2
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/PlainTextImport.java2
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/RAWBinaryImport.java2
-rw-r--r--memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/SRecordImport.java6
7 files changed, 20 insertions, 10 deletions
diff --git a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/PlainTextTransportTest.java b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/PlainTextTransportTest.java
index 1e9dc9959af..534ec7c505d 100644
--- a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/PlainTextTransportTest.java
+++ b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/PlainTextTransportTest.java
@@ -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 {
diff --git a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/RAWBinaryTransportTest.java b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/RAWBinaryTransportTest.java
index 34efd396b30..1e96226753a 100644
--- a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/RAWBinaryTransportTest.java
+++ b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/RAWBinaryTransportTest.java
@@ -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 {
diff --git a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/SRecordTransportTest.java b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/SRecordTransportTest.java
index aaf6666805a..51a0b112120 100644
--- a/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/SRecordTransportTest.java
+++ b/memory/org.eclipse.cdt.debug.core.memory.tests/src/org/eclipse/cdt/debug/core/memory/tests/SRecordTransportTest.java
@@ -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 {
diff --git a/memory/org.eclipse.cdt.debug.core.memory/META-INF/MANIFEST.MF b/memory/org.eclipse.cdt.debug.core.memory/META-INF/MANIFEST.MF
index e9e2e9745eb..e7a1eb40455 100644
--- a/memory/org.eclipse.cdt.debug.core.memory/META-INF/MANIFEST.MF
+++ b/memory/org.eclipse.cdt.debug.core.memory/META-INF/MANIFEST.MF
@@ -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
diff --git a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/PlainTextImport.java b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/PlainTextImport.java
index 521b203ee49..ecdeafdebc8 100644
--- a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/PlainTextImport.java
+++ b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/PlainTextImport.java
@@ -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);
}
} \ No newline at end of file
diff --git a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/RAWBinaryImport.java b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/RAWBinaryImport.java
index 95b6371ab9a..48d7c85b430 100644
--- a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/RAWBinaryImport.java
+++ b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/RAWBinaryImport.java
@@ -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);
}
} \ No newline at end of file
diff --git a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/SRecordImport.java b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/SRecordImport.java
index 414f44d30ca..db02fcc647d 100644
--- a/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/SRecordImport.java
+++ b/memory/org.eclipse.cdt.debug.core.memory/src/org/eclipse/cdt/debug/internal/core/memory/transport/SRecordImport.java
@@ -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);
}
} \ No newline at end of file

Back to the top