Skip to content

Commit 1ceae9d

Browse files
authored
Merge pull request #12266 from microsoft/seanmcm/1_20_3_cherryPicks
Cherry-picks for 1.20.3
2 parents efdc8e9 + d4d5d45 commit 1ceae9d

File tree

4 files changed

+53
-17
lines changed

4 files changed

+53
-17
lines changed

Extension/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# C/C++ for Visual Studio Code Changelog
22

3+
## Version 1.20.3: April 30, 2024
4+
### Enhancement
5+
* Log `cpptools` and `cpptool-srv` crash call stacks in the 'C/C++ Crash Call Stacks' Output channel for bug reporting (on x64 Linux and x64/arm64 Mac).
6+
7+
### Bug Fixes
8+
* Fix directories being incorrectly recursively traversed in certain cases. [#11993](https://github.com/microsoft/vscode-cpptools/issues/11993)
9+
* Fix a crash during startup. [#12237](https://github.com/microsoft/vscode-cpptools/issues/12237)
10+
* Fix IntelliSense configuration on Windows ARM64. [#12253](https://github.com/microsoft/vscode-cpptools/issues/12253)
11+
312
## Version 1.20.2: April 22, 2024
413
### Bug Fixes
514
* Fix non-existent relative path variables not showing a warning in `c_cpp_properties.json` (and other related issues). [#12089](https://github.com/microsoft/vscode-cpptools/issues/12089)
@@ -25,6 +34,7 @@
2534
### Bug Fixes
2635
* Fix an IntelliSense parsing issue. [#6183](https://github.com/microsoft/vscode-cpptools/issues/6183)
2736
* Fix 'Copy Declaration / Definition' code not being formatted. [#10956](https://github.com/microsoft/vscode-cpptools/issues/10956)
37+
* Fix semantic colorization of certain macro arguments. [#11416](https://github.com/microsoft/vscode-cpptools/issues/11416)
2838
* Fix 'Create Declaration / Definition' not working if the cursor isn't on the function name. [#11834](https://github.com/microsoft/vscode-cpptools/issues/11834)
2939
* Fix duplicate 'Add #include' code actions. [#11989](https://github.com/microsoft/vscode-cpptools/issues/11989)
3040
* Fix `forcedInclude` resolution for relative paths. [PR #12035](https://github.com/microsoft/vscode-cpptools/pull/12035)

Extension/package.json

+1-1
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.20.2-main",
5+
"version": "1.20.3-main",
66
"publisher": "ms-vscode",
77
"icon": "LanguageCCPP_color_128x.png",
88
"readme": "README.md",

Extension/src/LanguageServer/extension.ts

+31-16
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { TargetPopulation } from 'vscode-tas-client';
1717
import * as which from 'which';
1818
import { logAndReturn } from '../Utility/Async/returns';
1919
import * as util from '../common';
20+
import { getCrashCallStacksChannel } from '../logger';
2021
import { PlatformInformation } from '../platform';
2122
import * as telemetry from '../telemetry';
2223
import { Client, DefaultClient, DoxygenCodeActionCommandArguments, openFileVersions } from './client';
@@ -38,6 +39,7 @@ export const configPrefix: string = "C/C++: ";
3839

3940
let prevMacCrashFile: string;
4041
let prevCppCrashFile: string;
42+
let prevCppCrashCallStackData: string = "";
4143
export let clients: ClientCollection;
4244
let activeDocument: vscode.TextDocument | undefined;
4345
let ui: LanguageStatusUI;
@@ -988,10 +990,12 @@ export function watchForCrashes(crashDirectory: string): void {
988990
if (!filename.startsWith("cpptools")) {
989991
return;
990992
}
993+
const crashDate: Date = new Date();
994+
991995
// Wait 5 seconds to allow time for the crash log to finish being written.
992996
setTimeout(() => {
993997
fs.readFile(path.resolve(crashDirectory, filename), 'utf8', (err, data) => {
994-
void handleCrashFileRead(crashDirectory, filename, err, data);
998+
void handleCrashFileRead(crashDirectory, filename, crashDate, err, data);
995999
});
9961000
}, 5000);
9971001
});
@@ -1116,7 +1120,7 @@ function handleMacCrashFileRead(err: NodeJS.ErrnoException | undefined | null, d
11161120
logMacCrashTelemetry(data);
11171121
}
11181122

1119-
async function handleCrashFileRead(crashDirectory: string, crashFile: string, err: NodeJS.ErrnoException | undefined | null, data: string): Promise<void> {
1123+
async function handleCrashFileRead(crashDirectory: string, crashFile: string, crashDate: Date, err: NodeJS.ErrnoException | undefined | null, data: string): Promise<void> {
11201124
if (err) {
11211125
if (err.code === "ENOENT") {
11221126
return; // ignore known issue
@@ -1126,23 +1130,23 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, er
11261130

11271131
const lines: string[] = data.split("\n");
11281132
let addressData: string = ".\n.";
1129-
data = (crashFile.startsWith("cpptools-srv") ? "cpptools-srv.txt" : crashFile) + "\n";
1133+
const isCppToolsSrv: boolean = crashFile.startsWith("cpptools-srv");
1134+
const telemetryHeader: string = (isCppToolsSrv ? "cpptools-srv.txt" : crashFile) + "\n";
11301135
const filtPath: string | null = which.sync("c++filt", { nothrow: true });
11311136
const isMac: boolean = process.platform === "darwin";
11321137
const startStr: string = isMac ? " _" : "<";
11331138
const offsetStr: string = isMac ? " + " : "+";
11341139
const endOffsetStr: string = isMac ? " " : " <";
11351140
const dotStr: string = "…";
1136-
data += lines[0]; // signal type
1141+
const signalType: string = lines[0];
1142+
let crashCallStack: string = "";
11371143
for (let lineNum: number = 2; lineNum < lines.length - 3; ++lineNum) { // skip first/last lines
1138-
if (lineNum > 1) {
1139-
data += "\n";
1140-
addressData += "\n";
1141-
}
1144+
crashCallStack += "\n";
1145+
addressData += "\n";
11421146
const line: string = lines[lineNum];
11431147
const startPos: number = line.indexOf(startStr);
11441148
if (startPos === -1 || line[startPos + (isMac ? 1 : 4)] === "+") {
1145-
data += dotStr;
1149+
crashCallStack += dotStr;
11461150
const startAddressPos: number = line.indexOf("0x");
11471151
const endAddressPos: number = line.indexOf(endOffsetStr, startAddressPos + 2);
11481152
if (startAddressPos === -1 || endAddressPos === -1 || startAddressPos >= endAddressPos) {
@@ -1154,7 +1158,7 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, er
11541158
}
11551159
const offsetPos: number = line.indexOf(offsetStr, startPos + startStr.length);
11561160
if (offsetPos === -1) {
1157-
data += "Missing offsetStr";
1161+
crashCallStack += "Missing offsetStr";
11581162
continue; // unexpected
11591163
}
11601164
const startPos2: number = startPos + 1;
@@ -1174,32 +1178,43 @@ async function handleCrashFileRead(crashDirectory: string, crashFile: string, er
11741178
funcStr = funcStr.replace(/, std::allocator<std::string>/g, "");
11751179
}
11761180
}
1177-
data += funcStr + offsetStr;
1181+
crashCallStack += funcStr + offsetStr;
11781182
const offsetPos2: number = offsetPos + offsetStr.length;
11791183
if (isMac) {
1180-
data += line.substring(offsetPos2);
1184+
crashCallStack += line.substring(offsetPos2);
11811185
const startAddressPos: number = line.indexOf("0x");
11821186
if (startAddressPos === -1 || startAddressPos >= startPos) {
11831187
// unexpected
1184-
data += "<Missing 0x>";
1188+
crashCallStack += "<Missing 0x>";
11851189
continue;
11861190
}
11871191
addressData += `${line.substring(startAddressPos, startPos)}`;
11881192
} else {
11891193
const endPos: number = line.indexOf(">", offsetPos2);
11901194
if (endPos === -1) {
1191-
data += "<Missing > >";
1195+
crashCallStack += "<Missing > >";
11921196
continue; // unexpected
11931197
}
1194-
data += line.substring(offsetPos2, endPos);
1198+
crashCallStack += line.substring(offsetPos2, endPos);
11951199
}
11961200
}
11971201

1202+
if (crashCallStack !== prevCppCrashCallStackData) {
1203+
prevCppCrashCallStackData = crashCallStack;
1204+
1205+
const settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", null);
1206+
if (lines.length >= 6 && util.getNumericLoggingLevel(settings.get<string>("loggingLevel")) >= 1) {
1207+
const out: vscode.OutputChannel = getCrashCallStacksChannel();
1208+
out.appendLine(`\n${isCppToolsSrv ? "cpptools-srv" : "cpptools"}\n${crashDate.toLocaleString()}\n${signalType}${crashCallStack}`);
1209+
}
1210+
}
1211+
1212+
data = telemetryHeader + signalType + crashCallStack;
1213+
11981214
if (data.length > 8192) { // The API has an 8k limit.
11991215
data = data.substring(0, 8191) + "…";
12001216
}
12011217

1202-
console.log(`Crash call stack:\n${data}`);
12031218
logCppCrashTelemetry(data, addressData);
12041219

12051220
await util.deleteFile(path.resolve(crashDirectory, crashFile)).catch(logAndReturn.undefined);

Extension/src/logger.ts

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class Logger {
7474

7575
export let outputChannel: vscode.OutputChannel | undefined;
7676
export let diagnosticsChannel: vscode.OutputChannel | undefined;
77+
export let crashCallStacksChannel: vscode.OutputChannel | undefined;
7778
export let debugChannel: vscode.OutputChannel | undefined;
7879
export let warningChannel: vscode.OutputChannel | undefined;
7980
export let sshChannel: vscode.OutputChannel | undefined;
@@ -98,6 +99,16 @@ export function getDiagnosticsChannel(): vscode.OutputChannel {
9899
return diagnosticsChannel;
99100
}
100101

102+
export function getCrashCallStacksChannel(): vscode.OutputChannel {
103+
if (!crashCallStacksChannel) {
104+
crashCallStacksChannel = vscode.window.createOutputChannel(localize("c.cpp.crash.call.stacks.title", "C/C++ Crash Call Stacks"));
105+
crashCallStacksChannel.appendLine(localize({ key: "c.cpp.crash.call.stacks.description", comment: ["{0} is a URL."] },
106+
"A C/C++ extension process has crashed. The crashing process name, date/time, signal, and call stack are below -- it would be helpful to include that in a bug report at {0}.",
107+
"https://github.com/Microsoft/vscode-cpptools/issues"));
108+
}
109+
return crashCallStacksChannel;
110+
}
111+
101112
export function getSshChannel(): vscode.OutputChannel {
102113
if (!sshChannel) {
103114
sshChannel = vscode.window.createOutputChannel(localize("c.cpp.ssh.channel", "{0}: SSH", "Cpptools"));

0 commit comments

Comments
 (0)