Skip to content

Commit 4fc18a7

Browse files
authored
Merge pull request #9400 from microsoft/main
2 parents c3dd440 + 40821ed commit 4fc18a7

7 files changed

Lines changed: 340 additions & 172 deletions

File tree

Extension/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# C/C++ for Visual Studio Code Change Log
22

3+
## Version 1.10.4: June 3, 2022
4+
### Bug Fixes
5+
* Fix formatting issue with vcFormat when using multi-byte UTF-8 sequences. [#9297](https://github.com/microsoft/vscode-cpptools/issues/9297)
6+
* Add support for "user" level and "workspace" level debug configurations. [#9319](https://github.com/microsoft/vscode-cpptools/issues/9319)
7+
* Fix code analysis with g++ 12 system headers. [#9347](https://github.com/microsoft/vscode-cpptools/issues/9347)
8+
* Fix crash on macOS <= 10.14, due to missing symbol. [#9387](https://github.com/microsoft/vscode-cpptools/issues/9387)
9+
310
## Version 1.10.3: May 23, 2022
411
### New Feature
512
* Add code actions to apply clang-tidy fixes. [#8476](https://github.com/microsoft/vscode-cpptools/issues/8476)

Extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cpptools",
33
"displayName": "C/C++",
44
"description": "C/C++ IntelliSense, debugging, and code browsing.",
5-
"version": "1.10.3-main",
5+
"version": "1.10.4-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",

Extension/src/Debugger/configurationProvider.ts

Lines changed: 239 additions & 150 deletions
Large diffs are not rendered by default.

Extension/src/Debugger/configurations.ts

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,66 @@
55

66
import * as os from 'os';
77
import * as nls from 'vscode-nls';
8+
import * as vscode from 'vscode';
89
import { configPrefix } from '../LanguageServer/extension';
910

1011
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
1112
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
1213

14+
export function isDebugLaunchStr(str: string): boolean {
15+
return str.startsWith("(gdb) ") || str.startsWith("(lldb) ") || str.startsWith("(Windows) ");
16+
}
17+
18+
export interface ConfigMenu extends vscode.QuickPickItem {
19+
configuration: CppDebugConfiguration;
20+
}
21+
1322
export enum DebuggerType {
1423
cppvsdbg = "cppvsdbg",
1524
cppdbg = "cppdbg",
1625
all = "all"
1726
}
1827

1928
export enum DebuggerEvent {
20-
debugPanel = "debugPanel",
21-
launchPlayButton = "launchPlayButton"
29+
debugPanel = "debugPanel", // F5 or "Run and Debug" Panel
30+
playButton = "playButton", // "Run and Debug" play button
31+
addConfigGear = "AddConfigGear"
32+
}
33+
34+
export enum TaskStatus {
35+
recentlyUsed = "Recently Used Task", // A configured task that has been used recently.
36+
37+
configured = "Configured Task", // The tasks that are configured in tasks.json file.
38+
detected = "Detected Task" // The tasks that are available based on detected compilers.
39+
}
40+
41+
export enum ConfigSource {
42+
singleFile = "singleFile", // a debug config defined for a single mode file
43+
workspaceFolder = "workspaceFolder", // a debug config defined in launch.json
44+
workspace = "workspace", // a debug config defined in workspace level
45+
global = "global", // a debug config defined in user level
46+
unknown = "unknown"
47+
}
48+
49+
export enum ConfigMode {
50+
launchConfig = "launchConfig",
51+
noLaunchConfig = "noLaunchConfig",
52+
unknown = "unknown"
53+
}
54+
55+
export enum DebugType {
56+
debug = "debug",
57+
run = "run"
58+
}
59+
60+
export interface CppDebugConfiguration extends vscode.DebugConfiguration {
61+
detail?: string;
62+
taskStatus?: TaskStatus;
63+
isDefault?: boolean; // The debug configuration is considered as default, if the prelaunch task is set as default.
64+
configSource?: ConfigSource;
65+
debuggerEvent?: DebuggerEvent;
66+
debugType?: DebugType;
67+
existing?: boolean;
2268
}
2369

2470
export interface IConfigurationSnippet {

Extension/src/LanguageServer/cppBuildTaskProvider.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,32 @@ export class CppBuildTaskProvider implements TaskProvider {
226226
return buildTasksJson.filter((task: CppBuildTask) => task !== null);
227227
}
228228

229-
public async writeDefaultBuildTask(taskLabel: string): Promise<void> {
230-
return this.writeBuildTask(taskLabel, true);
229+
public async writeDefaultBuildTask(taskLabel: string, workspaceFolder?: WorkspaceFolder): Promise<void> {
230+
return this.writeBuildTask(taskLabel, workspaceFolder, true);
231231
}
232232

233-
public async writeBuildTask(taskLabel: string, setAsDefault: boolean = false): Promise<void> {
234-
const rawTasksJson: any = await this.getRawTasksJson();
233+
public async isExistingTask(taskLabel: string, workspaceFolder?: WorkspaceFolder): Promise<boolean> {
234+
const rawTasksJson: any = await this.getRawTasksJson(workspaceFolder);
235+
if (!rawTasksJson.tasks) {
236+
return false;
237+
}
238+
// Check if the task exists in the user's task.json.
239+
return rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
240+
}
241+
242+
public async writeBuildTask(taskLabel: string, workspaceFolder?: WorkspaceFolder, setAsDefault: boolean = false): Promise<void> {
243+
const rawTasksJson: any = await this.getRawTasksJson(workspaceFolder);
235244
if (!rawTasksJson.tasks) {
236245
rawTasksJson.tasks = new Array();
237246
}
238247
// Check if the task exists in the user's task.json.
239-
let selectedTask: any;
240-
selectedTask = rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel);
241-
if (selectedTask) {
248+
if (rawTasksJson.tasks.find((task: any) => task.label && task.label === taskLabel)) {
242249
return;
243250
}
244251

245252
// Create the task which should be created based on the selected "debug configuration".
246253
const buildTasks: CppBuildTask[] = await this.getTasks(true);
247-
const normalizedLabel: string = (taskLabel.indexOf("ver(") !== -1) ? taskLabel.slice(0, taskLabel.indexOf("ver(")).trim() : taskLabel;
248-
selectedTask = buildTasks.find(task => task.name === normalizedLabel);
254+
const selectedTask: any = buildTasks.find(task => task.name === taskLabel);
249255
console.assert(selectedTask);
250256
if (!selectedTask) {
251257
throw new Error("Failed to get selectedTask in checkBuildTaskExists()");
@@ -313,12 +319,12 @@ export class CppBuildTaskProvider implements TaskProvider {
313319
}
314320
}
315321

316-
private getTasksJsonPath(): string | undefined {
317-
return util.getJsonPath("tasks.json");
322+
private getTasksJsonPath(workspaceFolder?: WorkspaceFolder): string | undefined {
323+
return util.getJsonPath("tasks.json", workspaceFolder);
318324
}
319325

320-
public getRawTasksJson(): Promise<any> {
321-
const path: string | undefined = this.getTasksJsonPath();
326+
public getRawTasksJson(workspaceFolder?: WorkspaceFolder): Promise<any> {
327+
const path: string | undefined = this.getTasksJsonPath(workspaceFolder);
322328
return util.getRawJson(path);
323329
}
324330

Extension/src/LanguageServer/extension.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,19 +905,32 @@ function handleMacCrashFileRead(err: NodeJS.ErrnoException | undefined | null, d
905905
binaryVersion = binaryVersionMatches && binaryVersionMatches.length > 1 ? binaryVersionMatches[1] : "";
906906
}
907907

908+
// Extract any message indicating missing dynamically loaded symbols.
909+
let dynamicLoadError: string = "";
910+
const dynamicLoadErrorStart: string = "Dyld Error Message:";
911+
const startDynamicLoadError: number = data.indexOf(dynamicLoadErrorStart);
912+
if (startDynamicLoadError >= 0) {
913+
// Scan until the next blank line.
914+
const dynamicLoadErrorEnd: string = "\n\n";
915+
const endDynamicLoadError: number = data.indexOf(dynamicLoadErrorEnd, startDynamicLoadError);
916+
if (endDynamicLoadError >= 0) {
917+
dynamicLoadError = data.substring(startDynamicLoadError, endDynamicLoadError) + "\n\n";
918+
}
919+
}
920+
908921
// Extract the crashing thread's call stack.
909922
const crashStart: string = " Crashed:";
910923
let startCrash: number = data.indexOf(crashStart);
911924
if (startCrash < 0) {
912-
return logMacCrashTelemetry("No crash start");
925+
return logMacCrashTelemetry(dynamicLoadError + "No crash start");
913926
}
914927
startCrash += crashStart.length + 1; // Skip past crashStart.
915928
let endCrash: number = data.indexOf("Thread ", startCrash);
916929
if (endCrash < 0) {
917930
endCrash = data.length - 1; // Not expected, but just in case.
918931
}
919932
if (endCrash <= startCrash) {
920-
return logMacCrashTelemetry("No crash end");
933+
return logMacCrashTelemetry(dynamicLoadError + "No crash end");
921934
}
922935
data = data.substring(startCrash, endCrash);
923936

@@ -926,7 +939,10 @@ function handleMacCrashFileRead(err: NodeJS.ErrnoException | undefined | null, d
926939
data = data.replace(/0x1........ \+ 0/g, "");
927940

928941
// Get rid of the process names on each line and just add it to the start.
929-
const processNames: string[] = ["cpptools-srv", "cpptools-wordexp", "cpptools" ];
942+
const processNames: string[] = ["cpptools-srv", "cpptools-wordexp", "cpptools",
943+
// Since only crash logs that start with "cpptools" are reported, the cases below would only occur
944+
// if the crash were to happen before the new process had fully started and renamed itself.
945+
"clang-tidy", "clang-format", "clang", "gcc" ];
930946
let processNameFound: boolean = false;
931947
for (const processName of processNames) {
932948
if (data.includes(processName)) {
@@ -938,7 +954,8 @@ function handleMacCrashFileRead(err: NodeJS.ErrnoException | undefined | null, d
938954
}
939955
if (!processNameFound) {
940956
// Not expected, but just in case a new binary gets added.
941-
data = `cpptools???\t${binaryVersion}\n${data}`;
957+
// Warning: Don't use ??? because that is checked below.
958+
data = `cpptools??\t${binaryVersion}\n${data}`;
942959
}
943960

944961
// Remove runtime lines because they can be different on different machines.
@@ -953,6 +970,9 @@ function handleMacCrashFileRead(err: NodeJS.ErrnoException | undefined | null, d
953970
});
954971
data = data.trimRight();
955972

973+
// Prepend the dynamic load error.
974+
data = dynamicLoadError + data;
975+
956976
if (data.length > 8192) { // The API has an 8k limit.
957977
data = data.substring(0, 8189) + "...";
958978
}

Extension/src/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ export function getPackageJsonPath(): string {
109109
return getExtensionFilePath("package.json");
110110
}
111111

112-
export function getJsonPath(jsonFilaName: string): string | undefined {
112+
export function getJsonPath(jsonFilaName: string, workspaceFolder?: vscode.WorkspaceFolder): string | undefined {
113113
const editor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
114114
if (!editor) {
115115
return undefined;
116116
}
117-
const folder: vscode.WorkspaceFolder | undefined = vscode.workspace.getWorkspaceFolder(editor.document.uri);
117+
const folder: vscode.WorkspaceFolder | undefined = workspaceFolder ? workspaceFolder : vscode.workspace.getWorkspaceFolder(editor.document.uri);
118118
if (!folder) {
119119
return undefined;
120120
}

0 commit comments

Comments
 (0)