1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Bug 396081 - Revert commit 5ee1a4a174:

Duplicate target breakpoints created when setting a GDB console
breakpoint with relative path.  We keep the new API though.

Change-Id: I0dd473fff033e9adbdbb5d79a51915e607043c66
Reviewed-on: https://git.eclipse.org/r/13528
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Marc Khouzam 2013-06-03 21:10:55 -04:00
parent b1052736a1
commit 1ae2226284

View file

@ -37,7 +37,6 @@ import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor; import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
@ -743,115 +742,80 @@ public class MIBreakpointsSynchronizer extends AbstractDsfService implements IMI
} }
String type = (String)attributes.get(MIBreakpoints.BREAKPOINT_TYPE); String type = (String)attributes.get(MIBreakpoints.BREAKPOINT_TYPE);
if (MIBreakpoints.BREAKPOINT.equals(type)) { if (MIBreakpoints.BREAKPOINT.equals(type)) {
getTargetLineBreakpoint( rm.done(getTargetLineBreakpoint(
context,
map.values(), map.values(),
(String)attributes.get(MIBreakpoints.FILE_NAME), (String)attributes.get(MIBreakpoints.FILE_NAME),
(Integer)attributes.get(MIBreakpoints.LINE_NUMBER), (Integer)attributes.get(MIBreakpoints.LINE_NUMBER),
(String)attributes.get(MIBreakpoints.FUNCTION), (String)attributes.get(MIBreakpoints.FUNCTION),
(String)attributes.get(MIBreakpoints.ADDRESS), (String)attributes.get(MIBreakpoints.ADDRESS),
(Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE), (Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE),
(Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY), (Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY)));
rm);
} }
else if (MIBreakpoints.TRACEPOINT.equals(type)) { else if (MIBreakpoints.TRACEPOINT.equals(type)) {
getTargetTracepoint( rm.done(getTargetTracepoint(
context,
map.values(), map.values(),
(String)attributes.get(MIBreakpoints.FILE_NAME), (String)attributes.get(MIBreakpoints.FILE_NAME),
(Integer)attributes.get(MIBreakpoints.LINE_NUMBER), (Integer)attributes.get(MIBreakpoints.LINE_NUMBER),
(String)attributes.get(MIBreakpoints.FUNCTION), (String)attributes.get(MIBreakpoints.FUNCTION),
(String)attributes.get(MIBreakpoints.ADDRESS), (String)attributes.get(MIBreakpoints.ADDRESS),
(Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE), (Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE),
(Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY), (Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY)));
rm);
} }
else if (MIBreakpoints.WATCHPOINT.equals(type)) { else if (MIBreakpoints.WATCHPOINT.equals(type)) {
getTargetWatchpoint( rm.done(getTargetWatchpoint(
context,
map.values(), map.values(),
(String)attributes.get(MIBreakpoints.EXPRESSION), (String)attributes.get(MIBreakpoints.EXPRESSION),
(Boolean)attributes.get(MIBreakpoints.READ), (Boolean)attributes.get(MIBreakpoints.READ),
(Boolean)attributes.get(MIBreakpoints.WRITE), (Boolean)attributes.get(MIBreakpoints.WRITE),
(Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE), (Boolean)attributes.get(MIBreakpointDMData.IS_HARDWARE),
(Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY), (Boolean)attributes.get(MIBreakpointDMData.IS_TEMPORARY)));
rm);
} } else {
else {
rm.done(); rm.done();
} }
} }
private void getTargetLineBreakpoint( private MIBreakpoint getTargetLineBreakpoint(
IBreakpointsTargetDMContext bpTargetDMC,
Collection<MIBreakpoint> targetBreakpoints, Collection<MIBreakpoint> targetBreakpoints,
String fileName, String fileName,
Integer lineNumber, Integer lineNumber,
String function, String function,
String address, String address,
Boolean isHardware, Boolean isHardware,
Boolean isTemporary, Boolean isTemporary) {
DataRequestMonitor<MIBreakpoint> drm) {
List<MIBreakpoint> candidates = new ArrayList<MIBreakpoint>(targetBreakpoints.size());
for (MIBreakpoint miBpt : targetBreakpoints) { for (MIBreakpoint miBpt : targetBreakpoints) {
if (!miBpt.isWatchpoint() && !isCatchpoint(miBpt) && !miBpt.isTracepoint()) { if (!miBpt.isWatchpoint() && !isCatchpoint(miBpt) && !miBpt.isTracepoint()
// Filter out target breakpoints with different file names and line numbers && compareBreakpointAttributes(
if (fileName == null miBpt, fileName, lineNumber, function, address, isHardware, isTemporary))
|| (new File(fileName).getName().equals(new File(getFileName(miBpt)).getName()) return miBpt;
&& getLineNumber(miBpt) == lineNumber)) {
candidates.add(miBpt);
}
}
} }
if (candidates.size() == 0) { return null;
drm.done();
return;
}
findTargetLineBreakpoint(bpTargetDMC, candidates,
fileName, lineNumber, function, address, isHardware, isTemporary, drm);
} }
private void getTargetTracepoint( private MIBreakpoint getTargetTracepoint(
IBreakpointsTargetDMContext bpTargetDMC,
Collection<MIBreakpoint> targetBreakpoints, Collection<MIBreakpoint> targetBreakpoints,
String fileName, String fileName,
Integer lineNumber, Integer lineNumber,
String function, String function,
String address, String address,
Boolean isHardware, Boolean isHardware,
Boolean isTemporary, Boolean isTemporary) {
DataRequestMonitor<MIBreakpoint> rm) {
List<MIBreakpoint> candidates = new ArrayList<MIBreakpoint>(targetBreakpoints.size());
for (MIBreakpoint miBpt : targetBreakpoints) { for (MIBreakpoint miBpt : targetBreakpoints) {
if (miBpt.isTracepoint()) { if (miBpt.isTracepoint()
// Filter out target breakpoints with different file names and line numbers && compareBreakpointAttributes(
if (new File(fileName).getName().equals(new File(getFileName(miBpt)).getName()) miBpt, fileName, lineNumber, function, address, isHardware, isTemporary))
&& miBpt.getLine() == lineNumber) { return miBpt;
candidates.add(miBpt);
}
}
} }
if (candidates.size() == 0) { return null;
rm.done();
return;
}
findTargetLineBreakpoint(bpTargetDMC, candidates,
fileName, lineNumber, function, address, isHardware, isTemporary, rm);
} }
private void getTargetWatchpoint( private MIBreakpoint getTargetWatchpoint(
IBreakpointsTargetDMContext bpTargetDMC,
Collection<MIBreakpoint> targetBreakpoints, Collection<MIBreakpoint> targetBreakpoints,
String expression, String expression,
boolean readAccess, boolean readAccess,
boolean writeAccess, boolean writeAccess,
Boolean isHardware, Boolean isHardware,
Boolean isTemporary, Boolean isTemporary) {
DataRequestMonitor<MIBreakpoint> rm) {
for (MIBreakpoint miBpt : targetBreakpoints) { for (MIBreakpoint miBpt : targetBreakpoints) {
if (!miBpt.isWatchpoint()) if (!miBpt.isWatchpoint())
continue; continue;
@ -865,92 +829,25 @@ public class MIBreakpointsSynchronizer extends AbstractDsfService implements IMI
continue; continue;
if (!compareBreakpointTypeAttributes(miBpt, isHardware, isTemporary)) if (!compareBreakpointTypeAttributes(miBpt, isHardware, isTemporary))
continue; continue;
rm.setData(miBpt); return miBpt;
break;
} }
rm.done(); return null;
}
private void findTargetLineBreakpoint(
final IBreakpointsTargetDMContext bpTargetDMC,
final List<MIBreakpoint> candidates,
final String fileName,
final Integer lineNumber,
final String function,
final String address,
final Boolean isHardware,
final Boolean isTemporary,
final DataRequestMonitor<MIBreakpoint> drm) {
// We need to convert the debugger paths of the candidate target breakpoints
// before comparing them with the platform breakpoint's file name.
final List<MIBreakpoint> bpts = new ArrayList<MIBreakpoint>(candidates);
class FindBreakpointRM extends ImmediateDataRequestMonitor<MIBreakpoint> {
@Override
@ConfinedToDsfExecutor("fExecutor")
protected void handleCompleted() {
if (bpts.isEmpty()) {
drm.done();
return;
}
final MIBreakpoint bpt = bpts.remove(0);
final String debuggerPath = getFileName(bpt);
getSource(
bpTargetDMC,
debuggerPath,
new DataRequestMonitor<String>(getExecutor(), drm) {
@Override
@ConfinedToDsfExecutor( "fExecutor" )
protected void handleCompleted() {
// If an error occur performing source lookup
// log it and use the debugger path.
if (!isSuccess()) {
GdbPlugin.log(getStatus());
}
if (compareBreakpointAttributes(
bpt,
isSuccess() ? getData() : debuggerPath,
fileName,
lineNumber,
function,
address,
isHardware,
isTemporary)) {
// The target breakpoint is found, we're done.
drm.setData(bpt);
drm.done();
}
else {
// Try the next candidate
new FindBreakpointRM().done();
}
}
});
}
};
// Start the search.
new FindBreakpointRM().done();
} }
private boolean compareBreakpointAttributes( private boolean compareBreakpointAttributes(
MIBreakpoint miBpt, MIBreakpoint miBpt,
String miBptFileName,
String fileName, String fileName,
Integer lineNumber, Integer lineNumber,
String function, String function,
String address, String address,
Boolean isHardware, Boolean isHardware,
Boolean isTemporary) { Boolean isTemporary) {
return compareBreakpointLocationAttributes(miBpt, miBptFileName, fileName, lineNumber, function, address) return compareBreakpointLocationAttributes(miBpt, fileName, lineNumber, function, address)
&& compareBreakpointTypeAttributes(miBpt, isHardware, isTemporary); && compareBreakpointTypeAttributes(miBpt, isHardware, isTemporary);
} }
private boolean compareBreakpointLocationAttributes( private boolean compareBreakpointLocationAttributes(
MIBreakpoint miBpt, MIBreakpoint miBpt,
String miBptFileName,
String fileName, String fileName,
Integer lineNumber, Integer lineNumber,
String function, String function,
@ -961,6 +858,7 @@ public class MIBreakpointsSynchronizer extends AbstractDsfService implements IMI
&& (address == null || !address.equals(getPlatformAddress(miBpt.getAddress()).toHexAddressString()))) && (address == null || !address.equals(getPlatformAddress(miBpt.getAddress()).toHexAddressString())))
return false; return false;
if (isLineBreakpoint(miBpt)) { if (isLineBreakpoint(miBpt)) {
String miBptFileName = getFileName(miBpt);
if (fileName == null || miBptFileName == null || !new File(fileName).equals(new File(miBptFileName))) if (fileName == null || miBptFileName == null || !new File(fileName).equals(new File(miBptFileName)))
return false; return false;
if (lineNumber == null || lineNumber.intValue() != getLineNumber(miBpt)) if (lineNumber == null || lineNumber.intValue() != getLineNumber(miBpt))