Skip to content
Merged
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
24 changes: 23 additions & 1 deletion src/debugger/direct/directDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -29,6 +29,18 @@ export interface IDirectLaunchRequestArgs extends DebugProtocol.LaunchRequestArg

export class DirectDebugAdapter extends ChromeDebugAdapter {

/**
* @description The Hermes native functions calls mark in call stack
* @type {string}
*/
private static HERMES_NATIVE_FUNCTION_NAME: string = "(native)";

/**
* @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";

private outputLogger: (message: string, error?: boolean | string) => void;
private projectRootPath: string;
private remoteExtension: RemoteExtension;
Expand Down Expand Up @@ -156,6 +168,16 @@ export class DirectDebugAdapter extends ChromeDebugAdapter {
super.disconnect(args);
}

protected async onPaused(notification: Crdp.Debugger.PausedEvent, expectingStopReason = this._expectingStopReason): Promise<IOnPausedResult> {
// 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
);
return super.onPaused(notification, expectingStopReason);
}

private initializeSettings(args: any): Q.Promise<any> {
if (!this.isSettingsInitialized) {
let chromeDebugCoreLogs = getLoggingDirectory();
Expand Down