GP-0: GDB Diagnostics, debugger framework test fixes.

This commit is contained in:
Dan 2021-05-21 13:55:35 -04:00
parent 5808049c83
commit 9fa2a722d8
4 changed files with 18 additions and 3 deletions

View file

@ -759,6 +759,11 @@ public class DBTraceMemorySpace implements Unfinished, TraceMemorySpace, DBTrace
protected Address doFindBytesInRange(long snap, AddressRange range, ByteBuffer data,
ByteBuffer mask, boolean forward, TaskMonitor monitor) {
int len = data.capacity();
assert len != 0; // Caller should have checked
if (range.getLength() > 0 /*treat length unsigned*/ && range.getLength() < len) {
return null;
}
AddressRange rangeOfStarts =
new AddressRangeImpl(range.getMinAddress(), range.getMaxAddress().subtract(len - 1));
ByteBuffer read = ByteBuffer.allocate(len);
@ -790,7 +795,8 @@ public class DBTraceMemorySpace implements Unfinished, TraceMemorySpace, DBTrace
if (mask != null && mask.capacity() != len) {
throw new IllegalArgumentException("data and mask must have same capacity");
}
if (len == 0 || range.getLength() > 0 && range.getLength() < len) {
if (len == 0 ||
range.getLength() > 0 /*treat length unsigned*/ && range.getLength() < len) {
return null;
}

View file

@ -256,7 +256,7 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
"bx r6")); // 4 bytes
byte[] mov = asm.assembleLine(tb.addr(0x00401000),
"mov r0, #123", thumbPat); // #123 is decimal
"movs r0, #123", thumbPat); // #123 is decimal
try (UndoableTransaction tid = tb.startTransaction()) {
asm.patchProgram(mov, tb.addr(0x00401000));
}

View file

@ -719,7 +719,7 @@ public abstract class AbstractDBTraceMemoryManagerTest
@Test
public void testFindBytes() {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) {
assertEquals(4, memory.putBytes(3, addr(0x4000), buf(1, 2, 3, 4)));
assertEquals(5, memory.putBytes(3, addr(0x4000), buf(1, 2, 3, 4, 5)));
}
try {
@ -750,6 +750,11 @@ public abstract class AbstractDBTraceMemoryManagerTest
memory.findBytes(3, range(0x4001, 0x4004), buf(1, 2, 3, 4), buf(-1, -1, -1, -1),
true, TaskMonitor.DUMMY));
// Too high, into unknown
assertNull(
memory.findBytes(3, range(0x4001, 0x4005), buf(1, 2, 3, 4, 5), buf(-1, -1, -1, -1, -1),
true, TaskMonitor.DUMMY));
// Too low
assertNull(
memory.findBytes(3, range(0x3fff, 0x4002), buf(1, 2, 3, 4), buf(-1, -1, -1, -1),