Ghidra is a software reverse engineering (SRE) framework
GP-6340: Use view when deciding what emu needs to read from target.
Dan0d33fa39242b
diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationIntegration.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationIntegration.javaindex ecc2da1d92..a38f9d098e 100644--- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationIntegration.java+++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationIntegration.java@@ -132,7 +132,7 @@ public enum DebuggerEmulationIntegration {@Overridepublic AddressSetView readUninitialized(PcodeTraceDataAccess acc, PcodeThread<?> thread,PcodeExecutorStatePiece<byte[], byte[]> piece, AddressSetView set) {- AddressSetView unknown = acc.intersectUnknown(set);+ AddressSetView unknown = set.subtract(acc.intersectViewKnown(set, false));if (unknown.isEmpty()) {return super.readUninitialized(acc, thread, piece, set);}@@ -148,7 +148,7 @@ public enum DebuggerEmulationIntegration {}if (acc instanceof PcodeDebuggerMemoryAccess memAcc) {if (memAcc.isLive() && waitTimeout(memAcc.readFromTargetMemory(unknown))) {- unknown = memAcc.intersectUnknown(set);+ unknown = set.subtract(memAcc.intersectViewKnown(set, false));if (unknown.isEmpty()) {return super.readUninitialized(acc, thread, piece, set);}diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/AbstractPcodeTraceDataAccess.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/AbstractPcodeTraceDataAccess.javaindex 0bf9ec3fed..a0cb53020a 100644--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/AbstractPcodeTraceDataAccess.java+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/AbstractPcodeTraceDataAccess.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -162,20 +162,6 @@ public abstract class AbstractPcodeTraceDataAccess implements InternalPcodeTracereturn platform.mapHostToGuest(hostResult);}- @Override- public AddressSetView intersectUnknown(AddressSetView guestView) {- TraceMemoryOperations ops = getMemoryOps(false);- if (ops == null) {- return guestView;- }-- AddressSetView hostView = toOverlay(platform.mapGuestToHost(guestView));- AddressSetView hostKnown = ops.getAddressesWithState(snap, hostView,- s -> s != null && s != TraceMemoryState.UNKNOWN);- AddressSetView hostResult = TraceRegisterUtils.getPhysicalSet(hostView.subtract(hostKnown));- return platform.mapHostToGuest(hostResult);- }-@Overridepublic int putBytes(Address start, ByteBuffer buf) {// TODO: Truncate or verify range?diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/DefaultPcodeTraceThreadAccess.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/DefaultPcodeTraceThreadAccess.javaindex d6eaf8bb51..19f3b1bb6b 100644--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/DefaultPcodeTraceThreadAccess.java+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/DefaultPcodeTraceThreadAccess.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -76,11 +76,6 @@ public class DefaultPcodeTraceThreadAccess.union(registers.intersectViewKnown(view, useFullSpans));}- @Override- public AddressSetView intersectUnknown(AddressSetView view) {- return memory.intersectUnknown(view).union(registers.intersectUnknown(view));- }-@Overridepublic int putBytes(Address start, ByteBuffer buf) {if (start.isRegisterAddress()) {diff --git a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/PcodeTraceDataAccess.java b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/PcodeTraceDataAccess.javaindex 3d4e6d66f4..4f19953595 100644--- a/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/PcodeTraceDataAccess.java+++ b/Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/pcode/exec/trace/data/PcodeTraceDataAccess.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -73,15 +73,6 @@ public interface PcodeTraceDataAccess {*/AddressSetView intersectViewKnown(AddressSetView view, boolean useFullSpans);- /**- * Compute the intersection of the given address set and the set of- * {@link TraceMemoryState#UNKNOWN} memory- *- * @param view the address set- * @return the intersection- */- AddressSetView intersectUnknown(AddressSetView view);-/*** Write bytes into the trace*