Merge remote-tracking branch 'origin/GP-4905_Dan_fixCloseAll' into Ghidra_11.2

This commit is contained in:
Ryan Kurtz 2024-09-09 15:07:16 -04:00
commit 1a1ea00a48
2 changed files with 21 additions and 7 deletions

View File

@ -197,6 +197,9 @@ public class TraceRmiHandler implements TraceRmiConnection {
List<OpenTrace> all = List.copyOf(byId.values());
byId.clear();
byTrace.clear();
for (OpenTrace open : all) {
plugin.withdrawTarget(open.target);
}
return all;
}

View File

@ -48,6 +48,11 @@ import ghidra.debug.api.tracermi.TraceRmiConnection;
import ghidra.util.exception.CancelledException;
public class TraceRmiConnectionManagerProviderTest extends AbstractGhidraHeadedDebuggerTest {
private static final String SCHEMA_XML = """
<context>
<schema name="Root" elementResync="NEVER" attributeResync="NEVER" />
</context>
""";
TraceRmiConnectionManagerProvider provider;
TraceRmiService traceRmiService;
DebuggerControlService controlService;
@ -178,6 +183,17 @@ public class TraceRmiConnectionManagerProviderTest extends AbstractGhidraHeadedD
}
}
@Test
public void testCloseWithdrawsTargets() throws Exception {
Target target;
try (Cx cx = Cx.connect(traceRmiService, "Test client")) {
cx.client.createTrace(0, "bash");
target = waitForPass(() -> Unique.assertOne(targetService.getPublishedTargets()));
}
// Outside the try, the connection has been closed
waitForPass(() -> assertFalse(targetService.getPublishedTargets().contains(target)));
}
@Test
public void testServerNode() throws Exception {
TraceRmiServerNode node = TraceRmiConnectionTreeHelper.getServerNode(provider.rootNode);
@ -213,8 +229,7 @@ public class TraceRmiConnectionManagerProviderTest extends AbstractGhidraHeadedD
}
public record Cx(SocketChannel channel, TestTraceRmiClient client,
TraceRmiConnection connection)
implements AutoCloseable {
TraceRmiConnection connection) implements AutoCloseable {
public static Cx complete(TraceRmiAcceptor acceptor, String description)
throws IOException, CancelledException {
SocketChannel channel = null;
@ -378,11 +393,7 @@ public class TraceRmiConnectionManagerProviderTest extends AbstractGhidraHeadedD
@Test
public void testActivateTargetNode() throws Exception {
SchemaContext ctx = XmlSchemaContext.deserialize("""
<context>
<schema name="Root" elementResync="NEVER" attributeResync="NEVER" />
</context>
""");
SchemaContext ctx = XmlSchemaContext.deserialize(SCHEMA_XML);
try (Cx cx = Cx.connect(traceRmiService, "Test client")) {
cx.client.createTrace(1, "bash");
try (Tx tx = cx.client.new Tx(1, 1, "Create snapshots")) {