add terminate reason to debugger

This commit is contained in:
Dave Holoway
2020-07-03 00:47:38 +01:00
parent f551a92236
commit 6a29651208

View File

@@ -109,6 +109,8 @@ class AndroidDebugSession extends DebugSession {
*/ */
this.debug_mode = null; this.debug_mode = null;
this.terminate_reason = '';
this.session_id = uuidv4(); this.session_id = uuidv4();
this.session_start = new Date(); this.session_start = new Date();
analytics.init(); 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 // "null" is returned from the device picker if there's an error or if the
// user cancels. // user cancels.
D('targetDevice === "null"'); D('targetDevice === "null"');
this.terminate_reason = "null-targetdevice";
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; return;
} }
if (!args.processId) { if (!args.processId) {
this.LOG(`Attach failed: Missing "processId" property in launch.json`); this.LOG(`Attach failed: Missing "processId" property in launch.json`);
this.terminate_reason = "no-processid";
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; return;
} }
@@ -359,6 +363,7 @@ class AndroidDebugSession extends DebugSession {
// - a JSON object returned from the process picker (contains the target device and process ID), // - a JSON object returned from the process picker (contains the target device and process ID),
let attach_info = this.extractPidAndTargetDevice(args.processId); let attach_info = this.extractPidAndTargetDevice(args.processId);
if (!attach_info) { if (!attach_info) {
this.terminate_reason = "null-attachinfo";
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; return;
} }
@@ -376,6 +381,7 @@ class AndroidDebugSession extends DebugSession {
// wow, we really didn't make it very far... // wow, we really didn't make it very far...
this.LOG(err.message); this.LOG(err.message);
this.LOG('Check the "appSrcRoot" entries in launch.json'); this.LOG('Check the "appSrcRoot" entries in launch.json');
this.terminate_reason = `init-exception: ${err.message}`;
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; 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.'); 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 // tell the client we're done
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
this.sendEvent(new TerminatedEvent(false)); 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 // "null" is returned from the device picker if there's an error or if the
// user cancels. // user cancels.
D('targetDevice === "null"'); D('targetDevice === "null"');
this.terminate_reason = "null-targetdevice";
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; 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) // we don't allow both amStartArgs and launchActivity to be specified (the launch activity must be included in amStartArgs)
if (args.amStartArgs && args.launchActivity) { if (args.amStartArgs && args.launchActivity) {
this.LOG('amStartArgs and launchActivity options cannot both be specified in the launch configuration.'); this.LOG('amStartArgs and launchActivity options cannot both be specified in the launch configuration.');
this.terminate_reason = "amStartArgs+launchActivity";
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; return;
} }
@@ -515,6 +524,7 @@ class AndroidDebugSession extends DebugSession {
// wow, we really didn't make it very far... // wow, we really didn't make it very far...
this.LOG(err.message); this.LOG(err.message);
this.LOG('Check the "appSrcRoot" and "apkFile" entries in launch.json'); this.LOG('Check the "appSrcRoot" and "apkFile" entries in launch.json');
this.terminate_reason = `init-exception: ${err.message}`;
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
return; 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.'); 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 // tell the client we're done
this.terminate_reason = `start-exception: ${e.message||e.msg}`;
this.sendEvent(new TerminatedEvent(false)); this.sendEvent(new TerminatedEvent(false));
} }
} }
@@ -776,6 +787,7 @@ class AndroidDebugSession extends DebugSession {
analytics.event('debug-end', { analytics.event('debug-end', {
dbg_session_id: this.session_id, dbg_session_id: this.session_id,
dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3), dbg_elapsed: Math.trunc((Date.now() - this.session_start.getTime())/1e3),
dbg_term_reason: this.terminate_reason,
}); });
if (this.debuggerAttached) { if (this.debuggerAttached) {
try { try {