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

@ -720,6 +720,10 @@ public class GdbManagerImpl implements GdbManager {
curCmd = pcmd; curCmd = pcmd;
} }
//Msg.debug(this, "CURCMD = " + curCmd); //Msg.debug(this, "CURCMD = " + curCmd);
if (LOG_IO) {
DBG_LOG.println("*CMD: " + cmd.getClass());
DBG_LOG.flush();
}
String text = cmd.encode(); String text = cmd.encode();
if (text != null) { if (text != null) {
Interpreter interpreter = cmd.getInterpreter(); Interpreter interpreter = cmd.getInterpreter();

View file

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

View file

@ -256,7 +256,7 @@ public class TracePcodeEmulatorTest extends AbstractGhidraHeadlessIntegrationTes
"bx r6")); // 4 bytes "bx r6")); // 4 bytes
byte[] mov = asm.assembleLine(tb.addr(0x00401000), 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()) { try (UndoableTransaction tid = tb.startTransaction()) {
asm.patchProgram(mov, tb.addr(0x00401000)); asm.patchProgram(mov, tb.addr(0x00401000));
} }

View file

@ -719,7 +719,7 @@ public abstract class AbstractDBTraceMemoryManagerTest
@Test @Test
public void testFindBytes() { public void testFindBytes() {
try (UndoableTransaction tid = UndoableTransaction.start(trace, "Testing", true)) { 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 { 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), memory.findBytes(3, range(0x4001, 0x4004), buf(1, 2, 3, 4), buf(-1, -1, -1, -1),
true, TaskMonitor.DUMMY)); 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 // Too low
assertNull( assertNull(
memory.findBytes(3, range(0x3fff, 0x4002), buf(1, 2, 3, 4), buf(-1, -1, -1, -1), memory.findBytes(3, range(0x3fff, 0x4002), buf(1, 2, 3, 4), buf(-1, -1, -1, -1),