From ce88d1386c290cea5b703b3a07bc48ffcc2d1102 Mon Sep 17 00:00:00 2001 From: RedMickey Date: Wed, 25 Dec 2019 12:43:45 +0300 Subject: [PATCH 1/6] Fix VM_unknown calls in Call Stack issue --- src/debugger/direct/directDebugAdapter.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index da4f3a55c..510eb2660 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -12,7 +12,7 @@ import { Telemetry } from "../../common/telemetry"; import { OutputEvent, Logger } from "vscode-debugadapter"; import { TelemetryHelper } from "../../common/telemetryHelper"; import { RemoteTelemetryReporter } from "../../common/telemetryReporters"; -import { ChromeDebugAdapter, ChromeDebugSession, IChromeDebugSessionOpts, IAttachRequestArgs, logger } from "vscode-chrome-debug-core"; +import { ChromeDebugAdapter, ChromeDebugSession, IChromeDebugSessionOpts, IAttachRequestArgs, logger, IOnPausedResult, Crdp } from "vscode-chrome-debug-core"; import { InternalErrorCode } from "../../common/error/internalErrorCode"; import { RemoteExtension } from "../../common/remoteExtension"; import { DebugProtocol } from "vscode-debugprotocol"; @@ -29,6 +29,9 @@ export interface IDirectLaunchRequestArgs extends DebugProtocol.LaunchRequestArg export class DirectDebugAdapter extends ChromeDebugAdapter { + private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)"; // the name of Hermes native functions in call stack (https://github.com/facebook/hermes/issues/168) + private static HERMES_NATIVE_FUNCTION_SCRIPT_ID: string = "4294967295"; // equals to 0xfffffff - the scriptId returned by Hermes debugger, that means "invalid script ID" + private outputLogger: (message: string, error?: boolean | string) => void; private projectRootPath: string; private remoteExtension: RemoteExtension; @@ -156,6 +159,15 @@ export class DirectDebugAdapter extends ChromeDebugAdapter { super.disconnect(args); } + protected async onPaused(notification: Crdp.Debugger.PausedEvent, expectingStopReason = this._expectingStopReason): Promise { + // excluding Hermes native function calls from call stack, since VS Code can't process them properly (https://github.com/facebook/hermes/issues/168) + notification.callFrames = notification.callFrames.filter(callFrame => + callFrame.functionName !== DirectDebugAdapter.HERMES_NATIVE_FUNCTION_NAME && + callFrame.location.scriptId !== DirectDebugAdapter.HERMES_NATIVE_FUNCTION_SCRIPT_ID + ); + return super.onPaused(notification, expectingStopReason); + } + private initializeSettings(args: any): Q.Promise { if (!this.isSettingsInitialized) { let chromeDebugCoreLogs = getLoggingDirectory(); From bed065db667f18ccd0b07d0aae26b4a9018e22c1 Mon Sep 17 00:00:00 2001 From: RedMickey Date: Wed, 25 Dec 2019 13:09:09 +0300 Subject: [PATCH 2/6] Minor fix --- src/debugger/direct/directDebugAdapter.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index 510eb2660..5ce155f4f 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -29,8 +29,15 @@ export interface IDirectLaunchRequestArgs extends DebugProtocol.LaunchRequestArg export class DirectDebugAdapter extends ChromeDebugAdapter { - private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)"; // the name of Hermes native functions in call stack (https://github.com/facebook/hermes/issues/168) - private static HERMES_NATIVE_FUNCTION_SCRIPT_ID: string = "4294967295"; // equals to 0xfffffff - the scriptId returned by Hermes debugger, that means "invalid script ID" + /** + * @type {string} - the Hermes native functions calls mark in call stack (https://github.com/facebook/hermes/issues/168) + */ + private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)"; + + /** + * @type {string} - equals to 0xfffffff - the scriptId returned by Hermes debugger, that means "invalid script ID" + */ + private static HERMES_NATIVE_FUNCTION_SCRIPT_ID: string = "4294967295"; private outputLogger: (message: string, error?: boolean | string) => void; private projectRootPath: string; From ef7c10af6ff5b8e7a34220939e9b74d7f5c1313a Mon Sep 17 00:00:00 2001 From: RedMickey Date: Wed, 25 Dec 2019 13:16:25 +0300 Subject: [PATCH 3/6] Minor fix2 --- src/debugger/direct/directDebugAdapter.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index 5ce155f4f..86b088cb0 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -30,12 +30,14 @@ export interface IDirectLaunchRequestArgs extends DebugProtocol.LaunchRequestArg export class DirectDebugAdapter extends ChromeDebugAdapter { /** - * @type {string} - the Hermes native functions calls mark in call stack (https://github.com/facebook/hermes/issues/168) + * @description The Hermes native functions calls mark in call stack (https://github.com/facebook/hermes/issues/168) + * @type {string} */ private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)"; - + /** - * @type {string} - equals to 0xfffffff - the scriptId returned by Hermes debugger, that means "invalid script ID" + * @description Equals to 0xfffffff - the scriptId returned by Hermes debugger, that means "invalid script ID" + * @type {string} */ private static HERMES_NATIVE_FUNCTION_SCRIPT_ID: string = "4294967295"; From 9e8a9d1ebdf9b2e6c4d41d2941a71cf3c097e579 Mon Sep 17 00:00:00 2001 From: RedMickey <33267199+RedMickey@users.noreply.github.com> Date: Wed, 25 Dec 2019 13:26:48 +0300 Subject: [PATCH 4/6] Update comments Co-Authored-By: Yuri Skorokhodov --- src/debugger/direct/directDebugAdapter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index 86b088cb0..edacaf1f6 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -30,7 +30,7 @@ export interface IDirectLaunchRequestArgs extends DebugProtocol.LaunchRequestArg export class DirectDebugAdapter extends ChromeDebugAdapter { /** - * @description The Hermes native functions calls mark in call stack (https://github.com/facebook/hermes/issues/168) + * @description The Hermes native functions calls mark in call stack * @type {string} */ private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)"; From 09fbe807ee66adb0f02827a1b0bc9eac7676bf52 Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Wed, 25 Dec 2019 14:26:40 +0300 Subject: [PATCH 5/6] Update src/debugger/direct/directDebugAdapter.ts --- src/debugger/direct/directDebugAdapter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index edacaf1f6..3b4dc61e5 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -169,7 +169,8 @@ export class DirectDebugAdapter extends ChromeDebugAdapter { } protected async onPaused(notification: Crdp.Debugger.PausedEvent, expectingStopReason = this._expectingStopReason): Promise { - // excluding Hermes native function calls from call stack, since VS Code can't process them properly (https://github.com/facebook/hermes/issues/168) + // Excluding Hermes native function calls from call stack, since VS Code can't process them properly + // More info: https://github.com/facebook/hermes/issues/168 notification.callFrames = notification.callFrames.filter(callFrame => callFrame.functionName !== DirectDebugAdapter.HERMES_NATIVE_FUNCTION_NAME && callFrame.location.scriptId !== DirectDebugAdapter.HERMES_NATIVE_FUNCTION_SCRIPT_ID From 3e0411bfa78ac1520f23938dcd85c0648b779cca Mon Sep 17 00:00:00 2001 From: Yuri Skorokhodov Date: Wed, 25 Dec 2019 14:29:07 +0300 Subject: [PATCH 6/6] Update src/debugger/direct/directDebugAdapter.ts --- src/debugger/direct/directDebugAdapter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debugger/direct/directDebugAdapter.ts b/src/debugger/direct/directDebugAdapter.ts index 3b4dc61e5..4ef640313 100644 --- a/src/debugger/direct/directDebugAdapter.ts +++ b/src/debugger/direct/directDebugAdapter.ts @@ -169,7 +169,7 @@ export class DirectDebugAdapter extends ChromeDebugAdapter { } protected async onPaused(notification: Crdp.Debugger.PausedEvent, expectingStopReason = this._expectingStopReason): Promise { - // Excluding Hermes native function calls from call stack, since VS Code can't process them properly + // Excluding Hermes native function calls from call stack, since VS Code can't process them properly // More info: https://github.com/facebook/hermes/issues/168 notification.callFrames = notification.callFrames.filter(callFrame => callFrame.functionName !== DirectDebugAdapter.HERMES_NATIVE_FUNCTION_NAME &&