From 53a368fc460f9f67677c7fc25751fb7106089a8f Mon Sep 17 00:00:00 2001 From: adelphes Date: Thu, 26 Jan 2017 11:09:50 +0000 Subject: [PATCH] Update behaviour of break-on-exception Altered so that uncaught exceptions never have a filter applied. Fixes #5 --- src/debugger.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/debugger.js b/src/debugger.js index 7aed072..68b6643 100644 --- a/src/debugger.js +++ b/src/debugger.js @@ -1491,10 +1491,10 @@ Debugger.prototype = { // when setting up the exceptions, we filter by packages containing public classes in the current session // - each filter needs a separate call (I think), so we do this as an asynchronous list var pkgs = this.session.build.packages; - var pkgs_to_monitor = Object.keys(pkgs).filter(pkgname => pkgs[pkgname].public_classes.length); + var pkgs_to_monitor = c ? Object.keys(pkgs).filter(pkgname => pkgs[pkgname].public_classes.length) : []; var o = { dbgr: this, - pkgs: pkgs_to_monitor, + filters: pkgs_to_monitor.map(pkg=>pkg+'.*'), caught: c, uncaught: u, onevent: onevent, @@ -1502,13 +1502,20 @@ Debugger.prototype = { def: $.Deferred(), extra: extra, next() { - if (!this.pkgs.length) { - this.def.resolveWith(this.dbgr, [this.extra]); // done - return; + var uncaught = false; + if (!this.filters.length) { + if (!this.uncaught) { + this.def.resolveWith(this.dbgr, [this.extra]); // done + return; + } + // setup the uncaught exception break - with no filter + uncaught = true; + this.filters.push(null); + this.caught = this.uncaught = false; } // setup next pattern this.dbgr.session.adbclient.jdwp_command({ - cmd: this.dbgr.JDWP.Commands.SetExceptionBreak(this.pkgs.shift() + '.*', this.caught, this.uncaught, this.onevent), + cmd: this.dbgr.JDWP.Commands.SetExceptionBreak(this.filters.shift(), this.caught, uncaught, this.onevent), }) .then(x => { this.dbgr.exception_ids.push(x.id);