Skip to content

Commit

Permalink
Merge pull request #6438 from dibarbet/crash_dumps
Browse files Browse the repository at this point in the history
Add support for collecting dumps on crash
  • Loading branch information
dibarbet authored Sep 26, 2023
2 parents c513822 + 4517f8e commit fb2e221
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@
"default": null,
"description": "%configuration.dotnet.server.extensionPaths%"
},
"dotnet.server.crashDumpPath": {
"scope": "machine-overridable",
"type": "string",
"default": null,
"description": "%configuration.dotnet.server.crashDumpPath%"
},
"dotnet.projects.binaryLogPath": {
"scope": "machine-overridable",
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"configuration.dotnet.server.waitForDebugger": "Passes the --debug flag when launching the server to allow a debugger to be attached. (Previously `omnisharp.waitForDebugger`)",
"configuration.dotnet.server.trace": "Sets the logging level for the language server",
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
"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.",
"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)",
"configuration.dotnet.implementType.insertionBehavior": "The insertion location of properties, events, and methods When implement interface or abstract class.",
"configuration.dotnet.implementType.insertionBehavior.withOtherMembersOfTheSameKind": "Place them with other members of the same kind.",
Expand Down
11 changes: 11 additions & 0 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,17 @@ export class RoslynLanguageServer {
// Save user's DOTNET_ROOT env-var value so server can recover the user setting when needed
env.DOTNET_ROOT_USER = process.env.DOTNET_ROOT ?? 'EMPTY';

if (languageServerOptions.crashDumpPath) {
// Enable dump collection
env.DOTNET_DbgEnableMiniDump = '1';
// Collect heap dump
env.DOTNET_DbgMiniDumpType = '2';
// Collect crashreport.json with additional thread and stack frame information.
env.DOTNET_EnableCrashReport = '1';
// The dump file name format is <executable>.<pid>.dmp
env.DOTNET_DbgMiniDumpName = path.join(languageServerOptions.crashDumpPath, '%e.%p.dmp');
}

let args: string[] = [];

if (commonOptions.waitForDebugger) {
Expand Down
4 changes: 4 additions & 0 deletions src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface LanguageServerOptions {
readonly extensionsPaths: string[] | null;
readonly preferCSharpExtension: boolean;
readonly startTimeout: number;
readonly crashDumpPath: string | undefined;
}

export interface RazorOptions {
Expand Down Expand Up @@ -385,6 +386,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
public get startTimeout() {
return readOption<number>('dotnet.server.startTimeout', 30000);
}
public get crashDumpPath() {
return readOption<string | undefined>('dotnet.server.crashDumpPath', undefined);
}
}

class RazorOptionsImpl implements RazorOptions {
Expand Down

0 comments on commit fb2e221

Please sign in to comment.