|
Lines 392-397
Link Here
|
| 392 |
* A map of thread id to thread group id. We use this to find out to which threadGroup a thread belongs. |
392 |
* A map of thread id to thread group id. We use this to find out to which threadGroup a thread belongs. |
| 393 |
*/ |
393 |
*/ |
| 394 |
private Map<String, String> fThreadToGroupMap = new HashMap<String, String>(); |
394 |
private Map<String, String> fThreadToGroupMap = new HashMap<String, String>(); |
|
|
395 |
/** |
| 396 |
* A map of thread group id to process id. We use this to find out to which pid a group refers. |
| 397 |
*/ |
| 398 |
private Map<String, String> fGroupToPidMap = new HashMap<String, String>(); |
| 395 |
|
399 |
|
| 396 |
private IGDBControl fCommandControl; |
400 |
private IGDBControl fCommandControl; |
| 397 |
private IGDBBackend fBackend; |
401 |
private IGDBBackend fBackend; |
|
Lines 549-558
Link Here
|
| 549 |
} |
553 |
} |
| 550 |
} |
554 |
} |
| 551 |
} |
555 |
} |
| 552 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
556 |
|
| 553 |
return createContainerContext(processDmc, groupId); |
557 |
return createContainerContextFromGroupId(controlDmc, groupId); |
| 554 |
} |
558 |
} |
| 555 |
|
559 |
|
|
|
560 |
/** @since 4.0 */ |
| 561 |
public IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) { |
| 562 |
String pid = fGroupToPidMap.get(groupId); |
| 563 |
if (pid == null) { |
| 564 |
pid = groupId; |
| 565 |
} |
| 566 |
IProcessDMContext processDmc = createProcessContext(controlDmc, pid); |
| 567 |
return createContainerContext(processDmc, groupId); |
| 568 |
} |
| 569 |
|
| 556 |
public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) { |
570 |
public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) { |
| 557 |
String groupId = containerDmc.getGroupId(); |
571 |
String groupId = containerDmc.getGroupId(); |
| 558 |
List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); |
572 |
List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); |
|
Lines 765-775
Link Here
|
| 765 |
@Override |
779 |
@Override |
| 766 |
protected void handleFailure() { |
780 |
protected void handleFailure() { |
| 767 |
// If the target is not available, generate the list ourselves |
781 |
// If the target is not available, generate the list ourselves |
| 768 |
IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fDebuggedProcessesAndNames.size()]; |
782 |
IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fGroupToPidMap.size()]; |
| 769 |
int i = 0; |
783 |
int i = 0; |
| 770 |
for (String groupId : fDebuggedProcessesAndNames.keySet()) { |
784 |
for (String groupId : fGroupToPidMap.keySet()) { |
| 771 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
785 |
containerDmcs[i++] = createContainerContextFromGroupId(controlDmc, groupId); |
| 772 |
containerDmcs[i++] = createContainerContext(processDmc, groupId); |
|
|
| 773 |
} |
786 |
} |
| 774 |
rm.setData(containerDmcs); |
787 |
rm.setData(containerDmcs); |
| 775 |
rm.done(); |
788 |
rm.done(); |
|
Lines 808-816
Link Here
|
| 808 |
// code can be removed when GDB 7.2 is released |
821 |
// code can be removed when GDB 7.2 is released |
| 809 |
// START OF WORKAROUND |
822 |
// START OF WORKAROUND |
| 810 |
if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) { |
823 |
if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) { |
| 811 |
String groupId = MIProcesses.UNIQUE_GROUP_ID; |
824 |
return new IMIContainerDMContext[] {createContainerContextFromGroupId(controlDmc, MIProcesses.UNIQUE_GROUP_ID)}; |
| 812 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
|
|
| 813 |
return new IMIContainerDMContext[] {createContainerContext(processDmc, groupId)}; |
| 814 |
} |
825 |
} |
| 815 |
// END OF WORKAROUND to be removed when GDB 7.2 is available |
826 |
// END OF WORKAROUND to be removed when GDB 7.2 is available |
| 816 |
|
827 |
|
|
Lines 828-835
Link Here
|
| 828 |
continue; |
839 |
continue; |
| 829 |
} |
840 |
} |
| 830 |
String groupId = group.getGroupId(); |
841 |
String groupId = group.getGroupId(); |
| 831 |
IProcessDMContext procDmc = createProcessContext(controlDmc, groupId); |
842 |
containerDmcs.add(createContainerContextFromGroupId(controlDmc, groupId)); |
| 832 |
containerDmcs.add(createContainerContext(procDmc, groupId)); |
|
|
| 833 |
} |
843 |
} |
| 834 |
return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]); |
844 |
return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]); |
| 835 |
} |
845 |
} |
|
Lines 1049-1054
Link Here
|
| 1049 |
"thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
1059 |
"thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
| 1050 |
|
1060 |
|
| 1051 |
String groupId = null; |
1061 |
String groupId = null; |
|
|
1062 |
String pId = null; |
| 1052 |
|
1063 |
|
| 1053 |
MIResult[] results = exec.getMIResults(); |
1064 |
MIResult[] results = exec.getMIResults(); |
| 1054 |
for (int i = 0; i < results.length; i++) { |
1065 |
for (int i = 0; i < results.length; i++) { |
|
Lines 1058-1076
Link Here
|
| 1058 |
if (val instanceof MIConst) { |
1069 |
if (val instanceof MIConst) { |
| 1059 |
groupId = ((MIConst) val).getString().trim(); |
1070 |
groupId = ((MIConst) val).getString().trim(); |
| 1060 |
} |
1071 |
} |
|
|
1072 |
} else if (var.equals("pid")) { //$NON-NLS-1$ |
| 1073 |
// Available starting with GDB 7.2 |
| 1074 |
if (val instanceof MIConst) { |
| 1075 |
pId = ((MIConst) val).getString().trim(); |
| 1076 |
} |
| 1061 |
} |
1077 |
} |
| 1062 |
} |
1078 |
} |
| 1063 |
|
1079 |
|
|
|
1080 |
if (pId == null) { |
| 1081 |
// Before GDB 7.2, the groupId was the pid of the process |
| 1082 |
pId = groupId; |
| 1083 |
} |
| 1084 |
|
| 1064 |
if (groupId != null) { |
1085 |
if (groupId != null) { |
| 1065 |
if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$ |
1086 |
if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 1066 |
fDebuggedProcessesAndNames.put(groupId, ""); //$NON-NLS-1$ |
1087 |
|
|
|
1088 |
fGroupToPidMap.put(groupId, pId); |
| 1089 |
|
| 1090 |
fDebuggedProcessesAndNames.put(pId, ""); //$NON-NLS-1$ |
| 1067 |
|
1091 |
|
| 1068 |
// GDB is debugging a new process. Let's fetch its |
1092 |
// GDB is debugging a new process. Let's fetch its |
| 1069 |
// name and remember it. In order to get the name, |
1093 |
// name and remember it. In order to get the name, |
| 1070 |
// we have to request all running processes, not |
1094 |
// we have to request all running processes, not |
| 1071 |
// just the ones being debugged. We got a lot more |
1095 |
// just the ones being debugged. We got a lot more |
| 1072 |
// information when we request all processes. |
1096 |
// information when we request all processes. |
| 1073 |
final String finalGroupId = groupId; |
1097 |
final String finalPId = pId; |
| 1074 |
fListThreadGroupsAvailableCache.execute( |
1098 |
fListThreadGroupsAvailableCache.execute( |
| 1075 |
fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true), |
1099 |
fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true), |
| 1076 |
new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) { |
1100 |
new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) { |
|
Lines 1081-1090
Link Here
|
| 1081 |
// sending of this command. |
1105 |
// sending of this command. |
| 1082 |
fListThreadGroupsAvailableCache.reset(); |
1106 |
fListThreadGroupsAvailableCache.reset(); |
| 1083 |
|
1107 |
|
|
|
1108 |
// Note that the output of the "-list-thread-groups --available" command |
| 1109 |
// still shows the pid as a groupId, even for GDB 7.2. |
| 1084 |
if (isSuccess()) { |
1110 |
if (isSuccess()) { |
| 1085 |
for (IThreadGroupInfo groupInfo : getData().getGroupList()) { |
1111 |
for (IThreadGroupInfo groupInfo : getData().getGroupList()) { |
| 1086 |
if (groupInfo.getPid().equals(finalGroupId)) { |
1112 |
if (groupInfo.getPid().equals(finalPId)) { |
| 1087 |
fDebuggedProcessesAndNames.put(finalGroupId, groupInfo.getName()); |
1113 |
fDebuggedProcessesAndNames.put(finalPId, groupInfo.getName()); |
| 1088 |
} |
1114 |
} |
| 1089 |
} |
1115 |
} |
| 1090 |
} |
1116 |
} |
|
Lines 1097-1106
Link Here
|
| 1097 |
IProcessList list = null; |
1123 |
IProcessList list = null; |
| 1098 |
try { |
1124 |
try { |
| 1099 |
list = CCorePlugin.getDefault().getProcessList(); |
1125 |
list = CCorePlugin.getDefault().getProcessList(); |
| 1100 |
int groupId_int = Integer.parseInt(finalGroupId); |
1126 |
int pId_int = Integer.parseInt(finalPId); |
| 1101 |
for (IProcessInfo procInfo : list.getProcessList()) { |
1127 |
for (IProcessInfo procInfo : list.getProcessList()) { |
| 1102 |
if (procInfo.getPid() == groupId_int) { |
1128 |
if (procInfo.getPid() == pId_int) { |
| 1103 |
fDebuggedProcessesAndNames.put(finalGroupId, procInfo.getName()); |
1129 |
fDebuggedProcessesAndNames.put(finalPId, procInfo.getName()); |
|
|
1130 |
break; |
| 1104 |
} |
1131 |
} |
| 1105 |
} |
1132 |
} |
| 1106 |
} catch (CoreException e) { |
1133 |
} catch (CoreException e) { |
|
Lines 1110-1117
Link Here
|
| 1110 |
} |
1137 |
} |
| 1111 |
}); |
1138 |
}); |
| 1112 |
} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
1139 |
} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
|
|
1140 |
|
| 1141 |
fGroupToPidMap.remove(groupId); |
| 1142 |
|
| 1113 |
// GDB is no longer debugging this process. Remove it from our list. |
1143 |
// GDB is no longer debugging this process. Remove it from our list. |
| 1114 |
fDebuggedProcessesAndNames.remove(groupId); |
1144 |
fDebuggedProcessesAndNames.remove(pId); |
| 1115 |
|
1145 |
|
| 1116 |
// Remove any entries for that group from our thread to group map |
1146 |
// Remove any entries for that group from our thread to group map |
| 1117 |
// When detaching from a group, we won't have received any thread-exited event |
1147 |
// When detaching from a group, we won't have received any thread-exited event |