1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 510833 - [lldb] IllegalStateException in LLDBProcesses$LLDBMIThreadDMData starting session

Re-arrange the code to prevent done() from being called twice.

Change-Id: I25737e9b6a7c188db62381695562046e326cacd0
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2018-09-01 02:05:51 -04:00 committed by Marc-André Laperle
parent b803d1030c
commit 55245c4252

View file

@ -103,32 +103,39 @@ public class LLDBProcesses extends GDBProcesses_7_4 {
@Override
public void getExecutionData(IThreadDMContext dmc, DataRequestMonitor<IThreadDMData> rm) {
if (dmc instanceof IMIProcessDMContext) {
String pidStr = ((IMIProcessDMContext) dmc).getProcId();
int pid = -1;
try {
pid = Integer.parseInt(pidStr);
} catch (NumberFormatException e) {
}
// It's possible that we get here without getRunningProcesses called
// yet so the process names map will be empty. This can happen when
// doing local debugging but not attach mode.
if (fProcessNames.isEmpty()) {
// FIXME: This triggers a double done()!! (Bug 510833)
getRunningProcesses(dmc, new DataRequestMonitor<>(getExecutor(), rm));
}
String name = fProcessNames.get(pid);
if (name == null) {
name = Messages.LLDBProcesses_unknown_process_name;
}
rm.setData(new LLDBMIThreadDMData(name, pidStr));
rm.done();
} else {
if (!(dmc instanceof IMIProcessDMContext)) {
super.getExecutionData(dmc, rm);
return;
}
String pidStr = ((IMIProcessDMContext) dmc).getProcId();
int pid = -1;
try {
pid = Integer.parseInt(pidStr);
} catch (NumberFormatException e) {
}
int pid2 = pid;
// It's possible that we get here without getRunningProcesses called
// yet so the process names map will be empty. This can happen when
// doing local debugging but not attach mode.
if (fProcessNames.isEmpty()) {
getRunningProcesses(dmc, new DataRequestMonitor<IProcessDMContext[]>(getExecutor(), rm) {
@Override
protected void handleSuccess() {
rm.setData(new LLDBMIThreadDMData(getProcessName(pid2), pidStr));
super.handleSuccess();
}
});
} else {
rm.setData(new LLDBMIThreadDMData(getProcessName(pid2), pidStr));
rm.done();
}
}
private String getProcessName(int pid) {
String name = fProcessNames.get(pid);
return name != null ? name : Messages.LLDBProcesses_unknown_process_name;
}
private static class LLDBMIThreadDMData implements IThreadDMData {