Skip to content

Commit b730c49

Browse files
authored
Merge branch 'main' into feature/add-cpp-name-demangling
2 parents 0e914ee + 7bbf261 commit b730c49

13 files changed

Lines changed: 215 additions & 78 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
## 1.21
44

5+
Features:
6+
7+
- Add an option to specify the launch target for debugging CTest tests. [#4273](https://github.com/microsoft/vscode-cmake-tools/pull/4273)
8+
59
Improvements:
610

711
- Add name de-mangling for C++ symbols in the Test Explorer view when running tests with coverage. [#4340](https://github.com/microsoft/vscode-cmake-tools/pull/4340) [@rjaegers](https://github.com/rjaegers)
12+
- No longer convert paths on lowercase on MacOS to enable cpp tools to resolve them. [#4325](https://github.com/microsoft/vscode-cmake-tools/pull/4325) [@tringenbach](https://github.com/tringenbach)
13+
14+
Bug Fixes:
15+
16+
- Fix bug that makes `Configure Task` lists only first folder in workspace. [#3232](https//github.com/microsoft/vscode-cmake-tools/issues/3232)
17+
- Fix displaying "Go to Test" in the Test Explorer when the DEF_SOURCE_LINE property is set, but there is no backtrace information present. [#4321](https://github.com/microsoft/vscode-cmake-tools/pull/4321) [@rjaegers](https://github.com/rjaegers)
18+
- Fix gnuld error parsing false positive on make errors, false negative due to trailing \r, and false parsing of new "multiple definitions" error [#2864](https://github.com/microsoft/vscode-cmake-tools/issues/2864) [@0xemgy](https://github.com/0xemgy)
819

920
## 1.20.53
1021

docs/debug-launch.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ A couple of examples:
227227

228228
Depending on your configuration or your settings, there may need to be additional configuration options set.
229229

230+
To use a specific launch configuration when debugging tests, set `cmake.ctest.debugLaunchTarget` to the desired name of the configuration (e.g. `(ctest) Launch`).
231+
230232
## Run without debugging
231233

232234
You can run a target without debugging it, by running the *CMake: Run Without Debugging* from VS Code's command palette, by selecting the play button in the status bar or the play button to the left of the Launch node, or by pressing the keyboard shortcut (**Shift+Ctrl+F5**).

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,12 @@
22552255
"markdownDescription": "%cmake-tools.configuration.cmake.ctest.testSuiteDelimiter.markdownDescription%",
22562256
"scope": "machine-overridable"
22572257
},
2258+
"cmake.ctest.debugLaunchTarget": {
2259+
"type": "string",
2260+
"default": null,
2261+
"description": "%cmake-tools.configuration.cmake.ctest.debugLaunchTarget.description%",
2262+
"scope": "resource"
2263+
},
22582264
"cmake.parseBuildDiagnostics": {
22592265
"type": "boolean",
22602266
"default": true,

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
"Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered."
113113
]
114114
},
115+
"cmake-tools.configuration.cmake.ctest.debugLaunchTarget.description": "Target name from launch.json to start when debugging a test with CTest. By default and in case of a non-existing target, this will show a picker with all available targets.",
115116
"cmake-tools.configuration.cmake.parseBuildDiagnostics.description": "Parse compiler output for warnings and errors.",
116117
"cmake-tools.configuration.cmake.enabledOutputParsers.description": {
117118
"message": "Output parsers to use. Supported parsers `cmake`, `gcc`, `gnuld` for GNULD-style linker output, `msvc` for Microsoft Visual C++, `ghs` for the Green Hills compiler with --no_wrap_diagnostics --brief_diagnostics, and `diab` for the Wind River Diab compiler.",

src/cmakeTaskProvider.ts

Lines changed: 107 additions & 49 deletions
Large diffs are not rendered by default.

src/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export interface ExtensionConfigurationSettings {
173173
buildToolArgs: string[];
174174
parallelJobs: number;
175175
ctestPath: string;
176-
ctest: { parallelJobs: number; allowParallelJobs: boolean; testExplorerIntegrationEnabled: boolean; testSuiteDelimiter: string };
176+
ctest: { parallelJobs: number; allowParallelJobs: boolean; testExplorerIntegrationEnabled: boolean; testSuiteDelimiter: string; debugLaunchTarget: string | null };
177177
parseBuildDiagnostics: boolean;
178178
enabledOutputParsers: string[];
179179
debugConfig: CppDebugConfiguration;
@@ -387,6 +387,9 @@ export class ConfigurationReader implements vscode.Disposable {
387387
get testSuiteDelimiter(): string {
388388
return this.configData.ctest.testSuiteDelimiter;
389389
}
390+
get ctestDebugLaunchTarget(): string | null {
391+
return this.configData.ctest.debugLaunchTarget;
392+
}
390393
get parseBuildDiagnostics(): boolean {
391394
return !!this.configData.parseBuildDiagnostics;
392395
}
@@ -602,7 +605,7 @@ export class ConfigurationReader implements vscode.Disposable {
602605
parallelJobs: new vscode.EventEmitter<number>(),
603606
ctestPath: new vscode.EventEmitter<string>(),
604607
cpackPath: new vscode.EventEmitter<string>(),
605-
ctest: new vscode.EventEmitter<{ parallelJobs: number; allowParallelJobs: boolean; testExplorerIntegrationEnabled: boolean; testSuiteDelimiter: string }>(),
608+
ctest: new vscode.EventEmitter<{ parallelJobs: number; allowParallelJobs: boolean; testExplorerIntegrationEnabled: boolean; testSuiteDelimiter: string; debugLaunchTarget: string | null }>(),
606609
parseBuildDiagnostics: new vscode.EventEmitter<boolean>(),
607610
enabledOutputParsers: new vscode.EventEmitter<string[]>(),
608611
debugConfig: new vscode.EventEmitter<CppDebugConfiguration>(),

src/ctest.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -799,29 +799,27 @@ export class CTestDriver implements vscode.Disposable {
799799
let testDefFile: string | undefined;
800800
let testDefLine: number | undefined;
801801

802-
if (test.backtrace !== undefined && this.tests!.backtraceGraph.nodes[test.backtrace] !== undefined) {
803-
// Use DEF_SOURCE_LINE CMake test property to find file and line number
804-
// Property must be set in the test's CMakeLists.txt file or its included modules for this to work
805-
const defSourceLineProperty = test.properties.filter(property => property.name === "DEF_SOURCE_LINE")[0];
806-
if (defSourceLineProperty && defSourceLineProperty.value && typeof defSourceLineProperty.value === 'string') {
807-
// Use RegEx to match the format "file_path:line" in value[0]
808-
const match = defSourceLineProperty.value.match(/(.*):(\d+)/);
809-
if (match && match[1] && match[2]) {
810-
testDefFile = match[1];
811-
testDefLine = parseInt(match[2]);
812-
if (isNaN(testDefLine)) {
813-
testDefLine = undefined;
814-
testDefFile = undefined;
815-
}
802+
// Use DEF_SOURCE_LINE CMake test property to find file and line number
803+
// Property must be set in the test's CMakeLists.txt file or its included modules for this to work
804+
const defSourceLineProperty = test.properties.filter(property => property.name === "DEF_SOURCE_LINE")[0];
805+
if (defSourceLineProperty && defSourceLineProperty.value && typeof defSourceLineProperty.value === 'string') {
806+
// Use RegEx to match the format "file_path:line" in value[0]
807+
const match = defSourceLineProperty.value.match(/(.*):(\d+)/);
808+
if (match && match[1] && match[2]) {
809+
testDefFile = match[1];
810+
testDefLine = parseInt(match[2]);
811+
if (isNaN(testDefLine)) {
812+
testDefLine = undefined;
813+
testDefFile = undefined;
816814
}
817815
}
816+
}
818817

819-
if (!testDefFile) {
820-
// Use the backtrace graph to find the file and line number
821-
// This finds the CMake module's file and line number and not the test file and line number
822-
testDefFile = this.tests!.backtraceGraph.files[this.tests!.backtraceGraph.nodes[test.backtrace].file];
823-
testDefLine = this.tests!.backtraceGraph.nodes[test.backtrace].line;
824-
}
818+
if (!testDefFile && test.backtrace !== undefined && this.tests!.backtraceGraph.nodes[test.backtrace] !== undefined) {
819+
// Use the backtrace graph to find the file and line number
820+
// This finds the CMake module's file and line number and not the test file and line number
821+
testDefFile = this.tests!.backtraceGraph.files[this.tests!.backtraceGraph.nodes[test.backtrace].file];
822+
testDefLine = this.tests!.backtraceGraph.nodes[test.backtrace].line;
825823
}
826824

827825
const testAndParentSuite = this.createTestItemAndSuiteTree(test.name, testExplorerRoot, initializedTestExplorer, testDefFile ? vscode.Uri.file(testDefFile) : undefined);
@@ -1074,7 +1072,12 @@ export class CTestDriver implements vscode.Disposable {
10741072
let chosenConfig: ConfigItem | undefined;
10751073
if (allConfigItems.length === 1) {
10761074
chosenConfig = allConfigItems[0];
1077-
} else {
1075+
}
1076+
if (!chosenConfig && this.ws.config.ctestDebugLaunchTarget) {
1077+
chosenConfig = allConfigItems.find(x => x.label === this.ws.config.ctestDebugLaunchTarget);
1078+
}
1079+
1080+
if (!chosenConfig) {
10781081
// TODO: we can remember the last choice once the CMake side panel work is done
10791082
const chosen = await vscode.window.showQuickPick(allConfigItems, { placeHolder: localize('choose.launch.config', 'Choose a launch configuration to debug the test with.') });
10801083
if (chosen) {

src/diagnostics/gnu-ld.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const regexPatterns: RegexPattern[] = [
1212
regexPattern: /^(?:.*ld(?:\.exe)?:)(?:\s*)?(.+):(\d+):\s+(?:fatal )?(\w+):\s+(.+)/,
1313
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Severity, MatchType.Message]
1414
},
15+
{ // path/to/ld[.exe]:[ ]path/to/file.obj:path/to/file:line: message
16+
regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)(?:.+?\.obj:)(.+?):(\d+):\s+(.+)/,
17+
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
18+
},
1519
{ // path/to/ld[.exe]:[ ]path/to/file:line: message
1620
regexPattern: /^(?:.*ld(?:\.exe)?\:)(?:\s*)?(.+):(\d+):\s+(.+)/,
1721
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
@@ -21,11 +25,11 @@ const regexPatterns: RegexPattern[] = [
2125
matchTypes: [MatchType.Full, MatchType.File, MatchType.Severity, MatchType.Message]
2226
},
2327
{ // path/to/ld[.exe]: message (without trailing colon)
24-
regexPattern: /^(.*ld(?:\.exe)?):\s+(.+)(?<!:)$/,
28+
regexPattern: /^(.*ld(?:\.exe)?):\s+(.+)(?<!:)\s*$/,
2529
matchTypes: [MatchType.Full, MatchType.File, MatchType.Message]
2630
},
27-
{ // /path/to/file:line: message (without "[fatal] severity:" or trailing colon)
28-
regexPattern: /^(.+?):(\d+):\s+(?!fatal\s+\w+:)(?!\w+:)(.+)(?<!:)$/,
31+
{ // path/to/file:line: message (with neither "[fatal] severity:" nor trailing colon nor leading "make: *** [" nor leading "make[line]: *** [")
32+
regexPattern: /^(?!\s*make.*:\s\*\*\*\s\[)(.+?):(\d+):\s+(?!fatal\s+\w+:)(?!\w+:)(.+)(?<!:)\s*$/,
2933
matchTypes: [MatchType.Full, MatchType.File, MatchType.Line, MatchType.Message]
3034
}
3135
];

src/drivers/cmakeDriver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
20022002
}
20032003
const useBuildTask: boolean = this.config.buildTask && isBuildCommand === true;
20042004
if (useBuildTask) {
2005-
const task: CMakeTask | undefined = await CMakeTaskProvider.findBuildTask(this._buildPreset?.name, targets, this.expansionOptions);
2005+
const task: CMakeTask | undefined = await CMakeTaskProvider.findBuildTask(this.workspaceFolder, this._buildPreset?.name, targets, this.expansionOptions);
20062006
if (task) {
20072007
const resolvedTask: CMakeTask | undefined = await CMakeTaskProvider.resolveInternalTask(task);
20082008
if (resolvedTask) {

src/extension.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,25 @@ export class ExtensionManager implements vscode.Disposable {
18301830
return projects.some(project => project.hasCMakeLists());
18311831
}
18321832

1833+
/**
1834+
* Get all CMake projects in the workspace
1835+
*
1836+
* @returns All CMake projects in the workspace
1837+
*/
1838+
getAllCMakeProjects(): CMakeProject[] {
1839+
return this.projectController.getAllCMakeProjects();
1840+
}
1841+
1842+
/**
1843+
* Get the CMake project for the given folder
1844+
*
1845+
* @param folder The folder to get the project for
1846+
* @returns The CMake project for the folder
1847+
*/
1848+
async getProjectForFolder(folder: vscode.WorkspaceFolder): Promise<CMakeProject | undefined> {
1849+
return this.projectController.getProjectForFolder(folder.uri.path);
1850+
}
1851+
18331852
activeConfigurePresetName(): string {
18341853
telemetry.logEvent("substitution", { command: "activeConfigurePresetName" });
18351854
return this.getActiveProject()?.configurePreset?.name || '';

0 commit comments

Comments
 (0)