Skip to content

Commit

Permalink
Start crash reporter inside child processes
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed May 24, 2017
1 parent 94c647f commit 59fa62c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/vs/workbench/electron-browser/crashReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { Registry } from 'vs/platform/platform';
import { crashReporter } from 'electron';
import product from 'vs/platform/node/product';
import pkg from 'vs/platform/node/package';
import * as os from 'os';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';

const TELEMETRY_SECTION_ID = 'telemetry';

Expand Down Expand Up @@ -43,7 +45,8 @@ export class CrashReporter {
configuration: Electron.CrashReporterStartOptions,
@ITelemetryService telemetryService: ITelemetryService,
@IWindowsService windowsService: IWindowsService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService configurationService: IConfigurationService,
@IStorageService storageService: IStorageService
) {
const config = configurationService.getConfiguration<ICrashReporterConfig>(TELEMETRY_SECTION_ID);

Expand All @@ -52,14 +55,17 @@ export class CrashReporter {
}

telemetryService.getTelemetryInfo()
.then(info => ({
vscode_sessionId: info.sessionId,
vscode_version: pkg.version,
vscode_commit: product.commit,
vscode_machineId: info.machineId
}))
.then(extra => assign(configuration, { extra }))
.then(configuration => {
.then(info => {
let extra = {
vscode_sessionId: info.sessionId,
vscode_version: pkg.version,
vscode_commit: product.commit,
vscode_machineId: info.machineId,
crashesDirectory: os.tmpdir()
};
assign(configuration, { extra });
storageService.store('crashReporterArgs', configuration, StorageScope.GLOBAL);

// start crash reporter right here
crashReporter.start(clone(configuration));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { TerminalLinkHandler } from 'vs/workbench/parts/terminal/electron-browse
import { TerminalWidgetManager } from 'vs/workbench/parts/terminal/browser/terminalWidgetManager';
import { registerThemingParticipant, ITheme, ICssStyleCollector } from "vs/platform/theme/common/themeService";
import { scrollbarSliderBackground, scrollbarSliderHoverBackground, scrollbarSliderActiveBackground } from "vs/platform/theme/common/colorRegistry";
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';

/** The amount of time to consider terminal errors to be related to the launch */
const LAUNCHING_DURATION = 500;
Expand Down Expand Up @@ -97,7 +98,8 @@ export class TerminalInstance implements ITerminalInstance {
@IPanelService private _panelService: IPanelService,
@IWorkspaceContextService private _contextService: IWorkspaceContextService,
@IWorkbenchEditorService private _editorService: IWorkbenchEditorService,
@IInstantiationService private _instantiationService: IInstantiationService
@IInstantiationService private _instantiationService: IInstantiationService,
@IStorageService private _storageService: IStorageService
) {
this._instanceDisposables = [];
this._processDisposables = [];
Expand Down Expand Up @@ -467,7 +469,15 @@ export class TerminalInstance implements ITerminalInstance {
}
const env = TerminalInstance.createTerminalEnv(process.env, shell, this._getCwd(shell, workspace), locale, this._cols, this._rows);
this._title = shell.name || '';
this._process = cp.fork('./terminalProcess', [], {
let crashReporterArgs: Electron.CrashReporterStartOptions;
try {
crashReporterArgs = JSON.parse(this._storageService.get('crashReporterArgs', StorageScope.GLOBAL));
crashReporterArgs.extra.processName = 'terminalProcess';
} catch (error) {
// Error while parsing crash reporter args from loca storage
}
let processArgs = crashReporterArgs ? [crashReporterArgs.toString()] : [];
this._process = cp.fork('./terminalProcess', [processArgs], {
env: env,
cwd: URI.parse(path.dirname(require.toUrl('./terminalProcess'))).fsPath
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,10 @@ function sendProcessTitle() {
});
currentTitle = ptyProcess.process;
}

try {
var crashReporterArgs = JSON.parse(process.argv[2]);
process.crashReporter.start(crashReporterArgs);
} catch (error) {
// Error while fetching crash reporter args
}

0 comments on commit 59fa62c

Please sign in to comment.