blob: e8f4c28b03e9b3f14aa247bb1357164039250acf (
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
|
/*******************************************************************************
* Copyright (c) 2009, 2016 Freescale Semiconductors and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Freescale Semiconductor. - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.viewmodel;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.core.runtime.Platform;
/**
* Constants and utility functions used to trace VMViewerUpdate results. As
* VMViewerUpdate is an external class, we avoid polluting that API by housing
* these trace facilities in an internal package.
*/
public final class VMViewerUpdateTracing {
/**
* The value of the trace option "debug/vmUpdates/regex", which is a regular
* expression used to filter VMViewerUpdate traces.
*/
public final static String DEBUG_VMUPDATE_REGEX = Platform
.getDebugOption("org.eclipse.cdt.dsf.ui/debug/vm/updates/regex"); //$NON-NLS-1$
/**
* Has the "debug/vmUpdates/properties" tracing option been turned on? Requires
* "debug/vmUpdates" to also be turned on.
*/
public static final boolean DEBUG_VMUPDATES = DsfUIPlugin.DEBUG
&& Boolean.parseBoolean(Platform.getDebugOption("org.eclipse.cdt.dsf.ui/debug/vm/updates")); //$NON-NLS-1$
/**
* Looks at the optional filter (regular expression) set in the tracing
* options for VMViewerUpdates and determines if this class passes the
* filter (should be traced). If a filter is not set, then we trace all
* classes. Note that for optimization reasons, we expect the caller to
* first check that DEBUG_VMUPDATES is true before invoking us; we do not
* check it here (other than to assert it).
*
* @return true if this class's activity should be traced
*/
public static boolean matchesFilterRegex(Class<?> clazz) {
assert DEBUG_VMUPDATES;
if (DEBUG_VMUPDATE_REGEX == null || DEBUG_VMUPDATE_REGEX.length() == 0) {
return true;
}
try {
Pattern regex = Pattern.compile(DEBUG_VMUPDATE_REGEX);
Matcher matcher = regex.matcher(clazz.toString());
return matcher.find();
} catch (PatternSyntaxException exc) {
return false;
}
}
}
|