Improvements to multi-threaded debugging

Separate out thread-specific parts
Only pause event thread for step, bp and thread events
Continue now resumes the specified thread instead of all threads
Prioritise stepping thread to prevent context switching during step
Monitor thread starts/ends
This commit is contained in:
adelphes
2017-02-05 19:34:12 +00:00
parent baa3fb6bfd
commit fdbd5df16b
6 changed files with 960 additions and 709 deletions

View File

@@ -371,6 +371,12 @@ function _JDWP() {
event.exception = this.decodeTaggedObjectID(o);
event.catchlocation = this.decodeLocation(o); // 0 = uncaught
break;
case 6: // thread start
case 7: // thread end
event.reqid = this.decodeInt(o);
event.threadid = this.decodeORef(o);
event.state = event.kind.value === 6 ? 'start' : 'end';
break;
case 8: // classprepare
event.reqid = this.decodeInt(o);
event.threadid = this.decodeORef(o);
@@ -1048,7 +1054,7 @@ function _JDWP() {
}];
// kind(1=singlestep)
// suspendpolicy(0=none,1=event-thread,2=all)
return this.SetEventRequest("step",1,2,mods,
return this.SetEventRequest("step",1,1,mods,
function(m1, i, res) {
res.push(m1.modkind);
DataCoder.encodeRef(res, m1.threadid);
@@ -1084,7 +1090,7 @@ function _JDWP() {
}
// kind(2=breakpoint)
// suspendpolicy(0=none,1=event-thread,2=all)
return this.SetEventRequest("breakpoint",2,2,mods,
return this.SetEventRequest("breakpoint",2,1,mods,
function(m, i, res) {
m.encode(res,i);
},
@@ -1099,6 +1105,26 @@ function _JDWP() {
// kind(2=breakpoint)
return this.ClearEvent("breakpoint",2,requestid);
},
ThreadStartNotify:function(onevent) {
// a wrapper around SetEventRequest
var mods = [];
// kind(6=threadstart)
// suspendpolicy(0=none,1=event-thread,2=all)
return this.SetEventRequest("threadstart",6,1,mods,
function() {},
onevent
);
},
ThreadEndNotify:function(onevent) {
// a wrapper around SetEventRequest
var mods = [];
// kind(7=threadend)
// suspendpolicy(0=none,1=event-thread,2=all)
return this.SetEventRequest("threadend",7,1,mods,
function() {},
onevent
);
},
OnClassPrepare:function(pattern, onevent) {
// a wrapper around SetEventRequest
var mods = [{
@@ -1133,7 +1159,7 @@ function _JDWP() {
});
// kind(4=exception)
// suspendpolicy(0=none,1=event-thread,2=all)
return this.SetEventRequest("exception",4,2,mods,
return this.SetEventRequest("exception",4,1,mods,
function(m, i, res) {
res.push(m.modkind);
switch(m.modkind) {