diff options
Diffstat (limited to 'plugins')
2 files changed, 62 insertions, 47 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFSteppingModeTarget.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFSteppingModeTarget.java index 2466901be..4cf479e1a 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFSteppingModeTarget.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/TCFSteppingModeTarget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2011 Wind River Systems, Inc. and others. + * Copyright (c) 2010-2018 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 @@ -12,15 +12,9 @@ package org.eclipse.tcf.internal.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.tcf.internal.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. @@ -28,21 +22,21 @@ import org.eclipse.ui.PlatformUI; @SuppressWarnings("deprecation") public class TCFSteppingModeTarget implements ISteppingModeTarget, ITargetProperties { - private final Preferences fPreferences; - private final TCFModel fModel; + private final Preferences prefs; + private final TCFModel model; public TCFSteppingModeTarget(TCFModel model) { - fPreferences= new Preferences(); - fPreferences.setDefault(PREF_INSTRUCTION_STEPPING_MODE, model.isInstructionSteppingEnabled()); - fModel = model; + prefs= new Preferences(); + prefs.setDefault(PREF_INSTRUCTION_STEPPING_MODE, model.isInstructionSteppingEnabled()); + this.model = model; } public void addPropertyChangeListener(IPropertyChangeListener listener) { - fPreferences.addPropertyChangeListener(listener); + prefs.addPropertyChangeListener(listener); } public void removePropertyChangeListener(IPropertyChangeListener listener) { - fPreferences.removePropertyChangeListener(listener); + prefs.removePropertyChangeListener(listener); } public boolean supportsInstructionStepping() { @@ -50,27 +44,11 @@ public class TCFSteppingModeTarget implements ISteppingModeTarget, ITargetProper } 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); - } - } - } + prefs.setValue(PREF_INSTRUCTION_STEPPING_MODE, enabled); + model.setInstructionSteppingEnabled(enabled); } public boolean isInstructionSteppingEnabled() { - return fPreferences.getBoolean(PREF_INSTRUCTION_STEPPING_MODE); + return prefs.getBoolean(PREF_INSTRUCTION_STEPPING_MODE); } - } 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 d0b53ee20..1d4a34da8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Wind River Systems, Inc. and others. + * Copyright (c) 2007-2018 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 @@ -203,6 +203,11 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab } } + private static final int + DISPLAY_SOURCE_ON_REFRESH = 0, + DISPLAY_SOURCE_ON_SUSPEND = 1, + DISPLAY_SOURCE_ON_STEP_MODE = 2; + private final TCFLaunch launch; private final Display display; private final IExpressionManager expr_manager; @@ -1910,18 +1915,22 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab * The method is normally called from SourceLookupService. */ public void displaySource(Object model_element, final IWorkbenchPage page, boolean forceSourceLookup) { - final Object generation = displaySourceStart(page, wait_for_pc_update_after_step); - /* Because of racing in Eclipse Debug infrastructure, 'model_element' value can be invalid. - * As a workaround, get current debug view selection. - */ if (page != null) { + /* + * Because of racing in Eclipse Debug infrastructure, 'model_element' value can be invalid. + * As a workaround, get current debug view selection. + */ ISelection context = DebugUITools.getDebugContextManager().getContextService(page.getWorkbenchWindow()).getActiveContext(); if (context instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection)context; model_element = selection.isEmpty() ? null : selection.getFirstElement(); } + displaySource(model_element, page, DISPLAY_SOURCE_ON_SUSPEND); } - final Object element = model_element; + } + + private void displaySource(final Object element, final IWorkbenchPage page, final int event) { + final Object generation = displaySourceStart(page, wait_for_pc_update_after_step); Protocol.invokeLater(25, new Runnable() { public void run() { if (!displaySourceCheck(page, generation)) return; @@ -1978,7 +1987,7 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab top_frame = stack_frame.getFrameNo() == 0; ctx_id = stack_frame.parent.id; } - displaySource(generation, page, element, ctx_id, mem_id, top_frame, area); + displaySource(generation, page, element, ctx_id, mem_id, top_frame, area, event); } }); } @@ -2035,7 +2044,8 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab } private void displaySource(final Object generation, final IWorkbenchPage page, - final Object element, final String exe_id, final String mem_id, final boolean top_frame, final ILineNumbers.CodeArea area) { + final Object element, final String exe_id, final String mem_id, final boolean top_frame, + final ILineNumbers.CodeArea area, final int event) { final boolean disassembly_available = channel.getRemoteService(IDisassembly.class) != null; asyncExec(new Runnable() { public void run() { @@ -2071,11 +2081,23 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab } } if (exe_id != null && disassembly_available && - (editor_input == null || editor_id == null || instruction_stepping_enabled) && - PlatformUI.getWorkbench().getEditorRegistry().findEditor( - DisassemblyEditorInput.EDITOR_ID) != null) { - editor_id = DisassemblyEditorInput.EDITOR_ID; - editor_input = DisassemblyEditorInput.INSTANCE; + PlatformUI.getWorkbench().getEditorRegistry().findEditor(DisassemblyEditorInput.EDITOR_ID) != null) { + switch (event) { + case DISPLAY_SOURCE_ON_SUSPEND: + case DISPLAY_SOURCE_ON_REFRESH: + if (instruction_stepping_enabled || editor_input == null || editor_id == null) { + editor_id = DisassemblyEditorInput.EDITOR_ID; + editor_input = DisassemblyEditorInput.INSTANCE; + } + break; + case DISPLAY_SOURCE_ON_STEP_MODE: + if (instruction_stepping_enabled) { + editor_id = DisassemblyEditorInput.EDITOR_ID; + editor_input = DisassemblyEditorInput.INSTANCE; + break; + } + break; + } } if (!displaySourceCheck(page, generation)) return; displaySource(page, editor_id, editor_input, line); @@ -2127,7 +2149,14 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab if (windows == null) return; for (IWorkbenchWindow window : windows) { IWorkbenchPage page = window.getActivePage(); - if (page != null) displaySource(null, page, true); + if (page != null) { + ISelection context = DebugUITools.getDebugContextManager().getContextService(page.getWorkbenchWindow()).getActiveContext(); + if (context instanceof IStructuredSelection) { + IStructuredSelection selection = (IStructuredSelection)context; + Object element = selection.isEmpty() ? null : selection.getFirstElement(); + if (element != null) displaySource(element, page, DISPLAY_SOURCE_ON_REFRESH); + } + } } } }); @@ -2338,6 +2367,14 @@ public class TCFModel implements ITCFModel, IElementContentProvider, IElementLab */ public void setInstructionSteppingEnabled(boolean enabled) { instruction_stepping_enabled = enabled; + TCFNode node = DebugUITools.getDebugContext().getAdapter(TCFNode.class); + if (node != null && node.model == this) { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) displaySource(node, page, DISPLAY_SOURCE_ON_STEP_MODE); + } + } } /** |