mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-475: Completed the Debugger "Watches" plugin
This commit is contained in:
@@ -41,6 +41,7 @@ import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.memory.*;
|
||||
import ghidra.trace.model.stack.TraceStackFrame;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.MathUtilities;
|
||||
import ghidra.util.UnionAddressSetView;
|
||||
import ghidra.util.database.DBOpenMode;
|
||||
import ghidra.util.exception.DuplicateNameException;
|
||||
@@ -258,7 +259,12 @@ public class DBTraceMemoryManager
|
||||
|
||||
@Override
|
||||
public int getBytes(long snap, Address start, ByteBuffer buf) {
|
||||
return delegateReadI(start.getAddressSpace(), m -> m.getBytes(snap, start, buf), 0);
|
||||
return delegateReadI(start.getAddressSpace(), m -> m.getBytes(snap, start, buf), () -> {
|
||||
Address max = start.getAddressSpace().getMaxAddress();
|
||||
int len = MathUtilities.unsignedMin(buf.remaining(), max.subtract(start));
|
||||
buf.position(buf.position() + len);
|
||||
return len;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -105,6 +105,17 @@ public interface DBTraceDelegatingManager<M> {
|
||||
}
|
||||
}
|
||||
|
||||
default int delegateReadI(AddressSpace space, ToIntFunction<M> func, IntSupplier ifNull) {
|
||||
checkIsInMemory(space);
|
||||
try (LockHold hold = LockHold.lock(readLock())) {
|
||||
M m = getForSpace(space, false);
|
||||
if (m == null) {
|
||||
return ifNull.getAsInt();
|
||||
}
|
||||
return func.applyAsInt(m);
|
||||
}
|
||||
}
|
||||
|
||||
default boolean delegateReadB(AddressSpace space, Predicate<M> func, boolean ifNull) {
|
||||
checkIsInMemory(space);
|
||||
try (LockHold hold = LockHold.lock(readLock())) {
|
||||
|
||||
@@ -831,8 +831,7 @@ public abstract class AbstractDBTraceMemoryManagerTest
|
||||
assertEquals(expected, collectAsMap(memory.getStates(3, range(0x3000, 0x5000))));
|
||||
|
||||
ByteBuffer read = ByteBuffer.allocate(4);
|
||||
// NOTE: 0 is returned because the space is no longer active....
|
||||
assertEquals(0, memory.getBytes(3, addr(0x4000), read));
|
||||
assertEquals(4, memory.getBytes(3, addr(0x4000), read));
|
||||
assertArrayEquals(arr(0, 0, 0, 0), read.array());
|
||||
}
|
||||
|
||||
@@ -860,8 +859,7 @@ public abstract class AbstractDBTraceMemoryManagerTest
|
||||
assertEquals(expected, collectAsMap(memory.getStates(3, range(0x3000, 0x5000))));
|
||||
|
||||
ByteBuffer read = ByteBuffer.allocate(4);
|
||||
// NOTE: 0 is returned because the space is no longer active....
|
||||
assertEquals(0, memory.getBytes(3, addr(0x4000), read));
|
||||
assertEquals(4, memory.getBytes(3, addr(0x4000), read));
|
||||
assertArrayEquals(arr(0, 0, 0, 0), read.array());
|
||||
}
|
||||
|
||||
@@ -889,8 +887,7 @@ public abstract class AbstractDBTraceMemoryManagerTest
|
||||
assertEquals(expected, collectAsMap(memory.getStates(3, range(0x3000, 0x5000))));
|
||||
|
||||
ByteBuffer read = ByteBuffer.allocate(4);
|
||||
// NOTE: 0 is returned because the space is no longer active....
|
||||
assertEquals(0, memory.getBytes(3, addr(0x4000), read));
|
||||
assertEquals(4, memory.getBytes(3, addr(0x4000), read));
|
||||
assertArrayEquals(arr(0, 0, 0, 0), read.array());
|
||||
|
||||
trace.redo();
|
||||
|
||||
Reference in New Issue
Block a user