diff options
37 files changed, 815 insertions, 293 deletions
diff --git a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java index f6497540771..4dc47efb12f 100644 --- a/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java +++ b/build/org.eclipse.cdt.core.autotools.core/src/org/eclipse/cdt/core/autotools/core/AutotoolsBuildConfiguration.java @@ -106,7 +106,7 @@ public class AutotoolsBuildConfiguration extends CBuildConfiguration { try { // TODO Error parsers Process process = builder.start(); - watchProcess(process, console); + watchProcess(console, monitor); } catch (IOException e) { throw new CoreException(Activator.errorStatus("Error executing: " + String.join(" ", command), e)); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -153,7 +153,7 @@ public class AutotoolsBuildConfiguration extends CBuildConfiguration { Activator.errorStatus("Error executing: " + String.join(" ", command), null)); //$NON-NLS-1$ //$NON-NLS-2$ } - watchProcess(p, new IConsoleParser[] { epm }); + watchProcess(new IConsoleParser[] { epm }, monitor); } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF index 9d06cc089b6..ccd8ad9d5b8 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true -Bundle-Version: 8.2.200.qualifier +Bundle-Version: 8.2.300.qualifier Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index a16c798d21c..4611ce2a8d0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -9779,5 +9779,69 @@ </configuration> </projectType> </extension> + <extension + point="org.eclipse.cdt.managedbuilder.core.buildDefinitions"> + <tool + id="bug580009.tests.tool" + isAbstract="true" + isSystem="true" + outputs="o" + sources="c"> + <option + category="bug580009.tests.tool.optionsCategory" + defaultValue="UNSET" + id="bug580009.tests.option.string" + isAbstract="false" + name="Test" + resourceFilter="all" + value="UNSET" + valueType="string"> + </option> + <optionCategory + id="bug580009.tests.tool.optionsCategory" + name="name1"> + </optionCategory> + </tool> + <projectType + id="bug580009.tests.ptype" + isAbstract="false" + isTest="true"> + <configuration + id="bug580009.tests.cfg1" + name="cfg1"> + <toolChain + id="bug580009.tests.cfg1.tc2" + isAbstract="false" + isSystem="false" + superClass="bug580009.tests.cfg1.tc"> + </toolChain> + </configuration> + </projectType> + <toolChain + id="bug580009.tests.cfg1.tc" + isAbstract="true" + isSystem="true"> + <tool + id="bug580009.tests.cfg1.tc.tool" + isAbstract="false" + superClass="bug580009.tests.tool"> + </tool> + <builder + id="bug580009.tests.cfg1.tc.builder" + isAbstract="false" + isVariableCaseSensitive="false"> + </builder> + <option + category="bug580009.tests.cfg1.tc.optionCategory1" + id="bug580009.tests.cfg1.tc.option.string" + isAbstract="false" + valueType="boolean"> + </option> + <optionCategory + id="bug580009.tests.cfg1.tc.optionCategory1" + name="name"> + </optionCategory> + </toolChain> + </extension> </plugin> diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_580441Test.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_580441Test.java new file mode 100644 index 00000000000..c5dbe8f8852 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_580441Test.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2011, 2022 Broadcom Corporation 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 + * + * Contributors: + * Broadcom Corporation - Bug 303953 test + * John Dallaway - Initial implementation (derived from bug 303953 test) + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.regressions; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; + +import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest; +import org.eclipse.core.resources.IBuildConfiguration; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.junit.jupiter.api.Test; + +/** + * Test that removal of a directory containing source file(s) is + * processed correctly by the default GnuMakefileGenerator. + */ +public class Bug_580441Test extends AbstractBuilderTest { + + @Test + public void testBuildAfterPopulatedSourceFolderDelete() throws CoreException { + setWorkspace("regressions"); + final IProject app = loadProject("helloworldC"); + + // Create additional source file at src/test/test.c + final IFolder testFolder = app.getFolder("src/test"); + testFolder.create(false, false, null); + testFolder.getFile("test.c").create(new ByteArrayInputStream("int test;".getBytes()), false, null); + + // Build debug configuration + setActiveConfigurationByName(app, "Debug"); + buildConfig(app.getActiveBuildConfig()); + assertTrue(app.getFile("Debug/src/test/test.o").exists(), "test.o not created"); + + // Delete folder containing test.c and build again + testFolder.delete(false, null); + buildConfig(app.getActiveBuildConfig()); + assertFalse(app.getFolder("Debug/src/test").exists(), "test folder not deleted"); + } + + private void buildConfig(IBuildConfiguration config) throws CoreException { + ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { + @Override + public void run(IProgressMonitor monitor) throws CoreException { + ResourcesPlugin.getWorkspace().build(new IBuildConfiguration[] { config }, + IncrementalProjectBuilder.INCREMENTAL_BUILD, true, monitor); + } + }, null); + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java index 5adb0f5c1ed..5124f00b814 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java @@ -25,10 +25,12 @@ import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration; +import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; +import org.eclipse.cdt.managedbuilder.internal.core.ResourceInfo; import org.eclipse.cdt.managedbuilder.internal.core.Tool; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IFile; @@ -45,6 +47,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.junit.Assert; import junit.framework.Test; import junit.framework.TestCase; @@ -68,6 +71,7 @@ public class ResourceBuildCoreTests extends TestCase { TestSuite suite = new TestSuite(ResourceBuildCoreTests.class.getName()); suite.addTest(new ResourceBuildCoreTests("testResourceConfigurations")); suite.addTest(new ResourceBuildCoreTests("testResourceConfigurationReset")); + suite.addTest(new ResourceBuildCoreTests("testResourceConfiguration_Bug580009")); // suite.addTest(new ResourceBuildCoreTests("testResourceConfigurationBuildInfo")); // suite.addTest(new ResourceBuildCoreTests("testResourceRename")); return suite; @@ -969,4 +973,138 @@ public class ResourceBuildCoreTests extends TestCase { removeProject(renamedProjectName2); } + protected IResourceInfo getResourceConfiguration(final IConfiguration config, final IResource resource) { + + IResourceInfo resInfo = config.getResourceInfo(resource.getProjectRelativePath(), true); // 'true' to ensure exact path + if (resInfo == null) { + // Resource element for path may not yet exist, force-create it + resInfo = config.createFolderInfo(resource.getProjectRelativePath()); + } + return resInfo; + } + + /** + * Test that a folder level resource configuration correctly reloads from disk + * @throws Exception + */ + public void testResourceConfiguration_Bug580009() throws Exception { + + // Create a new project + IProject project = null; + + try { + project = createProject(projectName); + + // Now associate the builder with the project + ManagedBuildTestHelper.addManagedBuildNature(project); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + + } catch (CoreException e) { + fail("Test failed on project creation: " + e.getLocalizedMessage()); + } + + // Find the base project type definition + IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); + IProjectType projType = ManagedBuildManager.getProjectType("bug580009.tests.ptype"); + assertNotNull(projType); + + // Create the managed-project for our project + IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); + assertEquals(newProject.getName(), projType.getName()); + assertFalse(newProject.equals(projType)); + ManagedBuildManager.setNewProjectVersion(project); + + // Create a folder ('hello') + IFolder helloFolder = project.getProject().getFolder("hello"); + if (!helloFolder.exists()) { + helloFolder.create(true, true, null); + } + + // Get the configurations and make one of them as default configuration. + IConfiguration defaultConfig = null; + IConfiguration[] configs = projType.getConfigurations(); + for (int i = 0; i < configs.length; ++i) { + // Make the first configuration the default + if (i == 0) { + defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } else { + newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } + } + ManagedBuildManager.setDefaultConfiguration(project, defaultConfig); + + //Set toolchain level option + IOption tcOption = defaultConfig.getToolChain().getOptionById("bug580009.tests.cfg1.tc.option.string"); + ManagedBuildManager.setOption(defaultConfig, defaultConfig.getToolChain(), tcOption, true); + ManagedBuildManager.saveBuildInfo(project, true); + // Create Resource Configurations for hello.c + var resConfig = getResourceConfiguration(defaultConfig, helloFolder); + + // Get the tools associated with the resource 'hello'. + ITool[] resTools = resConfig.getTools(); + assertNotNull(resTools); + assertEquals(1, resTools.length); + + // Get the build properties for the resource hello + ITool resTool = resTools[0]; + String defaultResToolFlags = resTool.getToolFlags(); + + // Get the Test Option. + IOption resDebugOption = resTool.getOptionById("bug580009.tests.option.string"); + + // Get the default value of debug option for resource. + String defaultResDebugOptVal = resDebugOption.getStringValue(); + + // Now, override the value with "bug580009.tests.option.string" + IOption newResDebugOption = ManagedBuildManager.setOption(resConfig, resTool, resDebugOption, "SET"); + + // Get the overridden value of test option. + String newResDebugOptVal = newResDebugOption.getStringValue(); + String newResToolFlags = resTool.getToolFlags(); + + // Make sure, default and overridden values are different. + assertNotSame(defaultResDebugOptVal, newResDebugOptVal); + + //Check the config reports custom settings + Assert.assertTrue("hasCustomSettings should be true", ((ResourceInfo) resConfig).hasCustomSettings()); + + ManagedBuildManager.saveBuildInfo(project, true); + + //Close project + project.close(null); + project.open(null); + + //Reload configs + defaultConfig = ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration(); + var resInfo = defaultConfig.getResourceInfo(helloFolder.getProjectRelativePath(), true); + + //Check the config still reports custom settings (sanity check) + Assert.assertTrue("hasCustomSettings should be true", ((ResourceInfo) resInfo).hasCustomSettings()); + + resTools = resInfo.getTools(); + resTool = resTools[0]; + resDebugOption = resTool.getOptionBySuperClassId("bug580009.tests.option.string"); + + // Set back to default value + IOption newResDebugOption2 = ManagedBuildManager.setOption(resInfo, resTool, resDebugOption, "UNSET"); + + //Check the config now reports no custom settings + Assert.assertFalse("hasCustomSettings should be false", ((ResourceInfo) resInfo).hasCustomSettings()); + + ManagedBuildManager.saveBuildInfo(project, true); + + //Check the resource config no longer exists + resInfo = defaultConfig.getResourceInfo(helloFolder.getProjectRelativePath(), true); + Assert.assertNull("resInfo should be null", resInfo); + + // Close and remove project. + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + removeProject(projectName); + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF index bb7707b45a0..e83988ef44e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true -Bundle-Version: 9.4.0.qualifier +Bundle-Version: 9.4.100.qualifier Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java index 74a02ce33ff..393df9fe958 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java @@ -17,6 +17,7 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -29,6 +30,7 @@ import org.eclipse.cdt.internal.core.SafeStringInterner; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuildPropertiesRestriction; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IHoldsOptions; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; @@ -511,7 +513,37 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest if (superClassId != null && superClassId.length() > 0) { superClass = ManagedBuildManager.getExtensionOption(superClassId); if (superClass == null) { - // TODO: Report error + /* + * This can happen when options are set at the resource level, for a project using a toolchain definition + * where there are options at the toolchain level & one or more of those options is set at a + * non-default value. + * + * In these cases the superclass is set to the option from the parent not the extension's ID + * Workaround this by searching for any missing superclass IDs at on the parent configs toolchain + * + * See the "bug580009.tests.cfg1.tc" definition in org.eclipse.cdt.managedbuilder.core.tests for an example + */ + IBuildObject parent = this.getParent(); + if (parent instanceof IToolChain) { + IConfiguration config = ((IToolChain) parent).getParent(); + IOption foundOption = null; + //In rare cases the RootFolderInfo may not have loaded & will cause an NPE + if (config != null && config.getRootFolderInfo() != null) { + IToolChain parentToolchain = config.getToolChain(); + if (parentToolchain != null) { + foundOption = parentToolchain.getOptionById(superClassId); + } + } + if (foundOption != null) { + superClass = foundOption; + } else { + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + MessageFormat.format("Missing superclass \"{0}\" for \"{1}\"", superClassId, getId()))); //$NON-NLS-1$ + } + } else { + ManagedBuilderCorePlugin.log(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, + MessageFormat.format("Missing superclass \"{0}\" for \"{1}\"", superClassId, getId()))); //$NON-NLS-1$ + } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu2/GnuMakefileGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu2/GnuMakefileGenerator.java index c1e3d3e71d3..327551719ca 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu2/GnuMakefileGenerator.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu2/GnuMakefileGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2016 IBM Corporation and others. + * Copyright (c) 2003, 2022 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -17,6 +17,7 @@ * Marc-Andre Laperle * Liviu Ionescu - [322168] * Dorothea Pilz-Roeder (Advantest Europe GmbH) - [180451] + * John Dallaway - [580441] fix processing on source folder deletion *******************************************************************************/ package org.eclipse.cdt.managedbuilder.makegen.gnu2; @@ -192,7 +193,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 { // This is a source file so just add its container if (fo == null || fo.buildsFileType(ext)) { generator.appendDeletedFile(resource); - generator.appendModifiedSubdirectory(resource); + if (resource.getParent().exists()) { + generator.appendModifiedSubdirectory(resource); + } } } break; diff --git a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java index dc33eb56228..0be025a4838 100644 --- a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java +++ b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2018 QNX Software Systems and others. + * Copyright (c) 2015, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -183,7 +183,7 @@ public class MesonBuildConfiguration extends CBuildConfiguration { return null; } - watchProcess(p, console); + watchProcess(console, monitor); } if (!Files.exists(buildDir.resolve("build.ninja"))) { //$NON-NLS-1$ @@ -238,7 +238,7 @@ public class MesonBuildConfiguration extends CBuildConfiguration { return null; } - watchProcess(p, new IConsoleParser[] { epm }); + watchProcess(new IConsoleParser[] { epm }, monitor); } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); @@ -298,7 +298,7 @@ public class MesonBuildConfiguration extends CBuildConfiguration { return; } - watchProcess(p, console); + watchProcess(console, monitor); } outStream.write(String.format(Messages.MesonBuildConfiguration_BuildingComplete, buildDir.toString())); diff --git a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java index 4b39dc5a911..0827caca307 100644 --- a/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java +++ b/cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 QNX Software Systems and others. + * Copyright (c) 2015, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -175,9 +175,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { ParsingConsoleOutputStream errStream = new ParsingConsoleOutputStream(console.getErrorStream(), errorParser); IConsole errConsole = new CMakeConsoleWrapper(console, errStream); - // TODO startBuildProcess() calls java.lang.ProcessBuilder. - // Use org.eclipse.cdt.core.ICommandLauncher - // in order to run builds in a container. Process p = startBuildProcess(command.getArguments(), new IEnvironmentVariable[0], workingDir, errConsole, monitor); String arg0 = command.getArguments().get(0); @@ -190,7 +187,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { } // check cmake exit status - final int exitValue = watchProcess(p, errConsole); + final int exitValue = watchProcess(errConsole, monitor); if (exitValue != 0) { // cmake had errors... String msg = String.format(Messages.CMakeBuildConfiguration_ExitFailure, arg0, exitValue); @@ -230,8 +227,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path( getBuildDirectory().toString()); - // TODO startBuildProcess() calls java.lang.ProcessBuilder. Use org.eclipse.cdt.core.ICommandLauncher - // in order to run builds in a container. // TODO pass envvars from CommandDescriptor once we use ICommandLauncher Process p = startBuildProcess(command, envVars.toArray(new IEnvironmentVariable[0]), workingDir, console, monitor); @@ -241,7 +236,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { } // check exit status - final int exitValue = watchProcess(p, new IConsoleParser[] { epm }); + final int exitValue = watchProcess(new IConsoleParser[] { epm }, monitor); if (exitValue != 0) { // had errors... String msg2 = String.format(Messages.CMakeBuildConfiguration_ExitFailure, command.get(0), @@ -286,8 +281,6 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path( getBuildDirectory().toString()); - // TODO startBuildProcess() calls java.lang.ProcessBuilder. Use org.eclipse.cdt.core.ICommandLauncher - // in order to run builds in a container. Process p = startBuildProcess(command.getArguments(), new IEnvironmentVariable[0], workingDir, console, monitor); if (p == null) { @@ -299,7 +292,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration { } // check exit status - final int exitValue = watchProcess(p, console); + final int exitValue = watchProcess(console, monitor); if (exitValue != 0) { // had errors... String msg = String.format(Messages.CMakeBuildConfiguration_ExitFailure, command.getArguments().get(0), diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentOperatorChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentOperatorChecker.java index c3196b940fe..167b6dd0bfd 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentOperatorChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentOperatorChecker.java @@ -112,7 +112,7 @@ public class AssignmentOperatorChecker extends AbstractIndexAstChecker { reportProblem(MISS_SELF_CHECK_ID, info.decl); } info.decl = null; - } else { + } else if (expression.getPropertyInParent() != ICPPASTFunctionDeclarator.NOEXCEPT_EXPRESSION) { reportProblem(MISS_SELF_CHECK_ID, info.decl); info.decl = null; } diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentOperatorCheckerTest.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentOperatorCheckerTest.java index 3d687bd8c8c..1185530036a 100644 --- a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentOperatorCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/internal/checkers/AssignmentOperatorCheckerTest.java @@ -49,6 +49,22 @@ public class AssignmentOperatorCheckerTest extends CheckerTestCase { //class Foo { //public: + //Foo& operator=(Foo& f) noexcept (false); + //}; + //Foo& Foo::operator=(Foo& f) noexcept (false) { + // if (this != &f) { + // return *this; + // } + // return *this; + //} + public void testWithNoErrorNoexcept() throws Exception { + loadCodeAndRun(getAboveComment()); + checkNoErrorsOfKind(MISS_REF_ID); + checkNoErrorsOfKind(MISS_SELF_ID); + } + + //class Foo { + //public: //Foo operator=(const Foo& f); //}; //Foo Foo::operator=(const Foo& f) { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java index ee0d36b4f8b..755bf7bafea 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TestBase.java @@ -113,6 +113,7 @@ public class AST2TestBase extends SemanticTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_DOUBLE__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; @@ -123,6 +124,7 @@ public class AST2TestBase extends SemanticTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_DOUBLE__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java index 48160677923..226ac681328 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/IntegralValueTests.java @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2.cxx14.constexpr; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; import org.eclipse.cdt.internal.core.dom.parser.IntegralValue; import junit.framework.TestSuite; @@ -36,6 +37,16 @@ public abstract class IntegralValueTests extends TestBase { } } + @Override + protected void setUp() throws Exception { + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_SHORT__", "2"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_INT__", "4"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_LONG__", "8"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_LONG_LONG__", "8"); + TestScannerProvider.sDefinedSymbols.put("__SIZEOF_POINTER__", "8"); + super.setUp(); + } + // constexpr auto x = int{} + int(); public void testIntDefaultValue() throws Exception { assertEvaluationEquals(0); @@ -274,4 +285,59 @@ public abstract class IntegralValueTests extends TestBase { public void testBuiltinFfs() throws Exception { assertEvaluationEquals(5); } + + // constexpr int x = __builtin_ffs(0x100000000); + public void testBuiltinFfsNarrowing() throws Exception { + assertEvaluationEquals(0); + } + + // constexpr int x = __builtin_ffsl(0x100000000); + public void testBuiltinFfsl() throws Exception { + assertEvaluationEquals(33); + } + + // constexpr int x = __builtin_ctz(16); + public void testBuiltinCtz() throws Exception { + assertEvaluationEquals(4); + } + + // constexpr int x = __builtin_popcount(128 + 32 + 8 + 4 + 2); + public void testBuiltinPopcount() throws Exception { + assertEvaluationEquals(5); + } + + // constexpr int x = __builtin_popcountl(0x80000001); + public void testBuiltinPopcountHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_popcountl(0x8000000000000001); + public void testBuiltinPopcountlHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_popcountll(0x8000000000000001); + public void testBuiltinPopcountllHighBitSet() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_parity(128 + 32 + 8 + 4 + 2) + __builtin_parity(64) + __builtin_parity(0); + public void testBuiltinParity() throws Exception { + assertEvaluationEquals(2); + } + + // constexpr int x = __builtin_abs(700) + __builtin_abs(50); + public void testBuiltinAbs() throws Exception { + assertEvaluationEquals(750); + } + + // constexpr int x = __builtin_abs(-1); + public void testBuiltinAbsNegativeInput() throws Exception { + assertEvaluationEquals(1); + } + + // constexpr int x = __builtin_abs(0xFFFFFFFF); + public void testBuiltinAbsNarrowing() throws Exception { + assertEvaluationEquals(1); + } }
\ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java index 79badd6a337..81ef2344c50 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/cxx14/constexpr/TestBase.java @@ -66,6 +66,7 @@ public abstract class TestBase extends IndexBindingResolutionTestBase { map.put("__SIZEOF_SHORT__", "2"); map.put("__SIZEOF_INT__", "4"); map.put("__SIZEOF_LONG__", "8"); + map.put("__SIZEOF_LONG_LONG__", "8"); map.put("__SIZEOF_POINTER__", "8"); return map; } diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll Binary files differindex 71f3f1e8a77..db374f73310 100755 --- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll +++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/pty.dll diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll Binary files differindex 4a0984f5e0d..00b9a5c003d 100755 --- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll +++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/spawner.dll diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe Binary files differindex 1da0d377ee1..f66b4210461 100755 --- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe +++ b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/starter.exe diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index 6224785337c..bc52049ddfe 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true -Bundle-Version: 7.4.200.qualifier +Bundle-Version: 7.5.0.qualifier Bundle-Activator: org.eclipse.cdt.core.CCorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java index b5ab4d3b5df..407c02e1d05 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/GCCBuiltinSymbolProvider.java @@ -191,10 +191,24 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("bool", "__atomic_is_lock_free", "size_t", "void*"); ICPPExecution builtinFfs = new ExecBuiltin(ExecBuiltin.BUILTIN_FFS); + ICPPExecution builtinFfsl = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSL); + ICPPExecution builtinFfsll = new ExecBuiltin(ExecBuiltin.BUILTIN_FFSLL); + ICPPExecution builtinCtz = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZ); + ICPPExecution builtinCtzl = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZL); + ICPPExecution builtinCtzll = new ExecBuiltin(ExecBuiltin.BUILTIN_CTZLL); + ICPPExecution builtinPopcount = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNT); + ICPPExecution builtinPopcountl = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNTL); + ICPPExecution builtinPopcountll = new ExecBuiltin(ExecBuiltin.BUILTIN_POPCOUNTLL); + ICPPExecution builtinParity = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITY); + ICPPExecution builtinParityl = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITYL); + ICPPExecution builtinParityll = new ExecBuiltin(ExecBuiltin.BUILTIN_PARITYLL); + ICPPExecution builtinAbs = new ExecBuiltin(ExecBuiltin.BUILTIN_ABS); + ICPPExecution builtinLabs = new ExecBuiltin(ExecBuiltin.BUILTIN_LABS); + ICPPExecution builtinLlabs = new ExecBuiltin(ExecBuiltin.BUILTIN_LLABS); // Other Builtins (https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html) [incomplete] function("void", "__builtin_abort"); - function("int", "__builtin_abs", "int"); + function("int", "__builtin_abs", builtinAbs, "int"); function("double", "__builtin_acos", "double"); function("float", "__builtin_acosf", "float"); function("long double", "__builtin_acosl", "long double"); @@ -251,9 +265,9 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_creal", "complex double"); function("float", "__builtin_crealf", "complex float"); function("long double", "__builtin_creall", "complex long double"); - function("int", "__builtin_ctz", "unsigned int"); - function("int", "__builtin_ctzl", "unsigned long"); - function("int", "__builtin_ctzll", "unsigned long long"); + function("int", "__builtin_ctz", builtinCtz, "unsigned int"); + function("int", "__builtin_ctzl", builtinCtzl, "unsigned long"); + function("int", "__builtin_ctzll", builtinCtzll, "unsigned long long"); function("double", "__builtin_erf", "double"); function("float", "__builtin_erff", "float"); function("long double", "__builtin_erfl", "long double"); @@ -282,8 +296,8 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("float", "__builtin_fdimf", "float", "float"); function("long double", "__builtin_fdiml", "long double", "long double"); function("int", "__builtin_ffs", builtinFfs, "unsigned int"); - function("int", "__builtin_ffsl", builtinFfs, "unsigned long"); - function("int", "__builtin_ffsll", builtinFfs, "unsigned long long"); + function("int", "__builtin_ffsl", builtinFfsl, "unsigned long"); + function("int", "__builtin_ffsll", builtinFfsll, "unsigned long long"); function("double", "__builtin_floor", "double"); function("float", "__builtin_floorf", "float"); function("long double", "__builtin_floorl", "long double"); @@ -334,7 +348,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("bool", "__builtin_isnan", "double"); function("bool", "__builtin_isnormal", "double"); function("bool", "__builtin_isunordered", "float", "float"); - function("long", "__builtin_labs", "long"); + function("long", "__builtin_labs", builtinLabs, "long"); function("double", "__builtin_ldexp", "double", "int"); function("float", "__builtin_ldexpf", "float", "int"); function("long double", "__builtin_ldexpl", "long double", "int"); @@ -344,7 +358,7 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("int", "__builtin_LINE"); //TODO: This should technically be a constant integer expression function("const char *", "__builtin_FUNCTION"); function("const char *", "__builtin_FILE"); - function("long long", "__builtin_llabs", "long long"); + function("long long", "__builtin_llabs", builtinLlabs, "long long"); function("long long", "__builtin_llrint", "double"); function("long long", "__builtin_llrintf", "float"); function("long long", "__builtin_llrintl", "long double"); @@ -397,12 +411,12 @@ public class GCCBuiltinSymbolProvider implements IBuiltinBindingsProvider { function("double", "__builtin_nexttoward", "double", "long double"); function("float", "__builtin_nexttowardf", "float", "long double"); function("long double", "__builtin_nexttowardl", "long double", "long double"); - function("int", "__builtin_parity", "unsigned int"); - function("int", "__builtin_parityl", "unsigned long"); - function("int", "__builtin_parityll", "unsigned long long"); - function("int", "__builtin_popcount", "unsigned int"); - function("int", "__builtin_popcountl", "unsigned long"); - function("int", "__builtin_popcountll", "unsigned long long"); + function("int", "__builtin_parity", builtinParity, "unsigned int"); + function("int", "__builtin_parityl", builtinParityl, "unsigned long"); + function("int", "__builtin_parityll", builtinParityll, "unsigned long long"); + function("int", "__builtin_popcount", builtinPopcount, "unsigned int"); + function("int", "__builtin_popcountl", builtinPopcountl, "unsigned long"); + function("int", "__builtin_popcountll", builtinPopcountll, "unsigned long long"); function("double", "__builtin_pow", "double", "double"); function("float", "__builtin_powf", "float", "float"); function("long double", "__builtin_powl", "long double", "long double"); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java index 57c315ef531..fb3d3e4157f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/Conversions.java @@ -30,6 +30,7 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUti import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.isVoidType; +import java.math.BigInteger; import java.util.Collections; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -60,6 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator; +import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; @@ -1326,4 +1329,99 @@ public class Conversions { private static boolean isNullPtr(IType t1) { return t1 instanceof IBasicType && ((IBasicType) t1).getKind() == Kind.eNullPtr; } + + /** + * Narrow a numeric value to the range of a specified type. + * @param num the value to narrow (may be null) + * @param toType the type to narrow to + * @return a number representing the narrowed value, or null + */ + public static Number narrowNumberValue(Number num, IType toType) { + if (num == null) + return null; + + if (toType instanceof IBasicType) { + IBasicType basicType = (IBasicType) toType; + IBasicType.Kind basicTypeKind = basicType.getKind(); + switch (basicTypeKind) { + case eFloat: + if (num instanceof Float) + return num; + return Float.valueOf(num.floatValue()); + case eDouble: + if (num instanceof Double) + return num; + return Double.valueOf(num.doubleValue()); + case eInt: + SizeAndAlignment sizeToType = SizeofCalculator.getSizeAndAlignment(toType); + if (sizeToType == null) + return null; + // Note in the following we don't check type.isSigned() since that checks for the + // explicit presence of the "signed" modifier. So instead check !type.isUnsigned(). + if (sizeToType.size <= 8) { + // First, mask the value to the correct size + // Note that we take the longValue here which may be negative even though the + // original value is positive; the masking here should still be correct and we + // should ultimately end up with the correct narrowed value, regardless. + long longVal = num.longValue(); + long maskVal = 0xFFFFFFFFFFFFFFFFL; + long signBit = 0x8000000000000000L; + // Calculate a mask to reduce the size of the value to the target width: + maskVal >>>= (8 - sizeToType.size) * 8; + signBit >>>= (8 - sizeToType.size) * 8; + if (!basicType.isUnsigned() && (longVal & signBit) != 0) { + // We need to extend the sign bit. + long signBits = ~maskVal; + longVal |= signBits; + } else { + longVal &= maskVal; + } + + // The Java type used to store the numerical value is independent of the associated + // C type, but we go with a smaller type (Integer) where possible. For 4 bytes + // (signed) or less than 4 bytes (signed or not) we can use Integer. For 8 bytes + // (signed) or less than 8 bytes (signed or not) we can use Long. Any larger and we + // resort to BigInteger. + if (longVal >= 0 && longVal <= Integer.MAX_VALUE) { + return Integer.valueOf((int) longVal); + } + if (!basicType.isUnsigned() && longVal >= Integer.MIN_VALUE && longVal <= Integer.MAX_VALUE) { + return Integer.valueOf((int) longVal); + } + + if (!basicType.isUnsigned() || longVal > 0) { + return Long.valueOf(longVal); + } + + BigInteger biVal = BigInteger.valueOf(longVal); + // 2**64 = 18446744073709551616 + biVal = biVal.add(new BigInteger("18446744073709551616")); //$NON-NLS-1$ + return biVal; + } + // TODO handle larger int sizes? + return null; + case eChar: + // TODO don't assume signed char + if (num instanceof Byte) + return num; + return Byte.valueOf(num.byteValue()); + case eChar16: + int intVal = num.intValue(); + int maskedVal = intVal & 0xFFFF; + if (maskedVal == intVal && num instanceof Integer) + return num; + return Integer.valueOf(maskedVal); + case eChar32: + long longVal = num.longValue(); + long maskedVal32 = longVal & 0xFFFFFFFFL; + if (maskedVal32 == longVal && (num instanceof Integer || num instanceof Long)) + return num; + return Long.valueOf(maskedVal32); + default: + return null; + } + } + + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java index 338ef00240f..86e6aab7ae2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecBuiltin.java @@ -31,9 +31,13 @@ import org.eclipse.core.runtime.CoreException; * Constexpr-evaluation for compiler builtin functions. */ public class ExecBuiltin implements ICPPExecution { - public final static short BUILTIN_FFS = 0; + public final static short BUILTIN_FFS = 0, BUILTIN_FFSL = 1, BUILTIN_FFSLL = 2, BUILTIN_CTZ = 3, BUILTIN_CTZL = 4, + BUILTIN_CTZLL = 5, BUILTIN_POPCOUNT = 6, BUILTIN_POPCOUNTL = 7, BUILTIN_POPCOUNTLL = 8, BUILTIN_PARITY = 9, + BUILTIN_PARITYL = 10, BUILTIN_PARITYLL = 11, BUILTIN_ABS = 12, BUILTIN_LABS = 13, BUILTIN_LLABS = 14; private static IType intType = new CPPBasicType(Kind.eInt, 0); + private static IType longType = new CPPBasicType(Kind.eInt, CPPBasicType.IS_LONG); + private static IType longlongType = new CPPBasicType(Kind.eInt, CPPBasicType.IS_LONG_LONG); private short funcId; @@ -51,29 +55,131 @@ public class ExecBuiltin implements ICPPExecution { switch (funcId) { case BUILTIN_FFS: - return executeBuiltinFfs(record, context); + return executeBuiltinFfs(record, context, intType); + case BUILTIN_FFSL: + return executeBuiltinFfs(record, context, longType); + case BUILTIN_FFSLL: + return executeBuiltinFfs(record, context, longlongType); + case BUILTIN_CTZ: + return executeBuiltinCtz(record, context, intType); + case BUILTIN_CTZL: + return executeBuiltinCtz(record, context, longType); + case BUILTIN_CTZLL: + return executeBuiltinCtz(record, context, longlongType); + case BUILTIN_POPCOUNT: + return executeBuiltinPopcount(record, context, intType); + case BUILTIN_POPCOUNTL: + return executeBuiltinPopcount(record, context, longType); + case BUILTIN_POPCOUNTLL: + return executeBuiltinPopcount(record, context, longlongType); + case BUILTIN_PARITY: + return executeBuiltinParity(record, context, intType); + case BUILTIN_PARITYL: + return executeBuiltinParity(record, context, longType); + case BUILTIN_PARITYLL: + return executeBuiltinParity(record, context, longlongType); + case BUILTIN_ABS: + return executeBuiltinAbs(record, context, intType); + case BUILTIN_LABS: + return executeBuiltinAbs(record, context, longType); + case BUILTIN_LLABS: + return executeBuiltinAbs(record, context, longlongType); } return null; } - private ICPPExecution executeBuiltinFfs(ActivationRecord record, ConstexprEvaluationContext context) { + /* + * Return an execution representing __builtin_ffs or __builtin_ctz + */ + private ICPPExecution executeBuiltinFfsCtz(ActivationRecord record, ConstexprEvaluationContext context, + boolean isCtz, IType argType) { ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); IValue argValue = arg0.getValue(); - if (!(argValue instanceof IntegralValue)) + Number numberVal = argValue.numberValue(); + numberVal = Conversions.narrowNumberValue(numberVal, argType); + if (numberVal == null) return null; // __builtin_ffs returns 0 if arg is 0, or 1+count where count is the number of trailing 0 bits - long arg = argValue.numberValue().longValue(); + // __builtin_ctz is undefined if arg is 0, or returns count + long arg = numberVal.longValue(); if (arg == 0) { - return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(0))); + if (isCtz) { + return null; + } else { + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(0))); + } } int count = 0; while ((arg & 1) == 0) { arg >>= 1; count++; } - return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(count + 1))); + int increment = isCtz ? 0 : 1; + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(count + increment))); + } + + private ICPPExecution executeBuiltinFfs(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinFfsCtz(record, context, false /* ffs */, argType); + } + + private ICPPExecution executeBuiltinCtz(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinFfsCtz(record, context, true /* ctz */, argType); + } + + /* + * Return an execution representing __builtin_popcount + */ + private ICPPExecution executeBuiltinPopcountParity(ActivationRecord record, ConstexprEvaluationContext context, + boolean isParity, IType argType) { + ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); + + IValue argValue = arg0.getValue(); + Number numberVal = argValue.numberValue(); + numberVal = Conversions.narrowNumberValue(numberVal, argType); + if (numberVal == null) + return null; + + long arg = numberVal.longValue(); + int count = 0; + while (arg != 0) { + if ((arg & 1) != 0) + count++; + arg >>>= 1; + } + if (isParity) { + count = count & 1; + } + return new ExecReturn(new EvalFixed(intType, ValueCategory.PRVALUE, IntegralValue.create(count))); + } + + private ICPPExecution executeBuiltinPopcount(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinPopcountParity(record, context, false, argType); + } + + private ICPPExecution executeBuiltinParity(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + return executeBuiltinPopcountParity(record, context, true, argType); + } + + private ICPPExecution executeBuiltinAbs(ActivationRecord record, ConstexprEvaluationContext context, + IType argType) { + ICPPEvaluation arg0 = record.getVariable(new CPPBuiltinParameter(null, 0)); + + IValue argValue = arg0.getValue(); + Number argNumber = argValue.numberValue(); + argNumber = Conversions.narrowNumberValue(argNumber, argType); + if (argNumber == null) + return null; + + long arg = argNumber.longValue(); + long result = Math.abs(arg); + + return new ExecReturn(new EvalFixed(argType, ValueCategory.PRVALUE, IntegralValue.create(result))); } @Override diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java index 68e5c472eea..039e1a4518b 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java @@ -10,15 +10,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.build; -import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; import java.net.URI; import java.nio.file.Files; import java.nio.file.InvalidPathException; @@ -33,9 +28,11 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import java.util.stream.Collectors; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncherManager; +import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.IConsoleParser2; import org.eclipse.cdt.core.IMarkerGenerator; @@ -60,6 +57,8 @@ import org.eclipse.cdt.core.parser.IExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.resources.IConsole; +import org.eclipse.cdt.internal.core.BuildRunnerHelper; +import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.internal.core.build.Messages; import org.eclipse.cdt.internal.core.model.BinaryRunner; import org.eclipse.cdt.internal.core.model.CModelManager; @@ -116,6 +115,8 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu private final Map<IResource, List<IScannerInfoChangeListener>> scannerInfoListeners = new HashMap<>(); private ScannerInfoCache scannerInfoCache; + private ICommandLauncher launcher; + protected CBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { this.config = config; this.name = name; @@ -488,7 +489,8 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu .write(String.format(Messages.CBuildConfiguration_CommandNotFound, commands.get(0))); return null; } - commands.set(0, commandPath.toString()); + IPath cmd = new org.eclipse.core.runtime.Path(commandPath.toString()); + List<String> args = commands.subList(1, commands.size()); // check if includes have been removed/refreshed and scanner info refresh is needed boolean needRefresh = CommandLauncherManager.getInstance().checkIfIncludesChanged(this); @@ -497,18 +499,28 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu t.setProperty(NEED_REFRESH, Boolean.valueOf(needRefresh).toString()); } - ProcessBuilder processBuilder = new ProcessBuilder(commands).directory(buildDirectory.toFile()); - // Override environment variables - Map<String, String> environment = processBuilder.environment(); + // Generate environment block before launching process + launcher = CommandLauncherManager.getInstance().getCommandLauncher(this); + Properties envProps = launcher.getEnvironment(); + HashMap<String, String> environment = envProps.entrySet().stream() + .collect(Collectors.toMap(e -> String.valueOf(e.getKey()), e -> String.valueOf(e.getValue()), + (prev, next) -> next, HashMap::new)); for (IEnvironmentVariable envVar : envVars) { environment.put(envVar.getName(), envVar.getValue()); } setBuildEnvironment(environment); - process = processBuilder.start(); + launcher.setProject(getProject()); + process = launcher.execute(cmd, args.toArray(new String[0]), BuildRunnerHelper.envMapToEnvp(environment), + buildDirectory, monitor); } return process; } + /** + * @return The exit code of the build process. + * + * @deprecated use {@link #watchProcess(IConsole, IProgressMonitor)} or {@link #watchProcess(IConsoleParser[], IProgressMonitor)} instead + */ @Deprecated protected int watchProcess(Process process, IConsoleParser[] consoleParsers, IConsole console) throws CoreException { @@ -520,110 +532,42 @@ public abstract class CBuildConfiguration extends PlatformObject implements ICBu } /** + * @return The exit code of the build process. * @since 6.4 + * + * @deprecated use {@link #watchProcess(IConsole, IProgressMonitor)} instead and pass in a monitor */ + @Deprecated protected int watchProcess(Process process, IConsole console) throws CoreException { - Thread t1 = new ReaderThread(process.getInputStream(), console.getOutputStream()); - t1.start(); - Thread t2 = new ReaderThread(process.getErrorStream(), console.getErrorStream()); - t2.start(); - try { - int rc = process.waitFor(); - // Allow reader threads the chance to process all output to console - while (t1.isAlive()) { - Thread.sleep(100); - } - while (t2.isAlive()) { - Thread.sleep(100); - } - return rc; - } catch (InterruptedException e) { - CCorePlugin.log(e); - return -1; - } + return watchProcess(console, new NullProgressMonitor()); } /** + * @return The exit code of the build process. + * @since 7.5 + */ + protected int watchProcess(IConsole console, IProgressMonitor monitor) throws CoreException { + return launcher.waitAndRead(console.getInfoStream(), console.getErrorStream(), monitor); + } + + /** + * @return The exit code of the build process. * @since 6.4 + * + * @deprecated use {@link #watchProcess(IConsoleParser[], IProgressMonitor)} instead and pass in a monitor */ + @Deprecated protected int watchProcess(Process process, IConsoleParser[] consoleParsers) throws CoreException { - Thread t1 = new ReaderThread(this, process.getInputStream(), consoleParsers); - t1.start(); - Thread t2 = new ReaderThread(this, process.getErrorStream(), consoleParsers); - t2.start(); - try { - int rc = process.waitFor(); - // Allow reader threads the chance to process all output to console - while (t1.isAlive()) { - Thread.sleep(100); - } - while (t2.isAlive()) { - Thread.sleep(100); - } - return rc; - } catch (InterruptedException e) { - CCorePlugin.log(e); - return -1; - } + return watchProcess(consoleParsers, new NullProgressMonitor()); } - private static class ReaderThread extends Thread { - CBuildConfiguration config; - private final BufferedReader in; - private final IConsoleParser[] consoleParsers; - private final PrintStream out; - - public ReaderThread(CBuildConfiguration config, InputStream in, IConsoleParser[] consoleParsers) { - this.config = config; - this.in = new BufferedReader(new InputStreamReader(in)); - this.out = null; - this.consoleParsers = consoleParsers; - } - - public ReaderThread(InputStream in, OutputStream out) { - this.in = new BufferedReader(new InputStreamReader(in)); - this.out = new PrintStream(out); - this.consoleParsers = null; - this.config = null; - } - - @Override - public void run() { - List<Job> jobList = new ArrayList<>(); - try { - for (String line = in.readLine(); line != null; line = in.readLine()) { - if (consoleParsers != null) { - for (IConsoleParser consoleParser : consoleParsers) { - // Synchronize to avoid interleaving of lines - synchronized (consoleParser) { - // if we have an IConsoleParser2, use the processLine method that - // takes a job list (Container Build support) - if (consoleParser instanceof IConsoleParser2) { - ((IConsoleParser2) consoleParser).processLine(line, jobList); - } else { - consoleParser.processLine(line); - } - } - } - } - if (out != null) { - out.println(line); - } - } - for (Job j : jobList) { - try { - j.join(); - } catch (InterruptedException e) { - // ignore - } - } - if (config != null) { - config.shutdown(); - } - } catch (IOException e) { - CCorePlugin.log(e); - } - } + /** + * @return The exit code of the build process. + * @since 7.5 + */ + protected int watchProcess(IConsoleParser[] consoleParsers, IProgressMonitor monitor) throws CoreException { + ConsoleOutputSniffer sniffer = new ConsoleOutputSniffer(consoleParsers); + return launcher.waitAndRead(sniffer.getOutputStream(), sniffer.getErrorStream(), monitor); } private File getScannerInfoCacheFile() { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java index d10351cb41a..9f0d72803c0 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 QNX Software Systems and others. + * Copyright (c) 2016, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -267,7 +267,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { } IConsoleParser[] consoleParsers = new IConsoleParser[] { epm, this }; - watchProcess(p, consoleParsers); + watchProcess(consoleParsers, monitor); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); @@ -326,7 +326,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration { return; } - watchProcess(p, console); + watchProcess(console, monitor); outStream.write(Messages.CBuildConfiguration_BuildComplete); 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 c491ff4f6c3..cf07edf79bd 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 @@ -660,13 +660,18 @@ public class FinalLaunchSequence extends ReflectionSequence { @Execute public void stepAttachRemoteToDebugger(final RequestMonitor requestMonitor) { if (fGDBBackend.getIsAttachSession() && fGDBBackend.getSessionType() == SessionType.REMOTE) { - IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(), - MIProcesses.UNKNOWN_PROCESS_ID); - fProcService.attachDebuggerToProcess(processContext, - new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor)); - } else { - requestMonitor.done(); + DataRequestMonitor<Boolean> rm = new DataRequestMonitor<>(getExecutor(), null); + fProcService.canDetachDebuggerFromProcess(null, rm); + + if (rm.getData()) { + IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(), + MIProcesses.UNKNOWN_PROCESS_ID); + fProcService.attachDebuggerToProcess(processContext, + new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor)); + return; + } } + requestMonitor.done(); } /** diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java index b3c471c04c4..136116a6ed5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java @@ -285,19 +285,13 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat // NOTE: when we support multi-process in all-stop mode, // we will need to interrupt the target to when doing the attach. int numConnected = getNumConnected(); - switch (sessionType) { - case REMOTE: - // In remote session already one process is connected - // Bug 528145 - return numConnected == 1; - case LOCAL: - return numConnected == 0; - - default: - break; + + if (numConnected == 1 && sessionType == SessionType.REMOTE) { + // Bug 528145: Special case for remote sessions with an existing connection. + return true; } - return false; + return numConnected == 0; } return true; @@ -333,38 +327,38 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat public void execute(final RequestMonitor rm) { // The remote session is already connected to the process // Bug 528145 - if (fBackend.getSessionType() == SessionType.REMOTE) { + if (fBackend.getSessionType() == SessionType.REMOTE + && doCanDetachDebuggerFromProcess()) { rm.done(); - } else { - getProcessesBeingDebugged(procCtx, - new ImmediateDataRequestMonitor<IDMContext[]>(rm) { - @Override - protected void handleSuccess() { - assert getData() != null; - - boolean found = false; - for (IDMContext dmc : getData()) { - IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, - IProcessDMContext.class); - if (procCtx.equals(procDmc)) { - found = true; - } - } - if (found) { - // abort the sequence - Status failedStatus = new Status(IStatus.ERROR, - GdbPlugin.PLUGIN_ID, REQUEST_FAILED, - MessageFormat.format( - Messages.Already_connected_process_err, - ((IMIProcessDMContext) procCtx).getProcId()), - null); - rm.done(failedStatus); - return; - } - super.handleSuccess(); - } - }); + return; } + + getProcessesBeingDebugged(procCtx, new ImmediateDataRequestMonitor<IDMContext[]>(rm) { + @Override + protected void handleSuccess() { + assert getData() != null; + + boolean found = false; + for (IDMContext dmc : getData()) { + IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc, + IProcessDMContext.class); + if (procCtx.equals(procDmc)) { + found = true; + } + } + if (found) { + // abort the sequence + Status failedStatus = new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, + REQUEST_FAILED, + MessageFormat.format(Messages.Already_connected_process_err, + ((IMIProcessDMContext) procCtx).getProcId()), + null); + rm.done(failedStatus); + return; + } + super.handleSuccess(); + } + }); } }, @@ -477,24 +471,25 @@ public class GDBProcesses_7_2 extends GDBProcesses_7_1 implements IMultiTerminat public void execute(RequestMonitor rm) { // This call end the current attach to the gdbserver in remote session // Bug 528145 - if (fBackend.getSessionType() == SessionType.REMOTE) { + if (fBackend.getSessionType() == SessionType.REMOTE + && doCanDetachDebuggerFromProcess()) { rm.done(); - } else { - // For non-stop mode, we do a non-interrupting attach - // Bug 333284 - boolean shouldInterrupt = true; - IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class); - if (runControl != null && runControl.getRunMode() == MIRunMode.NON_STOP) { - shouldInterrupt = false; - } + return; + } - boolean extraNewline = targetAttachRequiresTrailingNewline(); - ICommand<MIInfo> miTargetAttach = fCommandFactory.createMITargetAttach( - fContainerDmc, ((IMIProcessDMContext) procCtx).getProcId(), shouldInterrupt, - extraNewline); - fCommandControl.queueCommand(miTargetAttach, - new ImmediateDataRequestMonitor<MIInfo>(rm)); + // For non-stop mode, we do a non-interrupting attach + // Bug 333284 + boolean shouldInterrupt = true; + IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class); + if (runControl != null && runControl.getRunMode() == MIRunMode.NON_STOP) { + shouldInterrupt = false; } + + boolean extraNewline = targetAttachRequiresTrailingNewline(); + ICommand<MIInfo> miTargetAttach = fCommandFactory.createMITargetAttach(fContainerDmc, + ((IMIProcessDMContext) procCtx).getProcId(), shouldInterrupt, extraNewline); + fCommandControl.queueCommand(miTargetAttach, + new ImmediateDataRequestMonitor<MIInfo>(rm)); } }, diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java index 35ca013667b..a8b970c1e8c 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java @@ -73,18 +73,12 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple */ class InternalListener implements IViewportListener, ITextListener, ISelectionChangedListener { - /* - * @see IViewportListener#viewportChanged(int) - */ @Override public void viewportChanged(int verticalPosition) { if (verticalPosition != fScrollPos) redraw(); } - /* - * @see ITextListener#textChanged(TextEvent) - */ @Override public void textChanged(TextEvent event) { @@ -102,9 +96,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } - /* - * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) - */ @Override public void selectionChanged(SelectionChangedEvent event) { postRedraw(); @@ -125,9 +116,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple /** The auto scroll direction */ private int fAutoScrollDirection; - /* - * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseUp(MouseEvent event) { // see bug 45700 @@ -138,9 +126,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseDown(MouseEvent event) { fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y); @@ -150,9 +135,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseDoubleClick(MouseEvent event) { fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y); @@ -160,9 +142,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple stopAutoScroll(); } - /* - * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseMove(MouseEvent event) { if (!autoScroll(event)) { @@ -171,23 +150,14 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseEnter(MouseEvent event) { } - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseExit(MouseEvent event) { } - /* - * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) - */ @Override public void mouseHover(MouseEvent event) { } @@ -478,17 +448,11 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple return DsfUIPlugin.getDefault().getPreferenceStore(); } - /* - * @see IVerticalRulerColumn#getControl() - */ @Override public Control getControl() { return fCanvas; } - /* - * @see IVerticalRuleColumnr#getWidth - */ @Override public int getWidth() { return fIndentation[0]; @@ -587,9 +551,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite) - */ @Override public Control createControl(CompositeRuler parentRuler, Composite parentControl) { @@ -932,9 +893,8 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple int widgetBaseline = fCachedTextWidget.getBaseline(); FontMetrics fm = gc.getFontMetrics(); int fontBaseline = fm.getAscent() + fm.getLeading(); - Assert.isTrue(widgetBaseline >= fontBaseline); int baselineBias = widgetBaseline - fontBaseline; - return baselineBias; + return Math.max(0, baselineBias); } /** @@ -977,9 +937,6 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see IVerticalRulerColumn#redraw() - */ @Override public void redraw() { @@ -995,16 +952,10 @@ public class DisassemblyRulerColumn extends AbstractContributedRulerColumn imple } } - /* - * @see IVerticalRulerColumn#setModel(IAnnotationModel) - */ @Override public void setModel(IAnnotationModel model) { } - /* - * @see IVerticalRulerColumn#setFont(Font) - */ @Override public void setFont(Font font) { fFont = font; diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.properties b/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.properties index f3692d6e606..ec44029a1bf 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.properties +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.properties @@ -11,4 +11,5 @@ which is available at https://www.eclipse.org/legal/epl-2.0/\n\ \n\ SPDX-License-Identifier: EPL-2.0 extension-point.name = Tool Detection Participant -CompileCommandsJsonParserMarker.name = JSON compilation database
\ No newline at end of file +CompileCommandsJsonParserMarker.name = JSON compilation database +CompilerBuiltinsDetectorMarker.name=Compiler Builtins Detector Problem diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.xml b/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.xml index aa2999e656f..a2c279069f5 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.xml +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/plugin.xml @@ -2,7 +2,6 @@ <?eclipse version="3.4"?> <plugin> <extension-point id="detectionParticipant" name="%extension-point.name" schema="schema/participant.exsd"/> -"org.eclipse.cdt.jsoncdb.core.internal.ui.CompileCommandsJsonParserOptionPage"> <extension id="CompileCommandsJsonParserMarker" name="%CompileCommandsJsonParserMarker.name" @@ -14,4 +13,10 @@ type="org.eclipse.core.resources.problemmarker"> </super> </extension> + <extension + id="CompilerBuiltinsDetectorMarker" + name="%CompilerBuiltinsDetectorMarker.name" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.cdt.jsoncdb.core.CompileCommandsJsonParserMarker"/> + </extension> </plugin> diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/CompilerBuiltinsDetector.java b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/CompilerBuiltinsDetector.java index 818fcf36247..db4e691b050 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/CompilerBuiltinsDetector.java +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/CompilerBuiltinsDetector.java @@ -130,13 +130,30 @@ public class CompilerBuiltinsDetector { } } if (state != ICommandLauncher.COMMAND_CANCELED) { - // check exit status - final int exitValue = proc.exitValue(); - if (exitValue != 0 && !builtinsDetectionBehavior.suppressErrormessage()) { - // compiler had errors... - String errMsg = String.format(Messages.CompilerBuiltinsDetector_errmsg_command_failed, command, - exitValue); - createMarker(errMsg); + try { + // check exit status + final int exitValue = proc.exitValue(); + if (exitValue != 0 && !builtinsDetectionBehavior.suppressErrormessage()) { + // compiler had errors... + String errMsg = String.format(Messages.CompilerBuiltinsDetector_errmsg_command_failed, command, + exitValue); + createMarker(errMsg); + } + } catch (IllegalThreadStateException e) { + // Bug 580045 - reused launcher race condition + String warnMsg = String.format(Messages.CompilerBuiltinsDetector_msg_unexpectedly_still_running, + command); + + if (console != null) { + final ConsoleOutputStream cis = console.getInfoStream(); + try { + cis.write(warnMsg.getBytes()); + cis.write("\n".getBytes()); //$NON-NLS-1$ + } catch (IOException ignore) { + } + } + createMarker(warnMsg); + Plugin.getDefault().getLog().log(Status.warning(warnMsg, e)); } } } else { diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/Messages.java b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/Messages.java index 70770488a18..25b703e3ef2 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/Messages.java +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/Messages.java @@ -22,6 +22,7 @@ class Messages extends NLS { public static String CompilerBuiltinsDetector_errmsg_command_failed; public static String CompilerBuiltinsDetector_msg_detection_finished; public static String CompilerBuiltinsDetector_msg_detection_start; + public static String CompilerBuiltinsDetector_msg_unexpectedly_still_running; public static String DetectorConsole_title; static { // initialize resource bundle diff --git a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/messages.properties b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/messages.properties index 03b19c5f6cf..09a209b9b21 100644 --- a/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/messages.properties +++ b/jsoncdb/org.eclipse.cdt.jsoncdb.core/src/org/eclipse/cdt/jsoncdb/core/internal/builtins/messages.properties @@ -14,4 +14,5 @@ CompilerBuiltinsDetector_errmsg_command_failed=%1$s exited with status %2$d. CompilerBuiltinsDetector_msg_detection_finished=Detecting compiler built-ins took %d ms. CompilerBuiltinsDetector_msg_detection_start=%1$s Detecting compiler built-ins for project '%2$s' +CompilerBuiltinsDetector_msg_unexpectedly_still_running=%1$s is unexpectedly still running. Some built-ins might not have been captured by the compiler built-ins detector. DetectorConsole_title=Compiler Built-ins Detection Console diff --git a/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll b/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll Binary files differindex d33f6fdccd1..94b335c339a 100755 --- a/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll +++ b/native/org.eclipse.cdt.native.serial/os/win32/x86_64/serial.dll @@ -43,7 +43,7 @@ <!-- When changing this value, consider also bumping the version numbers of all the docs plug-ins (those with build-doc profile in pom.xml) so that compare&replace does not replace the the newly built docs because the only change is in the filtered out index/* resources. --> - <help-docs-eclipserun-repo>https://download.eclipse.org/eclipse/updates/4.24-I-builds/</help-docs-eclipserun-repo> + <help-docs-eclipserun-repo>https://download.eclipse.org/eclipse/updates/4.24/</help-docs-eclipserun-repo> <tycho.scmUrl>scm:git:https://git.eclipse.org/r/cdt/org.eclipse.cdt</tycho.scmUrl> <base.test.vmargs>-Xms256m -Xmx512m -ea</base.test.vmargs> diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java index 8e05b7aef14..189ed99053d 100644 --- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java +++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 QNX Software Systems and others. + * Copyright (c) 2015, 2022 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -379,9 +379,8 @@ public class QtBuildConfiguration extends CBuildConfiguration implements IQtBuil IFile projectFile = project.getFile(project.getName() + ".pro"); //$NON-NLS-1$ command.add(projectFile.getLocation().toOSString()); - ProcessBuilder processBuilder = new ProcessBuilder(command).directory(getBuildDirectory().toFile()); - setBuildEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); + startBuildProcess(command, new IEnvironmentVariable[0], + new org.eclipse.core.runtime.Path(buildDir.toString()), console, monitor); StringBuffer msg = new StringBuffer(); for (String arg : command) { @@ -391,7 +390,7 @@ public class QtBuildConfiguration extends CBuildConfiguration implements IQtBuil outStream.write(msg.toString()); // TODO qmake error parser - watchProcess(process, console); + watchProcess(console, monitor); doFullBuild = false; } @@ -401,11 +400,11 @@ public class QtBuildConfiguration extends CBuildConfiguration implements IQtBuil // run make List<String> command = new ArrayList<>(Arrays.asList(makeCommand)); command.add("all"); //$NON-NLS-1$ - ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); - setBuildEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); + + startBuildProcess(command, new IEnvironmentVariable[0], + new org.eclipse.core.runtime.Path(buildDir.toString()), console, monitor); outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ - watchProcess(process, new IConsoleParser[] { epm }); + watchProcess(new IConsoleParser[] { epm }, monitor); } getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor); @@ -438,11 +437,10 @@ public class QtBuildConfiguration extends CBuildConfiguration implements IQtBuil // run make List<String> command = new ArrayList<>(Arrays.asList(makeCommand)); command.add("clean"); //$NON-NLS-1$ - ProcessBuilder processBuilder = new ProcessBuilder(command).directory(buildDir.toFile()); - setBuildEnvironment(processBuilder.environment()); - Process process = processBuilder.start(); + startBuildProcess(command, new IEnvironmentVariable[0], + new org.eclipse.core.runtime.Path(buildDir.toString()), console, monitor); outStream.write(String.join(" ", command) + '\n'); //$NON-NLS-1$ - watchProcess(process, new IConsoleParser[] { epm }); + watchProcess(new IConsoleParser[] { epm }, monitor); } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); diff --git a/releng/org.eclipse.cdt.target/cdt.target b/releng/org.eclipse.cdt.target/cdt.target index 9d596bf12a0..f5a0b9e8874 100644 --- a/releng/org.eclipse.cdt.target/cdt.target +++ b/releng/org.eclipse.cdt.target/cdt.target @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde version="3.8"?> -<target name="cdt" sequenceNumber="117"> +<target name="cdt" sequenceNumber="122"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> <repository location="https://download.eclipse.org/cbi/updates/license/"/> <unit id="org.eclipse.license.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> - <repository location="https://download.eclipse.org/eclipse/updates/4.24-I-builds/I20220519-0130/"/> + <repository location="https://download.eclipse.org/eclipse/updates/4.24/R-4.24-202206070700/"/> <unit id="org.eclipse.equinox.executable.feature.group" version="0.0.0"/> <unit id="org.eclipse.jdt.annotation" version="0.0.0"/> <unit id="org.eclipse.sdk.feature.group" version="0.0.0"/> @@ -19,7 +19,7 @@ <unit id="org.eclipse.egit.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> - <repository location="https://download.eclipse.org/linuxtools/updates-docker-nightly/"/> + <repository location="https://download.eclipse.org/linuxtools/update-2022-06-docker-rc2"/> <unit id="org.eclipse.linuxtools.docker.feature.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> @@ -41,16 +41,16 @@ <unit id="org.eclipse.tm4e.feature.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> - <repository location="https://download.eclipse.org/tools/cdt/releases/10.6/cdt-10.6.0/"/> + <repository location="https://download.eclipse.org/tools/cdt/releases/10.7/cdt-10.7.0/"/> <!-- We explicitly have CDT in target platform so that developers can develop org.eclipse.cdt.core/ui without requiring all the projects from CDT in their workspace. --> <unit id="org.eclipse.cdt.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> - <repository location="https://download.eclipse.org/wildwebdeveloper/snapshots/"/> + <repository location="https://download.eclipse.org/wildwebdeveloper/releases/0.13.5/"/> <unit id="org.eclipse.wildwebdeveloper.embedder.node.feature.feature.group" version="0.0.0"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit"> - <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/S20220517184036/repository/"/> + <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20220531185310/repository/"/> <unit id="com.google.gson" version="0.0.0"/> <unit id="com.sun.xml.bind" version="2.3.3.v20201118-1818"/> <unit id="javax.activation" version="1.2.2.v20201119-1642"/> diff --git a/remote/org.eclipse.remote.ui/META-INF/MANIFEST.MF b/remote/org.eclipse.remote.ui/META-INF/MANIFEST.MF index 90a96dc7b43..6fca78aa060 100644 --- a/remote/org.eclipse.remote.ui/META-INF/MANIFEST.MF +++ b/remote/org.eclipse.remote.ui/META-INF/MANIFEST.MF @@ -48,4 +48,5 @@ Import-Package: org.eclipse.core.commands, org.eclipse.ui.navigator, org.eclipse.ui.plugin, org.eclipse.ui.progress, - org.osgi.framework + org.osgi.framework, + org.osgi.service.prefs |