From 83d4fa001e6f12e1fcc2d01157cf5c7a8d10b2bf Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Sun, 4 Apr 2021 20:16:01 -0400 Subject: [PATCH] Bug 572581: reenable disabled DSF-GDB tests Many of the disabled tests were failing because they were dependent on specific combinations of GDB + GCC and where exactly code stops and steps effect when entering functions. The old code mostly ran to a function and then stepped a known number of times. But what changes between GDB versions is how many steps are needed. Therefore for all failing tests update to run to a specific line number by using tags in the .cc file and running to them to make sure the test is precisely on that line. This partially reverts commit 8220215a2e35334b16ef48c76e9c9e33ba03d07e and 92272c64659b19bbc11c27cf1a1857b4f1f68e0e Reason for revert: These tests were "temporarily" disabled a while ago as part of the JIRO migration in Bug 545624. Change-Id: I703429c8a81c856360f1cb4e899026200527f7c6 --- .../META-INF/MANIFEST.MF | 2 +- .../ICDTLaunchConfigurationConstants.java | 38 +++++ .../META-INF/MANIFEST.MF | 2 +- .../gdb/launching/FinalLaunchSequence.java | 5 + .../cdt/dsf/gdb/launching/GdbLaunch.java | 8 +- .../gdb/service/DebugNewProcessSequence.java | 35 ++++- .../mi/service/command/CommandFactory.java | 6 + .../commands/MIGDBSetStartupWithShell.java | 28 ++++ .../data/launch/src/ExpressionTestApp.cc | 38 +++-- .../LaunchConfigurationAndRestartTestApp.cc | 3 +- .../data/launch/src/Makefile | 8 +- dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml | 6 +- .../tests/dsf/gdb/framework/BaseTestCase.java | 2 +- .../dsf/gdb/tests/CommandLineArgsTest.java | 56 +++++-- .../LaunchConfigurationAndRestartTest.java | 1 - .../dsf/gdb/tests/MIExpressionsTest.java | 138 ++++++++---------- .../tests/dsf/gdb/tests/MIRunControlTest.java | 6 +- .../dsf/gdb/tests/PostMortemCoreTest.java | 2 - .../nonstop/MIExpressionsNonStopTest.java | 2 - .../nonstop/ThreadStackFrameSyncTest.java | 3 - 20 files changed, 263 insertions(+), 126 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetStartupWithShell.java diff --git a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF index 5f3cd1e0ae8..c7eca1d8a6b 100644 --- a/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF +++ b/debug/org.eclipse.cdt.debug.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.debug.core; singleton:=true -Bundle-Version: 8.6.0.qualifier +Bundle-Version: 8.7.0.qualifier Bundle-Activator: org.eclipse.cdt.debug.core.CDebugCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java index 7471b90dfd0..69022c310b1 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDTLaunchConfigurationConstants.java @@ -141,9 +141,47 @@ public interface ICDTLaunchConfigurationConstants { * Launch configuration attribute key. The value is a string specifying * application arguments for a C/C++ launch configuration, as they should * appear on the command line. + * + * @see ATTR_STARTUP_WITH_SHELL */ public static final String ATTR_PROGRAM_ARGUMENTS = CDT_LAUNCH_ID + ".PROGRAM_ARGUMENTS"; //$NON-NLS-1$ + /** + * Launch configuration attribute key. The value is a string as to whether to use + * gdb's startup-with-shell. This can affect how program arguments are expanded. + * Possible values are: + * - {@link #STARTUP_WITH_SHELL_ON} + * - {@link #STARTUP_WITH_SHELL_OFF} + * - {@link #STARTUP_WITH_SHELL_UNSET} - use gdb's default + * + * Only supported in GDB > 7.7 for local launches and 8.1 for remote launches. + * + * See https://sourceware.org/gdb/onlinedocs/gdb/Starting.html + * @since 8.7 + */ + public static final String ATTR_STARTUP_WITH_SHELL = CDT_LAUNCH_ID + ".STARTUP_WITH_SHELL"; //$NON-NLS-1$ + /** + * @see #ATTR_STARTUP_WITH_SHELL + * @since 8.7 + */ + public static final String STARTUP_WITH_SHELL_ON = "on"; //$NON-NLS-1$ + /** + * @see #ATTR_STARTUP_WITH_SHELL + * @since 8.7 + */ + public static final String STARTUP_WITH_SHELL_OFF = "off"; //$NON-NLS-1$ + /** + * @see #ATTR_STARTUP_WITH_SHELL + * @since 8.7 + */ + public static final String STARTUP_WITH_SHELL_UNSET = ""; //$NON-NLS-1$ + /** + * Default value for {@link #ATTR_STARTUP_WITH_SHELL} + * @see #ATTR_STARTUP_WITH_SHELL + * @since 8.7 + */ + public static final String STARTUP_WITH_SHELL_DEFAULT = STARTUP_WITH_SHELL_UNSET; + /** * Launch configuration attribute key. The value is a string specifying a * path to the working directory to use when launching a the application. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF index 4f1996970cf..bc10f86d201 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true -Bundle-Version: 6.2.0.qualifier +Bundle-Version: 6.3.0.qualifier Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index 64370c349e8..0b9649cd8f7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -63,6 +63,11 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; +/** + * Final launch sequence for GDB < 7.0, extended by subclasses for newer versions. + * + * @see FinalLaunchSequence_7_0 + */ public class FinalLaunchSequence extends ReflectionSequence { // The launchConfiguration attributes private Map fAttributes; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index fc302e776de..2d07991d859 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -170,7 +170,7 @@ public class GdbLaunch extends DsfLaunch implements ITracedLaunch, ITargetedLaun // To maintain a mapping of memory contexts to the corresponding memory // retrieval in this session try { - fExecutor.submit(new Callable() { + fExecutor.submit(new Callable<>() { @Override public Object call() throws CoreException { fMemRetrievalManager = new GdbMemoryBlockRetrievalManager(GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, @@ -550,7 +550,11 @@ public class GdbLaunch extends DsfLaunch implements ITracedLaunch, ITargetedLaun /** * Gets the CDT environment from the CDT project's configuration referenced - * by the launch + * by the launch. This environment is used as the environment to run GDB in + * and is different than the launch environment in ILaunchManager.ATTR_ENVIRONMENT_VARIABLES + * which is used to run the inferior in. + * + * Essentially this is getting the build environment of the associated project. * * @since 5.0 */ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java index 8523e08b046..ee3ab793db5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/DebugNewProcessSequence.java @@ -204,23 +204,48 @@ public class DebugNewProcessSequence extends ReflectionSequence { */ @Execute public void stepSetArguments(RequestMonitor rm) { + String[] argArray = null; try { String args = CDebugUtils.getAttribute(fAttributes, ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ if (args.length() != 0) { args = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(args); - String[] argArray = CommandLineUtil.argumentsToArray(args); - fCommandControl.queueCommand(fCommandFactory.createMIGDBSetArgs(getContainerContext(), argArray), - new ImmediateDataRequestMonitor(rm)); - } else { - rm.done(); + argArray = CommandLineUtil.argumentsToArray(args); } } catch (CoreException e) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.REQUEST_FAILED, "Cannot get inferior arguments", e)); //$NON-NLS-1$ rm.done(); + return; } + + final String[] finalArgArray = argArray; + ImmediateDataRequestMonitor setArgsRm = new ImmediateDataRequestMonitor<>(rm) { + @Override + protected void handleSuccess() { + if (finalArgArray != null) { + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetArgs(getContainerContext(), finalArgArray), + new ImmediateDataRequestMonitor(rm)); + } else { + rm.done(); + } + } + }; + + String withshellString = CDebugUtils.getAttribute(fAttributes, + ICDTLaunchConfigurationConstants.ATTR_STARTUP_WITH_SHELL, + ICDTLaunchConfigurationConstants.STARTUP_WITH_SHELL_DEFAULT); + if (ICDTLaunchConfigurationConstants.STARTUP_WITH_SHELL_ON.equals(withshellString) + || ICDTLaunchConfigurationConstants.STARTUP_WITH_SHELL_OFF.equals(withshellString)) { + boolean withShell = ICDTLaunchConfigurationConstants.STARTUP_WITH_SHELL_ON.equals(withshellString); + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetStartupWithShell(fCommandControl.getContext(), withShell), setArgsRm); + } else { + setArgsRm.done(); + } + } /** diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java index 7e1287d02db..d92b9afdcee 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CommandFactory.java @@ -146,6 +146,7 @@ import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetRemoteTimeout; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSchedulerLocking; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibAbsolutePrefix; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetSolibSearchPath; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetStartupWithShell; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTargetAsync; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTargetCharset; import org.eclipse.cdt.dsf.mi.service.command.commands.MIGDBSetTargetWideCharset; @@ -885,6 +886,11 @@ public class CommandFactory { return new MIGDBSetSolibSearchPath(ctx, paths); } + /** @since 6.3 */ + public ICommand createMIGDBSetStartupWithShell(ICommandControlDMContext ctx, boolean enable) { + return new MIGDBSetStartupWithShell(ctx, enable); + } + public ICommand createMIGDBSetTargetAsync(ICommandControlDMContext ctx, boolean isSet) { return new MIGDBSetTargetAsync(ctx, isSet); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetStartupWithShell.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetStartupWithShell.java new file mode 100644 index 00000000000..f2d21c830ac --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetStartupWithShell.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2021 Kichwa Coders Canada Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.cdt.dsf.mi.service.command.commands; + +import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; + +/** + * + * -gdb-set startup-with-shell [on | off] + * + * Available with GDB 7.7 in GDB and 8.1 for gdbserver + * + * @since 6.3 + * + */ +public class MIGDBSetStartupWithShell extends MIGDBSet { + public MIGDBSetStartupWithShell(ICommandControlDMContext ctx, boolean enable) { + super(ctx, new String[] { "startup-with-shell", enable ? "on" : "off" });//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + } +} \ No newline at end of file diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc index 855925ba6c8..3deb936dd35 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc @@ -79,6 +79,7 @@ public: void test() { nested = 8; pNested = &nested; + /* BaseTest::test_init */ return; } Base Base; // make sure we don't get confused by the same name @@ -93,7 +94,7 @@ void locals2() { char lCharVar = 'i'; char *lCharPtr = &lCharVar; bool *lBoolPtr2 = (bool*)0xABCDE123; - lBoolPtr2 = 0; // step up to this line to ensure all locals are in scope + /* locals2_init */ return; } @@ -118,6 +119,7 @@ void testLocals() { double *lDoublePtr2 = (double*)0x2345; char *lCharPtr2 = (char*)0x1234; bool *lBoolPtr2 = (bool*)0x123ABCDE; + /* testLocals_init */ locals2(); lBoolPtr2 = (bool*)0; // step-out from locals2() will land here; ensures our vars are still visible @@ -128,7 +130,7 @@ int testChildren() { foo f; f.d = 1; - + /* testChildren_init */ return 0; } @@ -143,11 +145,13 @@ int testWrite() { int testName1(int newVal) { int a = newVal; + /* testName1_init */ return a; } int testName2(int newVal) { int a = newVal; + /* testName2_init */ return a; } @@ -155,6 +159,7 @@ int testSameName1(int newVal) { int a = newVal; Z z; z.x = newVal; + /* testSameName1_a_init */ z.x = newVal; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible return a; } @@ -162,6 +167,7 @@ int testSameName1(int newVal, int ignore) { int a = newVal; Z z; z.x = newVal; + /* testSameName1_b_init */ a = newVal; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible return a; } @@ -177,14 +183,17 @@ int testSameName() { int testConcurrent() { int a[2] = {28, 32}; + /* testConcurrent_init */ return a[0]; } int testSubblock() { int a = 8; int b = 1; + /* testSubblock_init */ if (a) { int a = 12; + /* testSubblock_subblock_init */ b = a; } return b; @@ -193,7 +202,7 @@ int testSubblock() { int testAddress() { int a = 8; int* a_ptr = &a; - + /* testAddress_init */ return a; } @@ -203,7 +212,7 @@ int testUpdateChildren(int val) { childStruct a; a.z.x = val + 10; a.z.y = val + 11; - + /* testUpdateChildren_init */ a.z.x = val + 20; a.z.y = val + 21; @@ -213,7 +222,7 @@ int testUpdateChildren2(int val) { childStruct a; a.z.x = val + 10; a.z.y = val + 11; - + /* testUpdateChildren2_init */ a.z.x = val + 20; a.z.y = val + 21; @@ -233,12 +242,14 @@ int testUpdateGDBBug() { // since binary of 3 is 11 which is the same as the old value // in natural format int a = 11; + /* testUpdateGDBBug_init */ a = 3; return 0; } int testUpdateIssue() { double a = 1.99; + /* testUpdateIssue_init */ a = 1.22; a = 1.22; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible } @@ -249,6 +260,7 @@ int testUpdateIssue2() { } z; z.d = 1.0; + /* testUpdateIssue2_init */ z.d = 1.22; z.d = 1.22; // this redundant line is here to ensure 3 steps after running to this func leaves locals visible } @@ -259,6 +271,7 @@ int testConcurrentReadAndUpdateChild() { }z; z.d = 1; + /* testConcurrentReadAndUpdateChild_init */ z.d = 2; } @@ -268,6 +281,7 @@ int testConcurrentUpdateOutOfScopeChildThenParent1() { }z; z.d = 1; + /* testConcurrentUpdateOutOfScopeChildThenParent1_init */ z.d = 1; // this redundant line is here to ensure 2 steps after running to this func leaves locals visible } @@ -277,6 +291,7 @@ int testConcurrentUpdateOutOfScopeChildThenParent2() { }z; z.d = 2; + /* testConcurrentUpdateOutOfScopeChildThenParent2_init */ z.d = 2; // this redundant line is here to ensure 2 steps after running to this func leaves locals visible } @@ -357,7 +372,7 @@ int testCasting() { int array_small[4] = {65, 0x41424344, 0x45464748}; // Decimal: 65, 1094861636, 1162233672, Char: A, ABCD, EFGH int* int_ptr = &array_small[0]; - + /* testCasting_init */ return 1; } @@ -387,13 +402,14 @@ private: int f[4]; }; int testRTTI() { - Derived derived; + Derived derived; // here derived.ptr is of type VirtualBase Derived child1; OtherDerived child2; - - derived.ptr = &child1; // here derived.b is of type bar - - derived.ptr = &child2; // here derived.b is of type foo + /* testRTTI_tag1 */ + derived.ptr = &child1; // here derived.ptr is of type Derived + /* testRTTI_tag2 */ + derived.ptr = &child2; // here derived.ptr is of type OtherDerived + /* testRTTI_tag3 */ return 1; // here derived.b is of type Derived } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc index 8fa1492e62e..75b4a2fd2ad 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/LaunchConfigurationAndRestartTestApp.cc @@ -24,7 +24,8 @@ int envTest() { int main (int argc, char *argv[]) { - envTest(); // FIRST_LINE_IN_MAIN + int dummy = 1; // FIRST_LINE_IN_MAIN + envTest(); // main_init reverseTest(); // tests assume that every line between first and last stopAtOther(); // is steppable, so no blank lines allowed. return 36; // LAST_LINE_IN_MAIN diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile index 0e49ec76dfc..50b090a7411 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Makefile @@ -66,8 +66,12 @@ $(BINDIR)/%.exe: %.cc $(HEADERS) Makefile | $(BINDIR) # Generate a core file that is needed for post-morted core-file tests $(COREFILE): $(BINDIR)/ExpressionTestApp.exe Makefile | $(BINDIR) - gdb -nx --batch -ex 'b testLocals' -ex 'run' --ex 'next 16' \ - -ex 'gcore ../bin/core' $(BINDIR)/ExpressionTestApp.exe > /dev/null + line=$(shell grep -n testLocals_init ../src/ExpressionTestApp.cc | cut -d : -f 1); \ + gdb -nx --batch \ + -ex 'b ExpressionTestApp.cc:'$$line \ + -ex 'run' \ + -ex 'gcore ../bin/core' \ + $(BINDIR)/ExpressionTestApp.exe > /dev/null # Compile sourcelookup once with old dwarf flags $(BINDIR)/SourceLookupDwarf2.exe: SourceLookup.cc $(HEADERS) Makefile | $(BINDIR) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml index 539a134ccf2..aebc914b593 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/pom.xml @@ -67,7 +67,11 @@ false ${tycho.testArgLine} ${base.ui.test.vmargs} -ea -Xms256m -Xmx512m -Dcdt.tests.dsf.gdb.path=${dsf.gdb.tests.gdbPath} -Ddsf.gdb.tests.timeout.multiplier=${dsf.gdb.tests.timeout.multiplier} -Dcdt.tests.dsf.gdb.versions=${cdt.tests.dsf.gdb.versions} - -debug ./dsf.debug.options -pluginCustomization ${basedir}/../../disable_intro_in_tests.ini + -debug ./dsf.debug.options -pluginCustomization ${basedir}/../../disable_intro_in_tests.ini + + + /bin/bash + diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index bb467e61562..b0cbd776c6b 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -455,7 +455,7 @@ public class BaseTestCase { * @return The line number corresponding to tag. * @throws NoSuchElementException if the tag does not exist. */ - protected int getLineForTag(String tag) { + protected int getLineForTag(String tag) throws Exception { if (!fTagLocations.containsKey(tag)) { throw new NoSuchElementException("tag " + tag); } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java index 23c4c3f30ba..b847eebb256 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/CommandLineArgsTest.java @@ -22,8 +22,10 @@ import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.concurrent.TimeUnit; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; @@ -39,13 +41,13 @@ import org.eclipse.cdt.dsf.service.DsfSession; import org.eclipse.cdt.tests.dsf.gdb.framework.BaseParametrizedTestCase; import org.eclipse.cdt.tests.dsf.gdb.framework.SyncUtil; import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @RunWith(Parameterized.class) public class CommandLineArgsTest extends BaseParametrizedTestCase { + protected static final String SOURCE_NAME = "LaunchConfigurationAndRestartTestApp.cc"; protected static final String EXEC_NAME = "LaunchConfigurationAndRestartTestApp.exe"; private DsfSession fSession; @@ -67,6 +69,20 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { // Set the binary setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EXEC_PATH + EXEC_NAME); + + // while testing command line arguments we are trying to make sure command line gets from + // cdt to gdb as expected - we don't want to be affected by whatever shell may be on + // the machine. We can't turn startup_with_shell off because GDB's primitive argument + // parsing in that mode causes these tests to be useless. Therefore, force a specific + // shell to use so that we have consistent results. + // There is no way today of setting the SHELL environement variable when GDB runs from + // these tests (that comes from org.eclipse.cdt.dsf.gdb.launching.GdbLaunch.getLaunchEnvironment()) + // So, instead we ensure that the environement we have has SHELL set appropriately + // and rely on what we are running in to have SHELL set properly. + assertEquals("/bin/bash", System.getenv("SHELL")); + // XXX: The above may need to be updated to verify their validity on Windows/Mac. To + // make it easier to know where to look for such testers fail the test here as + // almost surely the SHELL work above need to be addressed on those platforms. } // This method cannot be tagged as @Before, because the launch is not @@ -86,6 +102,26 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { fSession.getExecutor().submit(runnable).get(); } + @Override + protected int getLineForTag(String tag) throws Exception { + try { + super.getLineForTag(tag); + } catch (Exception e) { + resolveLineTagLocations(SOURCE_NAME, tag); + } + return super.getLineForTag(tag); + } + + /** + * Run to one of the tags in {@link #LINE_TAGS} + * @throws Throwable + */ + private MIStoppedEvent runToTag(String tag) throws Throwable { + String location = String.format("%s:%d", SOURCE_NAME, getLineForTag(tag)); + MIStoppedEvent stoppedEvent = SyncUtil.runToLocation(location); + return stoppedEvent; + } + /** * Convert a string of form 0x123456 "ab\"cd" to ab"cd */ @@ -138,7 +174,7 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { */ protected void checkArguments(String... expected) throws Throwable { - MIStoppedEvent stoppedEvent = getInitialStoppedEvent(); + MIStoppedEvent stoppedEvent = runToTag("main_init"); // Check that argc is correct final IExpressionDMContext argcDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), "argc"); @@ -152,14 +188,12 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { fExpService.getExecutor().execute(query); FormattedValueDMData value = query.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); - - assertTrue("Expected " + (1 + expected.length) + " but got " + value.getFormattedValue(), - value.getFormattedValue().trim().equals(Integer.toString(1 + expected.length))); - + int actualArgc = Integer.parseInt(value.getFormattedValue().trim()); + List actualArgv = new ArrayList<>(); // check all argvs are correct - for (int i = 0; i < expected.length; i++) { + for (int i = 1; i < actualArgc; i++) { final IExpressionDMContext argvDmc = SyncUtil.createExpression(stoppedEvent.getDMContext(), - "argv[" + (i + 1) + "]"); + "argv[" + i + "]"); Query query2 = new Query<>() { @Override protected void execute(DataRequestMonitor rm) { @@ -172,8 +206,9 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { FormattedValueDMData value2 = query2.get(TestsPlugin.massageTimeout(500), TimeUnit.MILLISECONDS); String details = value2.getFormattedValue(); String actual = convertDetails(details); - assertEquals(expected[i], actual); + actualArgv.add(actual); } + assertEquals(Arrays.asList(expected), actualArgv); } /** @@ -213,7 +248,6 @@ public class CommandLineArgsTest extends BaseParametrizedTestCase { * bug 474648 */ @Test - @Ignore public void testSettingArgumentsWithSpecialSymbols() throws Throwable { // Test that arguments are parsed correctly: // The string provided by the user is split into arguments on spaces diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java index c24e9439ae5..5708336828e 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/LaunchConfigurationAndRestartTest.java @@ -72,7 +72,6 @@ import org.junit.runners.Parameterized; @RunWith(Parameterized.class) @Intermittent(repetition = 3) -@Ignore public class LaunchConfigurationAndRestartTest extends BaseParametrizedTestCase { public @Rule IntermittentRule intermittentRule = new IntermittentRule(); protected static final String EXEC_NAME = "LaunchConfigurationAndRestartTestApp.exe"; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java index d6d087d8c80..1d70ca228a2 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java @@ -95,17 +95,10 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EXEC_PATH + EXEC_NAME); } - /* Line tags in the source file. */ - private static final String[] LINE_TAGS = new String[] { "testUpdateOfPointer_1", "testUpdateOfPointer_2", - "testUpdateOfPointerTypedef_1", "testUpdateOfPointerTypedef_2", }; - @Override public void doBeforeTest() throws Exception { super.doBeforeTest(); - /* Resolve line tags in source file. */ - resolveLineTagLocations(SOURCE_NAME, LINE_TAGS); - fSession = getGDBLaunch().getSession(); Runnable runnable = () -> { fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId()); @@ -129,6 +122,26 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { } } + @Override + protected int getLineForTag(String tag) throws Exception { + try { + super.getLineForTag(tag); + } catch (Exception e) { + resolveLineTagLocations(SOURCE_NAME, tag); + } + return super.getLineForTag(tag); + } + + /** + * Run to one of the tags in {@link #LINE_TAGS} + * @throws Throwable + */ + private MIStoppedEvent runToTag(String tag) throws Throwable { + String location = String.format("%s:%d", SOURCE_NAME, getLineForTag(tag)); + MIStoppedEvent stoppedEvent = SyncUtil.runToLocation(location); + return stoppedEvent; + } + // Handles ExpressionChangedEvent @DsfServiceEventHandler public void eventDispatched(IExpressionChangedDMEvent e) { @@ -160,8 +173,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testLiteralIntegerExpressions() throws Throwable { - MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("testLocals"); - + MIStoppedEvent stoppedEvent = runToTag("testLocals_init"); // Create a map of expressions and their expected values. Map tests = new HashMap<>(); @@ -183,7 +195,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testLiteralFloatingPointExpressions() throws Throwable { - MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("testLocals"); + MIStoppedEvent stoppedEvent = runToTag("testLocals_init"); // Create a map of expressions and their expected values. Map tests = new HashMap<>(); @@ -206,11 +218,9 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * variables. */ @Test - @Ignore public void testLocalVariables() throws Throwable { // Run to the point where all local variables are initialized - SyncUtil.runToLocation("testLocals"); - MIStoppedEvent stoppedEvent = SyncUtil.step(16, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testLocals_init"); // Create a map of expressions to expected values. Map tests1 = new HashMap<>(); @@ -245,8 +255,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { // Step into the method and stop until all new local variables are // initialized - SyncUtil.step(StepType.STEP_INTO); - stoppedEvent = SyncUtil.step(5, StepType.STEP_OVER); + stoppedEvent = runToTag("locals2_init"); // Create a map of expressions to expected values. Map tests2 = new HashMap<>(); @@ -278,8 +287,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { @Ignore("Sublocks do not work with GDB") @Test public void testSubBlock() throws Throwable { - SyncUtil.runToLocation("testSubblock"); - MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testSubblock_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); Map tests = new HashMap<>(); @@ -290,7 +298,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { executeExpressionSubTests(tests, frameDmc); // Now enter a subblock with the same variable names - SyncUtil.step(2, StepType.STEP_OVER); + runToTag("testSubblock_subblock_init"); tests = new HashMap<>(); @@ -455,10 +463,9 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * children. See bug 320277. */ @Test - @Ignore public void testNestedBaseChildrenBug() throws Throwable { - MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("BaseTest::test"); + MIStoppedEvent stoppedEvent = runToTag("BaseTest::test_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -626,13 +633,11 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * make sure the internal MI commands are sequenced properly. */ @Test - @Ignore public void testConcurrentReads() throws Throwable { // Next we test that we can read the value more than once // of the same variable object at the exact same time - SyncUtil.runToLocation("testConcurrent"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testConcurrent_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -919,14 +924,12 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * sure the internal MI commands are sequenced properly. */ @Test - @Ignore public void testConcurrentReadWrite() throws Throwable { // Next we test that we can deal with a write request and read request // at // the same time and vice-versa - SyncUtil.runToLocation("testConcurrent"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testConcurrent_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -1007,7 +1010,6 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * to make sure the internal MI commands are sequenced properly. */ @Test - @Ignore public void testConcurrentReadWriteChildren() throws Throwable { // Finally, we go nuts and request two reads, while requesting // a get children and get children count. @@ -1015,8 +1017,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { // go through at any time and we don't exactly know when it will // change the value we are reading. - SyncUtil.runToLocation("testConcurrent"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testConcurrent_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -1148,13 +1149,11 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * an MI command to the back-end */ @Test - @Ignore public void testWriteCache() throws Throwable { // Test the cache by changing a value but triggering a read before the // write clears the cache - SyncUtil.runToLocation("testConcurrent"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testConcurrent_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -1295,11 +1294,9 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * expression */ @Test - @Ignore public void testExprAddress() throws Throwable { - SyncUtil.runToLocation("testAddress"); - MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testAddress_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -1392,22 +1389,21 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testNamingSameDepth() throws Throwable { - SyncUtil.runToLocation("testName1"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testName1_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); Map tests = new HashMap<>(); tests.put("a", new String[] { "0x1", "01", "1", "1", "1", "1" }); executeExpressionSubTests(tests, frameDmc); - SyncUtil.runToLocation("testName2"); + runToTag("testName2_init"); stoppedEvent = SyncUtil.step(1, StepType.STEP_INTO); frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); tests = new HashMap<>(); tests.put("a", new String[] { "0x2", "02", "10", "2", "2", "2" }); executeExpressionSubTests(tests, frameDmc); - SyncUtil.runToLocation("testName1"); + runToTag("testName1_init"); stoppedEvent = SyncUtil.step(1, StepType.STEP_INTO); frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); tests = new HashMap<>(); @@ -1421,23 +1417,21 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testNamingSameMethod() throws Throwable { - SyncUtil.runToLocation("testSameName"); - MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_INTO); + MIStoppedEvent stoppedEvent = runToTag("testSameName1_a_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); Map tests = new HashMap<>(); tests.put("a", new String[] { "0x1", "01", "1", "1", "1", "1" }); executeExpressionSubTests(tests, frameDmc); - SyncUtil.step(StepType.STEP_RETURN); - stoppedEvent = SyncUtil.step(2, StepType.STEP_INTO); + stoppedEvent = runToTag("testSameName1_b_init"); frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); tests = new HashMap<>(); tests.put("a", new String[] { "0x2", "02", "10", "2", "2", "2" }); executeExpressionSubTests(tests, frameDmc); SyncUtil.step(StepType.STEP_RETURN); - stoppedEvent = SyncUtil.step(2, StepType.STEP_INTO); + stoppedEvent = runToTag("testSameName1_a_init"); frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); tests = new HashMap<>(); tests.put("a", new String[] { "0x3", "03", "11", "3", "3", "3" }); @@ -1449,12 +1443,11 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * a thread selected, the top-most stack frame is used for evaluation */ @Test - @Ignore public void testThreadContext() throws Throwable { - // Step to a stack level of 2 to be able to test differen stack frames - SyncUtil.runToLocation("locals2"); - MIStoppedEvent stoppedEvent = SyncUtil.step(StepType.STEP_OVER); + // Step to a stack level of 2 to be able to test different stack frames + String tag = String.format("%s:%d", SOURCE_NAME, getLineForTag("locals2_init")); + MIStoppedEvent stoppedEvent = SyncUtil.runToLocation(tag); // Create a map of expressions to expected values. Map tests = new HashMap<>(); @@ -1477,7 +1470,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { @Test public void testChildNamingSameMethod() throws Throwable { SyncUtil.runToLocation("testSameName"); - MIStoppedEvent stoppedEvent = SyncUtil.step(4, StepType.STEP_INTO); + MIStoppedEvent stoppedEvent = SyncUtil.step(5, StepType.STEP_INTO); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); @@ -1637,20 +1630,17 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testUpdatingChildren() throws Throwable { - SyncUtil.runToLocation("testUpdateChildren"); - MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testUpdateChildren_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); doUpdateTest(frameDmc, 0); // Re-run the test to test out-of-scope update again - SyncUtil.step(StepType.STEP_RETURN); - stoppedEvent = SyncUtil.step(3, StepType.STEP_INTO); + stoppedEvent = runToTag("testUpdateChildren_init"); final IFrameDMContext frameDmc2 = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); doUpdateTest(frameDmc2, 100); // Re-run the test within a different method test out-of-scope updates - SyncUtil.step(StepType.STEP_RETURN); - stoppedEvent = SyncUtil.step(3, StepType.STEP_INTO); + stoppedEvent = runToTag("testUpdateChildren2_init"); final IFrameDMContext frameDmc3 = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); doUpdateTest(frameDmc3, 200); @@ -1963,8 +1953,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testUpdateGDBBug() throws Throwable { - SyncUtil.runToLocation("testUpdateGDBBug"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testUpdateGDBBug_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); @@ -2060,8 +2049,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testUpdateIssue() throws Throwable { - SyncUtil.runToLocation("testUpdateIssue"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testUpdateIssue_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); @@ -2178,8 +2166,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testUpdateIssue2() throws Throwable { - SyncUtil.runToLocation("testUpdateIssue2"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testUpdateIssue2_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); @@ -2300,8 +2287,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { */ @Test public void testConcurrentReadAndUpdateChild() throws Throwable { - SyncUtil.runToLocation("testConcurrentReadAndUpdateChild"); - MIStoppedEvent stoppedEvent = SyncUtil.step(1, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testConcurrentReadAndUpdateChild_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); final AsyncCompletionWaitor wait = new AsyncCompletionWaitor(); @@ -2418,7 +2404,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { @Test public void testConcurrentUpdateOutOfScopeChildThenParent() throws Throwable { SyncUtil.runToLocation("testConcurrentUpdateOutOfScopeChildThenParent"); - MIStoppedEvent stoppedEvent = SyncUtil.step(2, StepType.STEP_INTO); + MIStoppedEvent stoppedEvent = runToTag("testConcurrentUpdateOutOfScopeChildThenParent1_init"); final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); @@ -2471,7 +2457,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { wait.waitReset(); SyncUtil.step(StepType.STEP_RETURN); - stoppedEvent = SyncUtil.step(2, StepType.STEP_INTO); + stoppedEvent = runToTag("testConcurrentUpdateOutOfScopeChildThenParent2_init"); // Now step to another method to make the previous variable objects out-of-scope // then first request the child and then the parent. We want to test this order @@ -2825,7 +2811,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { // Now run the current sub-test using each of // the formats available for the type of // the expression in the sub-test. - + System.out.println(Arrays.toString(formatIds)); for (final String formatId : formatIds) { // Get a FormattedValueCMContext object for // the expression-formatID pair. @@ -3318,10 +3304,8 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * This test verifies that we can cast to a type and then revert. */ @Test - @Ignore public void testCastToType() throws Throwable { - SyncUtil.runToLocation("testCasting"); - MIStoppedEvent stoppedEvent = SyncUtil.step(3, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testCasting_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "int_ptr"); @@ -3383,10 +3367,8 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * This test verifies that we can display as array and then revert. */ @Test - @Ignore public void testDisplayAsArray() throws Throwable { - SyncUtil.runToLocation("testCasting"); - MIStoppedEvent stoppedEvent = SyncUtil.step(3, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testCasting_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "int_ptr"); @@ -3435,10 +3417,8 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * and then revert. */ @Test - @Ignore public void testDisplayAsArrayAndCastToType() throws Throwable { - SyncUtil.runToLocation("testCasting"); - MIStoppedEvent stoppedEvent = SyncUtil.step(3, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testCasting_init"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "int_ptr"); @@ -4209,11 +4189,9 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { * 7.5. */ @Test - @Ignore public void testRTTI_7_5() throws Throwable { assumeGdbVersionAtLeast(ITestConstants.SUFFIX_GDB_7_5); - SyncUtil.runToLocation("testRTTI"); - MIStoppedEvent stoppedEvent = SyncUtil.step(3, StepType.STEP_OVER); + MIStoppedEvent stoppedEvent = runToTag("testRTTI_tag1"); IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0); // The expression we will follow as it changes types: derived.ptr @@ -4229,7 +4207,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { getChildren(exprDmc, expectedValues); // Make the type of our expression change - SyncUtil.step(1, StepType.STEP_OVER); + runToTag("testRTTI_tag2"); // Now, the expression should be type Derived getExpressionType(exprDmc, "Derived *"); assertChildrenCount(exprDmc, 5); @@ -4243,7 +4221,7 @@ public class MIExpressionsTest extends BaseParametrizedTestCase { getChildren(exprDmc, expectedValues); // Make the type of our expression change - SyncUtil.step(1, StepType.STEP_OVER); + runToTag("testRTTI_tag3"); // Now, the expression should be type OtherDerived getExpressionType(exprDmc, "OtherDerived *"); assertChildrenCount(exprDmc, 4); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java index 952be08ad6b..257d4a40e30 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIRunControlTest.java @@ -618,8 +618,10 @@ public class MIRunControlTest extends BaseParametrizedTestCase { ServiceEventWaitor suspendedEventWaitor = new ServiceEventWaitor<>( getGDBLaunch().getSession(), ISuspendedDMEvent.class); - fRunCtrl.getExecutor().submit(() -> fRunCtrl.runToLine(fThreadExecDmc, SOURCE_NAME, - getLineForTag("LINE_MAIN_ALL_THREADS_STARTED"), true, new RequestMonitor(fRunCtrl.getExecutor(), null) { + int lineForTag = getLineForTag("LINE_MAIN_ALL_THREADS_STARTED"); + + fRunCtrl.getExecutor().submit(() -> fRunCtrl.runToLine(fThreadExecDmc, SOURCE_NAME, lineForTag, true, + new RequestMonitor(fRunCtrl.getExecutor(), null) { @Override protected void handleCompleted() { wait.waitFinished(getStatus()); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java index 4d570041b86..f1bde7ce184 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/PostMortemCoreTest.java @@ -360,7 +360,6 @@ public class PostMortemCoreTest extends BaseParametrizedTestCase { * variables. */ @Test - @Ignore public void testLocalVariables() throws Throwable { doLaunch(); @@ -397,7 +396,6 @@ public class PostMortemCoreTest extends BaseParametrizedTestCase { } @Test - @Ignore public void readMemoryArray() throws Throwable { doLaunch(); diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/MIExpressionsNonStopTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/MIExpressionsNonStopTest.java index f9b0823b95b..626903086c0 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/MIExpressionsNonStopTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/MIExpressionsNonStopTest.java @@ -18,12 +18,10 @@ import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.eclipse.cdt.tests.dsf.gdb.tests.MIExpressionsTest; import org.junit.Assume; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @RunWith(Parameterized.class) -@Ignore public class MIExpressionsNonStopTest extends MIExpressionsTest { @BeforeClass diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/ThreadStackFrameSyncTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/ThreadStackFrameSyncTest.java index 0a2a53301e2..624918e9296 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/ThreadStackFrameSyncTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/nonstop/ThreadStackFrameSyncTest.java @@ -53,7 +53,6 @@ import org.eclipse.cdt.tests.dsf.gdb.tests.ITestConstants; import org.junit.Assert; import org.junit.Assume; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; public class ThreadStackFrameSyncTest extends BaseParametrizedTestCase { @@ -177,7 +176,6 @@ public class ThreadStackFrameSyncTest extends BaseParametrizedTestCase { * triggers a GDB notification that a new frame has been selected. */ @Test - @Ignore public void testChangingCurrentFrameCLINotification() throws Throwable { ServiceEventWaitor eventWaitor = new ServiceEventWaitor<>(fMultiRunControl.getSession(), MIStoppedEvent.class); @@ -265,7 +263,6 @@ public class ThreadStackFrameSyncTest extends BaseParametrizedTestCase { * the current GDB stack frame */ @Test - @Ignore public void testGdbSyncServiceCanSwitchGDBStackFrame() throws Throwable { ServiceEventWaitor eventWaitor = new ServiceEventWaitor<>(fMultiRunControl.getSession(), MIStoppedEvent.class);