mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-691: Fixed R*-Tree implementation (closes #2760)
This commit is contained in:
parent
56f3f5c656
commit
8db624109a
7 changed files with 131 additions and 20 deletions
|
@ -23,6 +23,7 @@ import java.util.function.Predicate;
|
|||
|
||||
import com.google.common.collect.Range;
|
||||
|
||||
import ghidra.lifecycle.Internal;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMap.DBTraceAddressSnapRangePropertyMapDataFactory;
|
||||
import ghidra.trace.database.map.DBTraceAddressSnapRangePropertyMapTree.AbstractDBTraceAddressSnapRangePropertyMapData;
|
||||
|
@ -200,4 +201,12 @@ public class DBTraceAddressSnapRangePropertyMapSpace<T, DR extends AbstractDBTra
|
|||
public DR getDataByKey(long key) {
|
||||
return tree.getDataByKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* For developers and testers.
|
||||
*/
|
||||
@Internal
|
||||
public void checkIntegrity() {
|
||||
tree.checkIntegrity();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -599,7 +599,7 @@ public class DBTraceAddressSnapRangePropertyMapTree<T, DR extends AbstractDBTrac
|
|||
}
|
||||
|
||||
protected void doInsertDataEntry(DR entry) {
|
||||
super.doInsert(entry, leafLevel, new BitSet());
|
||||
super.doInsert(entry, new LevelInfo(leafLevel));
|
||||
}
|
||||
|
||||
public DBTraceAddressSnapRangePropertyMapSpace<T, DR> getMapSpace() {
|
||||
|
|
|
@ -61,7 +61,12 @@ public class TraceAddressSnapSpace implements EuclideanSpace2D<Address, Long> {
|
|||
|
||||
@Override
|
||||
public double distX(Address x1, Address x2) {
|
||||
return UnsignedUtils.unsignedLongToDouble(x2.subtract(x1));
|
||||
if (x2.compareTo(x1) > 0) {
|
||||
return UnsignedUtils.unsignedLongToDouble(x2.subtract(x1));
|
||||
}
|
||||
else {
|
||||
return UnsignedUtils.unsignedLongToDouble(x1.subtract(x2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +77,12 @@ public class TraceAddressSnapSpace implements EuclideanSpace2D<Address, Long> {
|
|||
if (y1 == null) {
|
||||
return Double.NEGATIVE_INFINITY;
|
||||
}
|
||||
return y2 - y1;
|
||||
if (y2 > y1) {
|
||||
return y2 - y1;
|
||||
}
|
||||
else {
|
||||
return y1 - y2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -964,4 +964,23 @@ public abstract class AbstractDBTraceMemoryManagerTest
|
|||
frame.getValue(0, r0).getUnsignedValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This test is based on the MWE submitted in GitHub issue #2760.
|
||||
*/
|
||||
@Test
|
||||
public void testManyStateEntries() throws Exception {
|
||||
Register pc = toyLanguage.getRegister("pc");
|
||||
DBTraceThread thread;
|
||||
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
|
||||
thread = trace.getThreadManager().addThread("Thread1", Range.atLeast(0L));
|
||||
DBTraceMemoryRegisterSpace regs = memory.getMemoryRegisterSpace(thread, true);
|
||||
|
||||
for (int i = 1; i < 2000; i++) {
|
||||
//System.err.println("Snap " + i);
|
||||
regs.setState(i, pc, TraceMemoryState.KNOWN);
|
||||
//regs.stateMapSpace.checkIntegrity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue