diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java index 9d3f813b92c..1e19d6f476a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_0.java @@ -797,13 +797,24 @@ public class GDBProcesses_7_0 extends AbstractDsfService } // END OF WORKAROUND to be removed when GDB 7.2 is available - IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[groups.length]; - for (int i = 0; i < groups.length; i++) { - String groupId = groups[i].getGroupId(); + // With GDB 7.1, we can receive a bogus process when we are not debugging anything + // -list-thread-groups + // ^done,groups=[{id="0",type="process",pid="0"}] + // As for GDB 7.2, the pid field is missing altogether in this case + // -list-thread-groups + // ^done,groups=[{id="i1",type="process"}] + // Just ignore that entry + List containerDmcs = new ArrayList(groups.length); + for (IThreadGroupInfo group : groups) { + if (group.getPid() == null || + group.getPid().equals("") || group.getPid().equals("0")) { //$NON-NLS-1$ //$NON-NLS-2$ + continue; + } + String groupId = group.getGroupId(); IProcessDMContext procDmc = createProcessContext(controlDmc, groupId); - containerDmcs[i] = createContainerContext(procDmc, groupId); + containerDmcs.add(createContainerContext(procDmc, groupId)); } - return containerDmcs; + return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]); } public void getRunningProcesses(final IDMContext dmc, final DataRequestMonitor rm) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java index 7bad1d93943..59a029d2db1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java @@ -318,8 +318,12 @@ public class MIListThreadGroupsInfo extends MIInfo { } } } - // In the case of -list-thread-groups --available, we can use the id as the pid - if (pid.equals("")) { //$NON-NLS-1$ + // In the case of -list-thread-groups --available, the pid field is not present, but the + // pid is used as the main id. To know we are in this case, we check that we have + // a description, that only happens for -list-thread-groups --available + // We must check this because with GDB 7.2, there will be no pid field as a result + // of -list-thread-groups, if no process is actually running yet. + if (pid.equals("") && !desc.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ pid = id; } fGroupList[i] = new ThreadGroupInfo(id, desc, type, pid, user, cores, exec);