|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2007, 2010 Wind River and others. |
2 |
* Copyright (c) 2007, 2011 Wind River and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 11-16
Link Here
|
| 11 |
* Ericsson - Added breakpoint filter support |
11 |
* Ericsson - Added breakpoint filter support |
| 12 |
* Ericsson - Re-factored the service and put a few comments |
12 |
* Ericsson - Re-factored the service and put a few comments |
| 13 |
* Ericsson - Added Action support |
13 |
* Ericsson - Added Action support |
|
|
14 |
* Marc Khouzam (Ericsson) - Fix support for thread filter (Bug 355833) |
| 14 |
*******************************************************************************/ |
15 |
*******************************************************************************/ |
| 15 |
|
16 |
|
| 16 |
package org.eclipse.cdt.dsf.mi.service; |
17 |
package org.eclipse.cdt.dsf.mi.service; |
|
Lines 422-428
Link Here
|
| 422 |
// Upon determining the debuggerPath, the breakpoint is installed |
423 |
// Upon determining the debuggerPath, the breakpoint is installed |
| 423 |
determineDebuggerPath(dmc, attributes, new RequestMonitor(getExecutor(), countingRm) { |
424 |
determineDebuggerPath(dmc, attributes, new RequestMonitor(getExecutor(), countingRm) { |
| 424 |
@Override |
425 |
@Override |
| 425 |
protected void handleSuccess() { |
426 |
protected void handleSuccess() { |
|
|
427 |
// Before installing a breakpoint, set the target filter for that target. |
| 428 |
// Even if the breakpoint is disabled when we start, the target filter |
| 429 |
// can be accessed by the user through the breakpoint properties UI, so |
| 430 |
// we must set it right now. |
| 431 |
// This is the reason we don't do this in 'installBreakpoint', which is not |
| 432 |
// called right away if the breakpoint is disabled. |
| 433 |
try { |
| 434 |
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class); |
| 435 |
IDsfBreakpointExtension filterExt = getFilterExtension(breakpoint); |
| 436 |
if (filterExt.getThreadFilters(containerDmc) == null) { |
| 437 |
// Do this only if there wasn't already an entry, or else we would |
| 438 |
// erase the content of that previous entry. |
| 439 |
filterExt.setTargetFilter(containerDmc); |
| 440 |
} |
| 441 |
} catch (CoreException e) { |
| 442 |
} |
| 443 |
|
| 426 |
// Install only if the breakpoint is enabled at startup (Bug261082) |
444 |
// Install only if the breakpoint is enabled at startup (Bug261082) |
| 427 |
// Note that Tracepoints are not affected by "skip-all" |
445 |
// Note that Tracepoints are not affected by "skip-all" |
| 428 |
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && |
446 |
boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && |
|
Lines 718-723
Link Here
|
| 718 |
final Map<ICBreakpoint, Set<String>> threadsIDs = fBreakpointThreads.get(dmc); |
736 |
final Map<ICBreakpoint, Set<String>> threadsIDs = fBreakpointThreads.get(dmc); |
| 719 |
assert threadsIDs != null; |
737 |
assert threadsIDs != null; |
| 720 |
|
738 |
|
|
|
739 |
// Remove any target filter (if any) |
| 740 |
try { |
| 741 |
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class); |
| 742 |
getFilterExtension(breakpoint).removeTargetFilter(containerDmc); |
| 743 |
} |
| 744 |
catch( CoreException e ) { |
| 745 |
} |
| 746 |
|
| 721 |
// Remove breakpoint problem marker (if any) |
747 |
// Remove breakpoint problem marker (if any) |
| 722 |
removeBreakpointProblemMarker(breakpoint); |
748 |
removeBreakpointProblemMarker(breakpoint); |
| 723 |
|
749 |
|
|
Lines 1127-1132
Link Here
|
| 1127 |
new RequestMonitor(getExecutor(), countingRm) { |
1153 |
new RequestMonitor(getExecutor(), countingRm) { |
| 1128 |
@Override |
1154 |
@Override |
| 1129 |
protected void handleSuccess() { |
1155 |
protected void handleSuccess() { |
|
|
1156 |
// For a new breakpoint, set the target filter. |
| 1157 |
try { |
| 1158 |
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IContainerDMContext.class); |
| 1159 |
IDsfBreakpointExtension filterExt = getFilterExtension((ICBreakpoint)breakpoint); |
| 1160 |
if (filterExt.getThreadFilters(containerDmc) == null) { |
| 1161 |
// Do this only if there wasn't already an entry, or else we would |
| 1162 |
// erase the content of that previous entry. |
| 1163 |
filterExt.setTargetFilter(containerDmc); |
| 1164 |
} |
| 1165 |
} catch (CoreException e) { |
| 1166 |
} |
| 1167 |
|
| 1130 |
installBreakpoint(dmc, (ICBreakpoint) breakpoint, |
1168 |
installBreakpoint(dmc, (ICBreakpoint) breakpoint, |
| 1131 |
attrs, countingRm); |
1169 |
attrs, countingRm); |
| 1132 |
} |
1170 |
} |
|
Lines 1372-1386
Link Here
|
| 1372 |
for (IBreakpointsTargetDMContext ctx : fPlatformBPs.keySet()) { |
1410 |
for (IBreakpointsTargetDMContext ctx : fPlatformBPs.keySet()) { |
| 1373 |
Map<ICBreakpoint, Map<String, Object>> breakpoints = fPlatformBPs.get(ctx); |
1411 |
Map<ICBreakpoint, Map<String, Object>> breakpoints = fPlatformBPs.get(ctx); |
| 1374 |
clearBreakpointStatus(breakpoints.keySet().toArray(new ICBreakpoint[breakpoints.size()]), ctx); |
1412 |
clearBreakpointStatus(breakpoints.keySet().toArray(new ICBreakpoint[breakpoints.size()]), ctx); |
|
|
1413 |
|
| 1414 |
// Also clear any target filter since we will not be calling uninstallBreakpoint() which |
| 1415 |
// usually does that work. |
| 1416 |
IContainerDMContext dmc = DMContexts.getAncestorOfType(ctx, IContainerDMContext.class); |
| 1417 |
clearTargetFilter(dmc, breakpoints.keySet()); |
| 1375 |
} |
1418 |
} |
| 1376 |
// This will prevent Shutdown() from trying to remove bps from a |
1419 |
// This will prevent Shutdown() from trying to remove bps from a |
| 1377 |
// backend that has already shutdown |
1420 |
// backend that has already shutdown |
| 1378 |
fPlatformBPs.clear(); |
1421 |
fPlatformBPs.clear(); |
| 1379 |
} |
1422 |
} |
| 1380 |
|
1423 |
|
| 1381 |
/////////////////////////////////////////////////////////////////////////// |
1424 |
private void clearTargetFilter(IContainerDMContext containerDmc, Set<ICBreakpoint> breakpoints) { |
| 1382 |
// Breakpoint status handling functions |
1425 |
// Remove any target filter (if any) |
| 1383 |
/////////////////////////////////////////////////////////////////////////// |
1426 |
try { |
|
|
1427 |
for (ICBreakpoint bp : breakpoints) { |
| 1428 |
getFilterExtension(bp).removeTargetFilter(containerDmc); |
| 1429 |
} |
| 1430 |
} |
| 1431 |
catch( CoreException e ) { |
| 1432 |
} |
| 1433 |
} |
| 1434 |
|
| 1384 |
|
1435 |
|
| 1385 |
/** |
1436 |
/** |
| 1386 |
* @param bps |
1437 |
* @param bps |
|
Lines 1651-1691
Link Here
|
| 1651 |
* @return |
1702 |
* @return |
| 1652 |
*/ |
1703 |
*/ |
| 1653 |
private Set<String> extractThreads(IBreakpointsTargetDMContext context, ICBreakpoint breakpoint) { |
1704 |
private Set<String> extractThreads(IBreakpointsTargetDMContext context, ICBreakpoint breakpoint) { |
| 1654 |
Set<String> results = new HashSet<String>(); |
1705 |
Set<String> results = new HashSet<String>(); |
|
|
1706 |
|
| 1707 |
IExecutionDMContext[] threads = null; |
| 1708 |
try { |
| 1709 |
IContainerDMContext containerDmc = DMContexts.getAncestorOfType(context, IContainerDMContext.class); |
| 1710 |
threads = getFilterExtension(breakpoint).getThreadFilters(containerDmc); |
| 1711 |
} catch (CoreException e) { |
| 1712 |
} |
| 1655 |
|
1713 |
|
| 1656 |
// Find the ancestor |
1714 |
if (threads == null || threads.length == 0) { |
| 1657 |
List<IExecutionDMContext[]> threads = new ArrayList<IExecutionDMContext[]>(1); |
1715 |
results.add("0"); //$NON-NLS-1$ |
| 1658 |
|
1716 |
return results; |
| 1659 |
try { |
|
|
| 1660 |
// Retrieve the targets |
| 1661 |
IDsfBreakpointExtension filterExtension = getFilterExtension(breakpoint); |
| 1662 |
IContainerDMContext[] targets = filterExtension.getTargetFilters(); |
| 1663 |
|
| 1664 |
// If no target is present, breakpoint applies to all. |
| 1665 |
if (targets.length == 0) { |
| 1666 |
results.add("0"); //$NON-NLS-1$ |
| 1667 |
return results; |
| 1668 |
} |
| 1669 |
|
| 1670 |
// Extract the thread IDs (if there is none, we are covered) |
| 1671 |
for (IContainerDMContext ctxt : targets) { |
| 1672 |
if (ctxt.equals(context) || DMContexts.isAncestorOf(ctxt, context)) { |
| 1673 |
threads.add(filterExtension.getThreadFilters(ctxt)); |
| 1674 |
} |
| 1675 |
} |
| 1676 |
} catch (CoreException e1) { |
| 1677 |
} |
1717 |
} |
| 1678 |
|
1718 |
|
| 1679 |
if (supportsThreads(breakpoint)) { |
1719 |
if (supportsThreads(breakpoint)) { |
| 1680 |
for (IExecutionDMContext[] targetThreads : threads) { |
1720 |
for (IExecutionDMContext thread : threads) { |
| 1681 |
if (targetThreads != null) { |
1721 |
if (thread instanceof IMIExecutionDMContext) { |
| 1682 |
for (IExecutionDMContext thread : targetThreads) { |
1722 |
results.add(Integer.toString(((IMIExecutionDMContext)thread).getThreadId())); |
| 1683 |
if (thread instanceof IMIExecutionDMContext) { |
|
|
| 1684 |
IMIExecutionDMContext dmc = (IMIExecutionDMContext) thread; |
| 1685 |
results.add(((Integer) dmc.getThreadId()).toString()); |
| 1686 |
} |
| 1687 |
} |
| 1688 |
} else { |
1723 |
} else { |
|
|
1724 |
// If any of the threads is not an IMIExecutionDMContext, |
| 1725 |
// we don't support thread filters at all. |
| 1726 |
results.clear(); |
| 1689 |
results.add("0"); //$NON-NLS-1$ |
1727 |
results.add("0"); //$NON-NLS-1$ |
| 1690 |
break; |
1728 |
break; |
| 1691 |
} |
1729 |
} |