Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.java4
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.properties5
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/sourcelookup/DsfSourceSelectionResolver.java226
3 files changed, 233 insertions, 2 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.java
index f28a4ab53a..0761ffcf44 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2013 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
@@ -8,6 +8,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
* Patrick Chuong (Texas Instruments) - Bug 315446: Invalid event breakpoint type (group) name
+ * Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui;
@@ -16,6 +17,7 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
public static String ToggleBreakpointsTargetFactory_description;
public static String ToggleBreakpointsTargetFactory_name;
+ public static String DsfUIStepIntoEditorSelection;
static {
// initialize resource bundle
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.properties
index 1faea82e17..37451dbd58 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.properties
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2009, 2010 Wind River Systems and others.
+# Copyright (c) 2009, 2013 Wind River Systems 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
@@ -8,7 +8,10 @@
# Contributors:
# Wind River Systems - initial API and implementation
# Ericsson - added Tracepoint support
+# Ericsson - added Step into selection support
###############################################################################
ToggleBreakpointsTargetFactory_description=Standard C/C++ breakpoint type.
ToggleBreakpointsTargetFactory_name=C/C++ Breakpoints
+
+DsfUIStepIntoEditorSelection=Step Into
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/sourcelookup/DsfSourceSelectionResolver.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/sourcelookup/DsfSourceSelectionResolver.java
new file mode 100644
index 0000000000..aa1f5ab065
--- /dev/null
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/sourcelookup/DsfSourceSelectionResolver.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson AB 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:
+ * Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.internal.ui.sourcelookup;
+
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
+import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.SelectionToDeclarationJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class DsfSourceSelectionResolver implements Runnable {
+ private ITextEditor fEditorPage = null;
+ private ITextSelection fSelection = null;
+ private LineLocation fLineLocation = new LineLocation();
+ private IFunctionDeclaration fFunction = null;
+ private boolean fSuccessful = false;
+
+ public class LineLocation {
+ private String fileName = null;
+ private int lineNumber = 0;
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ public void setLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+ }
+
+ private interface ResolveEditorRunnable extends Runnable {
+ TextEditor getEditor();
+ }
+
+ public DsfSourceSelectionResolver() {
+
+ }
+
+ public DsfSourceSelectionResolver(ITextEditor editor, ITextSelection selection) {
+ fEditorPage = editor;
+ fSelection = selection;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.internal.ui.sourcelookup.IDsfSourceSelectionResolver#run()
+ */
+ @Override
+ public void run() {
+ fEditorPage = resolveEditor();
+ if (fEditorPage != null) {
+ ITextSelection selection = resolveSelection();
+ if (selection != null) {
+ IFunctionDeclaration[] selectedFunctions = resolveSelectedFunction(selection);
+
+ IFunctionDeclaration selFunction = null;
+ if (selectedFunctions == null || selectedFunctions.length != 1 || selectedFunctions[0] == null) {
+ //Unable to resolve selection to a function
+ return;
+ } else {
+ // Continue as expected
+ selFunction = selectedFunctions[0];
+ }
+
+ LineLocation selectedLine = resolveSelectedLine();
+ if (selectedLine == null) {
+ // Unable to resolve the selected line
+ return;
+ }
+
+ fLineLocation = selectedLine;
+ fFunction = selFunction;
+ fSuccessful = true;
+ }
+ }
+ }
+
+ public ITextEditor resolveEditor() {
+ if (fEditorPage != null) {
+ return fEditorPage;
+ }
+
+ final IWorkbench wb = DsfUIPlugin.getDefault().getWorkbench();
+ // Run in UI thread to access UI resources
+ ResolveEditorRunnable reditorRunnable = new ResolveEditorRunnable() {
+ TextEditor result = null;
+
+ @Override
+ public void run() {
+ IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
+ if (win == null || win.getActivePage() == null || win.getActivePage().getActiveEditor() == null) {
+ result = null;
+ } else {
+ IEditorPart editorPart = win.getActivePage().getActiveEditor();
+ if (editorPart instanceof CEditor) {
+ result = (TextEditor) win.getActivePage().getActiveEditor();
+ }
+ }
+ }
+
+ @Override
+ public TextEditor getEditor() {
+ return result;
+ }
+ };
+
+ Display.getDefault().syncExec(reditorRunnable);
+ return reditorRunnable.getEditor();
+ }
+
+ private LineLocation resolveSelectedLine() {
+ String errorMessage = ""; //$NON-NLS-1$
+ IEditorInput input = fEditorPage.getEditorInput();
+ if (input == null) {
+ errorMessage = "Invalid Editor input on selection"; //$NON-NLS-1$
+ } else {
+ IDocument document = fEditorPage.getDocumentProvider().getDocument(input);
+ if (document == null) {
+ errorMessage = "Invalid Editor Document input on selection"; //$NON-NLS-1$
+ } else {
+ ITextSelection selection = resolveSelection();
+ if (selection == null) {
+ errorMessage = "Invalid selection. Only textual selections are supported"; //$NON-NLS-1$
+ } else {
+ String fileName = null;
+ try {
+ fileName = CDebugUIUtils.getEditorFilePath(input);
+ } catch (CoreException e) {
+ // unable to resolve the path
+ DsfUIPlugin.log(e);
+ return null;
+ }
+
+ if (fileName == null) {
+ errorMessage = "Unable to resolve fileName from selection"; //$NON-NLS-1$
+ DsfUIPlugin.logErrorMessage(errorMessage);
+ } else {
+ // Resolve the values
+ LineLocation lineLocation = new LineLocation();
+
+ lineLocation.setFileName(fileName);
+ lineLocation.setLineNumber(selection.getStartLine() + 1);
+ return lineLocation;
+ }
+ }
+ }
+ }
+
+ DsfUIPlugin.logErrorMessage(errorMessage);
+ return null;
+ }
+
+ public ITextSelection resolveSelection() {
+ if (fSelection != null) {
+ //Value received at construction time
+ return fSelection;
+ }
+
+ ISelection selection = fEditorPage.getEditorSite().getSelectionProvider().getSelection();
+ if (selection instanceof ITextSelection) {
+ return (ITextSelection) selection;
+ }
+
+ return null;
+ }
+
+ private IFunctionDeclaration[] resolveSelectedFunction(ITextSelection textSelection) {
+ if (textSelection != null) {
+ SelectionToDeclarationJob job;
+ try {
+ job = new SelectionToDeclarationJob(fEditorPage, textSelection);
+ job.schedule();
+ job.join();
+ } catch (CoreException e1) {
+ DsfUIPlugin.log(e1);
+ return null;
+ } catch (InterruptedException e) {
+ DsfUIPlugin.log(e);
+ return null;
+ }
+
+ //fetch the result
+ return job.getSelectedFunctions();
+ }
+
+ return null;
+ }
+
+ public LineLocation getLineLocation() {
+ return fLineLocation;
+ }
+
+ public IFunctionDeclaration getFunction() {
+ return fFunction;
+ }
+
+ public boolean isSuccessful() {
+ return fSuccessful;
+ }
+}

Back to the top