diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetModuleContainerImpl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetModuleContainerImpl.java index 0ef65f415f..b211bd07c5 100644 --- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetModuleContainerImpl.java +++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetModuleContainerImpl.java @@ -75,11 +75,7 @@ public class DbgModelTargetModuleContainerImpl extends DbgModelTargetObjectImpl //modulesByName.remove(name); module = getTargetModule(name); } - TargetThread eventThread = - (TargetThread) getModel().getModelObject(getManager().getEventThread()); changeElements(List.of(), List.of(module), Map.of(), "Loaded"); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_LOADED, - "Library " + name + " loaded", List.of(module)); } @Override @@ -87,10 +83,6 @@ public class DbgModelTargetModuleContainerImpl extends DbgModelTargetObjectImpl public void libraryUnloaded(String name) { DbgModelTargetModule targetModule = getTargetModule(name); if (targetModule != null) { - TargetThread eventThread = - (TargetThread) getModel().getModelObject(getManager().getEventThread()); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_UNLOADED, - "Library " + name + " unloaded", List.of(targetModule)); DbgModelImpl impl = (DbgModelImpl) model; impl.deleteModelObject(targetModule.getDbgModule()); } diff --git a/Ghidra/Debug/Debugger-agent-dbgmodel/src/main/java/agent/dbgmodel/model/impl/DbgModel2TargetRootImpl.java b/Ghidra/Debug/Debugger-agent-dbgmodel/src/main/java/agent/dbgmodel/model/impl/DbgModel2TargetRootImpl.java index 71d7bbc43e..6501ded7d6 100644 --- a/Ghidra/Debug/Debugger-agent-dbgmodel/src/main/java/agent/dbgmodel/model/impl/DbgModel2TargetRootImpl.java +++ b/Ghidra/Debug/Debugger-agent-dbgmodel/src/main/java/agent/dbgmodel/model/impl/DbgModel2TargetRootImpl.java @@ -181,9 +181,8 @@ public class DbgModel2TargetRootImpl extends DbgModel2DefaultTargetModelRoot public void objectSelected(Object object) { List objPath = findObject(object); - model.fetchModelObject(objPath, RefreshBehavior.REFRESH_WHEN_ABSENT).thenAccept(obj -> - update(obj) - ); + model.fetchModelObject(objPath, RefreshBehavior.REFRESH_WHEN_ABSENT) + .thenAccept(obj -> update(obj)); } @Override @@ -241,11 +240,6 @@ public class DbgModel2TargetRootImpl extends DbgModel2DefaultTargetModelRoot if (mod == null) { return; } - getObject(getManager().getEventThread()).thenAccept(t -> { - TargetThread eventThread = (TargetThread) t; - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_LOADED, - "Library " + info.getModuleName() + " loaded", List.of(mod)); - }); getObject(getManager().getEventProcess()).thenAccept(p -> { DbgModelTargetProcess eventProcess = (DbgModelTargetProcess) p; DbgModel2TargetObjectImpl memory = @@ -262,11 +256,6 @@ public class DbgModel2TargetRootImpl extends DbgModel2DefaultTargetModelRoot if (mod == null) { return; } - getObject(getManager().getEventThread()).thenAccept(t -> { - TargetThread eventThread = (TargetThread) t; - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_UNLOADED, - "Library " + info.getModuleName() + " unloaded", List.of(mod)); - }); getObject(getManager().getEventProcess()).thenAccept(p -> { DbgModelTargetProcess eventProcess = (DbgModelTargetProcess) p; DbgModel2TargetObjectImpl memory = @@ -604,7 +593,7 @@ public class DbgModel2TargetRootImpl extends DbgModel2DefaultTargetModelRoot stateful.fetchAttributes(RefreshBehavior.REFRESH_ALWAYS); } } - + private TargetEventType getEventType(DbgState state, DbgCause cause, DbgReason reason) { switch (state) { case RUNNING: diff --git a/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetKernelModuleContainerImpl.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetKernelModuleContainerImpl.java index 876d225ac0..feebbad837 100644 --- a/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetKernelModuleContainerImpl.java +++ b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetKernelModuleContainerImpl.java @@ -69,12 +69,7 @@ public class FridaModelTargetKernelModuleContainerImpl extends FridaModelTargetO Msg.error(this, "Module " + info.getModuleName(index) + " not found!"); return; } - FridaThread thread = getManager().getCurrentThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); changeElements(List.of(), List.of(targetModule), Map.of(), "Loaded"); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_LOADED, - "Library " + info.getModuleName(index) + " loaded", List.of(targetModule)); } @Override @@ -91,11 +86,6 @@ public class FridaModelTargetKernelModuleContainerImpl extends FridaModelTargetO FridaCause cause) { FridaModelTargetModule targetModule = getTargetModule(info.getModule(index)); if (targetModule != null) { - FridaThread thread = getManager().getCurrentThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_UNLOADED, - "Library " + info.getModuleName(index) + " unloaded", List.of(targetModule)); FridaModelImpl impl = (FridaModelImpl) model; impl.deleteModelObject(targetModule.getModule()); } diff --git a/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetModuleContainerImpl.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetModuleContainerImpl.java index 4e4a0131a2..134f4d3430 100644 --- a/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetModuleContainerImpl.java +++ b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/impl/FridaModelTargetModuleContainerImpl.java @@ -87,12 +87,7 @@ public class FridaModelTargetModuleContainerImpl extends FridaModelTargetObjectI Msg.error(this, "Module " + info.getModuleName(index) + " not found!"); return; } - FridaThread thread = getManager().getCurrentThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); changeElements(List.of(), List.of(targetModule), Map.of(), "Loaded"); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_LOADED, - "Library " + info.getModuleName(index) + " loaded", List.of(targetModule)); } @Override @@ -109,11 +104,6 @@ public class FridaModelTargetModuleContainerImpl extends FridaModelTargetObjectI FridaCause cause) { FridaModelTargetModule targetModule = getTargetModule(info.getModule(index)); if (targetModule != null) { - FridaThread thread = getManager().getCurrentThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_UNLOADED, - "Library " + info.getModuleName(index) + " unloaded", List.of(targetModule)); FridaModelImpl impl = (FridaModelImpl) model; impl.deleteModelObject(targetModule.getModule()); } diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetInferiorContainer.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetInferiorContainer.java index 7a726c2901..d6bf7f2231 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetInferiorContainer.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetInferiorContainer.java @@ -107,17 +107,12 @@ public class GdbModelTargetInferiorContainer @Override public void libraryLoaded(GdbInferior inf, String name, GdbCause cause) { GdbModelTargetInferior inferior = getTargetInferior(inf); - GdbModelTargetModule module = inferior.modules.libraryLoaded(name); - broadcast().event(parent, null, TargetEventType.MODULE_LOADED, - "Library " + name + " loaded", List.of(module)); + inferior.modules.libraryLoaded(name); } @Override public void libraryUnloaded(GdbInferior inf, String name, GdbCause cause) { GdbModelTargetInferior inferior = getTargetInferior(inf); - GdbModelTargetModule module = inferior.modules.getTargetModuleIfPresent(name); - broadcast().event(parent, null, TargetEventType.MODULE_UNLOADED, - "Library " + name + " unloaded", List.of(module)); inferior.modules.libraryUnloaded(name); } diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetModuleContainer.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetModuleContainer.java index 3ea6490b0b..a438729a6a 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetModuleContainer.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetModuleContainer.java @@ -53,7 +53,11 @@ public class GdbModelTargetModuleContainer @Internal public GdbModelTargetModule libraryLoaded(String name) { - GdbModule mod = Objects.requireNonNull(inferior.getKnownModules().get(name)); + GdbModule mod = inferior.getKnownModules().get(name); + if (mod == null) { + // We'll catch it the next time around. + return null; + } GdbModelTargetModule module = getTargetModule(mod); changeElements(List.of(), List.of(module), "Loaded"); return module; diff --git a/Ghidra/Debug/Debugger-agent-lldb/src/main/java/agent/lldb/model/impl/LldbModelTargetModuleContainerImpl.java b/Ghidra/Debug/Debugger-agent-lldb/src/main/java/agent/lldb/model/impl/LldbModelTargetModuleContainerImpl.java index ca25ceebbd..93daeb3df0 100644 --- a/Ghidra/Debug/Debugger-agent-lldb/src/main/java/agent/lldb/model/impl/LldbModelTargetModuleContainerImpl.java +++ b/Ghidra/Debug/Debugger-agent-lldb/src/main/java/agent/lldb/model/impl/LldbModelTargetModuleContainerImpl.java @@ -69,12 +69,7 @@ public class LldbModelTargetModuleContainerImpl extends LldbModelTargetObjectImp System.err.println("Module " + info.getModuleName(index) + " not found!"); return; } - SBThread thread = getManager().getEventThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); changeElements(List.of(), List.of(targetModule), Map.of(), "Loaded"); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_LOADED, - "Library " + info.getModuleName(index) + " loaded", List.of(targetModule)); } @Override @@ -82,11 +77,6 @@ public class LldbModelTargetModuleContainerImpl extends LldbModelTargetObjectImp public void libraryUnloaded(DebugModuleInfo info, int index) { LldbModelTargetModule targetModule = getTargetModule(info.getModule(index)); if (targetModule != null) { - SBThread thread = getManager().getEventThread(); - TargetThread eventThread = - (TargetThread) getModel().getModelObject(thread); - broadcast().event(getProxy(), eventThread, TargetEventType.MODULE_UNLOADED, - "Library " + info.getModuleName(index) + " unloaded", List.of(targetModule)); LldbModelImpl impl = (LldbModelImpl) model; impl.deleteModelObject(targetModule.getModule()); } diff --git a/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/client/GadpValueUtils.java b/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/client/GadpValueUtils.java index 5a5001f759..22711e823e 100644 --- a/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/client/GadpValueUtils.java +++ b/Ghidra/Debug/Debugger-gadp/src/main/java/ghidra/dbg/gadp/client/GadpValueUtils.java @@ -234,10 +234,6 @@ public enum GadpValueUtils { return TargetEventType.THREAD_CREATED; case EV_THREAD_EXITED: return TargetEventType.THREAD_EXITED; - case EV_MODULE_LOADED: - return TargetEventType.MODULE_LOADED; - case EV_MODULE_UNLOADED: - return TargetEventType.MODULE_UNLOADED; case EV_BREAKPOINT_HIT: return TargetEventType.BREAKPOINT_HIT; case EV_STEP_COMPLETED: @@ -264,10 +260,6 @@ public enum GadpValueUtils { return Gadp.TargetEventType.EV_THREAD_CREATED; case THREAD_EXITED: return Gadp.TargetEventType.EV_THREAD_EXITED; - case MODULE_LOADED: - return Gadp.TargetEventType.EV_MODULE_LOADED; - case MODULE_UNLOADED: - return Gadp.TargetEventType.EV_MODULE_UNLOADED; case BREAKPOINT_HIT: return Gadp.TargetEventType.EV_BREAKPOINT_HIT; case STEP_COMPLETED: diff --git a/Ghidra/Debug/Debugger-gadp/src/main/proto/gadp.proto b/Ghidra/Debug/Debugger-gadp/src/main/proto/gadp.proto index 920ec60e1d..f6d4b0f03c 100644 --- a/Ghidra/Debug/Debugger-gadp/src/main/proto/gadp.proto +++ b/Ghidra/Debug/Debugger-gadp/src/main/proto/gadp.proto @@ -484,8 +484,6 @@ enum TargetEventType { EV_PROCESS_EXITED = 3; EV_THREAD_CREATED = 4; EV_THREAD_EXITED = 5; - EV_MODULE_LOADED = 6; - EV_MODULE_UNLOADED = 7; EV_BREAKPOINT_HIT = 8; EV_STEP_COMPLETED = 9; EV_EXCEPTION = 10; diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceEventListener.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceEventListener.java index eed3417735..26ccfc8ac5 100644 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceEventListener.java +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/model/TraceEventListener.java @@ -34,11 +34,9 @@ import ghidra.program.model.address.*; import ghidra.trace.model.Trace; import ghidra.trace.model.memory.TraceMemoryManager; import ghidra.trace.model.memory.TraceMemoryState; -import ghidra.trace.model.modules.TraceModule; import ghidra.util.Msg; import ghidra.util.TimedMsg; import ghidra.util.datastruct.PrivatelyQueuedListener; -import ghidra.util.exception.DuplicateNameException; public class TraceEventListener extends AnnotatedDebuggerAttributeListener { @@ -143,28 +141,6 @@ public class TraceEventListener extends AnnotatedDebuggerAttributeListener { ManagedThreadRecorder rec = recorder.getThreadRecorder(eventThread); recorder.createSnapshot(description, rec == null ? null : rec.getTraceThread(), null); ignoreInvalidation = false; - - if (type == TargetEventType.MODULE_LOADED) { - long snap = recorder.getSnap(); - Object p0 = parameters.get(0); - if (!(p0 instanceof TargetModule)) { - return; - } - TargetModule mod = (TargetModule) p0; - String modPath = mod.getJoinedPath("."); - recorder.parTx.execute("Adjust module load: " + modPath, () -> { - TraceModule traceModule = recorder.getTraceModule(mod); - if (traceModule == null) { - return; - } - try { - traceModule.setLoadedSnap(snap); - } - catch (DuplicateNameException e) { - Msg.error(this, "Could not set module loaded snap", e); - } - }, modPath); - } } @AttributeCallback(TargetExecutionStateful.STATE_ATTRIBUTE_NAME) diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetEventScope.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetEventScope.java index f930a2a6c1..a599a5599b 100644 --- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetEventScope.java +++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/target/TargetEventScope.java @@ -64,17 +64,6 @@ public interface TargetEventScope extends TargetObject { * A target thread in this session has exited */ THREAD_EXITED(false), - /** - * A new module has been loaded by this session - * - *

- * The new module must be passed as a parameter. - */ - MODULE_LOADED(false), - /** - * A module has been unloaded by this session - */ - MODULE_UNLOADED(false), /** * The session has stopped, because one if its targets was trapped by a breakpoint * diff --git a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/EventValidator.java b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/EventValidator.java index 33d3559173..423151359f 100644 --- a/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/EventValidator.java +++ b/Ghidra/Debug/Framework-Debugging/src/test/java/ghidra/dbg/testutil/EventValidator.java @@ -203,12 +203,6 @@ public class EventValidator case THREAD_EXITED: validateDestroyed(type.name(), TargetThread.class, threads, parameters); break; - case MODULE_LOADED: - validateCreated(type.name(), TargetModule.class, modules, parameters); - break; - case MODULE_UNLOADED: - validateDestroyed(type.name(), TargetModule.class, modules, parameters); - break; case STOPPED: case RUNNING: case BREAKPOINT_HIT: