From f74b783b3e2b01bc45984ed50b24d39616bd3806 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 1 Jul 2025 18:15:47 +0000 Subject: [PATCH] GP-5796: Write event thread down in emulated snapshots. --- .../ghidra/app/plugin/core/debug/gui/time/SnapshotRow.java | 2 +- .../service/emulation/DebuggerEmulationServicePlugin.java | 2 ++ .../core/debug/service/emulation/ProgramEmulationUtils.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/time/SnapshotRow.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/time/SnapshotRow.java index 87c389db13..7525014d7f 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/time/SnapshotRow.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/time/SnapshotRow.java @@ -182,7 +182,7 @@ public class SnapshotRow { if (thread != null) { return thread; } - return getTime().getEventThread(trace); + return getTime().getLastThread(trace); } public String getEventThreadName() { diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServicePlugin.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServicePlugin.java index 400a3d163b..4ffab140c4 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServicePlugin.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/DebuggerEmulationServicePlugin.java @@ -736,6 +736,8 @@ public class DebuggerEmulationServicePlugin extends Plugin implements DebuggerEm destSnap.setDescription("Emulated"); try { ce.emulator().writeDown(key.platform, destSnap.getKey(), key.time.getSnap()); + TraceThread lastThread = key.time.getLastThread(key.trace); + destSnap.setEventThread(lastThread); } catch (Throwable e) { Msg.showError(this, null, "Emulate", diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/ProgramEmulationUtils.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/ProgramEmulationUtils.java index 226873b399..07e7e7f5aa 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/ProgramEmulationUtils.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/emulation/ProgramEmulationUtils.java @@ -645,7 +645,8 @@ public class ProgramEmulationUtils { pc.getAddressSpace().isOverlaySpace() ? List.of(pc.getAddressSpace()) : List.of(); loadExecutable(initial, program, overlays); - doLaunchEmulationThread(trace, snap, program, pc, pc); + TraceThread thread = doLaunchEmulationThread(trace, snap, program, pc, pc); + initial.setEventThread(thread); } trace.clearUndo(); success = true;