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.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.async.AsyncFence;
import ghidra.async.AsyncUtils;
@ -164,7 +164,8 @@ public class DefaultThreadRecorder implements ManagedThreadRecorder {
public CompletableFuture<Map<Register, RegisterValue>> captureThreadRegisters(
TraceThread thread, int frameLevel, Set<Register> registers) {
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()
.map(regMapper::traceToTarget)
@ -180,20 +181,25 @@ public class DefaultThreadRecorder implements ManagedThreadRecorder {
Set<TargetRegisterBank> banks = getTargetRegisterBank(thread, frameLevel);
if (banks == null) {
throw new IllegalArgumentException(
"Given thread and frame level does not have a live register bank");
return CompletableFuture.failedFuture(new IllegalArgumentException(
"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
AsyncFence fence = new AsyncFence();
Map<Register, RegisterValue> result = new HashMap<>();
for (TargetRegisterBank bank : banks) {
fence.include(bank.readRegisters(tRegs)
.thenApply(regMapper::targetToTrace)
.thenAccept(br -> {
synchronized (result) {
result.putAll(br);
}
}));
try {
fence.include(bank.readRegisters(tRegs)
.thenApply(regMapper::targetToTrace)
.thenAccept(br -> {
synchronized (result) {
result.putAll(br);
}
}));
}
catch (Exception e) {
fence.include(CompletableFuture.failedFuture(e));
}
}
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 says this is branch, but has a fallthru, then really isn't a fallthru
// 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;