diff --git a/src/protocol-events.ts b/src/protocol-events.ts index 126d5bb..7207666 100644 --- a/src/protocol-events.ts +++ b/src/protocol-events.ts @@ -31,9 +31,10 @@ export enum ProtocolVersion { SupportNativeDescriptors = 9, SupportEmptyTabs = 10, SupportDiagnosticsSetActive = 11, + SupportProfilerCaptureNotification = 12, } -export const DEBUGGER_PROTOCOL_VERSION = ProtocolVersion.SupportDiagnosticsSetActive; +export const DEBUGGER_PROTOCOL_VERSION = ProtocolVersion.SupportProfilerCaptureNotification; // ------------------------------------------------------------------------- // Interfaces for event message payloads (received from the debuggee) @@ -65,7 +66,9 @@ export interface ProtocolCapabilities { export interface ProfilerCapture { type: IncomingEventType.ProfilerCapture; capture_base_path: string; + capture_file_name: string; capture_data: string; + should_write_to_disk: boolean; } export interface StoppedEventMessage { diff --git a/src/session.ts b/src/session.ts index 595732c..8ee22e2 100644 --- a/src/session.ts +++ b/src/session.ts @@ -340,8 +340,13 @@ export class Session extends DebugSession implements IDebuggeeMessageSender { // MC has sent the profiler capture results to the debugger private async handleProfilerCapture(profilerCapture: ProfilerCapture) { + if (!profilerCapture.should_write_to_disk) { + this._eventEmitter.emit('new-profiler-capture', profilerCapture.capture_base_path, profilerCapture.capture_file_name); + return; + } + const formattedDate = new Date().toISOString().replace(/:/g, '-'); - const newCaptureFileNameJS = `Capture_${formattedDate}_JS.cpuprofile`; + const newCaptureFileNameJS = profilerCapture.capture_file_name !== undefined && profilerCapture.capture_file_name.length > 0 ? profilerCapture.capture_file_name : `Capture_${formattedDate}_JS.cpuprofile`; const captureFullPathJS = path.join(profilerCapture.capture_base_path, newCaptureFileNameJS); const jsFileCreated = this.writeProfilerCaptureToFile(