sections = header.getSections();
for (SectionHeader section : sections) {
diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java
index 047be6da11..33d1aa09c7 100644
--- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java
+++ b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/checksums/MyTestMemory.java
@@ -114,8 +114,8 @@ class MyTestMemory extends AddressSet implements Memory {
}
@Override
- public FileBytes createFileBytes(String filename, long offset, long size, InputStream is)
- throws IOException {
+ public FileBytes createFileBytes(String filename, long offset, long size, InputStream is,
+ TaskMonitor monitor) throws IOException {
throw new UnsupportedOperationException();
}
diff --git a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/ios/prelink/PrelinkFileSystem.java b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/ios/prelink/PrelinkFileSystem.java
index c492286592..20a03abf34 100644
--- a/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/ios/prelink/PrelinkFileSystem.java
+++ b/Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/ios/prelink/PrelinkFileSystem.java
@@ -187,7 +187,7 @@ public class PrelinkFileSystem extends GFileSystemBase implements GFileSystemPro
boolean success = false;
try {
FileBytes fileBytes = MemoryBlockUtils.createFileBytes(program, provider, offset,
- provider.length() - offset);
+ provider.length() - offset, monitor);
ByteProvider providerWrapper =
new ByteProviderWrapper(provider, offset, provider.length() - offset);
MachoProgramBuilder.buildProgram(program, providerWrapper, fileBytes, new MessageLog(),
diff --git a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/MemoryTestDummy.java b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/MemoryTestDummy.java
index dc4f8b3d22..d15e2c2049 100644
--- a/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/MemoryTestDummy.java
+++ b/Ghidra/Features/VersionTracking/src/test/java/ghidra/feature/vt/db/MemoryTestDummy.java
@@ -328,8 +328,8 @@ public class MemoryTestDummy extends AddressSet implements Memory {
}
@Override
- public FileBytes createFileBytes(String filename, long offset, long size, InputStream is)
- throws IOException {
+ public FileBytes createFileBytes(String filename, long offset, long size, InputStream is,
+ TaskMonitor monitor) throws IOException {
throw new UnsupportedOperationException();
}
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/MonitoredInputStream.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/MonitoredInputStream.java
index 19bf4a07e8..f7740685f0 100644
--- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/MonitoredInputStream.java
+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/MonitoredInputStream.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,231 +15,234 @@
*/
package ghidra.util;
+import java.io.IOException;
+import java.io.InputStream;
+
import ghidra.util.exception.IOCancelledException;
import ghidra.util.task.TaskMonitor;
-import java.io.*;
-
/**
* An InputStream which utilizes a TaskMonitor to indicate input progress and
* allows the operation to be cancelled via the TaskMonitor.
*/
public class MonitoredInputStream extends InputStream {
- private final static int PROGRESS_INCREMENT = 32*1024;
-
+ private final static int PROGRESS_INCREMENT = 32 * 1024;
+
protected InputStream in;
private TaskMonitor monitor;
private int smallCount = 0;
private int count = 0;
-
+
public MonitoredInputStream(InputStream in, TaskMonitor monitor) {
this.in = in;
- this.monitor = monitor;
+ this.monitor = monitor;
}
/**
* Reset the current progress count to the specified value.
- */
+ */
public void setProgress(int count) {
this.count = count;
}
-
+
/**
- * Reads the next byte of data from this input stream. The value
- * byte is returned as an int
in the range
- * 0
to 255
. If no byte is available
- * because the end of the stream has been reached, the value
- * -1
is returned. This method blocks until input data
- * is available, the end of the stream is detected, or an exception
- * is thrown.
- *
- * This method
- * simply performs in.read()
and returns the result.
- *
- * @return the next byte of data, or -1
if the end of the
- * stream is reached.
- * @exception IOException if an I/O error occurs.
- */
- @Override
- public int read() throws IOException {
+ * Reads the next byte of data from this input stream. The value
+ * byte is returned as an int
in the range
+ * 0
to 255
. If no byte is available
+ * because the end of the stream has been reached, the value
+ * -1
is returned. This method blocks until input data
+ * is available, the end of the stream is detected, or an exception
+ * is thrown.
+ *
+ * This method
+ * simply performs in.read()
and returns the result.
+ *
+ * @return the next byte of data, or -1
if the end of the
+ * stream is reached.
+ * @exception IOException if an I/O error occurs.
+ */
+ @Override
+ public int read() throws IOException {
+ if (monitor.isCancelled()) {
+ throw new IOCancelledException();
+ }
int n = in.read();
if (n != -1) {
++smallCount;
if (smallCount >= PROGRESS_INCREMENT) {
- if (monitor.isCancelled())
- throw new IOCancelledException();
count += smallCount;
smallCount = 0;
- monitor.setProgress(count);
+ monitor.setProgress(count);
}
}
return n;
- }
+ }
- /**
- * Reads up to byte.length
bytes of data from this
- * input stream into an array of bytes. This method blocks until some
- * input is available.
- *
- * This method simply performs the call
- * read(b, 0, b.length)
and returns
- * the result. It is important that it does
- * not do in.read(b)
instead;
- * certain subclasses of FilterInputStream
- * depend on the implementation strategy actually
- * used.
- *
- * @param b the buffer into which the data is read.
- * @return the total number of bytes read into the buffer, or
- * -1
if there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- * @see java.io.FilterInputStream#read(byte[], int, int)
- */
- @Override
- public int read(byte b[]) throws IOException {
+ /**
+ * Reads up to byte.length
bytes of data from this
+ * input stream into an array of bytes. This method blocks until some
+ * input is available.
+ *
+ * This method simply performs the call
+ * read(b, 0, b.length)
and returns
+ * the result. It is important that it does
+ * not do in.read(b)
instead;
+ * certain subclasses of FilterInputStream
+ * depend on the implementation strategy actually
+ * used.
+ *
+ * @param b the buffer into which the data is read.
+ * @return the total number of bytes read into the buffer, or
+ * -1
if there is no more data because the end of
+ * the stream has been reached.
+ * @exception IOException if an I/O error occurs.
+ * @see java.io.FilterInputStream#read(byte[], int, int)
+ */
+ @Override
+ public int read(byte b[]) throws IOException {
return read(b, 0, b.length);
- }
+ }
- /**
- * Reads up to len
bytes of data from this input stream
- * into an array of bytes. This method blocks until some input is
- * available.
- *
- * This method simply performs in.read(b, off, len)
- * and returns the result.
- *
- * @param b the buffer into which the data is read.
- * @param off the start offset of the data.
- * @param len the maximum number of bytes read.
- * @return the total number of bytes read into the buffer, or
- * -1
if there is no more data because the end of
- * the stream has been reached.
- * @exception IOException if an I/O error occurs.
- */
- @Override
- public int read(byte b[], int off, int len) throws IOException {
+ /**
+ * Reads up to len
bytes of data from this input stream
+ * into an array of bytes. This method blocks until some input is
+ * available.
+ *
+ * This method simply performs in.read(b, off, len)
+ * and returns the result.
+ *
+ * @param b the buffer into which the data is read.
+ * @param off the start offset of the data.
+ * @param len the maximum number of bytes read.
+ * @return the total number of bytes read into the buffer, or
+ * -1
if there is no more data because the end of
+ * the stream has been reached.
+ * @exception IOException if an I/O error occurs.
+ */
+ @Override
+ public int read(byte b[], int off, int len) throws IOException {
+ if (monitor.isCancelled()) {
+ throw new IOCancelledException();
+ }
int n = in.read(b, off, len);
smallCount += n;
if (smallCount >= PROGRESS_INCREMENT) {
- if (monitor.isCancelled())
- throw new IOCancelledException();
count += smallCount;
smallCount = 0;
- monitor.setProgress(count);
+ monitor.setProgress(count);
}
return n;
- }
+ }
- /**
- * Skips over and discards n
bytes of data from the
- * input stream. The skip
method may, for a variety of
- * reasons, end up skipping over some smaller number of bytes,
- * possibly 0
. The actual number of bytes skipped is
- * returned.
- *
- * This method
- * simply performs in.skip(n)
.
- *
- * @param n the number of bytes to be skipped.
- * @return the actual number of bytes skipped.
- * @exception IOException if an I/O error occurs.
- */
- @Override
- public long skip(long n) throws IOException {
+ /**
+ * Skips over and discards n
bytes of data from the
+ * input stream. The skip
method may, for a variety of
+ * reasons, end up skipping over some smaller number of bytes,
+ * possibly 0
. The actual number of bytes skipped is
+ * returned.
+ *
+ * This method
+ * simply performs in.skip(n)
.
+ *
+ * @param n the number of bytes to be skipped.
+ * @return the actual number of bytes skipped.
+ * @exception IOException if an I/O error occurs.
+ */
+ @Override
+ public long skip(long n) throws IOException {
return in.skip(n);
- }
+ }
- /**
- * Returns the number of bytes that can be read from this input
- * stream without blocking.
- *
- * This method
- * simply performs in.available()
and
- * returns the result.
- *
- * @return the number of bytes that can be read from the input stream
- * without blocking.
- * @exception IOException if an I/O error occurs.
- */
- @Override
- public int available() throws IOException {
+ /**
+ * Returns the number of bytes that can be read from this input
+ * stream without blocking.
+ *
+ * This method
+ * simply performs in.available()
and
+ * returns the result.
+ *
+ * @return the number of bytes that can be read from the input stream
+ * without blocking.
+ * @exception IOException if an I/O error occurs.
+ */
+ @Override
+ public int available() throws IOException {
return in.available();
- }
+ }
- /**
- * Closes this input stream and releases any system resources
- * associated with the stream.
- * This
- * method simply performs in.close()
.
- *
- * @exception IOException if an I/O error occurs.
- */
- @Override
- public void close() throws IOException {
+ /**
+ * Closes this input stream and releases any system resources
+ * associated with the stream.
+ * This
+ * method simply performs in.close()
.
+ *
+ * @exception IOException if an I/O error occurs.
+ */
+ @Override
+ public void close() throws IOException {
in.close();
- }
+ }
- /**
- * Marks the current position in this input stream. A subsequent
- * call to the reset
method repositions this stream at
- * the last marked position so that subsequent reads re-read the same bytes.
- *
- * The readlimit
argument tells this input stream to
- * allow that many bytes to be read before the mark position gets
- * invalidated.
- *
- * This method simply performs in.mark(readlimit)
.
- *
- * @param readlimit the maximum limit of bytes that can be read before
- * the mark position becomes invalid.
- * @see java.io.FilterInputStream#reset
- */
- @Override
- public synchronized void mark(int readlimit) {
+ /**
+ * Marks the current position in this input stream. A subsequent
+ * call to the reset
method repositions this stream at
+ * the last marked position so that subsequent reads re-read the same bytes.
+ *
+ * The readlimit
argument tells this input stream to
+ * allow that many bytes to be read before the mark position gets
+ * invalidated.
+ *
+ * This method simply performs in.mark(readlimit)
.
+ *
+ * @param readlimit the maximum limit of bytes that can be read before
+ * the mark position becomes invalid.
+ * @see java.io.FilterInputStream#reset
+ */
+ @Override
+ public synchronized void mark(int readlimit) {
in.mark(readlimit);
- }
+ }
- /**
- * Repositions this stream to the position at the time the
- * mark
method was last called on this input stream.
- *
- * This method
- * simply performs in.reset()
.
- *
- * Stream marks are intended to be used in
- * situations where you need to read ahead a little to see what's in
- * the stream. Often this is most easily done by invoking some
- * general parser. If the stream is of the type handled by the
- * parse, it just chugs along happily. If the stream is not of
- * that type, the parser should toss an exception when it fails.
- * If this happens within readlimit bytes, it allows the outer
- * code to reset the stream and try another parser.
- *
- * @exception IOException if the stream has not been marked or if the
- * mark has been invalidated.
- * @see java.io.FilterInputStream#mark(int)
- */
- @Override
- public synchronized void reset() throws IOException {
+ /**
+ * Repositions this stream to the position at the time the
+ * mark
method was last called on this input stream.
+ *
+ * This method
+ * simply performs in.reset()
.
+ *
+ * Stream marks are intended to be used in
+ * situations where you need to read ahead a little to see what's in
+ * the stream. Often this is most easily done by invoking some
+ * general parser. If the stream is of the type handled by the
+ * parse, it just chugs along happily. If the stream is not of
+ * that type, the parser should toss an exception when it fails.
+ * If this happens within readlimit bytes, it allows the outer
+ * code to reset the stream and try another parser.
+ *
+ * @exception IOException if the stream has not been marked or if the
+ * mark has been invalidated.
+ * @see java.io.FilterInputStream#mark(int)
+ */
+ @Override
+ public synchronized void reset() throws IOException {
in.reset();
- }
+ }
- /**
- * Tests if this input stream supports the mark
- * and reset
methods.
- * This method
- * simply performs in.markSupported()
.
- *
- * @return true
if this stream type supports the
- * mark
and reset
method;
- * false
otherwise.
- * @see java.io.InputStream#mark(int)
- * @see java.io.InputStream#reset()
- */
- @Override
- public boolean markSupported() {
+ /**
+ * Tests if this input stream supports the mark
+ * and reset
methods.
+ * This method
+ * simply performs in.markSupported()
.
+ *
+ * @return true
if this stream type supports the
+ * mark
and reset
method;
+ * false
otherwise.
+ * @see java.io.InputStream#mark(int)
+ * @see java.io.InputStream#reset()
+ */
+ @Override
+ public boolean markSupported() {
return in.markSupported();
- }
+ }
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytesAdapterV0.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytesAdapterV0.java
index 3dc050b024..dce9b3f888 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytesAdapterV0.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/FileBytesAdapterV0.java
@@ -20,6 +20,7 @@ import java.io.InputStream;
import java.util.*;
import db.*;
+import ghidra.util.exception.IOCancelledException;
import ghidra.util.exception.VersionException;
/**
@@ -158,9 +159,18 @@ class FileBytesAdapterV0 extends FileBytesAdapter {
}
buffers[bufCount - 1] = handle.createBuffer(sizeLastBuf);
- for (DBBuffer buffer : buffers) {
- buffer.fill(is);
+ try {
+ for (DBBuffer buffer : buffers) {
+ buffer.fill(is);
+ }
+ }
+ catch (IOCancelledException e) {
+ for (DBBuffer buffer : buffers) {
+ buffer.delete();
+ }
+ throw e;
}
return buffers;
+
}
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java
index bc9a2c7c17..dd5f360a56 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDB.java
@@ -494,8 +494,10 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
return newBlock;
}
catch (IOCancelledException e) {
- // TODO: this could leave things in a bad state.
- // Canceling requires additional improvements (see GT-3064)
+ // this assumes the adapter has already cleaned up any partially created buffers.
+ if (overlay) {
+ checkRemoveAddressSpace(start.getAddressSpace());
+ }
throw new CancelledException();
}
catch (IOException e) {
@@ -2022,14 +2024,18 @@ public class MemoryMapDB implements Memory, ManagerDB, LiveMemoryListener {
}
@Override
- public FileBytes createFileBytes(String filename, long offset, long size, InputStream is)
- throws IOException {
+ public FileBytes createFileBytes(String filename, long offset, long size, InputStream is,
+ TaskMonitor monitor) throws IOException, CancelledException {
lock.acquire();
try {
- // TODO: this should accept task monitor to permit cancellation although
- // canceling requires additional improvements (see GT-3064)
+ if (monitor != null && is != null) {
+ is = new MonitoredInputStream(is, monitor);
+ }
return fileBytesAdapter.createFileBytes(filename, offset, size, is);
}
+ catch (IOCancelledException e) {
+ throw new CancelledException();
+ }
finally {
lock.release();
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDBAdapterV3.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDBAdapterV3.java
index 1d9e923d1a..4f94565c4b 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDBAdapterV3.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryMapDBAdapterV3.java
@@ -148,6 +148,8 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
@Override
MemoryBlockDB createInitializedBlock(String name, Address startAddr, InputStream is,
long length, int permissions) throws AddressOverflowException, IOException {
+
+ // TODO verify that it is necessary to pre-define all segments in the address map
updateAddressMapForAllAddresses(startAddr, length);
List subBlocks = new ArrayList<>();
@@ -171,7 +173,7 @@ public class MemoryMapDBAdapterV3 extends MemoryMapDBAdapter {
Collections.sort(memoryBlocks);
return newBlock;
}
- catch (IOException e) {
+ catch (IOCancelledException e) {
// clean up any created DBBufferss
for (SubMemoryBlock subMemoryBlock : subBlocks) {
BufferSubMemoryBlock bufferSubMemoryBlock = (BufferSubMemoryBlock) subMemoryBlock;
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
index c5a60d60a2..034882dd68 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
@@ -729,11 +729,14 @@ public interface Memory extends AddressSetView {
* @param offset the offset into the file for the first byte in the input stream.
* @param size the number of bytes to store from the input stream.
* @param is the input stream that will supply the bytes to store in the program.
+ * @param monitor
* @return a FileBytes that was created to access the bytes.
* @throws IOException if there was an IOException saving the bytes to the program database.
+ * @throws CancelledException if the user cancelled this operation. Note: the database will
+ * be stable, but the buffers may contain 0s instead of the actual bytes.
*/
- public FileBytes createFileBytes(String filename, long offset, long size, InputStream is)
- throws IOException;
+ public FileBytes createFileBytes(String filename, long offset, long size, InputStream is,
+ TaskMonitor monitor) throws IOException, CancelledException;
/**
* Returns a list of all the stored original file bytes objects
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryStub.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryStub.java
index 29d4ff9a1a..f047d6a929 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryStub.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/MemoryStub.java
@@ -469,8 +469,8 @@ public class MemoryStub implements Memory {
}
@Override
- public FileBytes createFileBytes(String filename, long offset, long size, InputStream is)
- throws IOException {
+ public FileBytes createFileBytes(String filename, long offset, long size, InputStream is,
+ TaskMonitor monitor) throws IOException {
throw new UnsupportedOperationException();
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/FileBytesTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/FileBytesTest.java
index 5b0cde2424..efdf8c8666 100644
--- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/FileBytesTest.java
+++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/FileBytesTest.java
@@ -47,7 +47,7 @@ public class FileBytesTest extends AbstractGenericTest {
}
@Test
- public void testStoreAndRetrieveFileBytes() throws IOException {
+ public void testStoreAndRetrieveFileBytes() throws Exception {
int dataSize = MAX_BUFFER_SIZE_FOR_TESTING / 2;
FileBytes fileBytes = createFileBytes("testFile", dataSize);
@@ -186,13 +186,13 @@ public class FileBytesTest extends AbstractGenericTest {
}
}
- private FileBytes createFileBytes(String name, int size) throws IOException {
+ private FileBytes createFileBytes(String name, int size) throws Exception {
byte[] bytes = new byte[size];
for (int i = 0; i < size; i++) {
bytes[i] = (byte) i;
}
try (ByteArrayInputStream is = new ByteArrayInputStream(bytes)) {
- return mem.createFileBytes(name, 0, size, is);
+ return mem.createFileBytes(name, 0, size, is, TaskMonitor.DUMMY);
}
}
diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/MemBlockDBTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/MemBlockDBTest.java
index 04c8c049fd..ab0f53a9ef 100644
--- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/MemBlockDBTest.java
+++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/program/database/mem/MemBlockDBTest.java
@@ -18,7 +18,6 @@ package ghidra.program.database.mem;
import static org.junit.Assert.*;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.util.List;
import org.junit.*;
@@ -282,7 +281,8 @@ public class MemBlockDBTest extends AbstractGenericTest {
@Test
public void testCreateFileBytesBlockOutSideRange() throws Exception {
byte[] bytes = new byte[256];
- FileBytes fileBytes = mem.createFileBytes("test", 0, 100, new ByteArrayInputStream(bytes));
+ FileBytes fileBytes =
+ mem.createFileBytes("test", 0, 100, new ByteArrayInputStream(bytes), TaskMonitor.DUMMY);
try {
mem.createInitializedBlock("test", addr(100), fileBytes, 10, 100, false);
fail(
@@ -379,7 +379,6 @@ public class MemBlockDBTest extends AbstractGenericTest {
}
}
-
@Test
public void testJoinFileBytesBlockAndBufferBlock() throws Exception {
FileBytes fileBytes = createFileBytes();
@@ -695,7 +694,6 @@ public class MemBlockDBTest extends AbstractGenericTest {
assertEquals(2, ranges.getRangeCount()); // we have two sublocks so two distinct ranges
assertEquals(10, ranges.get(0).getSize() + ranges.get(1).getSize());
-
ByteSourceRange range = ranges.get(0);
assertEquals(10, range.getStart().getOffset());
assertEquals(15, range.getEnd().getOffset());
@@ -857,7 +855,7 @@ public class MemBlockDBTest extends AbstractGenericTest {
assertEquals(0, range.getOffset());
}
- @Test
+ @Test
public void testAddressSourceInfoForFileBytesBlock() throws Exception {
FileBytes fileBytes = createFileBytes();
mem.createInitializedBlock("block", addr(100), fileBytes, 10, 50, false);
@@ -919,12 +917,13 @@ public class MemBlockDBTest extends AbstractGenericTest {
false);
}
- private FileBytes createFileBytes() throws IOException {
+ private FileBytes createFileBytes() throws Exception {
byte[] bytes = new byte[256];
for (int i = 0; i < 256; i++) {
bytes[i] = (byte) i;
}
- FileBytes fileBytes = mem.createFileBytes("test", 0, 100, new ByteArrayInputStream(bytes));
+ FileBytes fileBytes =
+ mem.createFileBytes("test", 0, 100, new ByteArrayInputStream(bytes), TaskMonitor.DUMMY);
return fileBytes;
}