From 6a29651208bfeec3222eb8019fe2683219965fd2 Mon Sep 17 00:00:00 2001 From: Dave Holoway Date: Fri, 3 Jul 2020 00:47:38 +0100 Subject: [PATCH] add terminate reason to debugger --- src/debugMain.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/debugMain.js b/src/debugMain.js index 3424618..34778a2 100644 --- a/src/debugMain.js +++ b/src/debugMain.js @@ -109,6 +109,8 @@ class AndroidDebugSession extends DebugSession { */ this.debug_mode = null; + this.terminate_reason = ''; + this.session_id = uuidv4(); this.session_start = new Date(); analytics.init(); @@ -344,12 +346,14 @@ class AndroidDebugSession extends DebugSession { // "null" is returned from the device picker if there's an error or if the // user cancels. D('targetDevice === "null"'); + this.terminate_reason = "null-targetdevice"; this.sendEvent(new TerminatedEvent(false)); return; } if (!args.processId) { this.LOG(`Attach failed: Missing "processId" property in launch.json`); + this.terminate_reason = "no-processid"; this.sendEvent(new TerminatedEvent(false)); return; } @@ -359,6 +363,7 @@ class AndroidDebugSession extends DebugSession { // - a JSON object returned from the process picker (contains the target device and process ID), let attach_info = this.extractPidAndTargetDevice(args.processId); if (!attach_info) { + this.terminate_reason = "null-attachinfo"; this.sendEvent(new TerminatedEvent(false)); return; } @@ -376,6 +381,7 @@ class AndroidDebugSession extends DebugSession { // wow, we really didn't make it very far... this.LOG(err.message); this.LOG('Check the "appSrcRoot" entries in launch.json'); + this.terminate_reason = `init-exception: ${err.message}`; this.sendEvent(new TerminatedEvent(false)); return; } @@ -442,6 +448,7 @@ class AndroidDebugSession extends DebugSession { this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.'); } // tell the client we're done + this.terminate_reason = `start-exception: ${e.message||e.msg}`; this.sendEvent(new TerminatedEvent(false)); } } @@ -479,6 +486,7 @@ class AndroidDebugSession extends DebugSession { // "null" is returned from the device picker if there's an error or if the // user cancels. D('targetDevice === "null"'); + this.terminate_reason = "null-targetdevice"; this.sendEvent(new TerminatedEvent(false)); return; } @@ -495,6 +503,7 @@ class AndroidDebugSession extends DebugSession { // we don't allow both amStartArgs and launchActivity to be specified (the launch activity must be included in amStartArgs) if (args.amStartArgs && args.launchActivity) { this.LOG('amStartArgs and launchActivity options cannot both be specified in the launch configuration.'); + this.terminate_reason = "amStartArgs+launchActivity"; this.sendEvent(new TerminatedEvent(false)); return; } @@ -515,6 +524,7 @@ class AndroidDebugSession extends DebugSession { // wow, we really didn't make it very far... this.LOG(err.message); this.LOG('Check the "appSrcRoot" and "apkFile" entries in launch.json'); + this.terminate_reason = `init-exception: ${err.message}`; this.sendEvent(new TerminatedEvent(false)); return; } @@ -594,6 +604,7 @@ class AndroidDebugSession extends DebugSession { this.LOG('If you are running ADB on a non-default port, also make sure the adbPort value in your launch.json is correct.'); } // tell the client we're done + this.terminate_reason = `start-exception: ${e.message||e.msg}`; this.sendEvent(new TerminatedEvent(false)); } } @@ -776,6 +787,7 @@ class AndroidDebugSession extends DebugSession { analytics.event('debug-end', { dbg_session_id: this.session_id, dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3), + dbg_term_reason: this.terminate_reason, }); if (this.debuggerAttached) { try {