Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-05-27 08:13:32 -0400
committerAnton Leherbauer2015-05-27 08:13:59 -0400
commit7d37249d4d9f562b7073848d5e24c645d5710ed6 (patch)
tree68ab05f929446c6f7faeb1b8714ca467437db166
parent51b0d5bcf0f53a861894f4348ed6f58f92daeddc (diff)
downloadorg.eclipse.tcf-7d37249d4d9f562b7073848d5e24c645d5710ed6.tar.gz
org.eclipse.tcf-7d37249d4d9f562b7073848d5e24c645d5710ed6.tar.xz
org.eclipse.tcf-7d37249d4d9f562b7073848d5e24c645d5710ed6.zip
Bug 468464 - Add support for filtering variants according to discriminant value
Change-Id: I721d40aff17f1ac44af9a7ce64bc3310f3e8754e Signed-off-by: Anton Leherbauer <anton.leherbauer@windriver.com>
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/plugin.properties7
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/plugin.xml41
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ToggleFilterVariantsHandler.java41
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenSubExpressions.java117
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java13
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java1
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferences.java5
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferencesInitializer.java3
8 files changed, 213 insertions, 15 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/plugin.properties b/plugins/org.eclipse.tcf.debug.ui/plugin.properties
index 2e432a8b4..d5ce030e0 100644
--- a/plugins/org.eclipse.tcf.debug.ui/plugin.properties
+++ b/plugins/org.eclipse.tcf.debug.ui/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
+# Copyright (c) 2007, 2015 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
@@ -83,4 +83,7 @@ activities.activity.profiler.views.name=TCF Profiler Views
activities.activity.profiler.views.description=TCF Profiler related views.
showQualifiedNames.command.name = Show Qualified Type Names
-cpp.menu.label = C++ \ No newline at end of file
+cpp.menu.label = C++
+
+filterVariants.command.name = Filter Variants by Discriminant Value
+ada.menu.label = Ada
diff --git a/plugins/org.eclipse.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tcf.debug.ui/plugin.xml
index 705d94a37..a589b7406 100644
--- a/plugins/org.eclipse.tcf.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.tcf.debug.ui/plugin.xml
@@ -377,6 +377,16 @@
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
+ <command
+ categoryId="org.eclipse.tcf.debug.ui.commands"
+ defaultHandler="org.eclipse.tcf.internal.debug.ui.commands.ToggleFilterVariantsHandler"
+ id="org.eclipse.tcf.debug.ui.commands.toggleFilterVariants"
+ name="%filterVariants.command.name">
+ <state
+ class="org.eclipse.ui.handlers.RegistryToggleState"
+ id="org.eclipse.ui.commands.toggleState">
+ </state>
+ </command>
</extension>
<extension point="org.eclipse.ui.handlers">
@@ -553,7 +563,21 @@
commandId="org.eclipse.tcf.debug.ui.commands.toggleQualifiedTypeNames"
style="toggle">
</command>
-
+ </menu>
+ <menu
+ label="%ada.menu.label"
+ id="org.eclipse.tcf.debug.ui.commands.filter.variants.variables">
+ <visibleWhen checkEnabled="false">
+ <with variable="activeContexts">
+ <iterate ifEmpty="false" operator="or">
+ <equals value="org.eclipse.tcf.debug.ui.debugging"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.tcf.debug.ui.commands.toggleFilterVariants"
+ style="toggle">
+ </command>
</menu>
</menuContribution>
<!-- Expressions View -->
@@ -605,6 +629,21 @@
style="toggle">
</command>
</menu>
+ <menu
+ label="%ada.menu.label"
+ id="org.eclipse.tcf.debug.ui.commands.filter.variants.expressions">
+ <visibleWhen checkEnabled="false">
+ <with variable="activeContexts">
+ <iterate ifEmpty="false" operator="or">
+ <equals value="org.eclipse.tcf.debug.ui.debugging"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.tcf.debug.ui.commands.toggleFilterVariants"
+ style="toggle">
+ </command>
+ </menu>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.debug.ui.ExpressionView?after=additions">
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ToggleFilterVariantsHandler.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ToggleFilterVariantsHandler.java
new file mode 100644
index 000000000..eb573dc51
--- /dev/null
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/commands/ToggleFilterVariantsHandler.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.debug.ui.commands;
+
+import java.util.Map;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.tcf.internal.debug.ui.preferences.TCFPreferences;
+import org.eclipse.ui.commands.IElementUpdater;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.UIElement;
+
+/**
+ * Command handler toggling the "Filter Variants by Discriminant" preference.
+ */
+public class ToggleFilterVariantsHandler extends AbstractHandler implements IElementUpdater {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ boolean state = !HandlerUtil.toggleCommandState(event.getCommand());
+ TCFPreferences.getPreferenceStore().setValue(TCFPreferences.PREF_FILTER_VARIANTS_BY_DISCRIMINANT, state);
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void updateElement(UIElement element, Map parameters) {
+ element.setChecked(TCFPreferences.getPreferenceStore().getBoolean(TCFPreferences.PREF_FILTER_VARIANTS_BY_DISCRIMINANT));
+ }
+
+}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenSubExpressions.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenSubExpressions.java
index 3c90281eb..ec7e5fc64 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenSubExpressions.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFChildrenSubExpressions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2015 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
@@ -10,12 +10,17 @@
*******************************************************************************/
package org.eclipse.tcf.internal.debug.ui.model;
+import java.math.BigInteger;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.tcf.debug.ui.ITCFPrettyExpressionProvider;
+import org.eclipse.tcf.protocol.JSON;
import org.eclipse.tcf.services.IExpressions;
+import org.eclipse.tcf.services.IExpressions.Value;
import org.eclipse.tcf.services.ISymbols;
+import org.eclipse.tcf.services.ISymbols.Symbol;
import org.eclipse.tcf.util.TCFDataCache;
public class TCFChildrenSubExpressions extends TCFChildren {
@@ -116,27 +121,123 @@ public class TCFChildrenSubExpressions extends TCFChildren {
map.put(n.id, n);
}
break;
- case variant_part:
+ case variant:
if (!findFields(sym_data, map, deref)) return false;
break;
+ case variant_part:
+ if (node.model.isFilterVariantsByDiscriminant()) {
+ // find discriminant by offset
+ String discr_id = null;
+ int offset = sym_data.getOffset();
+ for (String id2 : children) {
+ if (id.equals(id2)) continue;
+ TCFDataCache<ISymbols.Symbol> discr_sym_cache = node.model.getSymbolInfoCache(id2);
+ if (!discr_sym_cache.validate()) {
+ pending = discr_sym_cache;
+ continue;
+ }
+ Symbol discr_sym_data = discr_sym_cache.getData();
+ if (discr_sym_data == null) continue;
+ if (discr_sym_data.getSymbolClass() == ISymbols.SymbolClass.variant_part) continue;
+ if (discr_sym_data.getOffset() == offset) {
+ discr_id = id2;
+ break;
+ }
+ }
+ if (discr_id == null) continue;
+ // filter variants by discriminant value
+ if (!filterVariants(sym_data, map, discr_id, deref)) return false;
+ }
+ else {
+ if (!findFields(sym_data, map, deref)) return false;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (pending == null) return true;
+ pending.wait(this);
+ return false;
+ }
+
+ private boolean filterVariants(ISymbols.Symbol type, Map<String,TCFNode> map, String discr_id, boolean deref) {
+ TCFNodeExpression discr_expr = getField(discr_id, deref);
+ TCFDataCache<Value> discr_value_cache = discr_expr.getValue();
+ if (!discr_value_cache.validate(this)) return false;
+ Value discr_value = discr_value_cache.getData();
+ if (discr_value == null) return true;
+ BigInteger discr = TCFNumberFormat.toBigInteger(discr_value.getValue(), discr_value.isBigEndian(), false);
+ TCFDataCache<String[]> children_cache = node.model.getSymbolChildrenCache(type.getID());
+ if (children_cache == null) return true;
+ if (!children_cache.validate(this)) return false;
+ String[] children = children_cache.getData();
+ if (children == null) return true;
+ TCFDataCache<?> pending = null;
+ ISymbols.Symbol variant_sym_data = null;
+ ISymbols.Symbol default_sym_data = null;
+ for (String id : children) {
+ TCFDataCache<ISymbols.Symbol> sym_cache = node.model.getSymbolInfoCache(id);
+ if (!sym_cache.validate()) {
+ pending = sym_cache;
+ }
+ else {
+ ISymbols.Symbol sym_data = sym_cache.getData();
+ if (sym_data == null) continue;
+ switch (sym_data.getSymbolClass()) {
case variant:
TCFDataCache<Map<String,Object>> sym_loc_cache = node.model.getSymbolLocationCache(id);
if (!sym_loc_cache.validate()) {
pending = sym_loc_cache;
continue;
}
- // Map<String,Object> sym_loc_data = sym_loc_cache.getData();
- // TODO: filter out fields according to discriminant info
- if (!findFields(sym_data, map, deref)) return false;
+ Map<String,Object> sym_loc_data = sym_loc_cache.getData();
+ Object discr_info = sym_loc_data.get("Discriminant");
+ if (discr_info instanceof List) {
+ List<?> values = (List<?>) discr_info;
+ for (Object value : values) {
+ if (value instanceof Number) {
+ BigInteger val = JSON.toBigInteger((Number) value);
+ if (discr.equals(val)) {
+ variant_sym_data = sym_data;
+ break;
+ }
+ }
+ else if (value instanceof Map) {
+ Map<?,?> range = (Map<?,?>) value;
+ Object x = range.get("X");
+ Object y = range.get("Y");
+ if (!(x instanceof Number) || !(y instanceof Number)) continue;
+ BigInteger lower = JSON.toBigInteger((Number) x);
+ BigInteger upper = JSON.toBigInteger((Number) y);
+ if (discr.compareTo(lower) >= 0 && discr.compareTo(upper) <= 0) {
+ variant_sym_data = sym_data;
+ break;
+ }
+ }
+ }
+ }
+ else if (discr_info == null) {
+ default_sym_data = sym_data;
+ }
break;
default:
+ assert false : "Unexpected symbol class: " + sym_data.getSymbolClass();
break;
}
}
+ if (variant_sym_data != null) break;
}
- if (pending == null) return true;
- pending.wait(this);
- return false;
+ if (pending != null) {
+ pending.wait(this);
+ return false;
+ }
+ if (variant_sym_data == null) variant_sym_data = default_sym_data;
+ if (variant_sym_data != null) {
+ if (!findFields(variant_sym_data, map, deref)) return false;
+ }
+ return true;
}
private TCFNodeExpression findReg(String reg_id) {
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
index 29fc6b25f..1fe1468ab 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFModel.java
@@ -235,6 +235,7 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
private boolean auto_children_list_updates;
private boolean show_full_error_reports;
private boolean qualified_type_names_enabled;
+ private boolean filter_variants_by_discriminant;
private final Map<String,String> action_results = new HashMap<String,String>();
private final HashMap<String,TCFAction> active_actions = new HashMap<String,TCFAction>();
@@ -730,7 +731,10 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
delay_children_list_updates = prefs_store.getBoolean(TCFPreferences.PREF_DELAY_CHILDREN_LIST_UPDATES);
show_full_error_reports = prefs_store.getBoolean(TCFPreferences.PREF_FULL_ERROR_REPORTS);
qualified_type_names_enabled = prefs_store.getBoolean(TCFPreferences.PREF_SHOW_QUALIFIED_TYPE_NAMES);
- final boolean affectsExpressionsOnly = event != null && TCFPreferences.PREF_SHOW_QUALIFIED_TYPE_NAMES.equals(event.getProperty());
+ filter_variants_by_discriminant = prefs_store.getBoolean(TCFPreferences.PREF_FILTER_VARIANTS_BY_DISCRIMINANT);
+ final boolean affectsExpressionsOnly = event != null && (
+ TCFPreferences.PREF_SHOW_QUALIFIED_TYPE_NAMES.equals(event.getProperty()) ||
+ TCFPreferences.PREF_FILTER_VARIANTS_BY_DISCRIMINANT.equals(event.getProperty()));
Protocol.invokeLater(new Runnable() {
public void run() {
for (TCFNode n : id2node.values()) {
@@ -2285,6 +2289,13 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab
return qualified_type_names_enabled;
}
+ /**
+ * @return whether to filter variant fields by discriminant value
+ */
+ public boolean isFilterVariantsByDiscriminant() {
+ return filter_variants_by_discriminant;
+ }
+
/*-------------------- Profiling/tracing interface -------------------------------- */
public interface ProfilerDataListener {
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java
index 7fea76f7c..15f5a21eb 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java
@@ -641,6 +641,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT
void onPreferencesChanged() {
type_name.reset();
+ children.reset();
postAllChangedDelta();
}
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferences.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferences.java
index dac2d492c..072a3be44 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferences.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferences.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2011, 2015 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
@@ -30,7 +30,8 @@ public class TCFPreferences {
PREF_AUTO_CHILDREN_LIST_UPDATES = "AutoChildrenListUpdates",
PREF_DELAY_CHILDREN_LIST_UPDATES = "DelayChildrenListUpdates",
PREF_FULL_ERROR_REPORTS = "FullErrorReports",
- PREF_SHOW_QUALIFIED_TYPE_NAMES = "ShowQualifiedTypeNames";
+ PREF_SHOW_QUALIFIED_TYPE_NAMES = "ShowQualifiedTypeNames",
+ PREF_FILTER_VARIANTS_BY_DISCRIMINANT = "FilterVariantsByDiscriminant";
public static IPreferenceStore getPreferenceStore() {
return Activator.getDefault().getPreferenceStore();
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferencesInitializer.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferencesInitializer.java
index 5e66bbb66..662a50aca 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferencesInitializer.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/preferences/TCFPreferencesInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2011, 2015 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
@@ -34,5 +34,6 @@ public class TCFPreferencesInitializer extends AbstractPreferenceInitializer {
prefs.setDefault(TCFPreferences.PREF_DELAY_CHILDREN_LIST_UPDATES, false);
prefs.setDefault(TCFPreferences.PREF_FULL_ERROR_REPORTS, false);
prefs.setDefault(TCFPreferences.PREF_SHOW_QUALIFIED_TYPE_NAMES, false);
+ prefs.setDefault(TCFPreferences.PREF_FILTER_VARIANTS_BY_DISCRIMINANT, false);
}
}

Back to the top