GP-2437: Change DBAddressFieldCodec to use FixedField10

This commit is contained in:
Dan 2022-08-15 14:02:22 -04:00
parent b289708a00
commit c0c25e3805
114 changed files with 2354 additions and 652 deletions

View file

@ -155,10 +155,9 @@ public class DBTrace extends DBCachedDomainObjectAdapter implements Trace, Trace
this.baseAddressFactory =
new TraceAddressFactory(this.baseLanguage, this.baseCompilerSpec);
try (UndoableTransaction tid = UndoableTransaction.start(this, "Create", false)) {
try (UndoableTransaction tid = UndoableTransaction.start(this, "Create")) {
initOptions(DBOpenMode.CREATE);
init();
tid.commit();
}
catch (VersionException | CancelledException e) {
throw new AssertionError(e);

View file

@ -60,7 +60,7 @@ public class DBTraceOverlaySpaceAdapter implements DBTraceManager {
* @param <OT> the type of object containing the field
*/
public static class AddressDBFieldCodec<OT extends DBAnnotatedObject & DecodesAddresses>
extends AbstractDBFieldCodec<Address, OT, BinaryField> {
extends AbstractDBFieldCodec<Address, OT, FixedField10> {
static final Charset UTF8 = Charset.forName("UTF-8");
public static byte[] encode(Address address) {
@ -68,16 +68,8 @@ public class DBTraceOverlaySpaceAdapter implements DBTraceManager {
return null;
}
AddressSpace as = address.getAddressSpace();
ByteBuffer buf = ByteBuffer.allocate(Byte.BYTES + Short.BYTES + Long.BYTES);
if (as instanceof OverlayAddressSpace) {
buf.put((byte) 1);
OverlayAddressSpace os = (OverlayAddressSpace) as;
buf.putShort((short) os.getDatabaseKey());
}
else {
buf.put((byte) 0);
buf.putShort((short) as.getSpaceID());
}
ByteBuffer buf = ByteBuffer.allocate(Short.BYTES + Long.BYTES);
buf.putShort((short) as.getSpaceID());
buf.putLong(address.getOffset());
return buf.array();
}
@ -86,29 +78,19 @@ public class DBTraceOverlaySpaceAdapter implements DBTraceManager {
if (enc == null) {
return null;
}
else {
ByteBuffer buf = ByteBuffer.wrap(enc);
byte overlay = buf.get();
final AddressSpace as;
if (overlay == 1) {
short key = buf.getShort();
as = osa.spacesByKey.get(key & 0xffffL);
}
else {
short id = buf.getShort();
as = osa.trace.getInternalAddressFactory().getAddressSpace(id);
}
long offset = buf.getLong();
return as.getAddress(offset);
}
ByteBuffer buf = ByteBuffer.wrap(enc);
short id = buf.getShort();
final AddressSpace as = osa.trace.getInternalAddressFactory().getAddressSpace(id);
long offset = buf.getLong();
return as.getAddress(offset);
}
public AddressDBFieldCodec(Class<OT> objectType, Field field, int column) {
super(Address.class, objectType, BinaryField.class, field, column);
super(Address.class, objectType, FixedField10.class, field, column);
}
@Override
public void store(Address value, BinaryField f) {
public void store(Address value, FixedField10 f) {
f.setBinaryData(encode(value));
}

View file

@ -43,8 +43,8 @@ import ghidra.trace.database.address.DBTraceOverlaySpaceAdapter.AddressDBFieldCo
import ghidra.trace.database.address.DBTraceOverlaySpaceAdapter.DecodesAddresses;
import ghidra.trace.database.data.DBTraceDataTypeManager;
import ghidra.trace.database.guest.DBTraceGuestPlatform;
import ghidra.trace.database.guest.DBTracePlatformManager;
import ghidra.trace.database.guest.DBTraceGuestPlatform.DBTraceGuestLanguage;
import ghidra.trace.database.guest.DBTracePlatformManager;
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.TraceAddressSnapRangeQuery;
import ghidra.trace.database.space.AbstractDBTraceSpaceBasedManager;
import ghidra.trace.database.space.DBTraceDelegatingManager;
@ -69,7 +69,17 @@ public class DBTraceCodeManager
implements TraceCodeManager, DBTraceDelegatingManager<DBTraceCodeSpace> {
public static final String NAME = "Code";
@DBAnnotatedObjectInfo(version = 0)
/**
* A prototype entry
*
* <p>
* Version history:
* <ul>
* <li>1: Change {@link #address} to 10-byte fixed encoding</li>
* <li>0: Initial version and previous unversioned implementation</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
public static class DBTraceCodePrototypeEntry extends DBAnnotatedObject
implements DecodesAddresses {
public static final String TABLE_NAME = "Prototypes";
@ -99,7 +109,7 @@ public class DBTraceCodeManager
@DBAnnotatedField(column = CONTEXT_COLUMN_NAME)
private byte[] context;
@DBAnnotatedField(column = ADDRESS_COLUMN_NAME, codec = AddressDBFieldCodec.class)
private Address address;
private Address address = Address.NO_ADDRESS;
@DBAnnotatedField(column = DELAY_COLUMN_NAME)
private boolean delaySlot;

View file

@ -34,7 +34,17 @@ import ghidra.util.LockHold;
import ghidra.util.database.*;
import ghidra.util.database.annot.*;
@DBAnnotatedObjectInfo(version = 0)
/**
* The implementation of a stack mapping, directly via a database object
*
* <p>
* Version history:
* <ul>
* <li>1: Change {@link #traceAddress} to 10-byte fixed encoding</li>
* <li>0: Initial version and previous unversioned implementation</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
public class DBTraceStaticMapping extends DBAnnotatedObject
implements TraceStaticMapping, DecodesAddresses {
public static final String TABLE_NAME = "StaticMappings";
@ -80,7 +90,7 @@ public class DBTraceStaticMapping extends DBAnnotatedObject
column = TRACE_ADDRESS_COLUMN_NAME,
indexed = true,
codec = AddressDBFieldCodec.class)
private Address traceAddress;
private Address traceAddress = Address.NO_ADDRESS;
@DBAnnotatedField(column = LENGTH_COLUMN_NAME)
private long length;
@DBAnnotatedField(column = START_SNAP_COLUMN_NAME)

View file

@ -33,7 +33,17 @@ import ghidra.util.LockHold;
import ghidra.util.database.*;
import ghidra.util.database.annot.*;
@DBAnnotatedObjectInfo(version = 0)
/**
* The implementation of a stack frame, directly via a database object
*
* <p>
* Version history:
* <ul>
* <li>1: Change {@link #pc} to 10-byte fixed encoding, make it sparse, so optional</li>
* <li>0: Initial version and previous unversioned implementations</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
public class DBTraceStackFrame extends DBAnnotatedObject
implements TraceStackFrame, DecodesAddresses {
public static final String TABLE_NAME = "StackFrames";
@ -56,7 +66,11 @@ public class DBTraceStackFrame extends DBAnnotatedObject
private long stackKey;
@DBAnnotatedField(column = LEVEL_COLUMN_NAME)
private int level;
@DBAnnotatedField(column = PC_COLUMN_NAME, indexed = true, codec = AddressDBFieldCodec.class)
@DBAnnotatedField(
column = PC_COLUMN_NAME,
indexed = true,
codec = AddressDBFieldCodec.class,
sparse = true)
private Address pc;
@DBAnnotatedField(column = COMMENT_COLUMN_NAME)
private String comment;

View file

@ -55,7 +55,17 @@ import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor;
@DBAnnotatedObjectInfo(version = 0)
/**
* The implementation of a function symbol, directly via a database object
*
* <p>
* Version history:
* <ul>
* <li>1: Change {link #entryPoint} to 10-byte fixed encoding</li>
* <li>0: Initial version and previous unversioned implementation</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
public class DBTraceFunctionSymbol extends DBTraceNamespaceSymbol
implements TraceFunctionSymbol, DecodesAddresses {
@SuppressWarnings("hiding")
@ -103,8 +113,9 @@ public class DBTraceFunctionSymbol extends DBTraceNamespaceSymbol
@DBAnnotatedColumn(STACK_RETURN_OFFSET_COLUMN_NAME)
static DBObjectColumn STACK_RETURN_OFFSET_COLUMN;
// Do I need to index entry, too? Not just body?
@DBAnnotatedField(column = ENTRY_COLUMN_NAME, codec = AddressDBFieldCodec.class)
protected Address entryPoint; // Do I need to index entry, too? Not just body?
protected Address entryPoint = Address.NO_ADDRESS;
@DBAnnotatedField(column = START_SNAP_COLUMN_NAME)
protected long startSnap;
@DBAnnotatedField(column = END_SNAP_COLUMN_NAME)

View file

@ -39,7 +39,17 @@ import ghidra.util.database.DBObjectColumn;
import ghidra.util.database.annot.*;
import ghidra.util.exception.DuplicateNameException;
@DBAnnotatedObjectInfo(version = 0)
/**
* The implementation of a label symbol, directly via a database object
*
* <p>
* Version history:
* <ul>
* <li>1: Change {@link #address} to 10-byte fixed encoding</li>
* <li>0: Initial version and previous unversioned implementation</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
public class DBTraceLabelSymbol extends AbstractDBTraceSymbol
implements TraceLabelSymbol, DBTraceSpaceKey, DecodesAddresses {
static final String TABLE_NAME = "Labels";
@ -61,8 +71,9 @@ public class DBTraceLabelSymbol extends AbstractDBTraceSymbol
@DBAnnotatedColumn(END_SNAP_COLUMN_NAME)
static DBObjectColumn END_SNAP_COLUMN;
// NOTE: Indexed in manager's range map
@DBAnnotatedField(column = ADDRESS_COLUMN_NAME, codec = AddressDBFieldCodec.class)
protected Address address; // NOTE: Indexed in manager's range map
protected Address address = Address.NO_ADDRESS;
@DBAnnotatedField(column = THREAD_COLUMN_NAME)
protected long threadKey;
@DBAnnotatedField(column = START_SNAP_COLUMN_NAME)

View file

@ -91,7 +91,17 @@ public class DBTraceReferenceSpace implements DBTraceSpaceBased, TraceReferenceS
protected abstract DBTraceReference construct(DBTraceReferenceEntry ent);
}
@DBAnnotatedObjectInfo(version = 0)
/**
* A reference entry
*
* <p>
* Version history:
* <ul>
* <li>1: Change {@link #toAddress} to 10-byte fixed encoding</li>
* <li>0: Initial version and previous unversioned implementation</li>
* </ul>
*/
@DBAnnotatedObjectInfo(version = 1)
protected static class DBTraceReferenceEntry
extends AbstractDBTraceAddressSnapRangePropertyMapData<DBTraceReferenceEntry>
implements DecodesAddresses {
@ -137,7 +147,7 @@ public class DBTraceReferenceSpace implements DBTraceSpaceBased, TraceReferenceS
column = TO_ADDR_COLUMN_NAME,
indexed = true,
codec = AddressDBFieldCodec.class)
protected Address toAddress;
protected Address toAddress = Address.NO_ADDRESS;
@DBAnnotatedField(column = SYMBOL_ID_COLUMN_NAME, indexed = true)
protected long symbolId; // TODO: Is this at the from or to address? I think TO...
@DBAnnotatedField(column = REF_TYPE_COLUMN_NAME, codec = RefTypeDBFieldCodec.class)
@ -514,12 +524,12 @@ public class DBTraceReferenceSpace implements DBTraceSpaceBased, TraceReferenceS
badOffsetReference = true;
}
}
if (badOffsetReference) {
Msg.warn(this, "Offset Reference from " + fromAddress +
" produces bad Xref into EXTERNAL block");
}
makeWay(lifespan, fromAddress, toAddress, operandIndex);
DBTraceReferenceEntry entry = referenceMapSpace.put(fromAddress, lifespan, null);

View file

@ -193,7 +193,7 @@ public class ToyDBTraceBuilder implements AutoCloseable {
}
public UndoableTransaction startTransaction() {
return UndoableTransaction.start(trace, "Testing", true);
return UndoableTransaction.start(trace, "Testing");
}
public DBTraceBookmarkType getOrAddBookmarkType(String name) {

View file

@ -80,7 +80,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
@Test
public void testSetName() throws InvalidNameException {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.setName("Another name");
}
assertEquals("Another name", trace.getName());
@ -93,12 +93,12 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
Path tmpDir = Files.createTempDirectory("test");
File archiveFile = tmpDir.resolve("test.gdt").toFile();
FileDataTypeManager dtm2 = FileDataTypeManager.createFileArchive(archiveFile);
try (UndoableTransaction tid = UndoableTransaction.start(dtm2, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(dtm2, "Testing")) {
dtm2.addDataType(mine, DataTypeConflictHandler.DEFAULT_HANDLER);
}
DataType got = dtm2.getDataType(minePath);
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(got, DataTypeConflictHandler.DEFAULT_HANDLER);
}
dtm2.delete();
@ -112,7 +112,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
public void testAddAndGet() {
StructureDataType mine = getTestDataType();
DataTypePath minePath = mine.getDataTypePath();
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mine, DataTypeConflictHandler.REPLACE_HANDLER);
}
@ -125,14 +125,14 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
public void testAddRemoveUndoThenGet() throws IOException {
StructureDataType mine = getTestDataType();
DataTypePath minePath = mine.getDataTypePath();
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mine, DataTypeConflictHandler.REPLACE_HANDLER);
}
DataType got = dtm.getDataType(minePath);
assertEquals(mine.toString(), got.toString()); // TODO: Eww
try (UndoableTransaction tid = UndoableTransaction.start(trace, "To Undo", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "To Undo")) {
dtm.remove(got, new ConsoleTaskMonitor());
}
@ -148,7 +148,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
public void testChangeDataType() {
StructureDataType mine = getTestDataType();
DataTypePath minePath = mine.getDataTypePath();
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mine, DataTypeConflictHandler.REPLACE_HANDLER);
Structure got = (Structure) dtm.getDataType(minePath);
@ -165,7 +165,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
DataTypePath mineAPath = mineA.getDataTypePath();
StructureDataType mineB = getTestDataTypeB();
DataTypePath mineBPath = mineB.getDataTypePath();
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mineA, DataTypeConflictHandler.REPLACE_HANDLER);
DataType got = dtm.getDataType(mineAPath);
@ -181,7 +181,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
StructureDataType mine = getTestDataType();
DataTypePath minePath = mine.getDataTypePath();
DataType got;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mine, DataTypeConflictHandler.REPLACE_HANDLER);
got = dtm.getDataType(minePath);
@ -197,7 +197,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
StructureDataType mine = getTestDataType();
DataTypePath minePath = mine.getDataTypePath();
DataType got;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.addDataType(mine, DataTypeConflictHandler.REPLACE_HANDLER);
got = dtm.getDataType(minePath);
@ -211,7 +211,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
@Test
public void testCreateCategory() {
Category category;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
category = dtm.createCategory(new CategoryPath("/Another/Path"));
}
assertEquals(category, dtm.getCategory(new CategoryPath("/Another/Path")));
@ -220,7 +220,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
@Test
public void testMoveCategory() throws DuplicateNameException {
Category toMove;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
Category category = dtm.createCategory(new CategoryPath("/Another/Path"));
toMove = dtm.createCategory(new CategoryPath("/MoveMe"));
category.moveCategory(toMove, new ConsoleTaskMonitor());
@ -231,7 +231,7 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
@Test
public void testRenameCategory() throws DuplicateNameException, InvalidNameException {
Category category;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
category = dtm.createCategory(new CategoryPath("/Another/Path"));
category.setName("Renamed");
}
@ -241,12 +241,12 @@ public class DBTraceDataTypeManagerTest extends AbstractGhidraHeadlessIntegratio
@Test
public void testRemoveCategory() {
Category category;
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
category = dtm.createCategory(new CategoryPath("/Another/Path"));
}
assertEquals(category, dtm.getCategory(new CategoryPath("/Another/Path")));
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing")) {
dtm.getCategory(new CategoryPath("/Another"))
.removeEmptyCategory("Path",
new ConsoleTaskMonitor());

View file

@ -145,7 +145,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
.getLanguage(new LanguageID("Toy:BE:64:default"));
obj = new MyObject(this);
factory = new DBCachedObjectStoreFactory(obj);
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable")) {
space = new DBTraceAddressSnapRangePropertyMapSpace<>("Entries", factory,
obj.getReadWriteLock(), toy.getDefaultSpace(), MyEntry.class, MyEntry::new);
}
@ -163,7 +163,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
view = makeIntersectingView(tasr(0x0100, 0x2fff, 0, 0), s -> true);
assertFalse(view.contains(addr(0x1800)));
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 9), "A");
}
@ -195,7 +195,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
view = makeIntersectingView(tasr(0x0100, 0x2fff, 0, 0), s -> true);
assertFalse(view.contains(addr(0x1000), addr(0x1fff)));
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x3fff, 1, 1), "B");
}
@ -232,7 +232,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
view = makeIntersectingView(tasr(0x0100, 0x2fff, 0, 0), s -> true);
assertFalse(view.contains(set(rng(0x1000, 0x1fff))));
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x3fff, 1, 1), "B");
}
@ -271,7 +271,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
assertEquals(0, view.getNumAddressRanges());
assertEquals(0, view.getNumAddresses());
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -307,7 +307,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
assertNull(view.getMinAddress());
assertNull(view.getMaxAddress());
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x3fff, 1, 1), "B");
}
@ -337,7 +337,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
view = makeIntersectingView(tasr(0x0100, 0x2fff, 0, 0), s -> true);
assertEquals(List.of(), list(view.iterator()));
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -376,7 +376,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
view = makeIntersectingView(tasr(0x0100, 0x2fff, 0, 0), s -> true);
assertEquals(List.of(), list(view.getAddresses(true)));
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(1, 5, 0, 0), "A");
}
@ -396,7 +396,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testIntersects() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -418,7 +418,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testUnion() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -431,7 +431,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testSubtract() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -445,7 +445,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testXor() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -459,7 +459,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testHasSameAddresses() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -475,7 +475,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testGetFirstLastRanges() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x27ff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -489,7 +489,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testGetRangeContaining() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");
@ -509,7 +509,7 @@ public class DBTraceAddressSnapRangePropertyMapAddressSetViewTest
@Test
public void testFindFirstAddressInCommon() {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction trans = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 0, 0), "A");
space.put(tasr(0x2000, 0x2fff, 1, 1), "B");

View file

@ -157,7 +157,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
new LanguageID("Toy:BE:64:default"));
obj = new MyObject(this);
factory = new DBCachedObjectStoreFactory(obj);
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable")) {
space = new DBTraceAddressSnapRangePropertyMapSpace<>("Entries", factory,
obj.getReadWriteLock(), toy.getDefaultSpace(), MyEntry.class, MyEntry::new);
}
@ -188,7 +188,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
@Test
public void testOutOfWindow() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 5, 10), "A");
}
@ -208,7 +208,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
@Test
public void testSingleEntry() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 90, 95), "A");
}
@ -232,7 +232,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
@Test
public void testEntriesAtExtremes() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x0000, 0x0fff, 5, 10), "W");
space.put(tasr(-0x1000, -0x0001, 5, 10), "E");
space.put(tasr(0x1000, 0x1fff, Long.MIN_VALUE, Long.MIN_VALUE + 10), "S");
@ -240,18 +240,18 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterableTest
}
it = makeOcclusionIterable(tasr(0x0000, -0x0001, Long.MIN_VALUE, Long.MAX_VALUE));
assertEquals(list( //
ent(0x0000, 0x0fff, 5, 10, "W"), //
ent(0x1000, 0x1fff, Long.MIN_VALUE, Long.MIN_VALUE + 10, "S"), //
ent(0x2000, 0x2fff, Long.MAX_VALUE - 10, Long.MAX_VALUE, "N"), //
ent(-0x1000, -0x0001, 5, 10, "E") //
), list(it));
assertEquals(list(
ent(0x0000, 0x0fff, 5, 10, "W"),
ent(0x1000, 0x1fff, Long.MIN_VALUE, Long.MIN_VALUE + 10, "S"),
ent(0x2000, 0x2fff, Long.MAX_VALUE - 10, Long.MAX_VALUE, "N"),
ent(-0x1000, -0x0001, 5, 10, "E")),
list(it));
}
@Test
public void testOcclusion() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoFutureIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 90, 95), "A");
space.put(tasr(0x1800, 0x27ff, 89, 95), "B");

View file

@ -157,7 +157,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
new LanguageID("Toy:BE:64:default"));
obj = new MyObject(this);
factory = new DBCachedObjectStoreFactory(obj);
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "CreateTable")) {
space = new DBTraceAddressSnapRangePropertyMapSpace<>("Entries", factory,
obj.getReadWriteLock(), toy.getDefaultSpace(), MyEntry.class, MyEntry::new);
}
@ -188,7 +188,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
@Test
public void testOutOfWindow() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 5, 10), "A");
}
@ -208,7 +208,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
@Test
public void testSingleEntry() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 5, 10), "A");
}
@ -232,7 +232,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
@Test
public void testEntriesAtExtremes() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x0000, 0x0fff, 5, 10), "W");
space.put(tasr(-0x1000, -0x0001, 5, 10), "E");
space.put(tasr(0x1000, 0x1fff, Long.MIN_VALUE, Long.MIN_VALUE + 10), "S");
@ -251,7 +251,7 @@ public class DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterableTest
@Test
public void testOcclusion() {
DBTraceAddressSnapRangePropertyMapOcclusionIntoPastIterable<String> it;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create Entries")) {
space.put(tasr(0x1000, 0x1fff, 5, 10), "A");
space.put(tasr(0x1800, 0x27ff, 5, 11), "B");

View file

@ -80,7 +80,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
}
protected void loadSpaces() throws VersionException, IOException {
try (UndoableTransaction tid = UndoableTransaction.start(this, "Create Tables", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(this, "Create Tables")) {
this.space1 = new DBTraceAddressSnapRangePropertyMapSpace<>("Entries1", factory,
getReadWriteLock(), toy.getDefaultSpace(), MyEntry.class, MyEntry::new);
this.space2 = new DBTraceAddressSnapRangePropertyMapSpace<>("Entries2", factory,
@ -236,7 +236,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Test
public void testDeleteValue() {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
MyEntry entry1 = obj.space1.put(at(0x1000, 5), null);
MyEntry entry2 = obj.space2.put(at(0x1001, 5), null);
String value3 = obj.space3.put(at(0x1002, 5), "Test");
@ -268,7 +268,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Test
@Ignore("TODO")
public void testRemove() {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
obj.space1.put(at(0x1000, 5), null);
obj.space2.put(at(0x1000, 5), null);
assertEquals(1, obj.space1.size());
@ -308,7 +308,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
public void testCollections() {
MyEntry entry1;
MyEntry entry2;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
entry1 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
entry2 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1001), 6), null);
}
@ -329,7 +329,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Test
public void testReduce() {
MyEntry ent1;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
ent1 = obj.space1.put(at(0x1000, 5), null);
}
@ -342,7 +342,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Test
public void testFirsts() {
MyEntry entry1;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
entry1 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
}
@ -353,7 +353,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Test
public void testClear() {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
MyEntry entry1 =
obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
assertEquals(1, obj.space1.size());
@ -369,7 +369,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
public void testGetDataByKey() {
assertNull(obj.space1.getDataByKey(0));
MyEntry entry1;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
entry1 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
}
@ -381,7 +381,7 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Ignore("TODO")
public void testSaveAndLoad() throws IOException, CancelledException, VersionException {
MyEntry entry1;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
entry1 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
}
assertEquals(ent(0x1000, 5, entry1), obj.space1.firstEntry());
@ -400,12 +400,12 @@ public class DBTraceAddressSnapRangePropertyMapSpaceTest
@Ignore("Related to GP-479")
public void testUndoThenRedo() throws IOException {
MyEntry entry1;
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Create entries")) {
entry1 = obj.space1.put(new ImmutableTraceAddressSnapRange(addr(0x1000), 5), null);
}
assertEquals(ent(0x1000, 5, entry1), obj.space1.firstEntry());
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Clear", true)) {
try (UndoableTransaction tid = UndoableTransaction.start(obj, "Clear")) {
obj.space1.clear();
}
assertNull(obj.space1.firstEntry());

View file

@ -34,49 +34,50 @@ import ghidra.util.database.UndoableTransaction;
public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessIntegrationTest {
ToyDBTraceBuilder b;
ToyDBTraceBuilder tb;
DBTraceStaticMappingManager staticMappingManager;
@Before
public void setUpStaticMappingManagerTest() throws IOException {
b = new ToyDBTraceBuilder("Testing", "Toy:BE:64:default");
staticMappingManager = b.trace.getStaticMappingManager();
tb = new ToyDBTraceBuilder("Testing", "Toy:BE:64:default");
staticMappingManager = tb.trace.getStaticMappingManager();
}
@After
public void tearDownStaticMappingManagerTest() {
b.close();
tb.close();
}
@Test
public void testAddAndGet() throws Exception {
try (UndoableTransaction tid = b.startTransaction()) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closed(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99), Range.closed(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
}
DBTraceStaticMapping found = staticMappingManager.findContaining(b.addr(0xdeadbeef), 2);
assertEquals(b.addr(0xdeadbeef), found.getMinTraceAddress());
DBTraceStaticMapping found = staticMappingManager.findContaining(tb.addr(0xdeadbeef), 2);
assertEquals(tb.addr(0xdeadbeef), found.getMinTraceAddress());
assertEquals(100, found.getLength());
assertEquals(2, found.getStartSnap());
assertEquals(5, found.getEndSnap());
assertEquals(new URL("ghidra://static"), found.getStaticProgramURL());
assertEquals("DEADBEEF", found.getStaticAddress());
assertEquals(found, staticMappingManager.findContaining(b.addr(0xdeadbeef + 99), 2));
assertEquals(found, staticMappingManager.findContaining(b.addr(0xdeadbeef + 99), 5));
assertEquals(found, staticMappingManager.findContaining(b.addr(0xdeadbeef), 5));
assertEquals(found, staticMappingManager.findContaining(tb.addr(0xdeadbeef + 99), 2));
assertEquals(found, staticMappingManager.findContaining(tb.addr(0xdeadbeef + 99), 5));
assertEquals(found, staticMappingManager.findContaining(tb.addr(0xdeadbeef), 5));
assertNull(staticMappingManager.findContaining(b.addr(0xdeadbeef - 1), 2));
assertNull(staticMappingManager.findContaining(b.addr(0xdeadbeef + 100), 2));
assertNull(staticMappingManager.findContaining(b.addr(0xdeadbeef), 1));
assertNull(staticMappingManager.findContaining(b.addr(0xdeadbeef), 6));
assertNull(staticMappingManager.findContaining(tb.addr(0xdeadbeef - 1), 2));
assertNull(staticMappingManager.findContaining(tb.addr(0xdeadbeef + 100), 2));
assertNull(staticMappingManager.findContaining(tb.addr(0xdeadbeef), 1));
assertNull(staticMappingManager.findContaining(tb.addr(0xdeadbeef), 6));
}
@Test
public void testAddAndEnumerate() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
}
@ -86,10 +87,11 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@Test
public void testAddRemoveAndEnumerate() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99),
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(7L, 10L),
new URL("ghidra://static"), "DEADBEEF");
@ -105,10 +107,11 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@Test
public void testOverlapCausesException() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
staticMappingManager.add(b.range(0xdeadbeef + 80, 0xdeadbeef + 179),
staticMappingManager.add(tb.range(0xdeadbeef + 80, 0xdeadbeef + 179),
Range.closedOpen(2L, 5L), new URL("ghidra://static"), "DEADBEEF");
fail();
}
@ -119,20 +122,22 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@Test
public void testOverlapAgreeingAccepted() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
staticMappingManager.add(b.range(0xdeadbeef + 80, 0xdeadbeef + 179),
staticMappingManager.add(tb.range(0xdeadbeef + 80, 0xdeadbeef + 179),
Range.closedOpen(2L, 5L), new URL("ghidra://static"), "DEADBF3F");
}
}
@Test
public void testTouchingProceedingIsNotOverlapping() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
staticMappingManager.add(b.range(0xdeadbeef + 100, 0xdeadbeef + 199),
staticMappingManager.add(tb.range(0xdeadbeef + 100, 0xdeadbeef + 199),
Range.closedOpen(2L, 5L), new URL("ghidra://static"), "DEADBEEF");
}
}
@ -140,12 +145,12 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@SuppressWarnings("hiding")
@Test
public void testSaveAndLoad() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closed(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99), Range.closed(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
}
File tmp = b.save();
File tmp = tb.save();
try (ToyDBTraceBuilder b = new ToyDBTraceBuilder(tmp)) {
DBTraceStaticMappingManager staticMappingManager = b.trace.getStaticMappingManager();
DBTraceStaticMapping found =
@ -161,8 +166,9 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@Test
public void testAddButAbortedStillEmpty() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
tid.abort();
}
@ -172,29 +178,31 @@ public class DBTraceStaticMappingManagerTest extends AbstractGhidraHeadlessInteg
@Test
public void testAddThenUndo() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
}
b.trace.undo();
tb.trace.undo();
assertEquals(0, staticMappingManager.getAllEntries().size());
}
@Test
public void testAddThenRemoveThenUndo() throws Exception {
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
staticMappingManager.add(b.range(0xdeadbeef, 0xdeadbeef + 99), Range.closedOpen(2L, 5L),
try (UndoableTransaction tid = tb.startTransaction()) {
staticMappingManager.add(tb.range(0xdeadbeef, 0xdeadbeef + 99),
Range.closedOpen(2L, 5L),
new URL("ghidra://static"), "DEADBEEF");
}
assertEquals(1, staticMappingManager.getAllEntries().size());
try (UndoableTransaction tid = UndoableTransaction.start(b.trace, "Testing", true)) {
try (UndoableTransaction tid = tb.startTransaction()) {
for (TraceStaticMapping m : staticMappingManager.getAllEntries()) {
m.delete();
}
}
assertEquals(0, staticMappingManager.getAllEntries().size());
b.trace.undo();
tb.trace.undo();
assertEquals(1, staticMappingManager.getAllEntries().size());
}
}

View file

@ -142,7 +142,7 @@ public class DBTraceDisassemblerIntegrationTest extends AbstractGhidraHeadlessIn
public void testThumbSampleProgramDB() throws Exception {
ProgramBuilder b = new ProgramBuilder(getName(), ProgramBuilder._ARM);
try (UndoableTransaction tid =
UndoableTransaction.start(b.getProgram(), "Disassemble (THUMB)", true)) {
UndoableTransaction.start(b.getProgram(), "Disassemble (THUMB)")) {
MemoryBlock text = b.createMemory(".text", "b6fa2cd0", 32, "Sample", (byte) 0);
text.putBytes(b.addr(0xb6fa2cdc), new byte[] {
// GDB: stmdb sp!, {r4,r5,r6,r7,r8,lr}