Skip to content

Commit fb2e221

Browse files
authored
Merge pull request #6438 from dibarbet/crash_dumps
Add support for collecting dumps on crash
2 parents c513822 + 4517f8e commit fb2e221

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,12 @@
11691169
"default": null,
11701170
"description": "%configuration.dotnet.server.extensionPaths%"
11711171
},
1172+
"dotnet.server.crashDumpPath": {
1173+
"scope": "machine-overridable",
1174+
"type": "string",
1175+
"default": null,
1176+
"description": "%configuration.dotnet.server.crashDumpPath%"
1177+
},
11721178
"dotnet.projects.binaryLogPath": {
11731179
"scope": "machine-overridable",
11741180
"type": "string",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"configuration.dotnet.server.waitForDebugger": "Passes the --debug flag when launching the server to allow a debugger to be attached. (Previously `omnisharp.waitForDebugger`)",
77
"configuration.dotnet.server.trace": "Sets the logging level for the language server",
88
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
9+
"configuration.dotnet.server.crashDumpPath": "Sets a folder path where crash dumps are written to if the language server crashes. Must be writeable by the user.",
910
"configuration.dotnet.preferCSharpExtension": "Forces projects to load with the C# extension only. This can be useful when using legacy project types that are not supported by C# Dev Kit. (Requires window reload)",
1011
"configuration.dotnet.implementType.insertionBehavior": "The insertion location of properties, events, and methods When implement interface or abstract class.",
1112
"configuration.dotnet.implementType.insertionBehavior.withOtherMembersOfTheSameKind": "Place them with other members of the same kind.",

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,17 @@ export class RoslynLanguageServer {
452452
// Save user's DOTNET_ROOT env-var value so server can recover the user setting when needed
453453
env.DOTNET_ROOT_USER = process.env.DOTNET_ROOT ?? 'EMPTY';
454454

455+
if (languageServerOptions.crashDumpPath) {
456+
// Enable dump collection
457+
env.DOTNET_DbgEnableMiniDump = '1';
458+
// Collect heap dump
459+
env.DOTNET_DbgMiniDumpType = '2';
460+
// Collect crashreport.json with additional thread and stack frame information.
461+
env.DOTNET_EnableCrashReport = '1';
462+
// The dump file name format is <executable>.<pid>.dmp
463+
env.DOTNET_DbgMiniDumpName = path.join(languageServerOptions.crashDumpPath, '%e.%p.dmp');
464+
}
465+
455466
let args: string[] = [];
456467

457468
if (commonOptions.waitForDebugger) {

src/shared/options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface LanguageServerOptions {
7474
readonly extensionsPaths: string[] | null;
7575
readonly preferCSharpExtension: boolean;
7676
readonly startTimeout: number;
77+
readonly crashDumpPath: string | undefined;
7778
}
7879

7980
export interface RazorOptions {
@@ -385,6 +386,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
385386
public get startTimeout() {
386387
return readOption<number>('dotnet.server.startTimeout', 30000);
387388
}
389+
public get crashDumpPath() {
390+
return readOption<string | undefined>('dotnet.server.crashDumpPath', undefined);
391+
}
388392
}
389393

390394
class RazorOptionsImpl implements RazorOptions {

0 commit comments

Comments
 (0)