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/internal/service/command/events/TraceRecordSelectedChangedEventListener.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 Ericsson and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Marc Khouzam (Ericsson) - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.gdb.internal.service.command.events;
13
14
import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent;
15
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
16
17
/**
18
 * Temporary class within an internal package to avoid adding a new API.
19
 * The class is an event listener for the ITraceRecordSelectedChangedDMEvent.
20
 */
21
public class TraceRecordSelectedChangedEventListener {
22
23
	public boolean fTracepointVisualizationEnabled = false;	
24
	
25
	@DsfServiceEventHandler
26
	public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
27
		fTracepointVisualizationEnabled = e.isVisualizationModeEnabled();
28
	}
29
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java (-1 / +36 lines)
Lines 30-38 Link Here
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.internal.commands.MITargetDisconnect;
32
import org.eclipse.cdt.dsf.gdb.internal.commands.MITargetDisconnect;
33
import org.eclipse.cdt.dsf.gdb.internal.service.command.events.TraceRecordSelectedChangedEventListener;
33
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
34
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
34
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
35
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
35
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
36
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext;
37
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
36
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
38
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
37
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
39
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
38
import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
40
import org.eclipse.cdt.dsf.mi.service.IMIRunControl.MIRunMode;
Lines 55-60 Link Here
55
 */
57
 */
56
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
58
public class GDBProcesses_7_2 extends GDBProcesses_7_1 {
57
    
59
    
60
    /**
61
     * The id of the single thread to be used during event visualization. 
62
     */
63
    private static final String TRACE_VISUALIZATION_THREAD_ID = "1"; //$NON-NLS-1$
64
58
    private CommandFactory fCommandFactory;
65
    private CommandFactory fCommandFactory;
59
    private IGDBControl fCommandControl;
66
    private IGDBControl fCommandControl;
60
    private IGDBBackend fBackend;
67
    private IGDBBackend fBackend;
Lines 74-79 Link Here
74
     * because we know the process will be restarted.
81
     * because we know the process will be restarted.
75
     */
82
     */
76
	private Set<IContainerDMContext> fProcRestarting = new HashSet<IContainerDMContext>();
83
	private Set<IContainerDMContext> fProcRestarting = new HashSet<IContainerDMContext>();
84
85
	/*
86
	 * Temporary to avoid API changes
87
	 */
88
	private TraceRecordSelectedChangedEventListener fTraceVisualizationEventListener = new TraceRecordSelectedChangedEventListener();
77
89
78
	public GDBProcesses_7_2(DsfSession session) {
90
	public GDBProcesses_7_2(DsfSession session) {
79
		super(session);
91
		super(session);
Lines 102-112 Link Here
102
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
114
        fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory();
103
    	fBackend = getServicesTracker().getService(IGDBBackend.class);
115
    	fBackend = getServicesTracker().getService(IGDBBackend.class);
104
    	
116
    	
117
        getSession().addServiceEventListener(fTraceVisualizationEventListener, null);
118
105
    	requestMonitor.done();
119
    	requestMonitor.done();
106
	}
120
	}
107
121
108
	@Override
122
	@Override
109
	public void shutdown(RequestMonitor requestMonitor) {
123
	public void shutdown(RequestMonitor requestMonitor) {
124
        getSession().removeServiceEventListener(fTraceVisualizationEventListener);
125
110
		super.shutdown(requestMonitor);
126
		super.shutdown(requestMonitor);
111
	}
127
	}
112
	
128
	
Lines 461-466 Link Here
461
		return new DebugNewProcessSequence_7_2(executor, isInitial, dmc, file, attributes, rm);
477
		return new DebugNewProcessSequence_7_2(executor, isInitial, dmc, file, attributes, rm);
462
	}
478
	}
463
	
479
	
480
	@Override
481
	public void getProcessesBeingDebugged(final IDMContext dmc, final DataRequestMonitor<IDMContext[]> rm) {
482
		if (fTraceVisualizationEventListener.fTracepointVisualizationEnabled) {
483
			// If we are visualizing data during a live session, we should not ask GDB for the list of threads,
484
			// because we will get the list of active threads, while GDB only cares about thread 1 for visualization.
485
			final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class);
486
			if (containerDmc != null) {
487
				IProcessDMContext procDmc = DMContexts.getAncestorOfType(containerDmc, IProcessDMContext.class);
488
				rm.setData(new IMIExecutionDMContext[]{createExecutionContext(containerDmc, 
489
                        createThreadContext(procDmc, TRACE_VISUALIZATION_THREAD_ID),
490
                        TRACE_VISUALIZATION_THREAD_ID)});
491
				rm.done();
492
				return;
493
			}
494
		}
495
		
496
		super.getProcessesBeingDebugged(dmc, rm);
497
	}
498
	
464
	/** 
499
	/** 
465
	 * Creates the container context that is to be used for the new process that will
500
	 * Creates the container context that is to be used for the new process that will
466
	 * be created by the restart operation.
501
	 * be created by the restart operation.
Lines 528-534 Link Here
528
     * 
563
     * 
529
     * See http://sourceware.org/ml/gdb-patches/2011-03/msg00531.html
564
     * See http://sourceware.org/ml/gdb-patches/2011-03/msg00531.html
530
     * and Bug 352998
565
     * and Bug 352998
531
     *      */
566
     */
532
    private boolean needFixForGDB72Bug352998() {
567
    private boolean needFixForGDB72Bug352998() {
533
    	return true;
568
    	return true;
534
    }
569
    }
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBRunControl_7_0_NS.java (-1 / +15 lines)
Lines 359-364 Link Here
359
	 */
359
	 */
360
	private boolean fRunControlOperationsEnabled = true;
360
	private boolean fRunControlOperationsEnabled = true;
361
	
361
	
362
	/**
363
	 * Keeps track if we are currently visualizing trace data or not.
364
	 * This will only be needed when running GDB 7.2 and tracing.
365
	 * However, we put it in this class to avoid adding new APIs to the
366
	 * maintenance branch.
367
	 */
368
	private boolean fTraceVisualization;
369
	
362
	///////////////////////////////////////////////////////////////////////////
370
	///////////////////////////////////////////////////////////////////////////
363
	// Initialization and shutdown
371
	// Initialization and shutdown
364
	///////////////////////////////////////////////////////////////////////////
372
	///////////////////////////////////////////////////////////////////////////
Lines 1590-1599 Link Here
1590
    @DsfServiceEventHandler 
1598
    @DsfServiceEventHandler 
1591
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
1599
    public void eventDispatched(ITraceRecordSelectedChangedDMEvent e) {
1592
    	if (e.isVisualizationModeEnabled()) {
1600
    	if (e.isVisualizationModeEnabled()) {
1601
    		fTraceVisualization = true;
1602
    		
1593
    		// We have started looking at trace records.  We can no longer
1603
    		// We have started looking at trace records.  We can no longer
1594
    		// do run control operations.
1604
    		// do run control operations.
1595
    		fRunControlOperationsEnabled = false;
1605
    		fRunControlOperationsEnabled = false;
1596
    	} else {
1606
    	} else {
1607
    		fTraceVisualization = false;
1608
    		
1597
    		// We stopped looking at trace data and gone back to debugger mode
1609
    		// We stopped looking at trace data and gone back to debugger mode
1598
    		fRunControlOperationsEnabled = true;
1610
    		fRunControlOperationsEnabled = true;
1599
    	}
1611
    	}
Lines 1604-1610 Link Here
1604
	}
1616
	}
1605
1617
1606
	private void refreshThreadStates() {
1618
	private void refreshThreadStates() {
1607
		fConnection.queueCommand(
1619
		if (fTraceVisualization == false) {
1620
		  fConnection.queueCommand(
1608
			fCommandFactory.createMIThreadInfo(fConnection.getContext()),
1621
			fCommandFactory.createMIThreadInfo(fConnection.getContext()),
1609
			new DataRequestMonitor<MIThreadInfoInfo>(getExecutor(), null) {
1622
			new DataRequestMonitor<MIThreadInfoInfo>(getExecutor(), null) {
1610
				@Override
1623
				@Override
Lines 1645-1650 Link Here
1645
					}
1658
					}
1646
				}
1659
				}
1647
			});
1660
			});
1661
		}
1648
	}
1662
	}
1649
	
1663
	
1650
	private void moveToLocation(final IExecutionDMContext context,
1664
	private void moveToLocation(final IExecutionDMContext context,
(-)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