Merge remote-tracking branch 'origin/GP-0_Dan_testFixes-2024-09-06-1'

This commit is contained in:
Ryan Kurtz 2024-09-09 06:09:53 -04:00
commit d7c1f65f43
3 changed files with 50 additions and 16 deletions

View File

@ -188,6 +188,18 @@ public class TraceRmiHandler implements TraceRmiConnection {
.collect(Collectors.toUnmodifiableList()); .collect(Collectors.toUnmodifiableList());
} }
/**
* Call only for cleanup. Cannot be re-used after this
*
* @return the open traces that were removed
*/
public synchronized List<OpenTrace> clearAll() {
List<OpenTrace> all = List.copyOf(byId.values());
byId.clear();
byTrace.clear();
return all;
}
public CompletableFuture<OpenTrace> getFirstAsync() { public CompletableFuture<OpenTrace> getFirstAsync() {
return first; return first;
} }
@ -273,14 +285,15 @@ public class TraceRmiHandler implements TraceRmiConnection {
terminateTerminals(); terminateTerminals();
socket.close(); socket.close();
while (!openTxes.isEmpty()) { synchronized (openTxes) {
Tid nextKey = openTxes.keySet().iterator().next(); while (!openTxes.isEmpty()) {
OpenTx open = openTxes.remove(nextKey); Tid nextKey = openTxes.keySet().iterator().next();
open.tx.close(); OpenTx open = openTxes.remove(nextKey);
open.tx.close();
}
} }
while (!openTraces.isEmpty()) {
DoId nextKey = openTraces.idSet().iterator().next(); for (OpenTrace open : openTraces.clearAll()) {
OpenTrace open = openTraces.removeById(nextKey);
if (traceManager == null || traceManager.isSaveTracesByDefault()) { if (traceManager == null || traceManager.isSaveTracesByDefault()) {
try (CloseableTaskMonitor monitor = plugin.createMonitor()) { try (CloseableTaskMonitor monitor = plugin.createMonitor()) {
open.trace.save("Save on Disconnect", monitor); open.trace.save("Save on Disconnect", monitor);
@ -610,7 +623,10 @@ public class TraceRmiHandler implements TraceRmiConnection {
} }
protected Tid requireAvailableTid(Tid tid) { protected Tid requireAvailableTid(Tid tid) {
OpenTx tx = openTxes.get(tid); OpenTx tx;
synchronized (openTxes) {
tx = openTxes.get(tid);
}
if (tx != null) { if (tx != null) {
throw new TxIdInUseError(); throw new TxIdInUseError();
} }
@ -946,7 +962,10 @@ public class TraceRmiHandler implements TraceRmiConnection {
} }
protected ReplyEndTx handleEndTx(RequestEndTx req) { protected ReplyEndTx handleEndTx(RequestEndTx req) {
OpenTx tx = openTxes.remove(new Tid(new DoId(req.getOid()), req.getTxid().getId())); OpenTx tx;
synchronized (openTxes) {
tx = openTxes.remove(new Tid(new DoId(req.getOid()), req.getTxid().getId()));
}
if (tx == null) { if (tx == null) {
throw new InvalidTxIdError(req.getTxid().getId()); throw new InvalidTxIdError(req.getTxid().getId());
} }
@ -1159,7 +1178,9 @@ public class TraceRmiHandler implements TraceRmiConnection {
@SuppressWarnings("resource") @SuppressWarnings("resource")
OpenTx tx = OpenTx tx =
new OpenTx(tid, open.trace.openTransaction(req.getDescription()), req.getUndoable()); new OpenTx(tid, open.trace.openTransaction(req.getDescription()), req.getUndoable());
openTxes.put(tx.txId, tx); synchronized (openTxes) {
openTxes.put(tx.txId, tx);
}
return ReplyStartTx.getDefaultInstance(); return ReplyStartTx.getDefaultInstance();
} }

View File

@ -700,6 +700,11 @@ public abstract class AbstractDebuggerParameterDialog<P> extends DialogComponent
return; return;
} }
memorized.put(parameterNameAndType(parameter), value); memorized.put(parameterNameAndType(parameter), value);
PropertyEditor editor = paramEditors.get(parameter);
// Editors may not be populated yet
if (editor != null) {
setEditorValue(editor, parameter, value);
}
} }
public void forgetMemorizedArguments() { public void forgetMemorizedArguments() {

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -37,7 +37,8 @@ import ghidra.app.plugin.PluginCategoryNames;
import ghidra.app.plugin.core.debug.DebuggerPluginPackage; import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
import ghidra.app.plugin.core.debug.gui.DebuggerResources.DisconnectAllAction; import ghidra.app.plugin.core.debug.gui.DebuggerResources.DisconnectAllAction;
import ghidra.app.plugin.core.debug.service.model.launch.DebuggerProgramLaunchOpinion; import ghidra.app.plugin.core.debug.service.model.launch.DebuggerProgramLaunchOpinion;
import ghidra.app.services.*; import ghidra.app.services.DebuggerModelService;
import ghidra.app.services.DebuggerTraceManagerService;
import ghidra.app.services.DebuggerTraceManagerService.ActivationCause; import ghidra.app.services.DebuggerTraceManagerService.ActivationCause;
import ghidra.async.AsyncFence; import ghidra.async.AsyncFence;
import ghidra.dbg.*; import ghidra.dbg.*;
@ -380,10 +381,17 @@ public class DebuggerModelServicePlugin extends Plugin
protected void removeRecorder(TraceRecorder recorder) { protected void removeRecorder(TraceRecorder recorder) {
synchronized (recordersByTarget) { synchronized (recordersByTarget) {
TraceRecorder old = recordersByTarget.remove(recorder.getTarget()); TraceRecorder old = recordersByTarget.remove(recorder.getTarget());
if (old != recorder) { /**
throw new AssertionError("Container-recorder mix up"); * Possible race condition when quickly launching and stopping a recording. If it's
* already removed, that's actually fine. If we get something non-null that doesn't
* match, then yeah, something's truly gone wrong.
*/
if (old != null) {
if (old != recorder) {
throw new AssertionError("Container-recorder mix up");
}
old.removeListener(listenerOnRecorders);
} }
old.removeListener(listenerOnRecorders);
} }
recorderListeners.invoke().elementRemoved(recorder); recorderListeners.invoke().elementRemoved(recorder);
} }