diff options
author | eutarass | 2010-11-30 17:51:34 +0000 |
---|---|---|
committer | eutarass | 2010-11-30 17:51:34 +0000 |
commit | 534bef71f2c57ac4fcfb7b2183837a58d64a56e0 (patch) | |
tree | 3afa5c84eedfe3f9800bcc00996194beceacadff /plugins/org.eclipse.tm.tcf.cdt.ui | |
parent | 4bbc4ca7baae382659dda259e1ef7ab6153213e5 (diff) | |
download | org.eclipse.tcf-534bef71f2c57ac4fcfb7b2183837a58d64a56e0.tar.gz org.eclipse.tcf-534bef71f2c57ac4fcfb7b2183837a58d64a56e0.tar.xz org.eclipse.tcf-534bef71f2c57ac4fcfb7b2183837a58d64a56e0.zip |
Bug 331423:[cdt] Enable Instruction Stepping Mode toggle button for TCF debugger
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.cdt.ui')
3 files changed, 126 insertions, 2 deletions
diff --git a/plugins/org.eclipse.tm.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tm.tcf.cdt.ui/plugin.xml index 4fc8a6a0e..b39eba7f5 100644 --- a/plugins/org.eclipse.tm.tcf.cdt.ui/plugin.xml +++ b/plugins/org.eclipse.tm.tcf.cdt.ui/plugin.xml @@ -15,7 +15,8 @@ <extension point="org.eclipse.tm.tcf.debug.ui.launch_context"> <class name="org.eclipse.tm.internal.tcf.cdt.ui.TCFLaunchContext" /> </extension> - <extension + + <extension point="org.eclipse.core.runtime.adapters"> <factory adaptableType="org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode" @@ -24,6 +25,13 @@ type="org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend"> </adapter> </factory> - </extension> + <factory + adaptableType="org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode" + class="org.eclipse.tm.internal.tcf.cdt.ui.TCFNodeAdapterFactory"> + <adapter + type="org.eclipse.cdt.debug.core.model.ISteppingModeTarget"> + </adapter> + </factory> + </extension> </plugin> diff --git a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFNodeAdapterFactory.java b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFNodeAdapterFactory.java new file mode 100644 index 000000000..e8c78c343 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFNodeAdapterFactory.java @@ -0,0 +1,41 @@ +/*******************************************************************************
+ * Copyright (c) 2010 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.cdt.ui;
+
+import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
+
+@SuppressWarnings("rawtypes")
+public class TCFNodeAdapterFactory implements IAdapterFactory {
+
+ private static final Class<?>[] CLASSES = { ISteppingModeTarget.class };
+
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof TCFNode) {
+ if (ISteppingModeTarget.class == adapterType) {
+ TCFNode node = (TCFNode) adaptableObject;
+ TCFModel model = node.getModel();
+ ISteppingModeTarget target = (ISteppingModeTarget) model.getAdapter(adapterType, node);
+ if (target == null) {
+ model.setAdapter(adapterType, target = new TCFSteppingModeTarget(model));
+ }
+ return target;
+ }
+ }
+ return null;
+ }
+
+ public Class[] getAdapterList() {
+ return CLASSES;
+ }
+
+}
diff --git a/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFSteppingModeTarget.java b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFSteppingModeTarget.java new file mode 100644 index 000000000..0c0681624 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.cdt.ui/src/org/eclipse/tm/internal/tcf/cdt/ui/TCFSteppingModeTarget.java @@ -0,0 +1,75 @@ +/*******************************************************************************
+ * Copyright (c) 2010 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.cdt.ui;
+
+import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
+import org.eclipse.cdt.debug.core.model.ITargetProperties;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
+import org.eclipse.tm.internal.tcf.debug.ui.model.TCFModel;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Integrates the TCF model with the "Instruction Stepping Mode" button from CDT.
+ */
+@SuppressWarnings("deprecation")
+public class TCFSteppingModeTarget implements ISteppingModeTarget, ITargetProperties {
+
+ private final Preferences fPreferences;
+ private final TCFModel fModel;
+
+ public TCFSteppingModeTarget(TCFModel model) {
+ fPreferences= new Preferences();
+ fPreferences.setDefault(PREF_INSTRUCTION_STEPPING_MODE, model.isInstructionSteppingEnabled());
+ fModel = model;
+ }
+
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ fPreferences.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ fPreferences.removePropertyChangeListener(listener);
+ }
+
+ public boolean supportsInstructionStepping() {
+ return true;
+ }
+
+ public void enableInstructionStepping(boolean enabled) {
+ fPreferences.setValue(PREF_INSTRUCTION_STEPPING_MODE, enabled);
+ fModel.setInstructionSteppingEnabled(enabled);
+ // switch to disassembly or source
+ forceSourceDisplay(DebugUITools.getDebugContext());
+ }
+
+ private void forceSourceDisplay(IAdaptable debugContext) {
+ ISourceDisplay sourceDisplay = (ISourceDisplay) debugContext.getAdapter(ISourceDisplay.class);
+ if (sourceDisplay != null) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page = window.getActivePage();
+ if (page != null) {
+ sourceDisplay.displaySource(debugContext, page, true);
+ }
+ }
+ }
+ }
+
+ public boolean isInstructionSteppingEnabled() {
+ return fPreferences.getBoolean(PREF_INSTRUCTION_STEPPING_MODE);
+ }
+
+}
|