Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2024-02-09 10:25:41 -05:00
commit 0224a1ad6d
2 changed files with 21 additions and 12 deletions

View file

@ -20,7 +20,7 @@ import java.util.Map.Entry;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import ghidra.app.plugin.core.debug.mapping.*; import ghidra.app.plugin.core.debug.mapping.DefaultDebuggerTargetTraceMapper;
import ghidra.app.plugin.core.debug.service.model.interfaces.*; import ghidra.app.plugin.core.debug.service.model.interfaces.*;
import ghidra.async.AsyncFence; import ghidra.async.AsyncFence;
import ghidra.async.AsyncUtils; import ghidra.async.AsyncUtils;
@ -164,7 +164,8 @@ public class DefaultThreadRecorder implements ManagedThreadRecorder {
public CompletableFuture<Map<Register, RegisterValue>> captureThreadRegisters( public CompletableFuture<Map<Register, RegisterValue>> captureThreadRegisters(
TraceThread thread, int frameLevel, Set<Register> registers) { TraceThread thread, int frameLevel, Set<Register> registers) {
if (regMapper == null) { if (regMapper == null) {
throw new IllegalStateException("Have not found register descriptions for " + thread); return CompletableFuture.failedFuture(
new IllegalStateException("Have not found register descriptions for " + thread));
} }
List<TargetRegister> tRegs = registers.stream() List<TargetRegister> tRegs = registers.stream()
.map(regMapper::traceToTarget) .map(regMapper::traceToTarget)
@ -180,20 +181,25 @@ public class DefaultThreadRecorder implements ManagedThreadRecorder {
Set<TargetRegisterBank> banks = getTargetRegisterBank(thread, frameLevel); Set<TargetRegisterBank> banks = getTargetRegisterBank(thread, frameLevel);
if (banks == null) { if (banks == null) {
throw new IllegalArgumentException( return CompletableFuture.failedFuture(new IllegalArgumentException(
"Given thread and frame level does not have a live register bank"); "Given thread and frame level does not have a live register bank"));
} }
// NOTE: Cache update, if applicable, will cause recorder to write values to trace // NOTE: Cache update, if applicable, will cause recorder to write values to trace
AsyncFence fence = new AsyncFence(); AsyncFence fence = new AsyncFence();
Map<Register, RegisterValue> result = new HashMap<>(); Map<Register, RegisterValue> result = new HashMap<>();
for (TargetRegisterBank bank : banks) { for (TargetRegisterBank bank : banks) {
fence.include(bank.readRegisters(tRegs) try {
.thenApply(regMapper::targetToTrace) fence.include(bank.readRegisters(tRegs)
.thenAccept(br -> { .thenApply(regMapper::targetToTrace)
synchronized (result) { .thenAccept(br -> {
result.putAll(br); synchronized (result) {
} result.putAll(br);
})); }
}));
}
catch (Exception e) {
fence.include(CompletableFuture.failedFuture(e));
}
} }
return fence.ready().thenApply(__ -> result); return fence.ready().thenApply(__ -> result);
} }

View file

@ -1465,7 +1465,10 @@ public class SymbolicPropogator {
if (ptype == PcodeOp.BRANCH || ptype == PcodeOp.RETURN || ptype == PcodeOp.BRANCHIND) { if (ptype == PcodeOp.BRANCH || ptype == PcodeOp.RETURN || ptype == PcodeOp.BRANCHIND) {
// if says this is branch, but has a fallthru, then really isn't a fallthru // if says this is branch, but has a fallthru, then really isn't a fallthru
// assume the future flow will have flowed the correct info. // assume the future flow will have flowed the correct info.
nextAddr = fallthru; // only assign for branch if it isn't a degenerate fallthru to itself
if (!minInstrAddress.equals(fallthru)) {
nextAddr = fallthru;
}
} }
return nextAddr; return nextAddr;