From 6e27a9faa260cdc8ea2292a710effad678356830 Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:51:07 +0000 Subject: [PATCH 1/3] GP-5799: Improve example InstallCustomLibraryScript and fix NPE. --- .../ghidra_scripts/InstallCustomLibraryScript.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/GhidraDocs/GhidraClass/Debugger/ghidra_scripts/InstallCustomLibraryScript.java b/GhidraDocs/GhidraClass/Debugger/ghidra_scripts/InstallCustomLibraryScript.java index 8039dc61b1..1554d2b57e 100644 --- a/GhidraDocs/GhidraClass/Debugger/ghidra_scripts/InstallCustomLibraryScript.java +++ b/GhidraDocs/GhidraClass/Debugger/ghidra_scripts/InstallCustomLibraryScript.java @@ -4,17 +4,17 @@ * 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. * See the License for the specific language governing permissions and * limitations under the License. */ -import ghidra.app.plugin.core.debug.service.emulation.*; -import ghidra.app.plugin.processors.sleigh.SleighLanguage; +import ghidra.app.plugin.core.debug.service.emulation.BytesDebuggerPcodeEmulator; +import ghidra.app.plugin.core.debug.service.emulation.BytesDebuggerPcodeEmulatorFactory; import ghidra.app.script.GhidraScript; import ghidra.debug.api.emulation.DebuggerPcodeMachine; import ghidra.debug.api.emulation.PcodeDebuggerAccess; @@ -30,8 +30,7 @@ public class InstallCustomLibraryScript extends GhidraScript implements FlatDebu @Override protected PcodeUseropLibrary createUseropLibrary() { return super.createUseropLibrary() - .compose(new ModelingScript.SleighStdLibPcodeUseropLibrary<>( - (SleighLanguage) access.getLanguage())); + .compose(new ModelingScript.SleighStdLibPcodeUseropLibrary<>(getLanguage())); } } From 044bd03ccb847e2ab0bc1fd3f48733f0a4f3f8be Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:57:15 +0000 Subject: [PATCH 2/3] GP-5790: Fix NPE on "Select Current Module" when cursor is not in a module. --- .../core/debug/gui/modules/DebuggerModulesProvider.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java index 8940f79a9f..1481bca4ed 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/modules/DebuggerModulesProvider.java @@ -1113,6 +1113,10 @@ public class DebuggerModulesProvider extends ComponentProviderAdapter } bestModule = module; } + if (bestModule == null) { + setSelectedModules(Set.of()); + return; + } if (bestModule.getSections(snap).isEmpty()) { setSelectedModules(Set.of(bestModule)); return; 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 3/3] 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;