|
Lines 375-380
Link Here
|
| 375 |
* A map of thread id to thread group id. We use this to find out to which threadGroup a thread belongs. |
375 |
* A map of thread id to thread group id. We use this to find out to which threadGroup a thread belongs. |
| 376 |
*/ |
376 |
*/ |
| 377 |
private Map<String, String> fThreadToGroupMap = new HashMap<String, String>(); |
377 |
private Map<String, String> fThreadToGroupMap = new HashMap<String, String>(); |
|
|
378 |
/** |
| 379 |
* A map of thread group id to process id. We use this to find out to which pid a group refers. |
| 380 |
*/ |
| 381 |
private Map<String, String> fGroupToPidMap = new HashMap<String, String>(); |
| 378 |
|
382 |
|
| 379 |
private IGDBControl fCommandControl; |
383 |
private IGDBControl fCommandControl; |
| 380 |
private IGDBBackend fBackend; |
384 |
private IGDBBackend fBackend; |
|
Lines 532-541
Link Here
|
| 532 |
} |
536 |
} |
| 533 |
} |
537 |
} |
| 534 |
} |
538 |
} |
| 535 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
539 |
|
| 536 |
return createContainerContext(processDmc, groupId); |
540 |
return createContainerContextFromGroupId(controlDmc, groupId); |
| 537 |
} |
541 |
} |
| 538 |
|
542 |
|
|
|
543 |
private IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) { |
| 544 |
String pid = fGroupToPidMap.get(groupId); |
| 545 |
if (pid == null) { |
| 546 |
pid = groupId; |
| 547 |
} |
| 548 |
IProcessDMContext processDmc = createProcessContext(controlDmc, pid); |
| 549 |
return createContainerContext(processDmc, groupId); |
| 550 |
} |
| 551 |
|
| 539 |
public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) { |
552 |
public IMIExecutionDMContext[] getExecutionContexts(IMIContainerDMContext containerDmc) { |
| 540 |
String groupId = containerDmc.getGroupId(); |
553 |
String groupId = containerDmc.getGroupId(); |
| 541 |
List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); |
554 |
List<IMIExecutionDMContext> execDmcList = new ArrayList<IMIExecutionDMContext>(); |
|
Lines 748-758
Link Here
|
| 748 |
@Override |
761 |
@Override |
| 749 |
protected void handleFailure() { |
762 |
protected void handleFailure() { |
| 750 |
// If the target is not available, generate the list ourselves |
763 |
// If the target is not available, generate the list ourselves |
| 751 |
IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fDebuggedProcessesAndNames.size()]; |
764 |
IMIContainerDMContext[] containerDmcs = new IMIContainerDMContext[fGroupToPidMap.size()]; |
| 752 |
int i = 0; |
765 |
int i = 0; |
| 753 |
for (String groupId : fDebuggedProcessesAndNames.keySet()) { |
766 |
for (String groupId : fGroupToPidMap.keySet()) { |
| 754 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
767 |
containerDmcs[i++] = createContainerContextFromGroupId(controlDmc, groupId); |
| 755 |
containerDmcs[i++] = createContainerContext(processDmc, groupId); |
|
|
| 756 |
} |
768 |
} |
| 757 |
rm.setData(containerDmcs); |
769 |
rm.setData(containerDmcs); |
| 758 |
rm.done(); |
770 |
rm.done(); |
|
Lines 791-799
Link Here
|
| 791 |
// code can be removed when GDB 7.2 is released |
803 |
// code can be removed when GDB 7.2 is released |
| 792 |
// START OF WORKAROUND |
804 |
// START OF WORKAROUND |
| 793 |
if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) { |
805 |
if (groups.length == 0 && fBackend.getSessionType() == SessionType.CORE) { |
| 794 |
String groupId = MIProcesses.UNIQUE_GROUP_ID; |
806 |
return new IMIContainerDMContext[] {createContainerContextFromGroupId(controlDmc, MIProcesses.UNIQUE_GROUP_ID)}; |
| 795 |
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); |
|
|
| 796 |
return new IMIContainerDMContext[] {createContainerContext(processDmc, groupId)}; |
| 797 |
} |
807 |
} |
| 798 |
// END OF WORKAROUND to be removed when GDB 7.2 is available |
808 |
// END OF WORKAROUND to be removed when GDB 7.2 is available |
| 799 |
|
809 |
|
|
Lines 811-818
Link Here
|
| 811 |
continue; |
821 |
continue; |
| 812 |
} |
822 |
} |
| 813 |
String groupId = group.getGroupId(); |
823 |
String groupId = group.getGroupId(); |
| 814 |
IProcessDMContext procDmc = createProcessContext(controlDmc, groupId); |
824 |
containerDmcs.add(createContainerContextFromGroupId(controlDmc, groupId)); |
| 815 |
containerDmcs.add(createContainerContext(procDmc, groupId)); |
|
|
| 816 |
} |
825 |
} |
| 817 |
return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]); |
826 |
return containerDmcs.toArray(new IMIContainerDMContext[containerDmcs.size()]); |
| 818 |
} |
827 |
} |
|
Lines 1020-1025
Link Here
|
| 1020 |
"thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
1029 |
"thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
| 1021 |
|
1030 |
|
| 1022 |
String groupId = null; |
1031 |
String groupId = null; |
|
|
1032 |
String pId = null; |
| 1023 |
|
1033 |
|
| 1024 |
MIResult[] results = exec.getMIResults(); |
1034 |
MIResult[] results = exec.getMIResults(); |
| 1025 |
for (int i = 0; i < results.length; i++) { |
1035 |
for (int i = 0; i < results.length; i++) { |
|
Lines 1029-1047
Link Here
|
| 1029 |
if (val instanceof MIConst) { |
1039 |
if (val instanceof MIConst) { |
| 1030 |
groupId = ((MIConst) val).getString().trim(); |
1040 |
groupId = ((MIConst) val).getString().trim(); |
| 1031 |
} |
1041 |
} |
|
|
1042 |
} else if (var.equals("pid")) { //$NON-NLS-1$ |
| 1043 |
// Available starting with GDB 7.2 |
| 1044 |
if (val instanceof MIConst) { |
| 1045 |
pId = ((MIConst) val).getString().trim(); |
| 1046 |
} |
| 1032 |
} |
1047 |
} |
| 1033 |
} |
1048 |
} |
| 1034 |
|
1049 |
|
|
|
1050 |
if (pId == null) { |
| 1051 |
// Before GDB 7.2, the groupId was the pid of the process |
| 1052 |
pId = groupId; |
| 1053 |
} |
| 1054 |
|
| 1035 |
if (groupId != null) { |
1055 |
if (groupId != null) { |
| 1036 |
if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$ |
1056 |
if ("thread-group-created".equals(miEvent) || "thread-group-started".equals(miEvent)) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 1037 |
fDebuggedProcessesAndNames.put(groupId, ""); //$NON-NLS-1$ |
1057 |
|
|
|
1058 |
fGroupToPidMap.put(groupId, pId); |
| 1059 |
|
| 1060 |
fDebuggedProcessesAndNames.put(pId, ""); //$NON-NLS-1$ |
| 1038 |
|
1061 |
|
| 1039 |
// GDB is debugging a new process. Let's fetch its |
1062 |
// GDB is debugging a new process. Let's fetch its |
| 1040 |
// name and remember it. In order to get the name, |
1063 |
// name and remember it. In order to get the name, |
| 1041 |
// we have to request all running processes, not |
1064 |
// we have to request all running processes, not |
| 1042 |
// just the ones being debugged. We got a lot more |
1065 |
// just the ones being debugged. We got a lot more |
| 1043 |
// information when we request all processes. |
1066 |
// information when we request all processes. |
| 1044 |
final String finalGroupId = groupId; |
1067 |
final String finalPId = pId; |
| 1045 |
fListThreadGroupsAvailableCache.execute( |
1068 |
fListThreadGroupsAvailableCache.execute( |
| 1046 |
fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true), |
1069 |
fCommandFactory.createMIListThreadGroups(fCommandControl.getContext(), true), |
| 1047 |
new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) { |
1070 |
new DataRequestMonitor<MIListThreadGroupsInfo>(getExecutor(), null) { |
|
Lines 1052-1061
Link Here
|
| 1052 |
// sending of this command. |
1075 |
// sending of this command. |
| 1053 |
fListThreadGroupsAvailableCache.reset(); |
1076 |
fListThreadGroupsAvailableCache.reset(); |
| 1054 |
|
1077 |
|
|
|
1078 |
// Note that the output of the "-list-thread-groups --available" command |
| 1079 |
// still shows the pid as a groupId, even for GDB 7.2. |
| 1055 |
if (isSuccess()) { |
1080 |
if (isSuccess()) { |
| 1056 |
for (IThreadGroupInfo groupInfo : getData().getGroupList()) { |
1081 |
for (IThreadGroupInfo groupInfo : getData().getGroupList()) { |
| 1057 |
if (groupInfo.getPid().equals(finalGroupId)) { |
1082 |
if (groupInfo.getPid().equals(finalPId)) { |
| 1058 |
fDebuggedProcessesAndNames.put(finalGroupId, groupInfo.getName()); |
1083 |
fDebuggedProcessesAndNames.put(finalPId, groupInfo.getName()); |
| 1059 |
} |
1084 |
} |
| 1060 |
} |
1085 |
} |
| 1061 |
} |
1086 |
} |
|
Lines 1068-1077
Link Here
|
| 1068 |
IProcessList list = null; |
1093 |
IProcessList list = null; |
| 1069 |
try { |
1094 |
try { |
| 1070 |
list = CCorePlugin.getDefault().getProcessList(); |
1095 |
list = CCorePlugin.getDefault().getProcessList(); |
| 1071 |
int groupId_int = Integer.parseInt(finalGroupId); |
1096 |
int pId_int = Integer.parseInt(finalPId); |
| 1072 |
for (IProcessInfo procInfo : list.getProcessList()) { |
1097 |
for (IProcessInfo procInfo : list.getProcessList()) { |
| 1073 |
if (procInfo.getPid() == groupId_int) { |
1098 |
if (procInfo.getPid() == pId_int) { |
| 1074 |
fDebuggedProcessesAndNames.put(finalGroupId, procInfo.getName()); |
1099 |
fDebuggedProcessesAndNames.put(finalPId, procInfo.getName()); |
|
|
1100 |
break; |
| 1075 |
} |
1101 |
} |
| 1076 |
} |
1102 |
} |
| 1077 |
} catch (CoreException e) { |
1103 |
} catch (CoreException e) { |
|
Lines 1081-1088
Link Here
|
| 1081 |
} |
1107 |
} |
| 1082 |
}); |
1108 |
}); |
| 1083 |
} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
1109 |
} else if ("thread-group-exited".equals(miEvent)) { //$NON-NLS-1$ |
|
|
1110 |
|
| 1111 |
fGroupToPidMap.remove(groupId); |
| 1112 |
|
| 1084 |
// GDB is no longer debugging this process. Remove it from our list. |
1113 |
// GDB is no longer debugging this process. Remove it from our list. |
| 1085 |
fDebuggedProcessesAndNames.remove(groupId); |
1114 |
fDebuggedProcessesAndNames.remove(pId); |
| 1086 |
|
1115 |
|
| 1087 |
// Remove any entries for that group from our thread to group map |
1116 |
// Remove any entries for that group from our thread to group map |
| 1088 |
// When detaching from a group, we won't have received any thread-exited event |
1117 |
// When detaching from a group, we won't have received any thread-exited event |