1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 375585: Add an option to not show running threads

Change-Id: If4525512ae1464455a49b13f3f0b822f93f72eb6
Reviewed-on: https://git.eclipse.org/r/5782
Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
Marc Khouzam 2012-05-04 12:58:45 -04:00
parent 27d49dfd54
commit 5d74bf2eaf
11 changed files with 275 additions and 47 deletions

View file

@ -624,11 +624,41 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
group1.setLayout(groupLayout); group1.setLayout(groupLayout);
final Group group2= new Group(parent, SWT.NONE); final Group group2= new Group(parent, SWT.NONE);
group2.setText(MessagesForPreferences.GdbDebugPreferencePage_traces_label); group2.setText(MessagesForPreferences.GdbDebugPreferencePage_general_behavior_label);
groupLayout= new GridLayout(3, false); groupLayout= new GridLayout(3, false);
group2.setLayout(groupLayout); group2.setLayout(groupLayout);
group2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); group2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
BooleanFieldEditor boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label,
group2);
boolField.fillIntoGrid(group2, 3);
addField(boolField);
// Need to set layout again.
group2.setLayout(groupLayout);
boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER,
MessagesForPreferences.GdbDebugPreferencePage_useInspectorHover_label,
group2);
boolField.fillIntoGrid(group2, 3);
addField(boolField);
// need to set layout again
group2.setLayout(groupLayout);
boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS,
MessagesForPreferences.GdbDebugPreferencePage_hideRunningThreads,
group2);
boolField.fillIntoGrid(group2, 3);
addField(boolField);
// Need to set layout again.
group2.setLayout(groupLayout);
final ListenableBooleanFieldEditor enableGdbTracesField = new ListenableBooleanFieldEditor( final ListenableBooleanFieldEditor enableGdbTracesField = new ListenableBooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
@ -659,39 +689,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
// Need to set layout again. // Need to set layout again.
group2.setLayout(groupLayout); group2.setLayout(groupLayout);
Group group= new Group(parent, SWT.NONE); Group group = new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_termination_label);
groupLayout= new GridLayout(3, false);
group.setLayout(groupLayout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
BooleanFieldEditor boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label,
group);
boolField.fillIntoGrid(group, 3);
addField(boolField);
// Need to set layout again.
group.setLayout(groupLayout);
group= new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_hover_label);
groupLayout= new GridLayout(3, false);
group.setLayout(groupLayout);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
boolField= new BooleanFieldEditor(
IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER,
MessagesForPreferences.GdbDebugPreferencePage_useInspectorHover_label,
group);
boolField.fillIntoGrid(group, 3);
addField(boolField);
// need to set layout again
group.setLayout(groupLayout);
group = new Group(parent, SWT.NONE);
group.setText(MessagesForPreferences.GdbDebugPreferencePage_prettyPrinting_label); group.setText(MessagesForPreferences.GdbDebugPreferencePage_prettyPrinting_label);
groupLayout = new GridLayout(3, false); groupLayout = new GridLayout(3, false);
group.setLayout(groupLayout); group.setLayout(groupLayout);

View file

@ -25,17 +25,18 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip; public static String GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip;
public static String GdbDebugPreferencePage_Advanced_Timeout_Settings; public static String GdbDebugPreferencePage_Advanced_Timeout_Settings;
public static String GdbDebugPreferencePage_description; public static String GdbDebugPreferencePage_description;
public static String GdbDebugPreferencePage_traces_label; /** @since 2.3 */
public static String GdbDebugPreferencePage_general_behavior_label;
public static String GdbDebugPreferencePage_enableTraces_label; public static String GdbDebugPreferencePage_enableTraces_label;
/** @since 2.2 */ /** @since 2.2 */
public static String GdbDebugPreferencePage_maxGdbTraces_label; public static String GdbDebugPreferencePage_maxGdbTraces_label;
public static String GdbDebugPreferencePage_termination_label;
public static String GdbDebugPreferencePage_autoTerminateGdb_label; public static String GdbDebugPreferencePage_autoTerminateGdb_label;
public static String GdbDebugPreferencePage_Command_column_name; public static String GdbDebugPreferencePage_Command_column_name;
public static String GdbDebugPreferencePage_Command_field_can_not_be_empty; public static String GdbDebugPreferencePage_Command_field_can_not_be_empty;
public static String GdbDebugPreferencePage_Command_timeout; public static String GdbDebugPreferencePage_Command_timeout;
public static String GdbDebugPreferencePage_hover_label;
public static String GdbDebugPreferencePage_useInspectorHover_label; public static String GdbDebugPreferencePage_useInspectorHover_label;
/** @since 2.3 */
public static String GdbDebugPreferencePage_hideRunningThreads;
/** @since 2.2 */ /** @since 2.2 */
public static String GdbDebugPreferencePage_prettyPrinting_label; public static String GdbDebugPreferencePage_prettyPrinting_label;
/** @since 2.2 */ /** @since 2.2 */
@ -56,6 +57,8 @@ class MessagesForPreferences extends NLS {
public static String GdbDebugPreferencePage_use_rtti_label1; public static String GdbDebugPreferencePage_use_rtti_label1;
/** @since 2.3 */ /** @since 2.3 */
public static String GdbDebugPreferencePage_use_rtti_label2; public static String GdbDebugPreferencePage_use_rtti_label2;
static { static {
// initialize resource bundle // initialize resource bundle
NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class); NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);

View file

@ -14,18 +14,18 @@
GdbDebugPreferencePage_Add_button=Add GdbDebugPreferencePage_Add_button=Add
GdbDebugPreferencePage_description=General settings for GDB Debugging GdbDebugPreferencePage_description=General settings for GDB Debugging
GdbDebugPreferencePage_traces_label=Traces GdbDebugPreferencePage_general_behavior_label=General Behavior
GdbDebugPreferencePage_enableTraces_label=Enable GDB traces GdbDebugPreferencePage_enableTraces_label=Enable GDB traces
GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters): GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (number of characters):
GdbDebugPreferencePage_termination_label=Termination
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
GdbDebugPreferencePage_Command_column_name=GDB/MI Command GdbDebugPreferencePage_Command_column_name=GDB/MI Command
GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
GdbDebugPreferencePage_Command_timeout=Command timeout (ms): GdbDebugPreferencePage_Command_timeout=Command timeout (ms):
GdbDebugPreferencePage_hover_label=Debug Text Hover
GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover GdbDebugPreferencePage_useInspectorHover_label=Use enhanced debug hover
GdbDebugPreferencePage_hideRunningThreads=Show only suspended threads in the Debug View
GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing GdbDebugPreferencePage_prettyPrinting_label=Pretty Printing
GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree GdbDebugPreferencePage_enablePrettyPrinting_label1=Enable pretty printers in variable/expression tree
GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB) GdbDebugPreferencePage_enablePrettyPrinting_label2=(requires python-enabled GDB)
@ -46,3 +46,4 @@ GdbDebugPreferencePage_Advanced_timeout_dialog_message=Specify commands and corr
GdbDebugPreferencePage_Advanced_timeout_dialog_title=Add/delete/modify custom timeouts for GDB/MI commands GdbDebugPreferencePage_Advanced_timeout_dialog_title=Add/delete/modify custom timeouts for GDB/MI commands
GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip=Specify commands and corresponding timeout values, use zero for "no timeout".\nMI commands must start with hyphen ('-'). For example, '-target-select'.\nThe default value will be used for all commands that are not mentioned here. GdbDebugPreferencePage_Advanced_timeout_settings_dialog_tooltip=Specify commands and corresponding timeout values, use zero for "no timeout".\nMI commands must start with hyphen ('-'). For example, '-target-select'.\nThe default value will be used for all commands that are not mentioned here.
GdbDebugPreferencePage_Advanced_Timeout_Settings=Advanced Timeout Settings GdbDebugPreferencePage_Advanced_Timeout_Settings=Advanced Timeout Settings

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2010 Ericsson and others. * Copyright (c) 2006, 2012 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -27,13 +27,17 @@ import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses; import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext; import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlShutdownDMEvent;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractContainerVMNode;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
@ -59,6 +63,9 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRe
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IMemento; import org.eclipse.ui.IMemento;
@ -66,10 +73,33 @@ import org.eclipse.ui.IMemento;
public class ContainerVMNode extends AbstractContainerVMNode public class ContainerVMNode extends AbstractContainerVMNode
implements IElementLabelProvider, IElementMementoProvider implements IElementLabelProvider, IElementMementoProvider
{ {
/** Indicator that we should not display running threads */
private boolean fHideRunningThreadsProperty = false;
/** PropertyChangeListener to keep track of the PREF_HIDE_RUNNING_THREADS preference */
private IPropertyChangeListener fPropertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS)) {
fHideRunningThreadsProperty = (Boolean)event.getNewValue();
}
}
};
public ContainerVMNode(AbstractDMVMProvider provider, DsfSession session) { public ContainerVMNode(AbstractDMVMProvider provider, DsfSession session) {
super(provider, session); super(provider, session);
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
store.addPropertyChangeListener(fPropertyChangeListener);
fHideRunningThreadsProperty = store.getBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS);
} }
@Override
public void dispose() {
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
super.dispose();
}
@Override @Override
public String toString() { public String toString() {
return "ContainerVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ return "ContainerVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
@ -90,7 +120,9 @@ public class ContainerVMNode extends AbstractContainerVMNode
ExecutionContextLabelText.PROP_ID_KNOWN, ExecutionContextLabelText.PROP_ID_KNOWN,
ILaunchVMConstants.PROP_ID, ILaunchVMConstants.PROP_ID,
IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN, IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN,
IGdbLaunchVMConstants.PROP_CORES_ID }), IGdbLaunchVMConstants.PROP_CORES_ID,
IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN,
IGdbLaunchVMConstants.PROP_THREAD_SUMMARY }),
new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]), new LabelText(MessagesForGdbLaunchVM.ContainerVMNode_No_columns__Error__label, new String[0]),
/* RUNNING CONTAINER - RED PIN */ /* RUNNING CONTAINER - RED PIN */
@ -276,6 +308,11 @@ public class ContainerVMNode extends AbstractContainerVMNode
} }
} }
if (update.getProperties().contains(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY)) {
fillThreadSummary(update, countringRm);
count++;
}
countringRm.setDoneCount(count); countringRm.setDoneCount(count);
} }
@ -302,6 +339,51 @@ public class ContainerVMNode extends AbstractContainerVMNode
update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr); update.setProperty(IGdbLaunchVMConstants.PROP_CORES_ID, coresStr);
} }
protected void fillThreadSummary(final IPropertiesUpdate update, final RequestMonitor rm) {
if (!fHideRunningThreadsProperty) {
// Disable the thread summary when we are not hiding threads
update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY, null);
rm.done();
return;
}
IProcesses processService = getServicesTracker().getService(IProcesses.class);
final IContainerDMContext procDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IContainerDMContext.class);
if (processService == null || procDmc == null) {
update.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.INVALID_HANDLE, "Service or handle invalid", null)); //$NON-NLS-1$
} else {
// Fetch all the threads
processService.getProcessesBeingDebugged(
procDmc,
new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update) {
@Override
public void handleCompleted() {
IRunControl runControl = getServicesTracker().getService(IRunControl.class);
if (!isSuccess() ||
!(getData() instanceof IExecutionDMContext[]) ||
runControl == null) {
update.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.INVALID_HANDLE, "Unable to get threads summary", null)); //$NON-NLS-1$
rm.done();
return;
}
// For each thread, count how many are running and therefore hidden
// Remove running threads from the list
int runningCount = 0;
for (IExecutionDMContext execDmc : (IExecutionDMContext[])getData()) {
// Keep suspended or stepping threads
if (!runControl.isSuspended(execDmc) && !runControl.isStepping(execDmc)) {
runningCount++;
}
}
update.setProperty(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY,
String.format("(%d %s)", runningCount, MessagesForGdbLaunchVM.ContainerVMNode_filtered_running_threads)); //$NON-NLS-1$
rm.done();
}
});
}
}
@Override @Override
public int getDeltaFlags(Object e) { public int getDeltaFlags(Object e) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2009 Wind River Systems and others. * Copyright (c) 2008, 2012 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -32,6 +32,9 @@ public class GdbExecutionContextLabelText extends ExecutionContextLabelText {
if (IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName)) { if (IGdbLaunchVMConstants.PROP_CORES_ID_KNOWN.equals(propertyName)) {
return properties.get(IGdbLaunchVMConstants.PROP_CORES_ID) != null ? 1 : 0; return properties.get(IGdbLaunchVMConstants.PROP_CORES_ID) != null ? 1 : 0;
} }
if (IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName)) {
return properties.get(IGdbLaunchVMConstants.PROP_THREAD_SUMMARY) != null ? 1 : 0;
}
return super.getPropertyValue(propertyName, status, properties); return super.getPropertyValue(propertyName, status, properties);
} }
@ -44,6 +47,11 @@ public class GdbExecutionContextLabelText extends ExecutionContextLabelText {
{ {
return true; return true;
} }
if (IGdbLaunchVMConstants.PROP_THREAD_SUMMARY_KNOWN.equals(propertyName) ||
IGdbLaunchVMConstants.PROP_THREAD_SUMMARY.equals(propertyName))
{
return true;
}
return super.checkProperty(propertyName, status, properties); return super.checkProperty(propertyName, status, properties);
} }
} }

View file

@ -39,4 +39,7 @@ public interface IGdbLaunchVMConstants {
* The pin color. One of the <code>IPinElementColorDescriptor</code> color value. * The pin color. One of the <code>IPinElementColorDescriptor</code> color value.
*/ */
public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$ public static final String PROP_PIN_COLOR = "pin_color"; //$NON-NLS-1$
public static final String PROP_THREAD_SUMMARY_KNOWN = "thread_summary_known"; //$NON-NLS-1$
public static final String PROP_THREAD_SUMMARY = "thread_summary"; //$NON-NLS-1$
} }

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -21,6 +21,8 @@ public class MessagesForGdbLaunchVM extends NLS {
public static String ThreadVMNode_No_columns__Error__label; public static String ThreadVMNode_No_columns__Error__label;
public static String ContainerVMNode_No_columns__text_format; public static String ContainerVMNode_No_columns__text_format;
public static String ContainerVMNode_No_columns__Error__label; public static String ContainerVMNode_No_columns__Error__label;
/** since 2.3 */
public static String ContainerVMNode_filtered_running_threads;
static { static {
// initialize resource bundle // initialize resource bundle

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2007, 2010 Wind River Systems and others. # Copyright (c) 2007, 2012 Wind River Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -32,6 +32,10 @@ ThreadVMNode_No_columns__Error__label=<unavailable>
# {3} - ID # {3} - ID
# {4} - Cores available, 0=not available/1=available # {4} - Cores available, 0=not available/1=available
# {5} - Cores # {5} - Cores
ContainerVMNode_No_columns__text_format={0,choice,0#Process|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# [cores: {5}]} # {6} - Thread summary available, 0=not available/1=available
# {7} - Thread summary in text format
ContainerVMNode_No_columns__text_format={0,choice,0#Process|1#{1}}{2,choice,0#|1# [{3}]}{4,choice,0#|1# [cores: {5}]}{6,choice,0#|1# {7}}
ContainerVMNode_No_columns__Error__label=<unavailable> ContainerVMNode_No_columns__Error__label=<unavailable>
ContainerVMNode_filtered_running_threads=filtered running threads

View file

@ -12,26 +12,36 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch; package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.launch;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils; import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils;
import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor; import org.eclipse.cdt.debug.ui.IPinProvider.IPinElementColorDescriptor;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses; import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IResumedDMEvent;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.AbstractThreadVMNode;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ExecutionContextLabelText;
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants; import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.ILaunchVMConstants;
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider; import org.eclipse.cdt.dsf.gdb.internal.ui.GdbPinProvider;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData; import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext; import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.dsf.service.DsfSession;
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor; import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor; import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext; import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate; import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
@ -43,12 +53,17 @@ import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate; import org.eclipse.cdt.dsf.ui.viewmodel.properties.VMDelegatingPropertiesUpdate;
import org.eclipse.cdt.ui.CDTSharedImages; import org.eclipse.cdt.ui.CDTSharedImages;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.IMemento; import org.eclipse.ui.IMemento;
@ -56,10 +71,34 @@ import org.eclipse.ui.IMemento;
public class ThreadVMNode extends AbstractThreadVMNode public class ThreadVMNode extends AbstractThreadVMNode
implements IElementLabelProvider, IElementMementoProvider implements IElementLabelProvider, IElementMementoProvider
{ {
/** Indicator that we should not display running threads */
private boolean fHideRunningThreadsProperty = false;
/** PropertyChangeListener to keep track of the PREF_HIDE_RUNNING_THREADS preference */
private IPropertyChangeListener fPropertyChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS)) {
fHideRunningThreadsProperty = (Boolean)event.getNewValue();
// Refresh the debug view to take in consideration this change
getDMVMProvider().refresh();
}
}
};
public ThreadVMNode(AbstractDMVMProvider provider, DsfSession session) { public ThreadVMNode(AbstractDMVMProvider provider, DsfSession session) {
super(provider, session); super(provider, session);
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
store.addPropertyChangeListener(fPropertyChangeListener);
fHideRunningThreadsProperty = store.getBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS);
} }
@Override
public void dispose() {
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
super.dispose();
}
@Override @Override
public String toString() { public String toString() {
return "ThreadVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ return "ThreadVMNode(" + getSession().getId() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
@ -197,6 +236,50 @@ public class ThreadVMNode extends AbstractThreadVMNode
return provider; return provider;
} }
@Override
protected void updateElementsInSessionThread(final IChildrenUpdate update) {
IProcesses procService = getServicesTracker().getService(IProcesses.class);
final IContainerDMContext contDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IContainerDMContext.class);
if (procService == null || contDmc == null) {
handleFailedUpdate(update);
return;
}
procService.getProcessesBeingDebugged(
contDmc,
new ViewerDataRequestMonitor<IDMContext[]>(getSession().getExecutor(), update){
@Override
public void handleCompleted() {
if (!isSuccess() || !(getData() instanceof IExecutionDMContext[])) {
handleFailedUpdate(update);
return;
}
IExecutionDMContext[] execDmcs = (IExecutionDMContext[])getData();
if (fHideRunningThreadsProperty) {
// Remove running threads from the list
IRunControl runControl = getServicesTracker().getService(IRunControl.class);
if (runControl == null) {
handleFailedUpdate(update);
return;
}
List<IExecutionDMContext> execDmcsNotRunning = new ArrayList<IExecutionDMContext>();
for (IExecutionDMContext execDmc : execDmcs) {
// Keep suspended or stepping threads
if (runControl.isSuspended(execDmc) || runControl.isStepping(execDmc)) {
execDmcsNotRunning.add(execDmc);
}
}
execDmcs = execDmcsNotRunning.toArray(new IExecutionDMContext[execDmcsNotRunning.size()]);
}
fillUpdateWithVMCs(update, execDmcs);
update.done();
}
});
}
@Override @Override
protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) { protected void updatePropertiesInSessionThread(IPropertiesUpdate[] updates) {
IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length]; IPropertiesUpdate[] parentUpdates = new IPropertiesUpdate[updates.length];
@ -282,6 +365,42 @@ public class ThreadVMNode extends AbstractThreadVMNode
return "Thread." + execCtx.getThreadId(); //$NON-NLS-1$ return "Thread." + execCtx.getThreadId(); //$NON-NLS-1$
} }
@Override
public int getDeltaFlags(Object e) {
if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) {
// Special handling in the case of hiding the running threads to
// cause a proper refresh when a thread is resumed.
// We don't need to worry about the ISuspendedDMEvent in this case
// because a proper refresh will be triggered anyway by the stack frame
// being displayed.
return IModelDelta.CONTENT;
}
return super.getDeltaFlags(e);
}
@Override
public void buildDelta(Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor rm) {
if (fHideRunningThreadsProperty && e instanceof IResumedDMEvent) {
// Special handling in the case of hiding the running threads to
// cause a proper refresh when a thread is resumed.
// We don't need to worry about the ISuspendedDMEvent in this case
// because a proper refresh will be triggered anyway by the stack frame
// being displayed.
//
// - If not stepping, update the content of the parent, to allow for
// this thread to become hidden.
// - If stepping, do nothing to avoid too many updates. If a
// time-out is reached before the step completes, the
// ISteppingTimedOutEvent will trigger a refresh.
if (((IResumedDMEvent)e).getReason() != IRunControl.StateChangeReason.STEP) {
VMDelta ancestorDelta = parentDelta.getParentDelta();
ancestorDelta.setFlags(ancestorDelta.getFlags() | IModelDelta.CONTENT);
}
rm.done();
} else {
super.buildDelta(e, parentDelta, nodeOffset, rm);
}
}
private static final String MEMENTO_NAME = "THREAD_MEMENTO_NAME"; //$NON-NLS-1$ private static final String MEMENTO_NAME = "THREAD_MEMENTO_NAME"; //$NON-NLS-1$
/* /*

View file

@ -124,5 +124,12 @@ public interface IGdbDebugPreferenceConstants {
*/ */
public static final String PREF_USE_RTTI = PREFIX + "useRtti"; //$NON-NLS-1$ public static final String PREF_USE_RTTI = PREFIX + "useRtti"; //$NON-NLS-1$
/**
* Boolean preference whether to hide or not, the running threads in the debug view.
* Default is <code>false</code>.
*
* @since 4.1
*/
public static final String PREF_HIDE_RUNNING_THREADS = PREFIX + "hideRunningThreads"; //$NON-NLS-1$
} }

View file

@ -42,5 +42,6 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT); node.putBoolean(IGdbDebugPreferenceConstants.PREF_DEFAULT_NON_STOP, IGDBLaunchConfigurationConstants.DEBUGGER_NON_STOP_DEFAULT);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false); node.putBoolean(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT, false);
node.putInt(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT); node.putInt(IGdbDebugPreferenceConstants.PREF_COMMAND_TIMEOUT_VALUE, IGdbDebugPreferenceConstants.COMMAND_TIMEOUT_VALUE_DEFAULT);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, false);
} }
} }