Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraleherbau2011-05-27 04:28:03 -0400
committeraleherbau2011-05-27 04:28:03 -0400
commit009543ef37841c5f1f7ae4dcb849573c3d3ea7a4 (patch)
tree76e1eb181492790ec469c6c252b9cae06f9e3d2f
parente69ff54e7d9525a6a46c6489ed8954e5c0d307db (diff)
downloadorg.eclipse.tcf-009543ef37841c5f1f7ae4dcb849573c3d3ea7a4.tar.gz
org.eclipse.tcf-009543ef37841c5f1f7ae4dcb849573c3d3ea7a4.tar.xz
org.eclipse.tcf-009543ef37841c5f1f7ae4dcb849573c3d3ea7a4.zip
TCF Debugger: Bug 347337 - Implement property page for TCF debug elements in the Debug view
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties2
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml14
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodeAdapterFactory.java5
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java195
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/properties/TCFPropertyPage.java46
5 files changed, 261 insertions, 1 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
index 237177866..37f3ca04a 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
@@ -41,3 +41,5 @@ BackReturn.description=Run backwards until return
BackResume.label=Run Backwards
BackResume.tooltip=Run Backwards
BackResume.description=Run backwards
+
+propertyPage.name = Debug Element
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
index 364af2165..dde55b90b 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
@@ -32,6 +32,7 @@
adaptableType="org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode">
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget"/>
<adapter type="org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension"/>
+ <adapter type="org.eclipse.ui.views.properties.IPropertySource"/>
</factory>
</extension>
@@ -304,4 +305,17 @@
debugModelId="org.eclipse.tm.tcf.debug"/>
</extension>
+ <extension point="org.eclipse.ui.propertyPages">
+ <page class="org.eclipse.tm.internal.tcf.debug.ui.properties.TCFPropertyPage"
+ id="org.eclipse.tcf.debug.node.propertyPage"
+ name="%propertyPage.name">
+ <filter name="debugModelId" value="org.eclipse.tm.tcf.debug"/>
+ <enabledWhen>
+ <instanceof
+ name="org.eclipse.cdt.debug.core.model.ICBreakpoint"
+ value="org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode"/>
+ </enabledWhen>
+ </page>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodeAdapterFactory.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodeAdapterFactory.java
index 92cbfce1a..e426c6174 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodeAdapterFactory.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodeAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 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
@@ -15,6 +15,7 @@ import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
import org.eclipse.tm.internal.tcf.debug.ui.commands.BreakpointCommand;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
+import org.eclipse.ui.views.properties.IPropertySource;
public class TCFNodeAdapterFactory implements IAdapterFactory {
@@ -22,6 +23,7 @@ public class TCFNodeAdapterFactory implements IAdapterFactory {
private static final Class<?>[] adapter_list = {
IToggleBreakpointsTarget.class,
IToggleBreakpointsTargetExtension.class,
+ IPropertySource.class,
};
private final BreakpointCommand breakpoint_command = new BreakpointCommand();
@@ -31,6 +33,7 @@ public class TCFNodeAdapterFactory implements IAdapterFactory {
if (obj instanceof TCFNode) {
if (cls == IToggleBreakpointsTarget.class) return breakpoint_command;
if (cls == IToggleBreakpointsTargetExtension.class) return breakpoint_command;
+ if (cls == IPropertySource.class) return new TCFNodePropertySource((TCFNode) obj);
}
return null;
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java
new file mode 100644
index 000000000..e2c71b751
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.tm.internal.tcf.debug.ui.adapters;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.tm.internal.tcf.debug.model.TCFContextState;
+import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext.MemoryRegion;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeStackFrame;
+import org.eclipse.tm.tcf.services.IRunControl;
+import org.eclipse.tm.tcf.services.IStackTrace;
+import org.eclipse.tm.tcf.util.TCFDataCache;
+import org.eclipse.tm.tcf.util.TCFTask;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Adapts TCFNode to IPropertySource.
+ */
+public class TCFNodePropertySource implements IPropertySource {
+
+ private final TCFNode fNode;
+ private final Map<String, Object> fProperties = new HashMap<String, Object>();
+ private IPropertyDescriptor[] fDescriptors;
+
+ public TCFNodePropertySource(TCFNode node) {
+ fNode = node;
+ }
+
+ public Object getEditableValue() {
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (fDescriptors == null) {
+ try {
+ fDescriptors = new TCFTask<IPropertyDescriptor[]>(fNode.getChannel()) {
+ final List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
+ public void run() {
+ if (fNode instanceof TCFNodeExecContext) {
+ getExecContextDescriptors((TCFNodeExecContext) fNode);
+ } else if (fNode instanceof TCFNodeStackFrame) {
+ getFrameDescriptors((TCFNodeStackFrame) fNode);
+ } else {
+ done(descriptors.toArray(new IPropertyDescriptor[descriptors.size()]));
+ }
+ }
+
+ private void getFrameDescriptors(TCFNodeStackFrame frameNode) {
+ TCFDataCache<IStackTrace.StackTraceContext> ctx_cache = frameNode.getStackTraceContext();
+ TCFDataCache<TCFSourceRef> line_info_cache = frameNode.getLineInfo();
+ if (!validateAll(ctx_cache, line_info_cache)) return;
+ IStackTrace.StackTraceContext ctx = ctx_cache.getData();
+ if (ctx != null) {
+ Map<String, Object> props = ctx.getProperties();
+ for (String key : props.keySet()) {
+ Object value = props.get(key);
+ if (value instanceof Number) {
+ value = toHexAddrString((Number) value);
+ }
+ addDescriptor("Context", key, value);
+ }
+ }
+ TCFSourceRef sourceRef = line_info_cache.getData();
+ if (sourceRef != null) {
+ if (sourceRef.area != null) {
+ addDescriptor("Source", "Directory", sourceRef.area.directory);
+ addDescriptor("Source", "File", sourceRef.area.file);
+ addDescriptor("Source", "Line", sourceRef.area.start_line);
+ }
+ if (sourceRef.error != null) {
+ addDescriptor("Source", "Error", sourceRef.error);
+ }
+ }
+ done(descriptors.toArray(new IPropertyDescriptor[descriptors.size()]));
+ }
+ private void getExecContextDescriptors(TCFNodeExecContext exeNode) {
+ TCFDataCache<IRunControl.RunControlContext> ctx_cache = exeNode.getRunContext();
+ TCFDataCache<TCFContextState> state_cache = exeNode.getState();
+ TCFDataCache<MemoryRegion[]> mem_map_cache = exeNode.getMemoryMap();
+ if (!validateAll(ctx_cache, state_cache, mem_map_cache)) return;
+ IRunControl.RunControlContext ctx = ctx_cache.getData();
+ if (ctx != null) {
+ Map<String, Object> props = ctx.getProperties();
+ for (String key : props.keySet()) {
+ Object value = props.get(key);
+ if (value instanceof Number) {
+ value = toHexAddrString((Number) value);
+ }
+ addDescriptor("Context", key, value);
+ }
+ }
+ TCFContextState state = state_cache.getData();
+ if (state != null) {
+ addDescriptor("State", "Suspended", state.is_suspended);
+ if (state.is_suspended) {
+ addDescriptor("State", "Suspend reason", state.suspend_reason);
+ addDescriptor("State", "PC", toHexAddrString(new BigInteger(state.suspend_pc)));
+ }
+ addDescriptor("State", "Active", !exeNode.isNotActive());
+ }
+ MemoryRegion[] mem_map = mem_map_cache.getData();
+ if (mem_map != null && mem_map.length > 0) {
+ int idx = 0;
+ for (MemoryRegion region : mem_map) {
+ Map<String, Object> props = region.region.getProperties();
+ for (String key : props.keySet()) {
+ Object value = props.get(key);
+ if (value instanceof Number) {
+ value = toHexAddrString((Number) value);
+ }
+ addDescriptor("MemoryRegion["+(idx++)+']', key, value);
+ }
+ }
+ }
+ done(descriptors.toArray(new IPropertyDescriptor[descriptors.size()]));
+ }
+ private void addDescriptor(String category, String key, Object value) {
+ String id = category + '.' + key;
+ PropertyDescriptor desc = new PropertyDescriptor(id, key);
+ desc.setCategory(category);
+ descriptors.add(desc);
+ fProperties.put(id, value);
+ }
+ boolean validateAll(TCFDataCache<?> ... caches) {
+ TCFDataCache<?> pending = null;
+ for (TCFDataCache<?> cache : caches) {
+ if (!cache.validate()) {
+ pending = cache;
+ }
+ }
+ if (pending != null) {
+ pending.wait(this);
+ return false;
+ }
+ return true;
+ }
+ }.get(5, TimeUnit.SECONDS);
+ }
+ catch (Exception e) {
+ Activator.log("Error retrieving property data", e);
+ fDescriptors = new IPropertyDescriptor[0];
+ }
+ }
+ return fDescriptors;
+ }
+
+ public Object getPropertyValue(final Object id) {
+ return fProperties.get(id);
+ }
+
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ }
+
+ private static String toHexAddrString(Number num) {
+ BigInteger n;
+ if (num instanceof BigInteger) {
+ n = (BigInteger) num;
+ } else {
+ n = BigInteger.valueOf(num.longValue());
+ }
+ String s = n.toString(16);
+ int sz = s.length() > 8 ? 16 : 8;
+ int l = sz - s.length();
+ if (l < 0) l = 0;
+ if (l > 16) l = 16;
+ return "0x0000000000000000".substring(0, 2 + l) + s;
+ }
+
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/properties/TCFPropertyPage.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/properties/TCFPropertyPage.java
new file mode 100644
index 000000000..fc4ed1286
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/properties/TCFPropertyPage.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.tm.internal.tcf.debug.ui.properties;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+/**
+ * Generic property page based on PropertySheetPage.
+ */
+public class TCFPropertyPage extends PropertyPage {
+
+ private PropertySheetPage fPage;
+
+ public TCFPropertyPage() {
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ noDefaultAndApplyButton();
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setFont(parent.getFont());
+ composite.setLayout(new GridLayout());
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fPage = new PropertySheetPage();
+ fPage.createControl(composite);
+ fPage.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
+ fPage.selectionChanged(null, new StructuredSelection(getElement()));
+ return composite;
+ }
+
+}

Back to the top