1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 336890: Allow IBreakpointTargetDMContext to be matched even if the processId is missing.

This commit is contained in:
Marc Khouzam 2011-04-02 01:50:49 +00:00
parent ce6f320fd8
commit 4a1aa3517c
5 changed files with 84 additions and 9 deletions

View file

@ -135,7 +135,7 @@ public class GdbLaunch extends DsfLaunch
GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, getLaunchConfiguration(), fSession); GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, getLaunchConfiguration(), fSession);
fSession.registerModelAdapter(IMemoryBlockRetrieval.class, fMemRetrieval); fSession.registerModelAdapter(IMemoryBlockRetrieval.class, fMemRetrieval);
IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), MIProcesses.UNIQUE_GROUP_ID); IProcessDMContext procDmc = procService.createProcessContext(commandControl.getContext(), MIProcesses.UNKNOWN_PROCESS_ID);
IMemoryDMContext memoryDmc = (IMemoryDMContext)procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID); IMemoryDMContext memoryDmc = (IMemoryDMContext)procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
fMemRetrieval.initialize(memoryDmc); fMemRetrieval.initialize(memoryDmc);
} }

View file

@ -164,7 +164,7 @@ public class GDBProcesses extends MIProcesses implements IGDBProcesses {
if (fProcId != null) { if (fProcId != null) {
processDmc = createProcessContext(controlDmc, fProcId); processDmc = createProcessContext(controlDmc, fProcId);
} else { } else {
processDmc = createProcessContext(controlDmc, groupId); processDmc = createProcessContext(controlDmc, MIProcesses.UNKNOWN_PROCESS_ID);
} }
return createContainerContext(processDmc, groupId); return createContainerContext(processDmc, groupId);
} }

View file

@ -301,12 +301,37 @@ public class GDBProcesses_7_0 extends AbstractDsfService
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return baseEquals(obj) && // We treat the UNKNOWN_PROCESS_ID as a wildcard. Any processId (except null) will be considered
(((MIProcessDMC)obj).fId == null ? fId == null : ((MIProcessDMC)obj).fId.equals(fId)); // equal to the UNKNOWN_PROCESS_ID. This is important because before starting a process, we don't
// have a pid yet, but we still need to create a process context, and we must use UNKNOWN_PROCESS_ID.
// Bug 336890
if (!baseEquals(obj)) {
return false;
}
MIProcessDMC other = (MIProcessDMC)obj;
if (fId == null || other.fId == null) {
return fId == null && other.fId == null;
}
// Now that we know neither is null, check for UNKNOWN_PROCESS_ID wildcard
if (fId.equals(MIProcesses.UNKNOWN_PROCESS_ID) || other.fId.equals(MIProcesses.UNKNOWN_PROCESS_ID)) {
return true;
}
return fId.equals(other.fId);
} }
@Override @Override
public int hashCode() { return baseHashCode() ^ (fId == null ? 0 : fId.hashCode()); } public int hashCode() {
// We cannot use fId in the hashCode. This is because we support
// the wildCard MIProcesses.UNKNOWN_PROCESS_ID which is equal to any other fId.
// But we also need the hashCode of the wildCard to be the same
// as the one of all other fIds, which is why we need a constant hashCode
// See bug 336890
return baseHashCode();
}
} }
/** /**
@ -549,6 +574,16 @@ public class GDBProcesses_7_0 extends AbstractDsfService
return fGroupToPidMap; return fGroupToPidMap;
} }
/** @since 4.0 */
protected int getNumConnected() {
return fNumConnected;
}
/** @since 4.0 */
protected void setNumConnected(int num) {
fNumConnected = num;
}
/** @since 4.0 */ /** @since 4.0 */
protected boolean isInitialProcess() { protected boolean isInitialProcess() {
return fInitialProcess; return fInitialProcess;
@ -631,6 +666,7 @@ public class GDBProcesses_7_0 extends AbstractDsfService
String pid = getGroupToPidMap().get(groupId); String pid = getGroupToPidMap().get(groupId);
if (pid == null) { if (pid == null) {
// For GDB 7.0 and 7.1, the groupId is the pid, so we can use it directly
pid = groupId; pid = groupId;
} }
IProcessDMContext processDmc = createProcessContext(controlDmc, pid); IProcessDMContext processDmc = createProcessContext(controlDmc, pid);

View file

@ -28,6 +28,7 @@ import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext; import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager; import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
@ -83,6 +84,17 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
super.shutdown(requestMonitor); super.shutdown(requestMonitor);
} }
@Override
public IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) {
String pid = getGroupToPidMap().get(groupId);
if (pid == null) {
// For GDB 7.2, the groupId is no longer the pid, so use our wildcard pid instead
pid = MIProcesses.UNKNOWN_PROCESS_ID;
}
IProcessDMContext processDmc = createProcessContext(controlDmc, pid);
return createContainerContext(processDmc, groupId);
}
@Override @Override
protected boolean doIsDebuggerAttachSupported() { protected boolean doIsDebuggerAttachSupported() {
// Multi-process is not applicable to post-mortem sessions (core) // Multi-process is not applicable to post-mortem sessions (core)

View file

@ -255,12 +255,37 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return super.baseEquals(obj) && // We treat the UNKNOWN_PROCESS_ID as a wildcard. Any processId (except null) will be considered
(((MIProcessDMC)obj).fId == null ? fId == null : ((MIProcessDMC)obj).fId.equals(fId)); // equal to the UNKNOWN_PROCESS_ID. This is important because before starting a process, we don't
// have a pid yet, but we still need to create a process context, and we must use UNKNOWN_PROCESS_ID.
// Bug 336890
if (!baseEquals(obj)) {
return false;
}
MIProcessDMC other = (MIProcessDMC)obj;
if (fId == null || other.fId == null) {
return fId == null && other.fId == null;
}
// Now that we know neither is null, check for UNKNOWN_PROCESS_ID wildcard
if (fId.equals(UNKNOWN_PROCESS_ID) || other.fId.equals(UNKNOWN_PROCESS_ID)) {
return true;
}
return fId.equals(other.fId);
} }
@Override @Override
public int hashCode() { return super.baseHashCode() ^ (fId == null ? 0 : fId.hashCode()); } public int hashCode() {
// We cannot use fId in the hashCode. This is because we support
// the wildCard MIProcesses.UNKNOWN_PROCESS_ID which is equal to any other fId.
// But we also need the hashCode of the wildCard to be the same
// as the one of all other fIds, which is why we need a constant hashCode
// See bug 336890
return baseHashCode();
}
} }
/* /*
@ -315,6 +340,8 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa
private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$ private static final String FAKE_THREAD_ID = "0"; //$NON-NLS-1$
// The unique id should be an empty string so that the views know not to display the fake id // The unique id should be an empty string so that the views know not to display the fake id
public static final String UNIQUE_GROUP_ID = ""; //$NON-NLS-1$ public static final String UNIQUE_GROUP_ID = ""; //$NON-NLS-1$
/** @since 4.0 */
public static final String UNKNOWN_PROCESS_ID = UNIQUE_GROUP_ID;
public MIProcesses(DsfSession session) { public MIProcesses(DsfSession session) {
super(session); super(session);
@ -420,7 +447,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa
/** @since 4.0 */ /** @since 4.0 */
public IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) { public IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) {
IProcessDMContext processDmc = createProcessContext(controlDmc, groupId); IProcessDMContext processDmc = createProcessContext(controlDmc, UNKNOWN_PROCESS_ID);
return createContainerContext(processDmc, groupId); return createContainerContext(processDmc, groupId);
} }