1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 464917: Add Line Breakpoint dialog and Breakpoints view menu item

line_brkpt_co.gif is edited version of function_brkpt_co.gif

Change-Id: Ifb74e86e1033a11e319c643f9ba1a7034a983173
Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
Jonah Graham 2015-05-22 21:17:45 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent e4dd059af0
commit 8328943db8
9 changed files with 277 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2012 QNX Software Systems and others.
# Copyright (c) 2000, 2015 QNX Software 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
@ -14,6 +14,7 @@
# Marc Dumais (Ericsson) - Added support for reverse debug action (Bug 365776)
# Alvaro Sanchez-Leon (Ericsson AB) - Support for Step into selection (bug 244865)
# Marc Khouzam (Ericsson) - Added dynamic printf support (Bug 400628)
# Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
###############################################################################
pluginName=C/C++ Development Tools Debugger UI
@ -66,6 +67,8 @@ AddEventBreakpoint.label=Add Event Breakpoint (C/C++)...
AddEventBreakpoint.tooltip=Add Event Breakpoint (C/C++)
AddFunctionBreakpoint.label=Add Function Breakpoint (C/C++)...
AddFunctionBreakpoint.tooltip=Add Function Breakpoint (C/C++)
AddLineBreakpoint.label=Add Line Breakpoint (C/C++)...
AddLineBreakpoint.tooltip=Add Line Breakpoint (C/C++)
AddGlobalsAction.label=Add Global Variables...
AddGlobalsAction.tooltip=Add Global Variables

View file

@ -933,6 +933,15 @@
style="push"
helpContextId="add_function_breakpoint_action_context"
tooltip="%AddFunctionBreakpoint.tooltip"/>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddLineBreakpointActionDelegate"
icon="icons/elcl16/line_brkpt_co.gif"
id="org.eclipse.cdt.debug.ui.addLineBreakpoint"
label="%AddLineBreakpoint.label"
menubarPath="cDebugActions"
style="push"
helpContextId="add_line_breakpoint_action_context"
tooltip="%AddLineBreakpoint.tooltip"/>
</viewContribution>
<viewContribution
targetID="org.eclipse.debug.ui.VariableView"

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2003, 2014 QNX Software Systems and others.
# Copyright (c) 2003, 2015 QNX Software 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
@ -12,6 +12,7 @@
# Simon Marchi (Ericsson) - Modified error messages in CastToArrayActionDelegate (437182)
# Marc Dumais (Ericsson) - Bug 437692
# Alvaro Sanchez-Leon (Ericsson) - Allow user to edit the register groups (Bug 235747)
# Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
###############################################################################
LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library.
@ -90,6 +91,7 @@ CastToArrayActionDelegate.8=Unable to display this variable as an array.
EnableVariablesActionDelegate.0=Exceptions occurred enabling the variable(s).
EnableVariablesActionDelegate.1=Enable variable(s) failed.
AddFunctionBreakpointActionDelegate.0=Cannot add function breakpoint.
AddLineBreakpointActionDelegate.0=Cannot add line breakpoint.
AddWatchpointActionDelegate.0=Cannot add watchpoint.
AddWatchpointDialog.0=Add Watchpoint
AddWatchpointDialog.1=Expression to watch:

View file

@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2004, 2015 QNX Software 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
* Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* A delegate for the "Add Line Breakpoint" action.
* <p>
* Initially derived from AddFunctionBreakpointActionDelegate
*/
public class AddLineBreakpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
private IViewPart fView;
private ISelection fSelection;
private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
@Override
public void init( IViewPart view ) {
setView( view );
}
private void setView(IViewPart view) {
fView = view;
}
protected IViewPart getView() {
return fView;
}
@Override
public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run( IAction action ) {
IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection);
IToggleBreakpointsTargetCExtension cToggleTarget = null;
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget;
} else {
cToggleTarget = fDefaultToggleTarget;
}
try {
cToggleTarget.createLineBreakpointsInteractive(fView, fSelection);
} catch (CoreException e) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddLineBreakpointActionDelegate.0" ), e ); //$NON-NLS-1$
}
}
}

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2003, 2014 QNX Software Systems and others.
# Copyright (c) 2003, 2015 QNX Software 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
@ -10,9 +10,12 @@
# Nokia - https://bugs.eclipse.org/bugs/show_bug.cgi?id=145606
# IBM Corporation
# Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
# Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
###############################################################################
CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer
CBreakpointPropertyPage.file_system_button=File S&ystem...
CBreakpointPropertyPage.fileName_errorMessage=Enter a file name:
CBreakpointPropertyPage.function_valueNotAvailable_label=Not available
CBreakpointPropertyPage.function_label=Function name:
CBreakpointPropertyPage.function_value_errorMessage=Enter a function expression:
@ -22,6 +25,7 @@ CBreakpointPropertyPage.address_label=Address:
CBreakpointPropertyPage.breakpointType_address_label=C/C++ Address Breakpoint
CBreakpointPropertyPage.sourceHandle_label=File:
CBreakpointPropertyPage.breakpointType_line_label=C/C++ Line Breakpoint
CBreakpointPropertyPage.lineNumber_errorMessage=Enter a line number greater than 0
CBreakpointPropertyPage.lineNumber_label=Line number:
CBreakpointPropertyPage.breakpointType_event_label=C/C++ Event Breakpoint
CBreakpointPropertyPage.project_label=Project:
@ -34,6 +38,7 @@ CBreakpointPropertyPage.watchpoint_expression_label=Expression to watch:
CBreakpointPropertyPage.watchpoint_expression_errorMessage=Enter the expression to watch:
CBreakpointPropertyPage.watchpoint_range_label=Range:
CBreakpointPropertyPage.watchpoint_memorySpace_label=Memory Space:
CBreakpointPropertyPage.workspace_button=W&orkspace...
CBreakpointPropertyPage.condition_label=&Condition:
CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition.
CBreakpointPropertyPage.ignoreCount_label=&Ignore count:

View file

@ -11,9 +11,11 @@
* Marc Khouzam (Ericsson) - Added support for Tracepoints (bug 376116)
* Marc Khouzam (Ericsson) - Added support for Dynamic-Printf (bug 400628)
* Jonah Graham - Set REQUESTED_* fields when creating from dialog (bug 46026)
* Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.breakpoints;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -29,13 +31,17 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICDynamicPrintf;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
@ -101,14 +107,59 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
ICBreakpoint bp = fContext.getBreakpoint();
if (bp.getMarker() != null && fIsDirty) {
saveToExistingMarker(bp, bp.getMarker());
}
else if (fContext.getResource() != null){
saveToNewMarker(bp, fContext.getResource());
} else {
throw new IOException("Unable to create breakpoint: no resource specified."); //$NON-NLS-1$
IResource resolved = getResource(fContext.getResource());
if (resolved != null) {
saveToNewMarker(bp, resolved);
} else {
throw new IOException("Unable to create breakpoint: no resource specified."); //$NON-NLS-1$
}
}
}
}
/**
* Get the resource to apply the marker against. This may not be the same
* resource the dialog was created for if the user has selected a different
* resource.
* <p>
* If the {@link ICBreakpoint#SOURCE_HANDLE} resolves to the same file on
* the filesystem as the preferred resource the preferred resource is used.
*
* @param preferred
* resource to use if it matches the SOURCE_HANDLE
* @return Resource to install marker on, or <code>null</code> for not
* available.
*/
private IResource getResource(IResource preferred) {
IResource resolved = null;
String source = getString(ICBreakpoint.SOURCE_HANDLE);
if (!"".equals(source)) { //$NON-NLS-1$
IPath rawLocation = preferred.getRawLocation();
if (rawLocation != null) {
File file = rawLocation.toFile();
File sourceFile = new File(source);
if (file.getAbsoluteFile().equals(sourceFile.getAbsoluteFile())) {
resolved = preferred;
}
}
if (resolved == null) {
IPath path = Path.fromOSString(source);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = root.getFileForLocation(path);
if (file == null) {
resolved = root;
} else {
resolved = file;
}
}
}
if (resolved == null) {
resolved = preferred;
}
return resolved;
}
private void saveToExistingMarker(final ICBreakpoint breakpoint, final IMarker marker) throws IOException {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2012 QNX Software Systems and others.
* Copyright (c) 2004, 2015 QNX Software 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
@ -10,6 +10,7 @@
* Nokia - https://bugs.eclipse.org/bugs/show_bug.cgi?id=145606
* QNX Software Systems - Catchpoints support https://bugs.eclipse.org/bugs/show_bug.cgi?id=226689
* Scott Tepavich (WindRiver) - Fixed bad reference to messages.properties string (Bug 393178)
* Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.breakpoints;
@ -34,11 +35,15 @@ import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution;
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
@ -54,18 +59,22 @@ import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchPropertyPage;
import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
import org.eclipse.ui.model.IWorkbenchAdapter;
/**
@ -196,6 +205,78 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
}
}
class BreakpointFileNameFieldEditor extends BreakpointStringFieldEditor {
private Composite composite;
public BreakpointFileNameFieldEditor(String name, String labelText, Composite parent) {
super(name, labelText, parent);
}
@Override
protected void adjustForNumColumns(int numColumns) {
super.adjustForNumColumns(numColumns);
((GridData) composite.getLayoutData()).horizontalSpan = numColumns;
}
@Override
protected void doFillIntoGrid(Composite parent, int numColumns) {
super.doFillIntoGrid(parent, numColumns);
composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(getNumberOfControls(), 1).align(SWT.END, SWT.FILL).create());
composite.setLayout(new FillLayout());
Button browseWorkspace = new Button(composite, SWT.PUSH);
browseWorkspace.setText(BreakpointsMessages.getString("CBreakpointPropertyPage.workspace_button")); //$NON-NLS-1$
browseWorkspace.setFont(parent.getFont());
browseWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
FilteredResourcesSelectionDialog dialog = new FilteredResourcesSelectionDialog(getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE);
String text = getTextControl().getText();
IPath path = Path.fromOSString(text);
String filename;
if (path.segmentCount() > 0) {
filename = path.segment(path.segmentCount() - 1);
} else {
filename = "*.c"; //$NON-NLS-1$
}
dialog.setInitialPattern(filename);
if (dialog.open() == Window.OK) {
Object[] result = dialog.getResult();
if (result.length == 0)
return;
if (result[0] instanceof IFile) {
IFile file = (IFile) result[0];
IPath location = file.getRawLocation();
if (location != null) {
String newValue = location.makeAbsolute().toOSString();
setStringValue(newValue);
}
}
}
}
});
Button browseFileSystem = new Button(composite, SWT.PUSH);
browseFileSystem.setText(BreakpointsMessages.getString("CBreakpointPropertyPage.file_system_button")); //$NON-NLS-1$
browseFileSystem.setFont(parent.getFont());
browseFileSystem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.SHEET);
dialog.setFileName(getTextControl().getText());
String newValue = dialog.open();
if (newValue != null) {
setStringValue(newValue);
}
}
});
}
}
class WatchpointRangeFieldEditor extends IntegerFieldEditor {
private static final String DISABLED_VALUE = "0"; //$NON-NLS-1$
@ -542,15 +623,7 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
}
else if ( breakpoint instanceof ILineBreakpoint ) {
String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
if ( fileName != null ) {
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), fileName ) ); //$NON-NLS-1$
}
int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER);
if (lNumber > 0) {
getPreferenceStore().setValue( IMarker.LINE_NUMBER, lNumber);
createLineNumberEditor(getFieldEditorParent());
}
createFileLineNumberEditor(getFieldEditorParent());
}
else if ( breakpoint instanceof CEventBreakpoint ) {
createEventBreakpointEditor( breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
@ -596,13 +669,44 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
function = BreakpointsMessages.getString( "CBreakpointPropertyPage.function_valueNotAvailable_label" ); //$NON-NLS-1$
}
addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.function_label" ), function ) ); //$NON-NLS-1$
}
}
}
}
protected void createFileLineNumberEditor( Composite parent ) {
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ); //$NON-NLS-1$
ICBreakpoint breakpoint = getBreakpoint();
boolean isNewBreakpoint = breakpoint == null || breakpoint.getMarker() == null;
String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
boolean isFilenameEditable = fileName != null && fileName.isEmpty();
if (isNewBreakpoint && isFilenameEditable) {
BreakpointFileNameFieldEditor fileNameEditor = new BreakpointFileNameFieldEditor(
ICLineBreakpoint.SOURCE_HANDLE, title, parent);
fileNameEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.fileName_errorMessage")); //$NON-NLS-1$
fileNameEditor.setEmptyStringAllowed(false);
addField(fileNameEditor);
} else {
if (fileName != null) {
addField(createLabelEditor(parent, title, fileName));
}
}
int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER);
if (lNumber > 0 || isNewBreakpoint) {
if (lNumber < 1) {
lNumber = 1;
}
getPreferenceStore().setValue(IMarker.LINE_NUMBER, lNumber);
createLineNumberEditor(parent);
}
}
protected void createLineNumberEditor( Composite parent ) {
String title = BreakpointsMessages.getString( "CBreakpointPropertyPage.lineNumber_label" ); //$NON-NLS-1$
BreakpointIntegerFieldEditor labelFieldEditor =new BreakpointIntegerFieldEditor( IMarker.LINE_NUMBER ,title, parent);
labelFieldEditor.setValidRange( 1, Integer.MAX_VALUE );
labelFieldEditor.setErrorMessage(BreakpointsMessages.getString("CBreakpointPropertyPage.lineNumber_errorMessage")); //$NON-NLS-1$
addField( labelFieldEditor );
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2014 Mentor Graphics and others.
* Copyright (c) 2011, 2015 Mentor Graphics 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
@ -9,6 +9,7 @@
* Mentor Graphics - Initial API and implementation
* Marc Khouzam (Ericsson) - Don't allow to set two bps at same line (bug 432503)
* Teodor Madan (Freescale) - Do not create multiple watchpoints /method breakpoints at same location ( 445375 )
* Jonah Graham (Kichwa Coders) - Create "Add Line Breakpoint (C/C++)" action (Bug 464917)
*******************************************************************************/
package org.eclipse.cdt.debug.ui.breakpoints;
@ -364,6 +365,9 @@ abstract public class AbstractToggleBreakpointAdapter
}
}
}
} else if (interactive && !toggle) {
createLineBreakpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1);
return;
} else {
errorMessage = ActionMessages.getString("RunToLineAdapter.Operation_is_not_supported_1"); //$NON-NLS-1$
}