Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 347514 | Differences between
and this patch

Collapse All | Expand All

(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSelectNextTraceRecordCommand.java (-8 / +16 lines)
Lines 80-93 Link Here
80
       						new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) {
80
       						new DataRequestMonitor<ITraceRecordDMContext>(fExecutor, rm) {
81
       							@Override
81
       							@Override
82
       							protected void handleSuccess() {
82
       							protected void handleSuccess() {
83
       							    final ITraceRecordDMContext nextDmc = traceControl.createNextRecordContext(getData());
83
       								final ITraceRecordDMContext previousDmc = getData();
84
       							    traceControl.selectTraceRecord(nextDmc, new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
84
       							    ITraceRecordDMContext nextDmc = traceControl.createNextRecordContext(previousDmc);
85
       							        @Override
85
       							    // Must send the event right away to tell the services we are starting visualization
86
       							        protected void handleSuccess() {
86
       							    // If we don't, the services won't behave accordingly soon enough
87
       							            fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(nextDmc), new Hashtable<String, String>());
87
       							    // Bug 347514
88
       							            rm.done();
88
						            fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(nextDmc), new Hashtable<String, String>());
89
       							        }
89
						            
90
       							    });
90
						            traceControl.selectTraceRecord(nextDmc, new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
91
						            	@Override
92
						            	protected void handleError() {
93
						            		// If we weren't able to select the next record, we must notify that we are still on the previous one
94
						            		// since we have already sent a TraceRecordSelectedChangedEvent early, but it didn't happen.
95
						            		fSession.dispatchEvent(new TraceRecordSelectedChangedEvent(previousDmc), new Hashtable<String, String>());
96
						            		rm.done();
97
						            	}
98
						            });
91
       							};
99
       							};
92
       						});
100
       						});
93
       			} else {
101
       			} else {
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java (+29 lines)
Lines 26-31 Link Here
26
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode;
26
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.LaunchRootVMNode;
27
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StackFramesVMNode;
27
import org.eclipse.cdt.dsf.debug.ui.viewmodel.launch.StackFramesVMNode;
28
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
28
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
29
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
29
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingStartedDMEvent;
30
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingStartedDMEvent;
30
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingStoppedDMEvent;
31
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingStoppedDMEvent;
31
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingSupportedChangeDMEvent;
32
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITracingSupportedChangeDMEvent;
Lines 45-50 Link Here
45
public class LaunchVMProvider extends AbstractLaunchVMProvider 
46
public class LaunchVMProvider extends AbstractLaunchVMProvider 
46
    implements IDebugEventSetListener, ILaunchesListener2
47
    implements IDebugEventSetListener, ILaunchesListener2
47
{
48
{
49
	
50
	/**
51
	 * Indicates that we are currently visualizing trace data.
52
	 */
53
	private boolean fTracepointVisualizationModeEnabled;
54
	
48
	@ThreadSafe
55
	@ThreadSafe
49
    public LaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)
56
    public LaunchVMProvider(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session)
50
    {
57
    {
Lines 91-96 Link Here
91
        		return true;
98
        		return true;
92
        	}
99
        	}
93
        }
100
        }
101
        
102
        if (eventToSkip instanceof ITraceRecordSelectedChangedDMEvent) {
103
    		ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent)eventToSkip;
104
    		if (recordChanged.isVisualizationModeEnabled() == fTracepointVisualizationModeEnabled) {
105
    			// We only care about this event if it indicates a change of visualization state
106
    			return true;
107
    		}
108
        }
109
        
94
        return super.canSkipHandlingEvent(newEvent, eventToSkip);
110
        return super.canSkipHandlingEvent(newEvent, eventToSkip);
95
    }
111
    }
96
    
112
    
Lines 107-112 Link Here
107
    		return;
123
    		return;
108
    	}    
124
    	}    
109
125
126
    	if (event instanceof ITraceRecordSelectedChangedDMEvent) {
127
    		ITraceRecordSelectedChangedDMEvent recordChanged = (ITraceRecordSelectedChangedDMEvent)event;
128
    		// If trace visualization has changed we have to refresh the debug view
129
    		if (recordChanged.isVisualizationModeEnabled() != fTracepointVisualizationModeEnabled) {
130
    			fTracepointVisualizationModeEnabled = recordChanged.isVisualizationModeEnabled();
131
    			
132
        		// Refresh the view because the set of threads has totally changed.
133
        		refresh();
134
        		rm.done();
135
        		return;
136
        	}
137
    	}
138
    	
110
    	super.handleEvent(event, rm);
139
    	super.handleEvent(event, rm);
111
    }
140
    }
112
141
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (+50 lines)
Lines 29-37 Link Here
29
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
29
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
30
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
30
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
31
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
31
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
32
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
32
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
33
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
33
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
34
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
34
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
35
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
36
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
35
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
37
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
36
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
38
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
37
import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
39
import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
Lines 54-59 Link Here
54
 */
56
 */
55
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
57
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
56
    
58
    
59
    /**
60
     * The id of the single thread to be used during event visualization. 
61
     * @since 4.1 
62
     */
63
    protected static final String TRACE_VISUALIZATION_THREAD_ID = "1"; //$NON-NLS-1$
64
57
    private CommandFactory fCommandFactory;
65
    private CommandFactory fCommandFactory;
58
    private IGDBControl fCommandControl;
66
    private IGDBControl fCommandControl;
59
    private IGDBBackend fBackend;
67
    private IGDBBackend fBackend;
Lines 73-78 Link Here
73
     * because we know the process will be restarted.
81
     * because we know the process will be restarted.
74
     */
82
     */
75
	private Set<IContainerDMContext> fProcRestarting = new HashSet<IContainerDMContext>();
83
	private Set<IContainerDMContext> fProcRestarting = new HashSet<IContainerDMContext>();
84
85
	/** 
86
	 * Indicates that we are currently visualizing trace data.
87
	 */
88
	private boolean fTraceVisualization;
76
89
77
	public GDBProcesses_7_2(DsfSession session) {
90
	public GDBProcesses_7_2(DsfSession session) {
78
		super(session);
91
		super(session);
Lines 107-112 Link Here
107
	@Override
120
	@Override
108
	public void shutdown(RequestMonitor requestMonitor) {
121
	public void shutdown(RequestMonitor requestMonitor) {
109
		super.shutdown(requestMonitor);
122
		super.shutdown(requestMonitor);
123
	}
124
	
125
	/** @since 4.1 */
126
	protected boolean getTraceVisualization() {
127
		return fTraceVisualization;
128
	}
129
130
	/** @since 4.1 */
131
	protected void setTraceVisualization(boolean visualizing) {
132
		fTraceVisualization = visualizing;
110
	}
133
	}
111
	
134
	
112
	@Override
135
	@Override
Lines 459-464 Link Here
459
		return new DebugNewProcessSequence_7_2(executor, isInitial, dmc, file, attributes, rm);
482
		return new DebugNewProcessSequence_7_2(executor, isInitial, dmc, file, attributes, rm);
460
	}
483
	}
461
	
484
	
485
	@Override
486
	public void getProcessesBeingDebugged(final IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) {
487
		if (getTraceVisualization()) {
488
			// If we are visualizing data during a live session, we should not ask GDB for the list of threads,
489
			// because we will get the list of active threads, while GDB only cares about thread 1 for visualization.
490
			final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class);
491
			if (containerDmc != null) {
492
				IProcessDMContext procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
493
				rm.setData(new IMIExecutionDMContext[]{createExecutionContext(containerDmc, 
494
                        createThreadContext(procDmc, TRACE_VISUALIZATION_THREAD_ID),
495
                        TRACE_VISUALIZATION_THREAD_ID)});
496
				rm.done();
497
				return;
498
			}
499
		}
500
		
501
		super.getProcessesBeingDebugged(dmc, rm);
502
	}
503
	
462
	/** 
504
	/** 
463
	 * Creates the container context that is to be used for the new process that will
505
	 * Creates the container context that is to be used for the new process that will
464
	 * be created by the restart operation.
506
	 * be created by the restart operation.
Lines 535-539 Link Here
535
    protected boolean needFixForGDB72Bug352998() {
577
    protected boolean needFixForGDB72Bug352998() {
536
    	return true;
578
    	return true;
537
    }
579
    }
580
    
581
    /**
582
	 * @since 4.1
583
	 */
584
    @DsfServiceEventHandler
585
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
586
    	setTraceVisualization(e.isVisualizationModeEnabled());
587
    }
538
}
588
}
539
589
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java (-8 / +13 lines)
Lines 398-403 Link Here
398
		super.shutdown(rm);
398
		super.shutdown(rm);
399
	}
399
	}
400
400
401
	/** @since 4.1 */
402
	protected boolean getRunControlOperationsEnabled() {
403
		return fRunControlOperationsEnabled;
404
	}
405
406
	/** @since 4.1 */
407
	protected void setRunControlOperationsEnabled(boolean runControlEnabled) {
408
		fRunControlOperationsEnabled = runControlEnabled;
409
	}
410
	
401
	///////////////////////////////////////////////////////////////////////////
411
	///////////////////////////////////////////////////////////////////////////
402
	// AbstractDsfService
412
	// AbstractDsfService
403
	///////////////////////////////////////////////////////////////////////////
413
	///////////////////////////////////////////////////////////////////////////
Lines 1585-1602 Link Here
1585
    }
1595
    }
1586
1596
1587
    /**
1597
    /**
1598
     * @deprecated Tracing is only supported with GDB 7.2, so this logic
1599
     * was moved to the GDBRunControl_7_2_NS class.
1588
	 * @since 3.0
1600
	 * @since 3.0
1589
	 */
1601
	 */
1602
    @Deprecated
1590
    @DsfServiceEventHandler 
1603
    @DsfServiceEventHandler 
1591
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
1604
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
1592
    	if (e.isVisualizationModeEnabled()) {
1593
    		// We have started looking at trace records.  We can no longer
1594
    		// do run control operations.
1595
    		fRunControlOperationsEnabled = false;
1596
    	} else {
1597
    		// We stopped looking at trace data and gone back to debugger mode
1598
    		fRunControlOperationsEnabled = true;
1599
    	}
1600
    }
1605
    }
1601
    
1606
    
1602
	public void flushCache(IDMContext context) {
1607
	public void flushCache(IDMContext context) {
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_2_NS.java (-2 / +45 lines)
Lines 21-32 Link Here
21
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
21
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
22
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
22
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
23
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
23
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
24
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
24
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
25
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
25
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
26
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
26
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
27
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
27
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
28
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
28
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
29
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
29
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
30
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
31
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
30
import org.eclipse.cdt.dsf.service.DsfSession;
32
import org.eclipse.cdt.dsf.service.DsfSession;
31
import org.eclipse.core.runtime.IStatus;
33
import org.eclipse.core.runtime.IStatus;
32
import org.eclipse.core.runtime.Status;
34
import org.eclipse.core.runtime.Status;
Lines 41-47 Link Here
41
43
42
	private ICommandControlService fConnection;
44
	private ICommandControlService fConnection;
43
	private CommandFactory fCommandFactory;
45
	private CommandFactory fCommandFactory;
44
46
	
47
	/**
48
	 * Keeps track if we are currently visualizing trace data or not
49
	 */
50
	private boolean fTraceVisualization;
51
	
45
	///////////////////////////////////////////////////////////////////////////
52
	///////////////////////////////////////////////////////////////////////////
46
	// Initialization and shutdown
53
	// Initialization and shutdown
47
	///////////////////////////////////////////////////////////////////////////
54
	///////////////////////////////////////////////////////////////////////////
Lines 81-86 Link Here
81
		super.shutdown(rm);
88
		super.shutdown(rm);
82
	}
89
	}
83
90
91
	/** @since 4.1 */
92
	protected boolean getTraceVisualization() {
93
		return fTraceVisualization;
94
	}
95
96
	/** @since 4.1 */
97
	protected void setTraceVisualization(boolean visualizing) {
98
		fTraceVisualization = visualizing;
99
	}
100
	
84
	// Now that the flag --thread-group is globally supported
101
	// Now that the flag --thread-group is globally supported
85
	// by GDB 7.2, we have to make sure not to use it twice.
102
	// by GDB 7.2, we have to make sure not to use it twice.
86
	// Bug 340262
103
	// Bug 340262
Lines 168-172 Link Here
168
185
169
	private void doResumeContainer(IMIContainerDMContext context, final RequestMonitor rm) {
186
	private void doResumeContainer(IMIContainerDMContext context, final RequestMonitor rm) {
170
		fConnection.queueCommand(fCommandFactory.createMIExecContinue(context), new DataRequestMonitor<MIInfo>(getExecutor(), rm));
187
		fConnection.queueCommand(fCommandFactory.createMIExecContinue(context), new DataRequestMonitor<MIInfo>(getExecutor(), rm));
171
	}	
188
	}
189
	
190
    /**
191
	 * @since 4.1
192
	 */
193
	@Override
194
    @DsfServiceEventHandler
195
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
196
    	setTraceVisualization(e.isVisualizationModeEnabled());
197
198
    	// Disable or re-enable run control operations if we are looking
199
    	// at trace data or we are not, respectively.
200
    	setRunControlOperationsEnabled(!e.isVisualizationModeEnabled());
201
    }
202
    
203
	@Override
204
	protected void refreshThreadStates() {
205
		// We should not refresh the thread state while we are visualizing trace data.
206
		// This is because GDB will report the state of the threads of the executing
207
		// program, while we should only deal with a 'fake' stopped thread 1, during
208
		// visualization.
209
		// So, simply keep the state of the threads as is until visualization stops.
210
		// Bug 347514
211
		if (getTraceVisualization() == false) {
212
			super.refreshThreadStates();
213
		}
214
	}
172
}
215
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBTraceControl_7_2.java (-1 / +1 lines)
Lines 972-978 Link Here
972
    										// process?
972
    										// process?
973
    										IContainerDMContext processContainerDmc = (IContainerDMContext)(getData()[0]);
973
    										IContainerDMContext processContainerDmc = (IContainerDMContext)(getData()[0]);
974
    										
974
    										
975
    										// Now find the proper thread.  We must do this hear because in post-mortem debugging
975
    										// Now find the proper thread.  We must do this here because in post-mortem debugging
976
    										// we cannot rely on MIRunControl using 'thread', as it will fail
976
    										// we cannot rely on MIRunControl using 'thread', as it will fail
977
    			    						IMIProcesses procService = getServicesTracker().getService(IMIProcesses.class);
977
    			    						IMIProcesses procService = getServicesTracker().getService(IMIProcesses.class);
978
    			    						if (procService == null) {
978
    			    						if (procService == null) {
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java (-12 lines)
Lines 345-362 Link Here
345
    /** @since 3.0 */
345
    /** @since 3.0 */
346
    @DsfServiceEventHandler 
346
    @DsfServiceEventHandler 
347
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
347
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
348
    	if (e.isVisualizationModeEnabled()) {
349
    		// Once we start looking at trace frames, we should not use
350
    		// the --thread or --frame options because GDB does not handle
351
    		// it well, there are no actual threads running.
352
    		// We only need to do this once, but it won't hurt to do it
353
    		// every time.
354
    		setUseThreadAndFrameOptions(false);
355
    	} else {
356
    		// We stopped looking at trace frames, so we can start
357
    		// using --thread and --frame again
358
    		setUseThreadAndFrameOptions(true);
359
    	}
360
    }
348
    }
361
349
362
    public static class InitializationShutdownStep extends Sequence.Step {
350
    public static class InitializationShutdownStep extends Sequence.Step {

Return to bug 347514