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 336008
Collapse All | Expand All

(-)data/launch/src/LaunchConfigurationAndRestartTestApp.cc (+32 lines)
Added Link Here
1
#include <stdio.h>
2
#include <stdlib.h>
3
4
int stopAtOther() {
5
    return 0;
6
}
7
8
int reverseTest() {
9
    int i = 0;
10
    i++;
11
    i++;
12
    i++;
13
    i++;
14
    i++;
15
    return 0;
16
}
17
18
int envTest() {
19
    char *home, *launchTest;
20
    home = getenv("HOME");
21
    launchTest = getenv("LAUNCHTEST");
22
    return 0;
23
}
24
25
int main (int argc, char *argv[])
26
{
27
    envTest();
28
    reverseTest();
29
    stopAtOther();
30
    return 0;
31
}
32
(-)data/launch/src/launchConfigTestGdbinit (+3 lines)
Added Link Here
1
echo "Reading launchConfigTestGdbinit and running command:"
2
echo "set args 1 2 3 4 5 6"
3
set args 1 2 3 4 5 6
(-)src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java (-6 / +14 lines)
Lines 39-44 Link Here
39
import org.junit.Assert;
39
import org.junit.Assert;
40
import org.junit.Before;
40
import org.junit.Before;
41
import org.junit.BeforeClass;
41
import org.junit.BeforeClass;
42
import org.junit.Rule;
43
import org.junit.rules.TestName;
42
44
43
/**
45
/**
44
 * This is the base class for the GDB/MI Unit tests.
46
 * This is the base class for the GDB/MI Unit tests.
Lines 49-61 Link Here
49
 * code is to be run.
51
 * code is to be run.
50
 */
52
 */
51
public class BaseTestCase {
53
public class BaseTestCase {
52
54
	
55
	// Make the current test naem available through testName.getMethodName()
56
	@Rule public TestName testName = new TestName();
57
	
53
	public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME";
58
	public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME";
54
	private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp";
59
	private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp";
55
	
60
	
56
    private static GdbLaunch fLaunch;
61
    private static GdbLaunch fLaunch;
57
	private static Map<String, Object> attrs = new HashMap<String, Object>();
62
	private static Map<String, Object> attrs;
58
    private static Process gdbserverProc = null;
63
    private static Process gdbserverProc;
59
    
64
    
60
	/** The MI event associated with the breakpoint at main() */
65
	/** The MI event associated with the breakpoint at main() */
61
	private MIStoppedEvent fInitialStoppedEvent;
66
	private MIStoppedEvent fInitialStoppedEvent;
Lines 114-119 Link Here
114
   
119
   
115
    @BeforeClass
120
    @BeforeClass
116
    public static void baseBeforeClassMethod() {
121
    public static void baseBeforeClassMethod() {
122
    	// Must clear all the attributes, because some tests change them.
123
    	attrs = new HashMap<String, Object>();
124
    	
117
		// Setup information for the launcher
125
		// Setup information for the launcher
118
   		attrs.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP);
126
   		attrs.put(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, DEFAULT_TEST_APP);
119
127
Lines 134-142 Link Here
134
    
142
    
135
    @Before
143
    @Before
136
 	public void baseBeforeMethod() throws Exception {
144
 	public void baseBeforeMethod() throws Exception {
137
    	System.out.println("====================================================================");
145
    	System.out.println("====================================================================================================");
138
		System.out.println("Launching test application: " + attrs.get(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME));
146
		System.out.println("Running test: " + testName.getMethodName() + " using GDB: " + attrs.get(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME));
139
		System.out.println("====================================================================");
147
    	System.out.println("====================================================================================================");
140
		
148
		
141
 		// First check if we should launch gdbserver in the case of a remote session
149
 		// First check if we should launch gdbserver in the case of a remote session
142
		launchGdbServer();
150
		launchGdbServer();
(-)src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java (-14 / +84 lines)
Lines 15-25 Link Here
15
import java.util.HashMap;
15
import java.util.HashMap;
16
import java.util.Map;
16
import java.util.Map;
17
import java.util.concurrent.Callable;
17
import java.util.concurrent.Callable;
18
import java.util.concurrent.TimeUnit;
18
19
19
import junit.framework.Assert;
20
import junit.framework.Assert;
20
21
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
22
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
23
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
22
import org.eclipse.cdt.dsf.concurrent.Query;
24
import org.eclipse.cdt.dsf.concurrent.Query;
25
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
23
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
26
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
24
import org.eclipse.cdt.dsf.datamodel.DMContexts;
27
import org.eclipse.cdt.dsf.datamodel.DMContexts;
25
import org.eclipse.cdt.dsf.datamodel.IDMContext;
28
import org.eclipse.cdt.dsf.datamodel.IDMContext;
Lines 35-42 Link Here
35
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
38
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
36
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
39
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
37
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
40
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
38
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
41
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
39
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
42
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
43
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
44
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
40
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
45
import org.eclipse.cdt.dsf.mi.service.IMICommandControl;
41
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
46
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
42
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
47
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
Lines 53-58 Link Here
53
import org.eclipse.cdt.dsf.service.DsfSession;
58
import org.eclipse.cdt.dsf.service.DsfSession;
54
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil.DefaultTimeouts.ETimeout;
59
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil.DefaultTimeouts.ETimeout;
55
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
60
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
61
import org.eclipse.core.runtime.CoreException;
56
import org.eclipse.core.runtime.IStatus;
62
import org.eclipse.core.runtime.IStatus;
57
import org.eclipse.core.runtime.Status;
63
import org.eclipse.core.runtime.Status;
58
64
Lines 61-67 Link Here
61
 */
67
 */
62
public class SyncUtil {
68
public class SyncUtil {
63
    
69
    
64
    private static ICommandControlService fCommandControl;
70
    private static IGDBControl fGdbControl;
65
    private static IMIRunControl fRunControl;
71
    private static IMIRunControl fRunControl;
66
    private static MIStack fStack;
72
    private static MIStack fStack;
67
    private static IExpressions fExpressions;
73
    private static IExpressions fExpressions;
Lines 82-95 Link Here
82
	        		new DsfServicesTracker(TestsPlugin.getBundleContext(), 
88
	        		new DsfServicesTracker(TestsPlugin.getBundleContext(), 
83
	        				fSession.getId());
89
	        				fSession.getId());
84
	        	
90
	        	
85
	        	fCommandControl = tracker.getService(ICommandControlService.class);		   		
91
	        	fGdbControl = tracker.getService(IGDBControl.class);		   		
86
	        	fRunControl = tracker.getService(IMIRunControl.class);
92
	        	fRunControl = tracker.getService(IMIRunControl.class);
87
	        	fStack = tracker.getService(MIStack.class);
93
	        	fStack = tracker.getService(MIStack.class);
88
	        	fExpressions = tracker.getService(IExpressions.class);
94
	        	fExpressions = tracker.getService(IExpressions.class);
89
	        	fProcessesService = tracker.getService(IMIProcesses.class);
95
	        	fProcessesService = tracker.getService(IMIProcesses.class);
90
	        	fCommandFactory = tracker.getService(IMICommandControl.class).getCommandFactory();
96
	        	fCommandFactory = tracker.getService(IMICommandControl.class).getCommandFactory();
91
	        	
97
	        	
92
	        	fBreakpointsDmc = (IBreakpointsTargetDMContext)fCommandControl.getContext();
98
	        	fBreakpointsDmc = (IBreakpointsTargetDMContext)fGdbControl.getContext();
93
	        	
99
	        	
94
	        	tracker.dispose();
100
	        	tracker.dispose();
95
            }
101
            }
Lines 139-151 Link Here
139
				// ServiceEvent telling us the program has been suspended again
145
				// ServiceEvent telling us the program has been suspended again
140
				switch(stepType) {
146
				switch(stepType) {
141
				case STEP_INTO:
147
				case STEP_INTO:
142
					fCommandControl.queueCommand(fCommandFactory.createMIExecStep(dmc), null);
148
					fGdbControl.queueCommand(fCommandFactory.createMIExecStep(dmc), null);
143
					break;
149
					break;
144
				case STEP_OVER:
150
				case STEP_OVER:
145
					fCommandControl.queueCommand(fCommandFactory.createMIExecNext(dmc), null);
151
					fGdbControl.queueCommand(fCommandFactory.createMIExecNext(dmc), null);
146
					break;
152
					break;
147
				case STEP_RETURN:
153
				case STEP_RETURN:
148
					fCommandControl.queueCommand(fCommandFactory.createMIExecFinish(fStack.createFrameDMContext(dmc, 0)), null);
154
					fGdbControl.queueCommand(fCommandFactory.createMIExecFinish(fStack.createFrameDMContext(dmc, 0)), null);
149
					break;
155
					break;
150
				default:
156
				default:
151
					Assert.assertTrue("Unsupported step type; " + stepType.toString(), false);
157
					Assert.assertTrue("Unsupported step type; " + stepType.toString(), false);
Lines 175-181 Link Here
175
				// No need for a RequestMonitor since we will wait for the
181
				// No need for a RequestMonitor since we will wait for the
176
				// ServiceEvent telling us the program has been suspended again
182
				// ServiceEvent telling us the program has been suspended again
177
				
183
				
178
				fCommandControl.queueCommand(
184
				fGdbControl.queueCommand(
179
						fCommandFactory.createMIExecUntil(dmc, fileName + ":" + lineNo), //$NON-NLS-1$
185
						fCommandFactory.createMIExecUntil(dmc, fileName + ":" + lineNo), //$NON-NLS-1$
180
						null);
186
						null);
181
			}
187
			}
Lines 234-240 Link Here
234
			}
240
			}
235
		};
241
		};
236
242
237
		fCommandControl.queueCommand(
243
		fGdbControl.queueCommand(
238
				fCommandFactory.createMIBreakInsert(fBreakpointsDmc, temporary, false, null, 0, location, 0),
244
				fCommandFactory.createMIBreakInsert(fBreakpointsDmc, temporary, false, null, 0, location, 0),
239
			    addBreakDone);
245
			    addBreakDone);
240
		
246
		
Lines 260-266 Link Here
260
			}
266
			}
261
		};
267
		};
262
268
263
		fCommandControl.queueCommand(fCommandFactory.createMIBreakList(fBreakpointsDmc), listDRM);
269
		fGdbControl.queueCommand(fCommandFactory.createMIBreakList(fBreakpointsDmc), listDRM);
264
		
270
		
265
        wait.waitUntilDone(timeout);
271
        wait.waitUntilDone(timeout);
266
        assertTrue(wait.getMessage(), wait.isOK());
272
        assertTrue(wait.getMessage(), wait.isOK());
Lines 293-299 Link Here
293
			}
299
			}
294
		};
300
		};
295
301
296
		fCommandControl.queueCommand(
302
		fGdbControl.queueCommand(
297
				fCommandFactory.createMIBreakDelete(fBreakpointsDmc, breakpointIndices), //$NON-NLS-1$
303
				fCommandFactory.createMIBreakDelete(fBreakpointsDmc, breakpointIndices), //$NON-NLS-1$
298
				deleteBreakDone);
304
				deleteBreakDone);
299
		
305
		
Lines 312-318 Link Here
312
			public void run() {
318
			public void run() {
313
				// No need for a RequestMonitor since we will wait for the
319
				// No need for a RequestMonitor since we will wait for the
314
				// ServiceEvent telling us the program has been suspended again
320
				// ServiceEvent telling us the program has been suspended again
315
				fCommandControl.queueCommand(
321
				fGdbControl.queueCommand(
316
						fCommandFactory.createMIExecContinue(dmc),
322
						fCommandFactory.createMIExecContinue(dmc),
317
						null);
323
						null);
318
			}
324
			}
Lines 341-347 Link Here
341
			public void run() {
347
			public void run() {
342
				// No need for a RequestMonitor since we will wait for the
348
				// No need for a RequestMonitor since we will wait for the
343
				// ServiceEvent telling us the program has been resumed
349
				// ServiceEvent telling us the program has been resumed
344
				fCommandControl.queueCommand(
350
				fGdbControl.queueCommand(
345
						fCommandFactory.createMIExecContinue(dmc),
351
						fCommandFactory.createMIExecContinue(dmc),
346
						null);
352
						null);
347
			}
353
			}
Lines 408-413 Link Here
408
        fSession.getExecutor().execute(sfQuery);
414
        fSession.getExecutor().execute(sfQuery);
409
        return sfQuery.get();
415
        return sfQuery.get();
410
    }
416
    }
417
    
418
    public static IFrameDMData getFrameData(final IExecutionDMContext execCtx, final int level) throws Throwable {
419
      	Query<IFrameDMData> query = new Query<IFrameDMData>() {
420
    		@Override
421
    		protected void execute(final DataRequestMonitor<IFrameDMData> rm) {
422
    			fStack.getFrames(execCtx, level, level, new DataRequestMonitor<IFrameDMContext[]>(ImmediateExecutor.getInstance(), rm) {
423
    				@Override
424
    				protected void handleSuccess() {
425
    					IFrameDMContext[] frameDmcs = getData();
426
    					assert frameDmcs != null;
427
    					assert frameDmcs.length == 1;
428
    					fStack.getFrameData(frameDmcs[0], rm);
429
    				}
430
    			});
431
    		}
432
    	};
433
434
    	fSession.getExecutor().execute(query);
435
    	return query.get(500, TimeUnit.MILLISECONDS);
436
    }
411
437
412
    public static IExpressionDMContext createExpression(final IDMContext parentCtx, final String expression)
438
    public static IExpressionDMContext createExpression(final IDMContext parentCtx, final String expression)
413
        throws Throwable {
439
        throws Throwable {
Lines 550-556 Link Here
550
		fProcessesService.getExecutor().submit(new Runnable() {
576
		fProcessesService.getExecutor().submit(new Runnable() {
551
            public void run() {
577
            public void run() {
552
            	fProcessesService.getProcessesBeingDebugged(
578
            	fProcessesService.getProcessesBeingDebugged(
553
            			fCommandControl.getContext(), 
579
            			fGdbControl.getContext(), 
554
            			new DataRequestMonitor<IDMContext[]>(fProcessesService.getExecutor(), null) {
580
            			new DataRequestMonitor<IDMContext[]>(fProcessesService.getExecutor(), null) {
555
                    @Override
581
                    @Override
556
                    protected void handleCompleted() {
582
                    protected void handleCompleted() {
Lines 576-579 Link Here
576
    	return (IContainerDMContext)waitor.getReturnInfo();
602
    	return (IContainerDMContext)waitor.getReturnInfo();
577
	}
603
	}
578
    
604
    
605
    /**
606
     * Restart the program.
607
     */
608
	public static void restart(final GdbLaunch launch) throws Throwable {	
609
    	// Check if restart is allowed
610
        Query<Boolean> query = new Query<Boolean>() {
611
			@Override
612
			protected void execute(DataRequestMonitor<Boolean> rm) {
613
			    rm.setData(fGdbControl.canRestart());
614
				rm.done();
615
			}
616
        };
617
618
        fGdbControl.getExecutor().execute(query);
619
        boolean canRestart = query.get(500, TimeUnit.MILLISECONDS);
620
        if (!canRestart) {
621
        	throw new CoreException(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID, "Unable to restart"));
622
        }
623
624
        // Now wait for the stopped event of the restart
625
		final ServiceEventWaitor<MIStoppedEvent> eventWaitor =
626
			new ServiceEventWaitor<MIStoppedEvent>(
627
					fSession,
628
					MIStoppedEvent.class);
629
			
630
        // Perform the restart
631
        Query<Boolean> query2 = new Query<Boolean>() {
632
			@Override
633
			protected void execute(final DataRequestMonitor<Boolean> rm) {
634
				fGdbControl.initInferiorInputOutput(new RequestMonitor(ImmediateExecutor.getInstance(), rm) {
635
                	@Override
636
                	protected void handleSuccess() {
637
                		fGdbControl.createInferiorProcess();
638
                		fGdbControl.restart(launch, rm);
639
                	}
640
                });
641
			}
642
        };
643
644
        fGdbControl.getExecutor().execute(query2);
645
        query2.get(500, TimeUnit.MILLISECONDS);
646
        
647
 		eventWaitor.waitForEvent(DefaultTimeouts.get(ETimeout.waitForStop));
648
    }
579
}
649
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/AllSuites.java (+2 lines)
Lines 15-20 Link Here
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8.Suite_6_8;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8.Suite_6_8;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0.Suite_7_0;
16
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0.Suite_7_0;
17
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.Suite_7_1;
17
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.Suite_7_1;
18
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2.Suite_7_2;
18
import org.junit.runner.RunWith;
19
import org.junit.runner.RunWith;
19
import org.junit.runners.Suite;
20
import org.junit.runners.Suite;
20
21
Lines 29-34 Link Here
29
30
30
@RunWith(Suite.class)
31
@RunWith(Suite.class)
31
@Suite.SuiteClasses({
32
@Suite.SuiteClasses({
33
	Suite_7_2.class,
32
	Suite_7_1.class,
34
	Suite_7_1.class,
33
	Suite_7_0.class,
35
	Suite_7_0.class,
34
	Suite_6_8.class,
36
	Suite_6_8.class,
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/AllTests.java (-1 / +2 lines)
Lines 32-38 Link Here
32
	MIBreakpointsTest.class,
32
	MIBreakpointsTest.class,
33
	MICatchpointsTest.class,
33
	MICatchpointsTest.class,
34
	MIDisassemblyTest.class,
34
	MIDisassemblyTest.class,
35
	GDBProcessesTest.class
35
	GDBProcessesTest.class,
36
	LaunchConfigurationAndRestartTest.class,
36
	/* Add your suite class here */
37
	/* Add your suite class here */
37
})
38
})
38
39
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java (+629 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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests;
12
13
import static org.junit.Assert.assertFalse;
14
import static org.junit.Assert.assertTrue;
15
import static org.junit.Assert.fail;
16
17
import java.util.HashMap;
18
import java.util.Map;
19
import java.util.concurrent.ExecutionException;
20
import java.util.concurrent.TimeUnit;
21
import java.util.concurrent.TimeoutException;
22
23
import org.eclipse.cdt.debug.core.CDIDebugModel;
24
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
25
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
26
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
27
import org.eclipse.cdt.dsf.concurrent.Query;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
30
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
31
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
32
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
33
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
34
import org.eclipse.cdt.dsf.mi.service.MIExpressions;
35
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
36
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
37
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
38
import org.eclipse.cdt.dsf.service.DsfSession;
39
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
40
import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
41
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
42
import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
43
import org.eclipse.core.resources.IFile;
44
import org.eclipse.core.runtime.CoreException;
45
import org.eclipse.core.runtime.IPath;
46
import org.eclipse.core.runtime.Path;
47
import org.eclipse.debug.core.ILaunchManager;
48
import org.junit.After;
49
import org.junit.Before;
50
import org.junit.Ignore;
51
import org.junit.Test;
52
import org.junit.runner.RunWith;
53
54
@RunWith(BackgroundRunner.class)
55
public class LaunchConfigurationAndRestartTest extends BaseTestCase {
56
57
	protected static final String PROGRAM_DIR = "data/launch/bin/";
58
	protected static final String PROGRAM_NAME = "LaunchConfigurationAndRestartTestApp.exe";
59
	protected static final String PROGRAM = PROGRAM_DIR + PROGRAM_NAME;
60
	
61
	protected static final int FIRST_LINE_IN_MAIN = 27;
62
	protected static final int LAST_LINE_IN_MAIN = 30;
63
64
	protected DsfSession fSession;
65
    protected DsfServicesTracker fServicesTracker;
66
    protected IExpressions fExpService;
67
    protected IGDBControl fGdbControl;
68
    
69
    // Indicates if a restart operation should be done
70
    // This allows us to re-use tests for restarts tests
71
    protected boolean fRestart;
72
    
73
    @Override
74
	@Before
75
 	public void baseBeforeMethod() throws Exception {
76
    	// The class BaseTestCase sets up the launch in its @BeforeClass method.
77
    	// Usually this is ok, because every test uses the same launch configuration.
78
    	// However, for the tests of this class, we are changing the launch
79
    	// configuration every time.  Therefore, we need to reset it to the default
80
    	// before every test; that means in the @Before method instead of @BeforeClass
81
82
    	// Reset the launch configuration
83
    	super.baseBeforeClassMethod();
84
    	// Set the binary
85
        setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, PROGRAM);
86
        
87
    	// Can't run the launch right away because each test needs to first set some 
88
        // parameters.  The individual tests will be responsible for starting the launch. 
89
    }
90
    
91
    // This method cannot be tagged as @Before, because the launch is not
92
    // running yet.  We have to call this manually after all the proper
93
    // parameters have been set for the launch
94
    public void performLaunch() throws Exception {
95
    	// perform the launch
96
        super.baseBeforeMethod();
97
 
98
        fSession = getGDBLaunch().getSession();
99
        Runnable runnable = new Runnable() {
100
            public void run() {
101
            	fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
102
            	
103
            	fExpService = fServicesTracker.getService(IExpressions.class);
104
            	fGdbControl = fServicesTracker.getService(IGDBControl.class);
105
            }
106
        };
107
        fSession.getExecutor().submit(runnable).get();
108
        
109
        // Restart the program if we are testing such a case
110
        if (fRestart) {
111
        	synchronized (this) {
112
				wait(1000);
113
			}
114
    		fRestart = false;
115
        	try {
116
				SyncUtil.restart(getGDBLaunch());
117
			} catch (Throwable e) {
118
				fail("Restart failed: " + e.getMessage());
119
			}
120
        }
121
    }
122
123
    @After
124
    public void shutdown() throws Exception {
125
        if (fServicesTracker != null) fServicesTracker.dispose();
126
    }
127
128
129
    // HACK to get the full path of the program, which we need in other
130
    // tests.  There must be a proper eclipse way to do this!
131
    private static String fFullProgramPath;
132
	@Test
133
    public void getFullPath() throws Throwable {
134
		performLaunch();
135
		MIStoppedEvent stopped = getInitialStoppedEvent();
136
		fFullProgramPath = stopped.getFrame().getFullname();
137
	}
138
139
    // *********************************************************************
140
    // Below are the tests for the launch configuration.
141
    // *********************************************************************
142
143
    /**
144
     * This test will tell the launch to set the working directory to data/launch/src/
145
     * and will verify that we can find the file LaunchConfigurationAndRestartTestApp.cpp.
146
     * This will confirm that GDB has been properly configured with the working dir.
147
     */
148
    @Test
149
    public void testSettingWorkingDirectory() throws Throwable {
150
    	IPath path = new Path(fFullProgramPath);
151
    	String dir = path.removeLastSegments(4).toPortableString() + "/" + PROGRAM_DIR;
152
        setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, dir);
153
        setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, dir + PROGRAM_NAME);
154
155
       	performLaunch();
156
        
157
    	Query<MIInfo> query = new Query<MIInfo>() {
158
    		@Override
159
    		protected void execute(DataRequestMonitor<MIInfo> rm) {
160
    			fGdbControl.queueCommand(
161
    					fGdbControl.getCommandFactory().createMIFileExecFile(
162
    							fGdbControl.getContext(), PROGRAM_NAME),
163
    				    rm);
164
    		}
165
    	};
166
    	try {
167
    		fExpService.getExecutor().execute(query);
168
    		query.get(500, TimeUnit.MILLISECONDS);
169
    	} catch (InterruptedException e) {
170
    		fail(e.getMessage());
171
    	} catch (ExecutionException e) {
172
    		fail(e.getCause().getMessage());
173
    	} catch (TimeoutException e) {
174
    		fail(e.getMessage());
175
    	}
176
    }
177
    	
178
	/**
179
	 * This test will verify that a launch will fail if the gdbinit file
180
	 * does not exist and is not called ".gdbinit".
181
	 */
182
    @Test
183
    public void testSourceInvalidGdbInit() throws Throwable {
184
        setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, 
185
                           "gdbinitThatDoesNotExist");
186
        try {
187
        	performLaunch();
188
        } catch (CoreException e) {
189
        	// Success of the test
190
        	return;
191
        }
192
        
193
        fail("Launch seems to have succeeded even though the gdbinit file did not exist");
194
    }
195
196
	/**
197
	 * This test will verify that a launch does not fail if the gdbinit file
198
	 * is called ".gdbinit" and does not exist
199
	 */
200
    @Test
201
    public void testSourceDefaultGdbInit() throws Throwable {
202
        setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, 
203
                           ".gdbinit");
204
        try {
205
        	performLaunch();
206
        } catch (CoreException e) {
207
        	fail("Launch has failed even though the gdbinit file has the default name of .gdbinit");
208
        }
209
    }
210
    
211
    /**
212
     * This test will tell the launch to use data/launch/src/launchConfigTestGdbinit
213
     * as the gdbinit file.  We then verify the that the content was properly read.
214
     * launchConfigTestGdbinit will simply set some arguments for the program to read;
215
     * the arguments are "1 2 3 4 5 6".
216
     */    
217
    @Test
218
    public void testSourceGdbInit() throws Throwable {
219
        setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_GDB_INIT, 
220
                           "data/launch/src/launchConfigTestGdbinit");
221
        performLaunch();
222
        
223
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
224
225
    	// Check that argc is correct
226
    	final IExpressionDMContext argcDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argc");
227
    	Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
228
    		@Override
229
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
230
    			fExpService.getFormattedExpressionValue(
231
    					fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
232
    		}
233
    	};
234
    	try {
235
    		fExpService.getExecutor().execute(query);
236
    		FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
237
    		
238
    		// Argc should be 7: the program name and the six arguments
239
    		assertTrue("Expected 7 but got " + value.getFormattedValue(),
240
    				value.getFormattedValue().trim().equals("7"));
241
    	} catch (InterruptedException e) {
242
    		fail(e.getMessage());
243
    	} catch (ExecutionException e) {
244
    		fail(e.getCause().getMessage());
245
    	} catch (TimeoutException e) {
246
    		fail(e.getMessage());
247
    	}
248
    	
249
    	// Check that argv is also correct.  For simplicity we only check the last argument
250
    	final IExpressionDMContext argvDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argv[argc-1]");
251
    	Query<FormattedValueDMData> query2 = new Query<FormattedValueDMData>() {
252
    		@Override
253
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
254
    			fExpService.getFormattedExpressionValue(
255
    					fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
256
    		}
257
    	};
258
    	try {
259
    		fExpService.getExecutor().execute(query2);
260
    		FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
261
    		assertTrue("Expected \"6\" but got " + value.getFormattedValue(),
262
    				value.getFormattedValue().trim().endsWith("\"6\""));
263
    	} catch (InterruptedException e) {
264
    		fail(e.getMessage());
265
    	} catch (ExecutionException e) {
266
    		fail(e.getCause().getMessage());
267
    	} catch (TimeoutException e) {
268
    		fail(e.getMessage());
269
    	}
270
    }
271
272
    /**
273
     * Repeat the test testSourceGdbInit, but after a restart.
274
     */
275
    @Test
276
    public void testSourceGdbInitRestart() throws Throwable {
277
    	fRestart = true;
278
    	testSourceGdbInit();
279
    }
280
281
    /**
282
     * This test will tell the launch to clear the environment variables.  We will
283
     * then check that the variable $HOME cannot be found by the program.
284
     */
285
    @Test
286
    public void testClearingEnvironment() throws Throwable {
287
        setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
288
        performLaunch();
289
        
290
        SyncUtil.runToLocation("envTest");
291
        MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
292
        
293
        // The program has stored the content of $HOME into a variable called 'home'.
294
        // Let's verify this variable is 0x0 which means $HOME does not exist.
295
        final IExpressionDMContext exprDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "home");
296
        Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
297
			@Override
298
			protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
299
				fExpService.getFormattedExpressionValue(
300
                		fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
301
			}
302
        };
303
        try {
304
        	fExpService.getExecutor().execute(query);
305
        	FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
306
        	assertTrue("Expected 0x0 but got " + value.getFormattedValue(),
307
        			   value.getFormattedValue().equals("0x0"));
308
        } catch (InterruptedException e) {
309
        	fail(e.getMessage());
310
        } catch (ExecutionException e) {
311
        	fail(e.getCause().getMessage());
312
        } catch (TimeoutException e) {
313
        	fail(e.getMessage());
314
        }
315
    }
316
    
317
    /**
318
     * Repeat the test testClearingEnvironment, but after a restart.
319
     */
320
    @Test
321
    public void testClearingEnvironmentRestart() throws Throwable {
322
    	fRestart = true;
323
    	testClearingEnvironment();
324
    }
325
326
    /**
327
     * This test will tell the launch to set a new environment variable LAUNCHTEST.  
328
     * We will then check that this new variable can be read by the program.
329
     */
330
    @Test
331
    public void testSettingEnvironment() throws Throwable {
332
    	setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true);
333
334
    	Map<String, String> map = new HashMap<String, String>(1);
335
    	map.put("LAUNCHTEST", "IS SET");
336
    	setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
337
    	performLaunch();
338
339
    	SyncUtil.runToLocation("envTest");
340
    	MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
341
342
    	// The program has stored the content of $LAUNCHTEST into a variable called 'launchTest'.
343
    	// Let's verify this variable is set to "IS SET".
344
    	final IExpressionDMContext exprDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "launchTest");
345
    	Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
346
    		@Override
347
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
348
    			fExpService.getFormattedExpressionValue(
349
    					fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
350
    		}
351
    	};
352
    	try {
353
    		fExpService.getExecutor().execute(query);
354
    		FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
355
    		assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(),
356
    				value.getFormattedValue().trim().endsWith("\"IS SET\""));
357
    	} catch (InterruptedException e) {
358
    		fail(e.getMessage());
359
    	} catch (ExecutionException e) {
360
    		fail(e.getCause().getMessage());
361
    	} catch (TimeoutException e) {
362
    		fail(e.getMessage());
363
    	}
364
    	
365
    	// Check that the normal environment is there by checking that $HOME (which is stored in 'home" exists.
366
        final IExpressionDMContext exprDmc2 = SyncUtil.createExpression(stoppedEvent.getDMContext(), "home");
367
        Query<FormattedValueDMData> query2 = new Query<FormattedValueDMData>() {
368
			@Override
369
			protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
370
				fExpService.getFormattedExpressionValue(
371
                		fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm);
372
			}
373
        };
374
        try {
375
        	fExpService.getExecutor().execute(query2);
376
        	FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
377
        	assertFalse("Expected something else than 0x0",
378
        			   value.getFormattedValue().equals("0x0"));
379
        } catch (InterruptedException e) {
380
        	fail(e.getMessage());
381
        } catch (ExecutionException e) {
382
        	fail(e.getCause().getMessage());
383
        } catch (TimeoutException e) {
384
        	fail(e.getMessage());
385
        }
386
387
    }
388
    
389
    /**
390
     * Repeat the test testSettingEnvironment, but after a restart.
391
     */
392
    @Test
393
    public void testSettingEnvironmentRestart() throws Throwable {
394
    	fRestart = true;
395
    	testSettingEnvironment();
396
    }
397
398
    /**
399
     * This test will tell the launch to clear the environment variables and then
400
     * set a new environment variable LAUNCHTEST.  We will then check that the variable 
401
     * $HOME cannot be found by the program and that the new variable LAUNCHTEST can be
402
     * read by the program.
403
     */
404
    @Test
405
    public void testClearingAndSettingEnvironment() throws Throwable {
406
        setLaunchAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, false);
407
        
408
       	Map<String, String> map = new HashMap<String, String>(1);
409
    	map.put("LAUNCHTEST", "IS SET");
410
    	setLaunchAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
411
    	performLaunch();
412
413
    	SyncUtil.runToLocation("envTest");
414
    	MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER);
415
416
    	// The program has stored the content of $LAUNCHTEST into a variable called 'launchTest'.
417
    	// Let's verify this variable is set to "IS SET".
418
    	final IExpressionDMContext exprDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "launchTest");
419
    	Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
420
    		@Override
421
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
422
    			fExpService.getFormattedExpressionValue(
423
    					fExpService.getFormattedValueContext(exprDmc, MIExpressions.DETAILS_FORMAT), rm);
424
    		}
425
    	};
426
    	try {
427
    		fExpService.getExecutor().execute(query);
428
    		FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
429
    		assertTrue("Expected a string ending with \"IS SET\" but got " + value.getFormattedValue(),
430
    				value.getFormattedValue().trim().endsWith("\"IS SET\""));
431
    	} catch (InterruptedException e) {
432
    		fail(e.getMessage());
433
    	} catch (ExecutionException e) {
434
    		fail(e.getCause().getMessage());
435
    	} catch (TimeoutException e) {
436
    		fail(e.getMessage());
437
    	}
438
    	
439
        // The program has stored the content of $HOME into a variable called 'home'.
440
        // Let's verify this variable is 0x0 which means it does not exist.
441
        final IExpressionDMContext exprDmc2 = SyncUtil.createExpression(stoppedEvent.getDMContext(), "home");
442
        Query<FormattedValueDMData> query2 = new Query<FormattedValueDMData>() {
443
			@Override
444
			protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
445
				fExpService.getFormattedExpressionValue(
446
                		fExpService.getFormattedValueContext(exprDmc2, MIExpressions.DETAILS_FORMAT), rm);
447
			}
448
        };
449
        try {
450
        	fExpService.getExecutor().execute(query2);
451
        	FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
452
        	assertTrue("Expected 0x0 but got " + value.getFormattedValue(),
453
        			   value.getFormattedValue().equals("0x0"));
454
        } catch (InterruptedException e) {
455
        	fail(e.getMessage());
456
        } catch (ExecutionException e) {
457
        	fail(e.getCause().getMessage());
458
        } catch (TimeoutException e) {
459
        	fail(e.getMessage());
460
        }
461
    }
462
463
    /**
464
     * Repeat the test testClearingAndSettingEnvironment, but after a restart.
465
     */
466
    @Test
467
    public void testClearingAndSettingEnvironmentRestart() throws Throwable {
468
    	fRestart = true;
469
    	testClearingAndSettingEnvironment();
470
    }
471
    
472
    /**
473
     * This test will tell the launch to set some arguments for the program.  We will
474
     * then check that the program has the same arguments.
475
     */
476
    @Test
477
    public void testSettingArguments() throws Throwable {
478
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "1 2 3\n4 5 6");
479
    	performLaunch();
480
481
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
482
483
    	// Check that argc is correct
484
    	final IExpressionDMContext argcDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argc");
485
    	Query<FormattedValueDMData> query = new Query<FormattedValueDMData>() {
486
    		@Override
487
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
488
    			fExpService.getFormattedExpressionValue(
489
    					fExpService.getFormattedValueContext(argcDmc, MIExpressions.DETAILS_FORMAT), rm);
490
    		}
491
    	};
492
    	try {
493
    		fExpService.getExecutor().execute(query);
494
    		FormattedValueDMData value = query.get(500, TimeUnit.MILLISECONDS);
495
    		
496
    		// Argc should be 7: the program name and the six arguments
497
    		assertTrue("Expected 7 but got " + value.getFormattedValue(),
498
    				value.getFormattedValue().trim().equals("7"));
499
    	} catch (InterruptedException e) {
500
    		fail(e.getMessage());
501
    	} catch (ExecutionException e) {
502
    		fail(e.getCause().getMessage());
503
    	} catch (TimeoutException e) {
504
    		fail(e.getMessage());
505
    	}
506
    	
507
    	// Check that argv is also correct.  For simplicity we only check the last argument
508
    	final IExpressionDMContext argvDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argv[argc-1]");
509
    	Query<FormattedValueDMData> query2 = new Query<FormattedValueDMData>() {
510
    		@Override
511
    		protected void execute(DataRequestMonitor<FormattedValueDMData> rm) {
512
    			fExpService.getFormattedExpressionValue(
513
    					fExpService.getFormattedValueContext(argvDmc, MIExpressions.DETAILS_FORMAT), rm);
514
    		}
515
    	};
516
    	try {
517
    		fExpService.getExecutor().execute(query2);
518
    		FormattedValueDMData value = query2.get(500, TimeUnit.MILLISECONDS);
519
    		assertTrue("Expected \"6\" but got " + value.getFormattedValue(),
520
    				value.getFormattedValue().trim().endsWith("\"6\""));
521
    	} catch (InterruptedException e) {
522
    		fail(e.getMessage());
523
    	} catch (ExecutionException e) {
524
    		fail(e.getCause().getMessage());
525
    	} catch (TimeoutException e) {
526
    		fail(e.getMessage());
527
    	}
528
    }
529
    
530
    /**
531
     * Repeat the test testSettingArguments, but after a restart.
532
     */
533
    @Test
534
    public void testSettingArgumentsRestart() throws Throwable {
535
    	fRestart = true;
536
    	testSettingArguments();
537
    }
538
539
    /**
540
     * This test will tell the launch to "stop on main" at method main(), which we will verify.
541
     */
542
     @Test
543
    public void testStopAtMain() throws Throwable {
544
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
545
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
546
    	performLaunch();
547
548
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
549
    	assertTrue("Expected to stop at main:27 but got " +
550
    			   stoppedEvent.getFrame().getFunction() + ":" +
551
    			   Integer.toString(stoppedEvent.getFrame().getLine()),
552
    			   stoppedEvent.getFrame().getFunction().equals("main") &&
553
    			   stoppedEvent.getFrame().getLine() == 27);
554
    }
555
    
556
    /**
557
     * Repeat the test testStopAtMain, but after a restart.
558
     */
559
    @Test
560
    public void testStopAtMainRestart() throws Throwable {
561
    	fRestart = true;
562
    	testStopAtMain();
563
    }
564
    
565
    /**
566
     * This test will tell the launch to "stop on main" at method stopAtOther(), 
567
     * which we will then verify.
568
     */
569
    @Test
570
    public void testStopAtOther() throws Throwable {
571
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
572
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "stopAtOther");
573
    	performLaunch();
574
575
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
576
    	assertTrue("Expected to stop at stopAtOther but got " +
577
    			   stoppedEvent.getFrame().getFunction() + ":",
578
    			   stoppedEvent.getFrame().getFunction().equals("stopAtOther"));
579
    }
580
    
581
    /**
582
     * Repeat the test testStopAtOther, but after a restart.
583
     */
584
    @Test
585
    public void testStopAtOtherRestart() throws Throwable {
586
    	fRestart = true;
587
    	testStopAtOther();
588
    }
589
590
    
591
    /**
592
     * This test will set a breakpoint at some place in the program and will tell 
593
     * the launch to NOT "stop on main".  We will verify that the first stop is
594
     * at the breakpoint that we set.
595
     */
596
    @Ignore
597
    @Test
598
    public void testNoStopAtMain() throws Throwable {
599
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
600
    	// Set this one as well to make sure it gets ignored
601
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
602
    	
603
    	// We need to set the breakpoint before the launch is started, but the only way to do that is
604
    	// to set it in the platorm.  Ok, but how do I get an IResource that points to my binary?
605
    	// The current workspace is the JUnit runtime workspace instead of the workspace containing
606
    	// the JUnit tests.
607
    	
608
    	IFile fakeFile = null;
609
        CDIDebugModel.createLineBreakpoint(PROGRAM, fakeFile, ICBreakpointType.REGULAR, LAST_LINE_IN_MAIN + 1, true, 0, "", true); //$NON-NLS-1$
610
    	performLaunch();
611
612
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
613
    	assertTrue("Expected to stop at envTest but got " +
614
    			   stoppedEvent.getFrame().getFunction() + ":",
615
    			   stoppedEvent.getFrame().getFunction().equals("envTest"));
616
    }
617
    
618
    /**
619
     * Repeat the test testNoStopAtMain, but after a restart.
620
     */
621
    @Ignore
622
    @Test
623
    public void testNoStopAtMainRestart() throws Throwable {
624
    	fRestart = true;
625
    	testNoStopAtMain();
626
    }
627
628
629
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/LaunchConfigurationAndRestartTest_6_6.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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6;
12
13
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
14
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.LaunchConfigurationAndRestartTest;
16
import org.junit.Before;
17
import org.junit.runner.RunWith;
18
19
@RunWith(BackgroundRunner.class)
20
public class LaunchConfigurationAndRestartTest_6_6 extends LaunchConfigurationAndRestartTest {
21
	
22
	// For the launch config test, we must set the attributes in the @Before method
23
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
24
	// by the tests themselves
25
	@Before
26
	public void beforeMethod_6_6() {
27
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_6);
28
	}
29
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_6/Suite_6_6.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_6_6.class,
34
	MICatchpointsTest_6_6.class,
35
	MIDisassemblyTest_6_6.class,
35
	MIDisassemblyTest_6_6.class,
36
	GDBProcessesTest_6_6.class,
36
	GDBProcessesTest_6_6.class,
37
	LaunchConfigurationAndRestartTest_6_6.class,
37
	Suite_Sessionless_Tests.class	
38
	Suite_Sessionless_Tests.class	
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/LaunchConfigurationAndRestartTest_6_7.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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7;
12
13
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
14
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_6.LaunchConfigurationAndRestartTest_6_6;
16
import org.junit.Before;
17
import org.junit.runner.RunWith;
18
19
@RunWith(BackgroundRunner.class)
20
public class LaunchConfigurationAndRestartTest_6_7 extends LaunchConfigurationAndRestartTest_6_6 {
21
	
22
	// For the launch config test, we must set the attributes in the @Before method
23
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
24
	// by the tests themselves
25
	@Before
26
	public void beforeMethod_6_7() {
27
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_7);
28
	}
29
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_7/Suite_6_7.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_6_7.class,
34
	MICatchpointsTest_6_7.class,
35
	MIDisassemblyTest_6_7.class,
35
	MIDisassemblyTest_6_7.class,
36
	GDBProcessesTest_6_7.class,
36
	GDBProcessesTest_6_7.class,
37
	LaunchConfigurationAndRestartTest_6_7.class,
37
	Suite_Sessionless_Tests.class	
38
	Suite_Sessionless_Tests.class	
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/LaunchConfigurationAndRestartTest_6_8.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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8;
12
13
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
14
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_7.LaunchConfigurationAndRestartTest_6_7;
16
import org.junit.Before;
17
import org.junit.runner.RunWith;
18
19
@RunWith(BackgroundRunner.class)
20
public class LaunchConfigurationAndRestartTest_6_8 extends LaunchConfigurationAndRestartTest_6_7 {
21
	
22
	// For the launch config test, we must set the attributes in the @Before method
23
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
24
	// by the tests themselves
25
	@Before
26
	public void beforeMethod_6_8() {
27
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_6_8);
28
	}
29
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_6_8/Suite_6_8.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_6_8.class,
34
	MICatchpointsTest_6_8.class,
35
	MIDisassemblyTest_6_8.class,
35
	MIDisassemblyTest_6_8.class,
36
	GDBProcessesTest_6_8.class,
36
	GDBProcessesTest_6_8.class,
37
	LaunchConfigurationAndRestartTest_6_8.class,
37
	Suite_Sessionless_Tests.class
38
	Suite_Sessionless_Tests.class
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/LaunchConfigurationAndRestartTest_7_0.java (+351 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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
12
13
import static org.junit.Assert.assertTrue;
14
import static org.junit.Assert.fail;
15
16
import java.util.concurrent.ExecutionException;
17
import java.util.concurrent.TimeUnit;
18
import java.util.concurrent.TimeoutException;
19
20
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
22
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
23
import org.eclipse.cdt.dsf.concurrent.Query;
24
import org.eclipse.cdt.dsf.datamodel.DMContexts;
25
import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
26
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
27
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
28
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
29
import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
30
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
31
import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
32
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
33
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakpoint;
34
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
35
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
36
import org.eclipse.cdt.tests.dsf.gdb.framework.ServiceEventWaitor;
37
import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil;
38
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
39
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_6_8.LaunchConfigurationAndRestartTest_6_8;
40
import org.junit.Before;
41
import org.junit.Ignore;
42
import org.junit.Test;
43
import org.junit.runner.RunWith;
44
45
@RunWith(BackgroundRunner.class)
46
public class LaunchConfigurationAndRestartTest_7_0 extends LaunchConfigurationAndRestartTest_6_8 {
47
	// For the launch config test, we must set the attributes in the @Before method
48
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
49
	// by the tests themselves
50
	@Before
51
	public void beforeMethod_7_0() {
52
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_0);
53
	}
54
	
55
	/**
56
	 * This test will confirm that we have turned on "pending breakpoints"
57
	 * The pending breakpoint setting only affects CLI commands so we have
58
	 * to test with one.  We don't have classes to set breakpoints using CLI,
59
	 * but we do for tracepoints, which is the same for this test.
60
	 * 
61
	 * The pending breakpoint feature only works with tracepoints starting
62
	 * with GDB 7.0.
63
	 * 
64
	 * We could run this test before 7.0 but we would have to use a breakpoint
65
	 * set using CLI commands.
66
	 */
67
    @Test
68
    public void testPendingBreakpointSetting() throws Throwable {
69
        performLaunch();
70
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
71
72
    	final IBreakpointsTargetDMContext bpTargetDmc = DMContexts.getAncestorOfType(stoppedEvent.getDMContext(),
73
    																				 IBreakpointsTargetDMContext.class);
74
    	Query<MIBreakListInfo> query = new Query<MIBreakListInfo>() {
75
    		@Override
76
    		protected void execute(final DataRequestMonitor<MIBreakListInfo> rm) {
77
    			fGdbControl.queueCommand(
78
    					fGdbControl.getCommandFactory().createCLITrace(bpTargetDmc, "invalid", ""),
79
    					new DataRequestMonitor<CLITraceInfo>(ImmediateExecutor.getInstance(), rm) {
80
    						@Override
81
    						protected void handleSuccess() {
82
    							fGdbControl.queueCommand(
83
    									fGdbControl.getCommandFactory().createMIBreakList(bpTargetDmc), 
84
    									new DataRequestMonitor<MIBreakListInfo>(ImmediateExecutor.getInstance(), rm) {
85
    			    						@Override
86
    			    						protected void handleSuccess() {
87
    			    							rm.setData(getData());
88
    			    							rm.done();
89
    			    						}
90
    									});
91
    						}
92
    					});
93
    		}
94
    	};
95
    	try {
96
    		fExpService.getExecutor().execute(query);
97
    		MIBreakListInfo value = query.get(500, TimeUnit.MILLISECONDS);
98
    		MIBreakpoint[] bps = value.getMIBreakpoints();
99
    		assertTrue("Expected 1 breakpoint but got " + bps.length,
100
    				   bps.length == 1);
101
    		assertTrue("Expending a <PENDING> breakpoint but got one at " + bps[0].getAddress(),
102
    				   bps[0].getAddress().equals("<PENDING>"));
103
    	} catch (InterruptedException e) {
104
    		fail(e.getMessage());
105
    	} catch (ExecutionException e) {
106
    		fail(e.getCause().getMessage());
107
    	} catch (TimeoutException e) {
108
    		fail(e.getMessage());
109
    	}
110
    }
111
    
112
    /**
113
     * This test will tell the launch to "stop on main" at method main() with reverse
114
     * debugging enabled.  We will verify that the launch stops at main() and that
115
     * reverse debugging is enabled.
116
     */
117
    @Test
118
    public void testStopAtMainWithReverse() throws Throwable {
119
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
120
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
121
    	setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE, true);
122
    	performLaunch();
123
124
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
125
    	// Make sure we stopped at the first line of main
126
    	assertTrue("Expected to stop at main:" + FIRST_LINE_IN_MAIN + " but got " +
127
    			   stoppedEvent.getFrame().getFunction() + ":" +
128
    			   Integer.toString(stoppedEvent.getFrame().getLine()),
129
    			   stoppedEvent.getFrame().getFunction().equals("main") &&
130
    			   stoppedEvent.getFrame().getLine() == FIRST_LINE_IN_MAIN);
131
    	
132
    	// Step a couple of times and check where we are
133
    	final int NUM_STEPS = 3;
134
    	stoppedEvent = SyncUtil.step(NUM_STEPS,  StepType.STEP_OVER);
135
    	assertTrue("Expected to stop at main:" + (FIRST_LINE_IN_MAIN+NUM_STEPS) + " but got " +
136
 			   stoppedEvent.getFrame().getFunction() + ":" +
137
 			   Integer.toString(stoppedEvent.getFrame().getLine()),
138
 			   stoppedEvent.getFrame().getFunction().equals("main") &&
139
 			   stoppedEvent.getFrame().getLine() == FIRST_LINE_IN_MAIN+NUM_STEPS);
140
    	
141
    	// Now step backwards to make sure reverse was enabled
142
    	
143
		final ServiceEventWaitor<MIStoppedEvent> eventWaitor =
144
			new ServiceEventWaitor<MIStoppedEvent>(
145
					fSession,
146
					MIStoppedEvent.class);
147
148
    	final int REVERSE_NUM_STEPS = 2;
149
    	final IExecutionDMContext execDmc = stoppedEvent.getDMContext();
150
    	Query<MIInfo> query = new Query<MIInfo>() {
151
    		@Override
152
    		protected void execute(DataRequestMonitor<MIInfo> rm) {
153
    			fGdbControl.queueCommand(
154
    					fGdbControl.getCommandFactory().createMIExecReverseNext(execDmc, REVERSE_NUM_STEPS),
155
    					rm);
156
    		}
157
    	};
158
    	try {
159
    		fGdbControl.getExecutor().execute(query);
160
    		query.get(500, TimeUnit.MILLISECONDS);
161
    	} catch (InterruptedException e) {
162
    		fail(e.getMessage());
163
    	} catch (ExecutionException e) {
164
    		fail(e.getCause().getMessage());
165
    	} catch (TimeoutException e) {
166
    		fail(e.getMessage());
167
    	}
168
    	
169
    	stoppedEvent = eventWaitor.waitForEvent(1000);
170
    	
171
    	assertTrue("Expected to stop at main:" + (FIRST_LINE_IN_MAIN+NUM_STEPS-REVERSE_NUM_STEPS) + " but got " +
172
  			   stoppedEvent.getFrame().getFunction() + ":" +
173
  			   Integer.toString(stoppedEvent.getFrame().getLine()),
174
  			   stoppedEvent.getFrame().getFunction().equals("main") &&
175
  			   stoppedEvent.getFrame().getLine() == FIRST_LINE_IN_MAIN+NUM_STEPS-REVERSE_NUM_STEPS);
176
    }
177
    
178
    /**
179
     * Repeat the test testStopAtMainWithReverse, but after a restart.
180
     */
181
    @Test
182
    public void testStopAtMainWithReverseRestart() throws Throwable {
183
    	fRestart = true;
184
    	testStopAtMainWithReverse();
185
    }
186
187
    /**
188
     * This test will tell the launch to "stop on main" at method stopAtOther(), 
189
     * with reverse debugging enabled.  We will then verify that the launch is properly
190
     * stopped at stopAtOther() and that it can go backwards until main() (this will
191
     * confirm that reverse debugging was enabled at the very start).
192
     */
193
	@Test
194
    public void testStopAtOtherWithReverse() throws Throwable {
195
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
196
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "stopAtOther");
197
    	setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE, true);
198
    	performLaunch();
199
200
    	// Wait for the launch to properly complete.  This is because with reverse
201
    	// the first stopped event does not mean the launch is complete.  There will
202
    	// be another stopped event
203
    	synchronized (this) {
204
    		wait(1000);			
205
		}
206
    	
207
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
208
    	
209
    	// The initial stopped event is not the last stopped event.
210
    	// With reverse we have to stop the program, turn on reverse and start it again.
211
    	// Let's get the frame where we really are stopped right now.
212
    	final IExecutionDMContext execDmc = stoppedEvent.getDMContext();
213
    	IFrameDMData frame = SyncUtil.getFrameData(execDmc, 0);
214
 
215
    	// Make sure we stopped at the first line of main
216
    	assertTrue("Expected to stop at stopAtOther but got " +
217
    			   frame.getFunction(),
218
    			   frame.getFunction().equals("stopAtOther"));
219
    	
220
    	// Now step backwards all the way to the start to make sure reverse was enabled from the very start   	
221
		final ServiceEventWaitor<MIStoppedEvent> eventWaitor =
222
			new ServiceEventWaitor<MIStoppedEvent>(
223
					fSession,
224
					MIStoppedEvent.class);
225
226
    	final int REVERSE_NUM_STEPS = 3;
227
    	Query<MIInfo> query2 = new Query<MIInfo>() {
228
    		@Override
229
    		protected void execute(DataRequestMonitor<MIInfo> rm) {
230
    			fGdbControl.queueCommand(
231
    					fGdbControl.getCommandFactory().createMIExecReverseNext(execDmc, REVERSE_NUM_STEPS),
232
    					rm);
233
    		}
234
    	};
235
    	try {
236
    		fGdbControl.getExecutor().execute(query2);
237
    		query2.get(500, TimeUnit.MILLISECONDS);
238
    	} catch (InterruptedException e) {
239
    		fail(e.getMessage());
240
    	} catch (ExecutionException e) {
241
    		fail(e.getCause().getMessage());
242
    	} catch (TimeoutException e) {
243
    		fail(e.getMessage());
244
    	}
245
    	
246
    	stoppedEvent = eventWaitor.waitForEvent(1000);
247
    	
248
    	assertTrue("Expected to stop at main:" + (FIRST_LINE_IN_MAIN) + " but got " +
249
  			   stoppedEvent.getFrame().getFunction() + ":" +
250
  			   Integer.toString(stoppedEvent.getFrame().getLine()),
251
  			   stoppedEvent.getFrame().getFunction().equals("main") &&
252
  			   stoppedEvent.getFrame().getLine() == FIRST_LINE_IN_MAIN);
253
    }
254
    
255
    /**
256
     * Repeat the test testStopAtOtherWithReverse, but after a restart.
257
     */
258
    @Test
259
    public void testStopAtOtherWithReverseRestart() throws Throwable {
260
    	fRestart = true;
261
    	testStopAtOtherWithReverse();
262
    }
263
    /**
264
     * This test will set a breakpoint at the last line of the program and will tell 
265
     * the launch to NOT "stop on main", with reverse debugging enabled.  We will 
266
     * verify that the first stop is at the last line of the program but that the program
267
     * can run backwards until main() (this will confirm that reverse debugging was 
268
     * enabled at the very start).
269
     */
270
    @Ignore
271
	@Test
272
    public void testNoStopAtMainWithReverse() throws Throwable {
273
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false);
274
    	// Set this one as well to make sure it gets ignored
275
    	setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN_SYMBOL, "main");
276
    	setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_REVERSE, true);
277
    	
278
    	// MUST SET BREAKPOINT AT LAST LINE BUT BEFORE LAUNCH IS STARTED
279
    	// MUST SET BREAKPOINT AT LAST LINE BUT BEFORE LAUNCH IS STARTED
280
    	// MUST SET BREAKPOINT AT LAST LINE BUT BEFORE LAUNCH IS STARTED
281
    	// see testNoStopAtMain()
282
    	
283
    	performLaunch();
284
285
    	// Wait for the launch to properly complete.  This is because with reverse
286
    	// the first stopped event does not mean the launch is complete.  There will
287
    	// be another stopped event
288
    	synchronized (this) {
289
    		wait(1000);			
290
		}
291
    	
292
    	MIStoppedEvent stoppedEvent = getInitialStoppedEvent();
293
    	
294
    	// The initial stopped event is not the last stopped event.
295
    	// With reverse we have to stop the program, turn on reverse and start it again.
296
    	// Let's get the frame where we really are stopped right now.
297
    	final IExecutionDMContext execDmc = stoppedEvent.getDMContext();
298
    	IFrameDMData frame = SyncUtil.getFrameData(execDmc, 0);
299
 
300
    	// Make sure we stopped at the first line of main
301
    	assertTrue("Expected to stop at main:" + LAST_LINE_IN_MAIN + " but got " +
302
    			   frame.getFunction() + ":" +
303
    			   Integer.toString(frame.getLine()),
304
    			   frame.getFunction().equals("main") &&
305
    			   frame.getLine() == LAST_LINE_IN_MAIN);
306
    	
307
    	// Now step backwards all the way to the start to make sure reverse was enabled from the very start   	
308
		final ServiceEventWaitor<MIStoppedEvent> eventWaitor =
309
			new ServiceEventWaitor<MIStoppedEvent>(
310
					fSession,
311
					MIStoppedEvent.class);
312
313
    	final int REVERSE_NUM_STEPS = 3;
314
    	Query<MIInfo> query2 = new Query<MIInfo>() {
315
    		@Override
316
    		protected void execute(DataRequestMonitor<MIInfo> rm) {
317
    			fGdbControl.queueCommand(
318
    					fGdbControl.getCommandFactory().createMIExecReverseNext(execDmc, REVERSE_NUM_STEPS),
319
    					rm);
320
    		}
321
    	};
322
    	try {
323
    		fGdbControl.getExecutor().execute(query2);
324
    		query2.get(500, TimeUnit.MILLISECONDS);
325
    	} catch (InterruptedException e) {
326
    		fail(e.getMessage());
327
    	} catch (ExecutionException e) {
328
    		fail(e.getCause().getMessage());
329
    	} catch (TimeoutException e) {
330
    		fail(e.getMessage());
331
    	}
332
    	
333
    	stoppedEvent = eventWaitor.waitForEvent(1000);
334
    	
335
    	assertTrue("Expected to stop at main:" + (FIRST_LINE_IN_MAIN) + " but got " +
336
  			   stoppedEvent.getFrame().getFunction() + ":" +
337
  			   Integer.toString(stoppedEvent.getFrame().getLine()),
338
  			   stoppedEvent.getFrame().getFunction().equals("main") &&
339
  			   stoppedEvent.getFrame().getLine() == FIRST_LINE_IN_MAIN);
340
    }
341
    
342
    /**
343
     * Repeat the test testNoStopAtMainWithReverse, but after a restart.
344
     */
345
    @Ignore
346
    @Test
347
    public void testNoStopAtMainWithReverseRestart() throws Throwable {
348
    	fRestart = true;
349
    	testNoStopAtMainWithReverse();
350
    }
351
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_7_0.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_7_0.class,
34
	MICatchpointsTest_7_0.class,
35
	MIDisassemblyTest_7_0.class,
35
	MIDisassemblyTest_7_0.class,
36
	GDBProcessesTest_7_0.class,
36
	GDBProcessesTest_7_0.class,
37
	LaunchConfigurationAndRestartTest_7_0.class,
37
	Suite_Sessionless_Tests.class	
38
	Suite_Sessionless_Tests.class	
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/LaunchConfigurationAndRestartTest_7_1.java (+28 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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1;
12
13
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
14
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0.LaunchConfigurationAndRestartTest_7_0;
16
import org.junit.Before;
17
import org.junit.runner.RunWith;
18
19
@RunWith(BackgroundRunner.class)
20
public class LaunchConfigurationAndRestartTest_7_1 extends LaunchConfigurationAndRestartTest_7_0 {
21
	// For the launch config test, we must set the attributes in the @Before method
22
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
23
	// by the tests themselves
24
	@Before
25
	public void beforeMethod_7_1() {
26
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_1);
27
	}
28
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_1/Suite_7_1.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_7_1.class,
34
	MICatchpointsTest_7_1.class,
35
	MIDisassemblyTest_7_1.class,
35
	MIDisassemblyTest_7_1.class,
36
	GDBProcessesTest_7_1.class,
36
	GDBProcessesTest_7_1.class,
37
	LaunchConfigurationAndRestartTest_7_1.class,
37
	Suite_Sessionless_Tests.class
38
	Suite_Sessionless_Tests.class
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/LaunchConfigurationAndRestartTest_7_2.java (+28 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
 *     Ericsson			  - Initial Implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_2;
12
13
import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
14
import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants;
15
import org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_1.LaunchConfigurationAndRestartTest_7_1;
16
import org.junit.Before;
17
import org.junit.runner.RunWith;
18
19
@RunWith(BackgroundRunner.class)
20
public class LaunchConfigurationAndRestartTest_7_2 extends LaunchConfigurationAndRestartTest_7_1 {
21
	// For the launch config test, we must set the attributes in the @Before method
22
	// instead of the @BeforeClass method.  This is because the attributes are overwritten
23
	// by the tests themselves
24
	@Before
25
	public void beforeMethod_7_2() {
26
		setGdbProgramNamesLaunchAttributes(ITestConstants.SUFFIX_GDB_7_2);
27
	}
28
}
(-)src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_2/Suite_7_2.java (+1 lines)
Lines 34-39 Link Here
34
	MICatchpointsTest_7_2.class,
34
	MICatchpointsTest_7_2.class,
35
	MIDisassemblyTest_7_2.class,
35
	MIDisassemblyTest_7_2.class,
36
	GDBProcessesTest_7_2.class,
36
	GDBProcessesTest_7_2.class,
37
	LaunchConfigurationAndRestartTest_7_2.class,
37
	Suite_Sessionless_Tests.class	
38
	Suite_Sessionless_Tests.class	
38
	/* Add your test class here */
39
	/* Add your test class here */
39
})
40
})

Return to bug 336008