blob: e46fe00cae379d2cb948642e0af6e0b7b05ef477 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/*******************************************************************************
* Copyright (c) 2011, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.internal.cdt.ui.breakpoints;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.tcf.internal.cdt.ui.Activator;
import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel;
public class TCFBreakpointScopeExtension implements ICBreakpointExtension {
private String[] fContextIds;
private ICBreakpoint fBreakpoint;
public void initialize(ICBreakpoint breakpoint) throws CoreException {
fBreakpoint = breakpoint;
IMarker m = breakpoint.getMarker();
if (m != null && m.exists()) {
String contextIdAttr = m.getAttribute(TCFBreakpointsModel.ATTR_CONTEXTIDS, null);
if (contextIdAttr != null) fContextIds = contextIdAttr.split(",\\s*");
}
}
public void setThreadFilter(String[] threadIds) {
fContextIds = threadIds;
if (fBreakpoint == null) return;
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
final IMarker m = fBreakpoint.getMarker();
if (m == null || !m.exists()) return;
String attr = null;
if (fContextIds != null) {
if (fContextIds.length == 0) {
// empty string is filtered out in TCFBreakpointsModel
attr = " ";
}
else {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < fContextIds.length - 1; i++) {
buf.append(fContextIds[i]).append(',');
}
buf.append(fContextIds[fContextIds.length - 1]);
attr = buf.toString();
}
}
m.setAttribute(TCFBreakpointsModel.ATTR_CONTEXTIDS, attr);
}
}, null);
}
catch (Exception e) {
Activator.log(e);
}
}
public String[] getThreadFilters() {
return fContextIds;
}
}
|