mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 03:45:35 +02:00
[230932] - [debug view] When a stack frame is selected another thread suspending causes the selection to change.
This commit is contained in:
parent
502681ed56
commit
614db74131
3 changed files with 204 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
|
||||
/**
|
||||
* Default model selection policy factory for DSF.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class DefaultDsfModelSelectionPolicyFactory implements IModelSelectionPolicyFactory {
|
||||
|
||||
/*
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory#createModelSelectionPolicyAdapter(java.lang.Object, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
public IModelSelectionPolicy createModelSelectionPolicyAdapter(Object element, IPresentationContext context) {
|
||||
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
|
||||
if (element instanceof IDMVMContext) {
|
||||
IDMVMContext dmvmContext= (IDMVMContext) element;
|
||||
IDMContext dmContext= dmvmContext.getDMContext();
|
||||
if (dmContext != null) {
|
||||
return new DefaultDsfSelectionPolicy(dmContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch;
|
||||
|
||||
import org.eclipse.dd.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.dd.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.dd.dsf.debug.internal.ui.DsfDebugUIPlugin;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl;
|
||||
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
|
||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeSelection;
|
||||
import org.eclipse.jface.viewers.TreePath;
|
||||
import org.eclipse.jface.viewers.TreeSelection;
|
||||
|
||||
/**
|
||||
* Default DSF selection policy implementation modelled after platform version
|
||||
* (<code>DefaultSelectionPolicy</code>).
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class DefaultDsfSelectionPolicy implements IModelSelectionPolicy {
|
||||
|
||||
private IDMContext fDMContext;
|
||||
|
||||
/**
|
||||
* Create selection policy instance for the given data model context.
|
||||
*
|
||||
* @param dmContext
|
||||
*/
|
||||
public DefaultDsfSelectionPolicy(IDMContext dmContext) {
|
||||
fDMContext= dmContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy#contains(org.eclipse.jface.viewers.ISelection, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
public boolean contains(ISelection selection, IPresentationContext context) {
|
||||
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss= (IStructuredSelection) selection;
|
||||
Object element= ss.getFirstElement();
|
||||
if (element instanceof IDMVMContext) {
|
||||
IDMVMContext dmvmContext= (IDMVMContext) element;
|
||||
IDMContext dmContext= dmvmContext.getDMContext();
|
||||
if (dmContext != null) {
|
||||
return fDMContext.getSessionId().equals(dmContext.getSessionId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy#isSticky(org.eclipse.jface.viewers.ISelection, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
public boolean isSticky(ISelection selection, IPresentationContext context) {
|
||||
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss= (IStructuredSelection) selection;
|
||||
Object element= ss.getFirstElement();
|
||||
return isSticky(element);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isSticky(Object element) {
|
||||
if (element instanceof IDMVMContext) {
|
||||
IDMVMContext dmvmContext= (IDMVMContext) element;
|
||||
IDMContext dmContext= dmvmContext.getDMContext();
|
||||
if (dmContext instanceof IFrameDMContext) {
|
||||
IExecutionDMContext execContext= DMContexts.getAncestorOfType(dmContext, IExecutionDMContext.class);
|
||||
if (execContext != null) {
|
||||
DsfServicesTracker servicesTracker = new DsfServicesTracker(DsfDebugUIPlugin.getBundleContext(), dmContext.getSessionId());
|
||||
try {
|
||||
IRunControl runControl= servicesTracker.getService(IRunControl.class);
|
||||
if (runControl != null) {
|
||||
if (runControl.isSuspended(execContext)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
servicesTracker.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy#overrides(org.eclipse.jface.viewers.ISelection, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext)
|
||||
*/
|
||||
public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) {
|
||||
if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) {
|
||||
if (existing instanceof IStructuredSelection && candidate instanceof IStructuredSelection) {
|
||||
IStructuredSelection ssExisting = (IStructuredSelection) existing;
|
||||
IStructuredSelection ssCandidate = (IStructuredSelection) candidate;
|
||||
return overrides(ssExisting.getFirstElement(), ssCandidate.getFirstElement());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected boolean overrides(Object existing, Object candidate) {
|
||||
if (existing == null || existing.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
if (existing instanceof IDMVMContext && candidate instanceof IDMVMContext) {
|
||||
IDMContext curr = ((IDMVMContext) existing).getDMContext();
|
||||
IDMContext cand = ((IDMVMContext) candidate).getDMContext();
|
||||
if (curr instanceof IFrameDMContext && cand instanceof IFrameDMContext) {
|
||||
IExecutionDMContext currExecContext= DMContexts.getAncestorOfType(curr, IExecutionDMContext.class);
|
||||
if (currExecContext != null) {
|
||||
IExecutionDMContext candExecContext= DMContexts.getAncestorOfType(cand, IExecutionDMContext.class);
|
||||
return currExecContext.equals(candExecContext) || !isSticky(existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
return !isSticky(existing);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy#replaceInvalidSelection(org.eclipse.jface.viewers.ISelection, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
|
||||
if (invalidSelection instanceof ITreeSelection) {
|
||||
ITreeSelection treeSelection = (ITreeSelection)invalidSelection;
|
||||
if (treeSelection.getPaths().length == 1) {
|
||||
TreePath path = treeSelection.getPaths()[0];
|
||||
return new TreeSelection(path.getParentPath());
|
||||
}
|
||||
}
|
||||
return newSelection;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
|
|||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.dd.dsf.concurrent.Immutable;
|
||||
import org.eclipse.dd.dsf.concurrent.ThreadSafe;
|
||||
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.launch.DefaultDsfModelSelectionPolicyFactory;
|
||||
import org.eclipse.dd.dsf.debug.ui.actions.DsfResumeCommand;
|
||||
import org.eclipse.dd.dsf.debug.ui.actions.DsfStepIntoCommand;
|
||||
import org.eclipse.dd.dsf.debug.ui.actions.DsfStepOverCommand;
|
||||
|
@ -47,6 +48,7 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
|||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
|
||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactory;
|
||||
import org.eclipse.debug.ui.contexts.ISuspendTrigger;
|
||||
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
||||
|
||||
|
@ -76,6 +78,7 @@ public class GdbAdapterFactory
|
|||
final IDebugModelProvider fDebugModelProvider;
|
||||
final DsfSuspendTrigger fSuspendTrigger;
|
||||
final DsfSteppingModeTarget fSteppingModeTarget;
|
||||
final IModelSelectionPolicyFactory fModelSelectionPolicyFactory;
|
||||
|
||||
SessionAdapterSet(GdbLaunch launch) {
|
||||
fLaunch = launch;
|
||||
|
@ -99,6 +102,8 @@ public class GdbAdapterFactory
|
|||
fRestartCommand = new GdbRestartCommand(session, fLaunch);
|
||||
fTerminateCommand = new DsfTerminateCommand(session);
|
||||
fSuspendTrigger = new DsfSuspendTrigger(session, fLaunch);
|
||||
fModelSelectionPolicyFactory = new DefaultDsfModelSelectionPolicyFactory();
|
||||
|
||||
session.registerModelAdapter(ISteppingModeTarget.class, fSteppingModeTarget);
|
||||
session.registerModelAdapter(IStepIntoHandler.class, fStepIntoCommand);
|
||||
session.registerModelAdapter(IStepOverHandler.class, fStepOverCommand);
|
||||
|
@ -107,6 +112,7 @@ public class GdbAdapterFactory
|
|||
session.registerModelAdapter(IResumeHandler.class, fResumeCommand);
|
||||
session.registerModelAdapter(IRestart.class, fRestartCommand);
|
||||
session.registerModelAdapter(ITerminateHandler.class, fTerminateCommand);
|
||||
session.registerModelAdapter(IModelSelectionPolicyFactory.class, fModelSelectionPolicyFactory);
|
||||
|
||||
fDebugModelProvider = new IDebugModelProvider() {
|
||||
// @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers()
|
||||
|
@ -140,6 +146,8 @@ public class GdbAdapterFactory
|
|||
session.unregisterModelAdapter(IResumeHandler.class);
|
||||
session.unregisterModelAdapter(IRestart.class);
|
||||
session.unregisterModelAdapter(ITerminateHandler.class);
|
||||
session.unregisterModelAdapter(IModelSelectionPolicyFactory.class);
|
||||
|
||||
fStepIntoCommand.dispose();
|
||||
fStepOverCommand.dispose();
|
||||
fStepReturnCommand.dispose();
|
||||
|
|
Loading…
Add table
Reference in a new issue