mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-27 21:10:26 +00:00
GP-0: Fix async invocation of model's listeners.
This commit is contained in:
parent
3f6c5ca189
commit
da0aeefa4f
|
@ -110,7 +110,7 @@ public class DbgModelImpl extends AbstractDbgModel implements DebuggerObjectMode
|
|||
|
||||
@Override
|
||||
public void terminate() throws IOException {
|
||||
listeners.invoke().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
broadcast().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
root.invalidateSubtree(root, "Dbgeng is terminating");
|
||||
dbg.terminate();
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class DbgModel2Impl extends AbstractDbgModel
|
|||
|
||||
@Override
|
||||
public void terminate() throws IOException {
|
||||
listeners.invoke().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
broadcast().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
root.invalidateSubtree(root, "Dbgmodel is terminating");
|
||||
dbg.terminate();
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class FridaModelImpl extends AbstractFridaModel implements DebuggerObject
|
|||
|
||||
@Override
|
||||
public void terminate() throws IOException {
|
||||
listeners.invoke().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
broadcast().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
root.invalidateSubtree(root, "Frida is terminating");
|
||||
manager.terminate();
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ public class GdbModelImpl extends AbstractDebuggerObjectModel {
|
|||
}
|
||||
|
||||
public void terminate() throws IOException {
|
||||
listeners.invoke().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
broadcast().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
session.invalidateSubtree(session, "GDB is terminating");
|
||||
gdb.terminate();
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public class LldbModelImpl extends AbstractLldbModel implements DebuggerObjectMo
|
|||
|
||||
@Override
|
||||
public void terminate() throws IOException {
|
||||
listeners.invoke().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
broadcast().modelClosed(DebuggerModelClosedReason.NORMAL);
|
||||
root.invalidateSubtree(root, "LLDB is terminating");
|
||||
manager.terminate();
|
||||
}
|
||||
|
|
|
@ -323,10 +323,10 @@ public class GadpClient extends AbstractDebuggerObjectModel
|
|||
protected void channelStateChanged(ChannelState old, ChannelState set,
|
||||
DebuggerModelClosedReason reason) {
|
||||
if (old == ChannelState.NEGOTIATING && set == ChannelState.ACTIVE) {
|
||||
listeners.invoke().modelOpened();
|
||||
broadcast().modelOpened();
|
||||
}
|
||||
else if (old == ChannelState.ACTIVE && set == ChannelState.CLOSED) {
|
||||
listeners.invoke().modelClosed(reason);
|
||||
broadcast().modelClosed(reason);
|
||||
root.invalidateSubtree(root, "GADP Client disconnected");
|
||||
messageMatcher.flush(new DebuggerModelTerminatingException("GADP Client disconnected"));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import ghidra.dbg.target.TargetObject;
|
|||
import ghidra.dbg.util.PathUtils;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.datastruct.ListenerSet;
|
||||
import ghidra.util.datastruct.PrivatelyQueuedListener;
|
||||
|
||||
public abstract class AbstractDebuggerObjectModel implements SpiDebuggerObjectModel {
|
||||
public final Object lock = new Object();
|
||||
|
@ -39,6 +40,10 @@ public abstract class AbstractDebuggerObjectModel implements SpiDebuggerObjectMo
|
|||
protected final ListenerSet<DebuggerModelListener> listeners =
|
||||
new ListenerSet<>(DebuggerModelListener.class, true);
|
||||
|
||||
protected final PrivatelyQueuedListener<DebuggerModelListener> asyncListeners =
|
||||
new PrivatelyQueuedListener<DebuggerModelListener>(DebuggerModelListener.class,
|
||||
clientExecutor, listeners.invoke());
|
||||
|
||||
protected SpiTargetObject root;
|
||||
protected boolean rootAdded;
|
||||
protected boolean cbRootAdded;
|
||||
|
@ -99,9 +104,8 @@ public abstract class AbstractDebuggerObjectModel implements SpiDebuggerObjectMo
|
|||
});
|
||||
this.completedRoot.completeAsync(() -> root, clientExecutor);
|
||||
|
||||
clientExecutor.execute(() -> {
|
||||
listeners.invoke().rootAdded(root);
|
||||
});
|
||||
// broadcast is privately queued on clientExecutor
|
||||
broadcast().rootAdded(root);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +205,10 @@ public abstract class AbstractDebuggerObjectModel implements SpiDebuggerObjectMo
|
|||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
protected DebuggerModelListener broadcast() {
|
||||
return asyncListeners.in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that dependent computations occur on the client executor
|
||||
*
|
||||
|
|
|
@ -304,6 +304,6 @@ public abstract class AbstractTargetObject<P extends TargetObject> implements Sp
|
|||
|
||||
@Override
|
||||
public DebuggerModelListener broadcast() {
|
||||
return model.listeners.invoke();
|
||||
return model.broadcast();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,6 +263,6 @@ public class TestDebuggerObjectModel extends EmptyDebuggerObjectModel {
|
|||
}
|
||||
|
||||
public DebuggerModelListener fire() {
|
||||
return listeners.invoke();
|
||||
return broadcast();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue