Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/ISSUE_TEMPLATE/do-not-file-issues-here-.md

This file was deleted.

4 changes: 0 additions & 4 deletions .github/assignment.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/locker.yml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/needs_more_info.yml

This file was deleted.

129 changes: 129 additions & 0 deletions Source/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import { DebugProtocol } from "vscode-debugprotocol";

import * as nls from "vscode-nls";
import { ErrorWithMessage } from "vscode-chrome-debug-core";
const localize = nls.loadMessageBundle();

export function runtimeNotFound(_runtime: string): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2001,
format: localize(
"VSND2001",
"Cannot find runtime '{0}' on PATH. Is '{0}' installed?",
"{_runtime}"
),
variables: { _runtime },
});
}

export function cannotLaunchInTerminal(_error: string): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2011,
format: localize(
"VSND2011",
"Cannot launch debug target in terminal ({0}).",
"{_error}"
),
variables: { _error },
});
}

export function cannotLaunchDebugTarget(_error: string): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2017,
format: localize(
"VSND2017",
"Cannot launch debug target ({0}).",
"{_error}"
),
variables: { _error },
showUser: true,
sendTelemetry: true,
});
}

export function cannotDebugExtension(_error: string): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2035,
format: localize(
"VSND2035",
"Cannot debug extension ({0}).",
"{_error}"
),
variables: { _error },
showUser: true,
sendTelemetry: true,
});
}

export function unknownConsoleType(consoleType: string): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2028,
format: localize(
"VSND2028",
"Unknown console type '{0}'.",
consoleType
),
});
}

export function cannotLaunchBecauseSourceMaps(
programPath: string
): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2002,
format: localize(
"VSND2002",
"Cannot launch program '{0}'; configuring source maps might help.",
"{path}"
),
variables: { path: programPath },
});
}

export function cannotLaunchBecauseOutFiles(
programPath: string
): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2003,
format: localize(
"VSND2003",
"Cannot launch program '{0}'; setting the '{1}' attribute might help.",
"{path}",
"outFiles"
),
variables: { path: programPath },
});
}

export function cannotLaunchBecauseJsNotFound(
programPath: string
): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2009,
format: localize(
"VSND2009",
"Cannot launch program '{0}' because corresponding JavaScript cannot be found.",
"{path}"
),
variables: { path: programPath },
});
}

export function cannotLoadEnvVarsFromFile(
error: string
): DebugProtocol.Message {
return new ErrorWithMessage({
id: 2029,
format: localize(
"VSND2029",
"Can't load environment variables from file ({0}).",
"{_error}"
),
variables: { _error: error },
});
}
50 changes: 50 additions & 0 deletions Source/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import * as vscode from "vscode";
import * as Core from "vscode-chrome-debug-core";

export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand(
"extension.node-debug2.toggleSkippingFile",
toggleSkippingFile
)
);
context.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider(
"legacy-extensionHost",
new ExtensionHostDebugConfigurationProvider()
)
);
}

export function deactivate() {}

function toggleSkippingFile(path: string | number): void {
if (!path) {
const activeEditor = vscode.window.activeTextEditor;
path = activeEditor && activeEditor.document.fileName;
}

if (path && vscode.debug.activeDebugSession) {
const args: Core.IToggleSkipFileStatusArgs =
typeof path === "string" ? { path } : { sourceReference: path };
vscode.debug.activeDebugSession.customRequest(
"toggleSkipFileStatus",
args
);
}
}

class ExtensionHostDebugConfigurationProvider
implements vscode.DebugConfigurationProvider
{
resolveDebugConfiguration(
folder: vscode.WorkspaceFolder | undefined,
debugConfiguration: vscode.DebugConfiguration
): vscode.ProviderResult<vscode.DebugConfiguration> {
return debugConfiguration;
}
}
102 changes: 102 additions & 0 deletions Source/nodeBreakpoints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {
Breakpoints,
chromeConnection,
InternalSourceBreakpoint,
ISetBreakpointResult,
ISetBreakpointsArgs,
logger,
ScriptContainer,
} from "vscode-chrome-debug-core";
import { NodeDebugAdapter } from "./nodeDebugAdapter";

export class NodeBreakpoints extends Breakpoints {
constructor(
private nodeDebugAdapter: NodeDebugAdapter,
chromeConnection: chromeConnection.ChromeConnection
) {
super(nodeDebugAdapter, chromeConnection);
}

/**
* Override addBreakpoints, which is called by setBreakpoints to make the actual call to Chrome.
*/
protected async addBreakpoints(
url: string,
breakpoints: InternalSourceBreakpoint[],
scripts: ScriptContainer
): Promise<ISetBreakpointResult[]> {
const responses = await super.addBreakpoints(url, breakpoints, scripts);
if (
this.nodeDebugAdapter.entryPauseEvent &&
!this.nodeDebugAdapter.finishedConfig
) {
const entryLocation =
this.nodeDebugAdapter.entryPauseEvent.callFrames[0].location;
const bpAtEntryLocationIdx = responses.findIndex((response) => {
// Don't compare column location, because you can have a bp at col 0, then break at some other column
return (
response &&
response.actualLocation &&
response.actualLocation.lineNumber ===
entryLocation.lineNumber &&
response.actualLocation.scriptId === entryLocation.scriptId
);
});
const bpAtEntryLocation =
bpAtEntryLocationIdx >= 0 && breakpoints[bpAtEntryLocationIdx];

if (bpAtEntryLocation) {
let conditionPassed = true;
if (bpAtEntryLocation.condition) {
const evalConditionResponse =
await this.nodeDebugAdapter.evaluateOnCallFrame(
bpAtEntryLocation.condition,
this.nodeDebugAdapter.entryPauseEvent.callFrames[0]
);
conditionPassed =
!evalConditionResponse.exceptionDetails &&
(!!evalConditionResponse.result.objectId ||
!!evalConditionResponse.result.value);
}

if (conditionPassed) {
// There is some initial breakpoint being set to the location where we stopped on entry, so need to pause even if
// the stopOnEntry flag is not set
logger.log(
"Got a breakpoint set in the entry location, so will stop even though stopOnEntry is not set"
);
this.nodeDebugAdapter.continueAfterConfigDone = false;
this.nodeDebugAdapter.expectingStopReason = "breakpoint";
} else {
logger.log(
"Breakpoint condition at entry location did not evaluate to truthy value"
);
}
}
}

return responses;
}

protected validateBreakpointsPath(
args: ISetBreakpointsArgs
): Promise<void> {
return super.validateBreakpointsPath(args).catch((e) => {
if (
!this.nodeDebugAdapter.launchAttachArgs.disableOptimisticBPs &&
args.source.path &&
this.nodeDebugAdapter.jsDeterminant.isJavaScript(
args.source.path
)
) {
return undefined;
} else {
return Promise.reject(e);
}
});
}
}
38 changes: 38 additions & 0 deletions Source/nodeDebug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

import {
ChromeDebugSession,
logger,
telemetry,
} from "vscode-chrome-debug-core";
import * as path from "path";
import * as os from "os";

import { NodeDebugAdapter } from "./nodeDebugAdapter";
import { NodeBreakpoints } from "./nodeBreakpoints";
import { NodeScriptContainer } from "./nodeScripts";

ChromeDebugSession.run(
ChromeDebugSession.getSession({
logFilePath: path.join(os.tmpdir(), "vscode-node-debug2.txt"), // non-.txt file types can't be uploaded to github
adapter: NodeDebugAdapter,
extensionName: "node-debug2",
breakpoints: NodeBreakpoints,
scriptContainer: NodeScriptContainer,
})
);

/* tslint:disable:no-var-requires */
const debugAdapterVersion = require("../../package.json").version;
logger.log("node-debug2: " + debugAdapterVersion);

/* __GDPR__FRAGMENT__
"DebugCommonProperties" : {
"Versions.DebugAdapter" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
telemetry.telemetry.addCustomGlobalProperty({
"Versions.DebugAdapter": debugAdapterVersion,
});
Loading