Skip to content
Closed
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
5 changes: 4 additions & 1 deletion src/protocol-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading