Clear last step request on exception break
This commit is contained in:
adelphes
2017-01-31 15:00:45 +00:00
parent 71fcf1b760
commit a677d636f3

View File

@@ -140,6 +140,7 @@ Debugger.prototype = {
// classprepare filters // classprepare filters
cpfilters: [], cpfilters: [],
preparedclasses: [], preparedclasses: [],
stepids: {}, // hashmap<threadid,stepid>
} }
return this; return this;
}, },
@@ -1320,16 +1321,26 @@ Debugger.prototype = {
return cmd.promise(); return cmd.promise();
}, },
_clearLastStepRequest: function (threadid, extra) {
if (!this.session || !this.session.stepids[threadid])
return $.Deferred().resolveWith(this,[extra]);
var clearStepCommand = this.session.adbclient.jdwp_command({
cmd: this.JDWP.Commands.ClearStep(this.session.stepids[threadid]),
extra: extra,
}).then((decoded, extra) => extra);
this.session.stepids[threadid] = 0;
return clearStepCommand;
},
_setupstepevent: function (steptype, threadid) { _setupstepevent: function (steptype, threadid) {
var onevent = { var onevent = {
data: { data: {
dbgr: this, dbgr: this,
}, },
fn: function (e) { fn: function (e) {
e.data.dbgr.session.adbclient.jdwp_command({ e.data.dbgr._clearLastStepRequest(e.event.threadid, e)
cmd: e.data.dbgr.JDWP.Commands.ClearStep(e.event.reqid), .then(function (e) {
})
.then(function () {
var x = e.data; var x = e.data;
var loc = e.event.location; var loc = e.event.location;
@@ -1351,6 +1362,10 @@ Debugger.prototype = {
}; };
var cmd = this.session.adbclient.jdwp_command({ var cmd = this.session.adbclient.jdwp_command({
cmd: this.JDWP.Commands.SetSingleStep(steptype, threadid, onevent), cmd: this.JDWP.Commands.SetSingleStep(steptype, threadid, onevent),
}).then(res => {
// save the step id so we can manually clear it if an exception break occurs
if (this.session && res && res.id)
this.session.stepids[threadid] = res.id;
}); });
return cmd.promise(); return cmd.promise();
@@ -1539,6 +1554,9 @@ Debugger.prototype = {
dbgr: this, dbgr: this,
}, },
fn: function (e) { fn: function (e) {
// if this exception break occurred during a step request, we must manually clear the event
// or the (device-side) debugger will crash on next step
this._clearLastStepRequest(e.event.threadid, e).then(e => {
this._findcmllocation(this.session.classes, e.event.throwlocation) this._findcmllocation(this.session.classes, e.event.throwlocation)
.then(tloc => { .then(tloc => {
this._findcmllocation(this.session.classes, e.event.catchlocation) this._findcmllocation(this.session.classes, e.event.catchlocation)
@@ -1552,6 +1570,7 @@ Debugger.prototype = {
this._trigger('exception', eventdata); this._trigger('exception', eventdata);
}) })
}) })
});
}.bind(this) }.bind(this)
}; };