mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
Bug 360735: Add support for multi-selection in the Debug view for "Show
Breakpoints Supported by Selected Target" Change-Id: I1605e080f15e1ce352c33236c4442778cdfdeee3 Reviewed-on: https://git.eclipse.org/r/7974 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com> 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:
parent
1709e1b676
commit
72d411a73b
1 changed files with 54 additions and 26 deletions
|
@ -8,12 +8,15 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
* Mikhail Khodjaiants (Mentor), Marc Khouzam (Ericsson)
|
* Mikhail Khodjaiants (Mentor), Marc Khouzam (Ericsson)
|
||||||
* - Optionally use aggressive breakpoint filtering (Bug 360735)
|
* - Optionally use aggressive breakpoint filtering (Bug 360735)
|
||||||
|
* Marc Khouzam (Ericsson) - Add support to display proper breakpoints when dealing
|
||||||
|
* with a multi-selection in the debug view (Bug 360735)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.viewmodel.breakpoints;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -25,6 +28,7 @@ import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
|
||||||
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.ImmediateCountingRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
|
||||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||||
|
@ -108,30 +112,52 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
protected void calcFileteredBreakpoints( final 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 ) ) ) {
|
||||||
if ( fUseAggressiveBpFilter ) {
|
if ( fUseAggressiveBpFilter ) {
|
||||||
// Aggressive filtering of breakpoints. Only return bps that are installed on the target.
|
// Aggressive filtering of breakpoints. Only return bps that are installed on the target.
|
||||||
IBreakpointsTargetDMContext bpContext = null;
|
ISelection debugContext = getDebugContext();
|
||||||
IExecutionDMContext execContext = null;
|
if ( debugContext instanceof IStructuredSelection ) {
|
||||||
ISelection debugContext = getDebugContext();
|
// Use a set to avoid duplicates
|
||||||
if ( debugContext instanceof IStructuredSelection ) {
|
final Set<IBreakpoint> bps = new HashSet<IBreakpoint>();
|
||||||
Object element = ( (IStructuredSelection)debugContext ).getFirstElement();
|
|
||||||
if ( element instanceof IDMVMContext ) {
|
|
||||||
bpContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IBreakpointsTargetDMContext.class );
|
|
||||||
execContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IExecutionDMContext.class );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bpContext == null || !fSession.getId().equals( bpContext.getSessionId() ) ) {
|
int count = 0;
|
||||||
rm.setStatus( new Status(
|
final ImmediateCountingRequestMonitor crm = new ImmediateCountingRequestMonitor( rm ) {
|
||||||
IStatus.ERROR,
|
@Override
|
||||||
GdbUIPlugin.PLUGIN_ID,
|
protected void handleSuccess() {
|
||||||
IDsfStatusConstants.INVALID_HANDLE,
|
rm.done( bps.toArray( new IBreakpoint[bps.size()] ) );
|
||||||
"Debug context doesn't contain a breakpoint context", //$NON-NLS-1$
|
}
|
||||||
null ) );
|
};
|
||||||
rm.done();
|
|
||||||
return;
|
for ( Object element : ( (IStructuredSelection)debugContext ).toList() ) {
|
||||||
}
|
|
||||||
|
IBreakpointsTargetDMContext bpContext = null;
|
||||||
|
IExecutionDMContext execContext = null;
|
||||||
|
if ( element instanceof IDMVMContext ) {
|
||||||
|
bpContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IBreakpointsTargetDMContext.class );
|
||||||
|
execContext = DMContexts.getAncestorOfType( ((IDMVMContext)element).getDMContext(), IExecutionDMContext.class );
|
||||||
|
|
||||||
getInstalledBreakpoints( bpContext, execContext, rm );
|
if ( bpContext != null && fSession.getId().equals( bpContext.getSessionId() ) ) {
|
||||||
|
count++;
|
||||||
|
getInstalledBreakpoints( bpContext, execContext, new DataRequestMonitor<Collection<IBreakpoint>>( getExecutor(), crm ) {
|
||||||
|
@Override
|
||||||
|
protected void handleCompleted() {
|
||||||
|
if ( isSuccess() ) {
|
||||||
|
bps.addAll( getData() );
|
||||||
|
}
|
||||||
|
crm.done();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
crm.setDoneCount(count);
|
||||||
|
} else {
|
||||||
|
rm.done( new Status(
|
||||||
|
IStatus.ERROR,
|
||||||
|
GdbUIPlugin.PLUGIN_ID,
|
||||||
|
IDsfStatusConstants.INVALID_HANDLE,
|
||||||
|
"Invalid debug selection", //$NON-NLS-1$
|
||||||
|
null ) );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Original behavior of bp filtering. Return all bp of type ICBreakpoint
|
// Original behavior of bp filtering. Return all bp of type ICBreakpoint
|
||||||
IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
|
IBreakpoint[] allBreakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints();
|
||||||
|
@ -225,7 +251,9 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
return StructuredSelection.EMPTY;
|
return StructuredSelection.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getInstalledBreakpoints( final IBreakpointsTargetDMContext targetContext, final IExecutionDMContext execContext, final DataRequestMonitor<IBreakpoint[]> rm ) {
|
private void getInstalledBreakpoints( final IBreakpointsTargetDMContext targetContext,
|
||||||
|
final IExecutionDMContext execContext,
|
||||||
|
final DataRequestMonitor<Collection<IBreakpoint>> rm ) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fSession.getExecutor().execute( new DsfRunnable() {
|
fSession.getExecutor().execute( new DsfRunnable() {
|
||||||
|
@ -262,7 +290,7 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
rm.setData( bps.toArray( new IBreakpoint[bps.size()] ) );
|
rm.setData( bps );
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -301,7 +329,7 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rm.setData( new IBreakpoint[0] );
|
rm.setData( new HashSet<IBreakpoint>() );
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue