diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_debug_bp_filter.png b/doc/org.eclipse.cdt.doc.user/images/cdt_debug_bp_filter.png new file mode 100644 index 00000000000..ce5f16c7392 Binary files /dev/null and b/doc/org.eclipse.cdt.doc.user/images/cdt_debug_bp_filter.png differ diff --git a/doc/org.eclipse.cdt.doc.user/images/cdt_dsfgdb_preferences_page.png b/doc/org.eclipse.cdt.doc.user/images/cdt_dsfgdb_preferences_page.png index 73e67454fb4..0d2ec5e54c0 100644 Binary files a/doc/org.eclipse.cdt.doc.user/images/cdt_dsfgdb_preferences_page.png and b/doc/org.eclipse.cdt.doc.user/images/cdt_dsfgdb_preferences_page.png differ diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_dsfgdb.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_dsfgdb.htm index cf041783ff3..f0e7d035056 100644 --- a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_dsfgdb.htm +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_dsfgdb.htm @@ -79,7 +79,7 @@ specifically when using a GDB (DSF) launcher. - General Behavior + General Behavior Terminate GDB when last process exits @@ -101,6 +101,14 @@ specifically when using a GDB (DSF) launcher. When checked, the Debug view will only show threads that are suspended. When dealing with a large number of threads, this helps focus on the threads being inspected. Obviously, this option is only valuable in non-stop mode, where some threads can run while others are stopped. + + + Use aggressive breakpoint filtering + When checked, the button "Show Breakpoints Supported by Selected Target" + of the Breakpoints view will only show the breakpoints that affect the currently selected C/C++ debug context + (e.g., thread, process). Otherwise, "Show Breakpoints Supported by Selected Target" will show all breakpoints + that are for any C/C++ target.

+ Show Breakpoints Supported by Selected Target button Enable GDB traces @@ -108,7 +116,17 @@ specifically when using a GDB (DSF) launcher. will contain all the gdb/mi activity. Basically, this details the interaction between the CDT debugger and GDB. This information is often critical when the debugger is not behaving as you expect. Include this console output when submitting a bugzilla report against the CDT debugger. It is recommended to keep this setting enabled at - all times, as it does not cause any negative effect. + all times, as it does not cause any negative effect. +

+ Once the number of characters specified by the limit field is reached, older trace lines will be discarded + gradually. This is to avoid these traces consuming too much memory, for very long debug sessions. + + + Display run-time type of variables + When checked, the CDT debugger will show the actual variable type (not the + declared one) in Variables and Expressions views. Not only does this allow to see what is the current run-time + type of a variable, but it allows to access fields that may not be in the base class. + Note that this feature will only work starting with GDB 7.5. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index 0f2dbc62618..d07a96aeb57 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -11,6 +11,7 @@ * Sergey Prigogin (Google) * Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536) * IBM Corporation + * Marc Khouzam (Ericsson) - Add preference for aggressive breakpoint filtering (Bug 360735) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.preferences; @@ -645,6 +646,16 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements // Need to set layout again. group2.setLayout(groupLayout); + boolField= new BooleanFieldEditor( + IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, + MessagesForPreferences.GdbDebugPreferencePage_useAggressiveBpFilter, + group2); + + boolField.fillIntoGrid(group2, 3); + addField(boolField); + // Need to set layout again. + group2.setLayout(groupLayout); + final IntegerWithBooleanFieldEditor enableGdbTracesField = new IntegerWithBooleanFieldEditor( IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index fe43d6cf09c..b4a4cd1b627 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -10,6 +10,7 @@ * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536) * IBM Corporation + * Marc Khouzam (Ericsson) - Add preference for aggressive breakpoint filtering (Bug 360735) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.preferences; @@ -37,6 +38,9 @@ class MessagesForPreferences extends NLS { public static String GdbDebugPreferencePage_useInspectorHover_label; /** @since 2.3 */ public static String GdbDebugPreferencePage_hideRunningThreads; + /** @since 2.4 */ + public static String GdbDebugPreferencePage_useAggressiveBpFilter; + /** @since 2.2 */ public static String GdbDebugPreferencePage_prettyPrinting_label; /** @since 2.2 */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties index 85c62111b46..4c99203d7d6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties @@ -10,6 +10,7 @@ # Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) # Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536) # IBM Corporation +# Marc Khouzam (Ericsson) - Add preference for aggressive breakpoint filtering (Bug 360735) ############################################################################### GdbDebugPreferencePage_Add_button=Add @@ -25,7 +26,7 @@ GdbDebugPreferencePage_Command_timeout=Command timeout (ms): GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover GdbDebugPreferencePage_hideRunningThreads=Show only suspended threads in the Debug View - +GdbDebugPreferencePage_useAggressiveBpFilter=Use aggressive breakpoint filtering GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree GdbDebugPreferencePage_enablePrettyPrinting_label2=(Note: requires python-enabled GDB) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java new file mode 100644 index 00000000000..44de92796ee --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMNode.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints; + +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.BreakpointVMProvider; +import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.RawBreakpointVMNode; +import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; +import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; +import org.eclipse.jface.util.PropertyChangeEvent; + +/** + * BreakpointVMNode for GDB which supports aggressive breakpoint filtering. + * @since 2.4 + */ +public class GdbBreakpointVMNode extends RawBreakpointVMNode { + + public GdbBreakpointVMNode(BreakpointVMProvider provider) { + super(provider); + } + + @Override + public int getDeltaFlags(Object event) { + if (event instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent)event).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { + return IModelDelta.CONTENT; + } + } + + return super.getDeltaFlags(event); + } + + @Override + public void buildDelta(Object event, VMDelta parent, int nodeOffset, RequestMonitor rm) { + if (event instanceof PropertyChangeEvent) { + String property = ((PropertyChangeEvent)event).getProperty(); + if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(property)) { + parent.setFlags(parent.getFlags() | IModelDelta.CONTENT); + rm.done(); + return; + } + } + + super.buildDelta(event, parent, nodeOffset, rm); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java index 734a9b32c31..aaf22db4549 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Wind River Systems and others. + * Copyright (c) 2008, 2012 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 @@ -7,13 +7,19 @@ * * Contributors: * Wind River Systems - initial API and implementation + * Mikhail Khodjaiants (Mentor), Marc Khouzam (Ericsson) + * - Optionally use aggressive breakpoint filtering (Bug 360735) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.RejectedExecutionException; +import org.eclipse.cdt.debug.core.CDebugCorePlugin; +import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; @@ -26,7 +32,7 @@ import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContex import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension; import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext; import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.BreakpointVMProvider; -import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.RawBreakpointVMNode; +import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData; @@ -38,10 +44,14 @@ import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants; import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; @@ -57,14 +67,35 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { final private DsfServicesTracker fServicesTracker; + /** Indicator that we should use aggressive breakpoint filtering */ + private boolean fUseAggressiveBpFilter = false; + + /** PropertyChangeListener to keep track of the PREF_HIDE_RUNNING_THREADS preference */ + private IPropertyChangeListener fPropertyChangeListener = new IPropertyChangeListener() { + @Override + public void propertyChange(final PropertyChangeEvent event) { + if (IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER.equals(event.getProperty())) { + fUseAggressiveBpFilter = (Boolean)event.getNewValue(); + // Set the property in the presentation context so it can be seen by the vmnode which + // will refresh the view + getPresentationContext().setProperty(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, fUseAggressiveBpFilter); + } + } + }; + public GdbBreakpointVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) { super(adapter, presentationContext); fSession = session; fServicesTracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); - } + + IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); + store.addPropertyChangeListener(fPropertyChangeListener); + fUseAggressiveBpFilter = store.getBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER); + } @Override public void dispose() { + GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); fServicesTracker.dispose(); super.dispose(); } @@ -72,6 +103,8 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { @Override protected void calcFileteredBreakpoints( final DataRequestMonitor rm ) { if ( Boolean.TRUE.equals( getPresentationContext().getProperty( IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION ) ) ) { + if (fUseAggressiveBpFilter) { + // Aggressive filtering of breakpoints. Only return bps that are installed on the target. IBreakpointsTargetDMContext bpContext = null; IMIExecutionDMContext threadContext = null; ISelection debugContext = getDebugContext(); @@ -88,13 +121,24 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_HANDLE, - "Debug context doesn't contain a thread", //$NON-NLS-1$ + "Debug context doesn't contain a breakpoint context", //$NON-NLS-1$ null ) ); rm.done(); return; } getInstalledBreakpoints( bpContext, threadContext, rm ); + } else { + // Original behavior of bp filtering. Return all bp of type ICBreakpoint + IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(); + List filteredBPs = new ArrayList(allBreakpoints.length); + for (IBreakpoint bp : allBreakpoints) { + if (bp instanceof ICBreakpoint && bp.getModelIdentifier().equals(CDebugCorePlugin.PLUGIN_ID)) { + filteredBPs.add(bp); + } + } + rm.done( filteredBPs.toArray(new IBreakpoint[filteredBPs.size()]) ); + } } else { super.calcFileteredBreakpoints( rm ); @@ -103,7 +147,7 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { @Override protected IVMNode createBreakpointVMNode() { - return new RawBreakpointVMNode(this); + return new GdbBreakpointVMNode(this); } @Override @@ -181,6 +225,7 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { try { fSession.getExecutor().execute( new DsfRunnable() { + @Override public void run() { final IBreakpointsExtension bpService = fServicesTracker.getService( IBreakpointsExtension.class ); if ( bpService == null ) { @@ -201,14 +246,14 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { rm.setStatus( new Status( IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, - "Breakpoints service not available", //$NON-NLS-1$ + "Breakpoint manager service not available", //$NON-NLS-1$ null ) ); rm.done(); return; } if ( getData().length > 0 ) { - final List bps = new ArrayList( getData().length ); + final Set bps = new HashSet( getData().length ); final CountingRequestMonitor crm = new CountingRequestMonitor( ImmediateExecutor.getInstance(), rm ) { @Override @@ -236,8 +281,8 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { if ( bp != null ) bps.add( bp ); } - crm.done(); - } + } + crm.done(); } } ); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java index eb8ac629006..d4870fd785c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java @@ -10,6 +10,7 @@ * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Sergey Prigogin (Google) * Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536) + * Marc Khouzam (Ericsson) - Add preference for aggressive breakpoint filtering (Bug 360735) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb; @@ -131,5 +132,19 @@ public interface IGdbDebugPreferenceConstants { * @since 4.1 */ public static final String PREF_HIDE_RUNNING_THREADS = PREFIX + "hideRunningThreads"; //$NON-NLS-1$ + + /** + * Boolean preference whether to use the new behavior of the command + * "Show Breakpoints Supported by Selected Target" from the Breakpoints view. + * The original behavior is to only show breakpoints that apply to the current debug + * session; so all C/C++ breakpoints but not Java ones. + * The new behavior is to only show breakpoints that are actually installed in the current + * debug session. + * + * Default is true. + * + * @since 4.2 + */ + public static final String PREF_AGGRESSIVE_BP_FILTER = PREFIX + "aggressiveBpFilter"; //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java index 054ea1edb48..07b0b858e76 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbPreferenceInitializer.java @@ -11,6 +11,7 @@ * Sergey Prigogin (Google) * Marc Khouzam (Ericsson) - Move to org.eclipse.cdt.dsf.gdb from UI plugin (bug 348159) * Anton Gorenkov - A preference to use RTTI for variable types determination (Bug 377536) + * Marc Khouzam (Ericsson) - Add preference for aggressive breakpoint filtering (Bug 360735) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.internal; @@ -43,5 +44,6 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer { node.putBoolean(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false); node.putInt(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT); node.putBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, false); + node.putBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, true); } }