From 5c316929b82c7f5bf4f77e762ed151e49c976f07 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:04:14 -0500 Subject: [PATCH 1/2] GP-4305: Return failed futures instead of throwing. --- .../service/model/DefaultThreadRecorder.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/DefaultThreadRecorder.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/DefaultThreadRecorder.java index 45f6d234e6..eba86126e5 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/DefaultThreadRecorder.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/DefaultThreadRecorder.java @@ -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> captureThreadRegisters( TraceThread thread, int frameLevel, Set 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 tRegs = registers.stream() .map(regMapper::traceToTarget) @@ -180,20 +181,25 @@ public class DefaultThreadRecorder implements ManagedThreadRecorder { Set 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 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); } From 1da47a720561c47859f8c0287427847c9401221b Mon Sep 17 00:00:00 2001 From: emteere <47253321+emteere@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:21:35 +0000 Subject: [PATCH 2/2] GP-4312 fixed lockup on instruction fallthru override to self --- .../main/java/ghidra/program/util/SymbolicPropogator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/util/SymbolicPropogator.java b/Ghidra/Features/Base/src/main/java/ghidra/program/util/SymbolicPropogator.java index 52404311c1..3d2c17248a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/program/util/SymbolicPropogator.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/program/util/SymbolicPropogator.java @@ -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;