mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 360735: "Show Breakpoints Supported by Selected Target" should allow
to filter bp that don't apply to the active context Change-Id: I60d554359859cba64e4dd0d840c4a6ca63fd54d8 Reviewed-on: https://git.eclipse.org/r/7921 IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com> Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
fb6d56fd3e
commit
1ca3907ef3
2 changed files with 159 additions and 18 deletions
|
@ -14,18 +14,22 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||||
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.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
|
import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension;
|
import org.eclipse.cdt.dsf.debug.service.IBreakpointsExtension;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
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.BreakpointVMProvider;
|
||||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.RawBreakpointVMNode;
|
import org.eclipse.cdt.dsf.debug.ui.viewmodel.breakpoints.RawBreakpointVMNode;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
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;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
|
import org.eclipse.cdt.dsf.mi.service.MIBreakpointsManager;
|
||||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||||
|
@ -34,12 +38,15 @@ import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
|
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
|
||||||
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
@ -63,20 +70,35 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void calcFileteredBreakpoints(DataRequestMonitor<IBreakpoint[]> rm) {
|
protected void calcFileteredBreakpoints( final DataRequestMonitor<IBreakpoint[]> rm ) {
|
||||||
if (Boolean.TRUE.equals(getPresentationContext().getProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION))) {
|
if ( Boolean.TRUE.equals( getPresentationContext().getProperty( IBreakpointUIConstants.PROP_BREAKPOINTS_FILTER_SELECTION ) ) ) {
|
||||||
IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
|
IBreakpointsTargetDMContext bpContext = null;
|
||||||
List<IBreakpoint> filteredBPs = new ArrayList<IBreakpoint>(allBreakpoints.length);
|
IMIExecutionDMContext threadContext = null;
|
||||||
for (IBreakpoint bp : allBreakpoints) {
|
ISelection debugContext = getDebugContext();
|
||||||
if (bp instanceof ICBreakpoint && bp.getModelIdentifier().equals(CDebugCorePlugin.PLUGIN_ID)) {
|
if ( debugContext instanceof IStructuredSelection ) {
|
||||||
filteredBPs.add(bp);
|
Object element = ((IStructuredSelection)debugContext).getFirstElement();
|
||||||
}
|
if ( element instanceof IDMVMContext ) {
|
||||||
}
|
bpContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IBreakpointsTargetDMContext.class );
|
||||||
rm.setData( filteredBPs.toArray(new IBreakpoint[filteredBPs.size()]) );
|
threadContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IMIExecutionDMContext.class );
|
||||||
rm.done();
|
}
|
||||||
} else {
|
}
|
||||||
super.calcFileteredBreakpoints(rm);
|
|
||||||
}
|
if ( bpContext == null || !fSession.getId().equals( bpContext.getSessionId() ) ) {
|
||||||
|
rm.setStatus( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.PLUGIN_ID,
|
||||||
|
IDsfStatusConstants.INVALID_HANDLE,
|
||||||
|
"Debug context doesn't contain a thread", //$NON-NLS-1$
|
||||||
|
null ) );
|
||||||
|
rm.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
getInstalledBreakpoints( bpContext, threadContext, rm );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
super.calcFileteredBreakpoints( rm );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,4 +168,118 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ISelection getDebugContext() {
|
||||||
|
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||||
|
if ( window != null ) {
|
||||||
|
return DebugUITools.getDebugContextManager().getContextService( window ).getActiveContext();
|
||||||
|
}
|
||||||
|
return StructuredSelection.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getInstalledBreakpoints( final IBreakpointsTargetDMContext targetContext, final IMIExecutionDMContext threadContext, final DataRequestMonitor<IBreakpoint[]> rm ) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
fSession.getExecutor().execute( new DsfRunnable() {
|
||||||
|
public void run() {
|
||||||
|
final IBreakpointsExtension bpService = fServicesTracker.getService( IBreakpointsExtension.class );
|
||||||
|
if ( bpService == null ) {
|
||||||
|
rm.setStatus( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE,
|
||||||
|
"Breakpoints service not available", //$NON-NLS-1$
|
||||||
|
null ) );
|
||||||
|
rm.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bpService.getBreakpoints( targetContext, new DataRequestMonitor<IBreakpoints.IBreakpointDMContext[]>( fSession.getExecutor(), rm ) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
final MIBreakpointsManager bpManager = fServicesTracker.getService( MIBreakpointsManager.class );
|
||||||
|
if ( bpManager == null ) {
|
||||||
|
rm.setStatus( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE,
|
||||||
|
"Breakpoints service not available", //$NON-NLS-1$
|
||||||
|
null ) );
|
||||||
|
rm.done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( getData().length > 0 ) {
|
||||||
|
final List<IBreakpoint> bps = new ArrayList<IBreakpoint>( getData().length );
|
||||||
|
final CountingRequestMonitor crm = new CountingRequestMonitor( ImmediateExecutor.getInstance(), rm ) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
rm.setData( bps.toArray( new IBreakpoint[bps.size()] ) );
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
crm.setDoneCount( getData().length );
|
||||||
|
|
||||||
|
for ( final IBreakpointDMContext bpCtx : getData() ) {
|
||||||
|
bpService.getBreakpointDMData(
|
||||||
|
bpCtx,
|
||||||
|
new DataRequestMonitor<IBreakpoints.IBreakpointDMData>( ImmediateExecutor.getInstance(), crm ) {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void handleSuccess() {
|
||||||
|
if ( getData() instanceof MIBreakpointDMData ) {
|
||||||
|
MIBreakpointDMData data = (MIBreakpointDMData)getData();
|
||||||
|
if ( !data.isPending() && isThreadBreakpoint( threadContext, data )) {
|
||||||
|
IBreakpoint bp = bpManager.findPlatformBreakpoint( bpCtx );
|
||||||
|
if ( bp != null )
|
||||||
|
bps.add( bp );
|
||||||
|
}
|
||||||
|
crm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rm.setData( new IBreakpoint[0] );
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
catch( RejectedExecutionException e ) {
|
||||||
|
rm.setStatus( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.PLUGIN_ID,
|
||||||
|
IDsfStatusConstants.INVALID_STATE,
|
||||||
|
"Request for monitor: '" + toString() + "' resulted in a rejected execution exception.", e ) ); //$NON-NLS-1$ //$NON-NLS-2$);
|
||||||
|
rm.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isThreadBreakpoint( IMIExecutionDMContext threadContext, MIBreakpointDMData data ) {
|
||||||
|
if ( threadContext == null || data.getThreadId() == null || data.getThreadId().length() == 0 ) {
|
||||||
|
// Ignore threads
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int threadId = threadContext.getThreadId();
|
||||||
|
try {
|
||||||
|
int bpThreadId = Integer.parseInt( data.getThreadId() );
|
||||||
|
if ( bpThreadId == 0 )
|
||||||
|
return true;
|
||||||
|
return ( threadId == bpThreadId );
|
||||||
|
}
|
||||||
|
catch( NumberFormatException e ) {
|
||||||
|
GdbUIPlugin.getDefault().getLog().log( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.getUniqueIdentifier(),
|
||||||
|
"Invalid breakpoint thread id" ) ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1408,7 +1408,12 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
|
||||||
*/
|
*/
|
||||||
public IBreakpoint findPlatformBreakpoint(IBreakpointDMContext bpContext) {
|
public IBreakpoint findPlatformBreakpoint(IBreakpointDMContext bpContext) {
|
||||||
if (bpContext instanceof MIBreakpointDMContext) {
|
if (bpContext instanceof MIBreakpointDMContext) {
|
||||||
return findPlatformBreakpoint(((MIBreakpointDMContext)bpContext).getReference());
|
IBreakpointsTargetDMContext targetCtx = DMContexts.getAncestorOfType(bpContext, IBreakpointsTargetDMContext.class);
|
||||||
|
if (targetCtx != null) {
|
||||||
|
Map<IBreakpointDMContext, ICBreakpoint> bps = fTargetBPs.get(targetCtx);
|
||||||
|
if (bps != null)
|
||||||
|
return bps.get(bpContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue