mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 906963 - Add a flag to pauseOnExceptions to optionally ignore caught exceptions.
This commit is contained in:
parent
5ca960bd08
commit
121849adfe
@ -1079,6 +1079,7 @@ ThreadClient.prototype = {
|
||||
get paused() { return this._state === "paused"; },
|
||||
|
||||
_pauseOnExceptions: false,
|
||||
_ignoreCaughtExceptions: false,
|
||||
_pauseOnDOMEvents: null,
|
||||
|
||||
_actor: null,
|
||||
@ -1121,6 +1122,9 @@ ThreadClient.prototype = {
|
||||
if (this._pauseOnExceptions) {
|
||||
aPacket.pauseOnExceptions = this._pauseOnExceptions;
|
||||
}
|
||||
if (this._ignoreCaughtExceptions) {
|
||||
aPacket.ignoreCaughtExceptions = this._ignoreCaughtExceptions;
|
||||
}
|
||||
if (this._pauseOnDOMEvents) {
|
||||
aPacket.pauseOnDOMEvents = this._pauseOnDOMEvents;
|
||||
}
|
||||
@ -1193,12 +1197,19 @@ ThreadClient.prototype = {
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet.
|
||||
*/
|
||||
pauseOnExceptions: function TC_pauseOnExceptions(aFlag, aOnResponse) {
|
||||
this._pauseOnExceptions = aFlag;
|
||||
pauseOnExceptions: function TC_pauseOnExceptions(aPauseOnExceptions,
|
||||
aIgnoreCaughtExceptions,
|
||||
aOnResponse) {
|
||||
this._pauseOnExceptions = aPauseOnExceptions;
|
||||
this._ignoreCaughtExceptions = aIgnoreCaughtExceptions;
|
||||
|
||||
// If the debuggee is paused, we have to send the flag via a reconfigure
|
||||
// request.
|
||||
if (this.paused) {
|
||||
this._client.reconfigureThread({ pauseOnExceptions: aFlag }, aOnResponse);
|
||||
this._client.reconfigureThread({
|
||||
pauseOnExceptions: aPauseOnExceptions,
|
||||
ignoreCaughtExceptions: aIgnoreCaughtExceptions
|
||||
}, aOnResponse);
|
||||
return;
|
||||
}
|
||||
// Otherwise send the flag using a standard resume request.
|
||||
|
@ -873,6 +873,7 @@ ThreadActor.prototype = {
|
||||
|
||||
if (aRequest) {
|
||||
this._options.pauseOnExceptions = aRequest.pauseOnExceptions;
|
||||
this._options.ignoreCaughtExceptions = aRequest.ignoreCaughtExceptions;
|
||||
this.maybePauseOnExceptions();
|
||||
// Break-on-DOMEvents is only supported in content debugging.
|
||||
let events = aRequest.pauseOnDOMEvents;
|
||||
@ -1961,6 +1962,18 @@ ThreadActor.prototype = {
|
||||
* The exception that was thrown.
|
||||
*/
|
||||
onExceptionUnwind: function TA_onExceptionUnwind(aFrame, aValue) {
|
||||
let willBeCaught = false;
|
||||
for (let frame = aFrame; frame != null; frame = frame.older) {
|
||||
if (frame.script.isInCatchScope(frame.offset)) {
|
||||
willBeCaught = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (willBeCaught && this._options.ignoreCaughtExceptions) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let { url } = this.synchronize(this.sources.getOriginalLocation({
|
||||
url: aFrame.script.url,
|
||||
line: aFrame.script.getOffsetLine(aFrame.offset),
|
||||
|
@ -0,0 +1,50 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that setting ignoreCaughtExceptions will cause the debugger to ignore
|
||||
* caught exceptions, but not uncaught ones.
|
||||
*/
|
||||
|
||||
var gDebuggee;
|
||||
var gClient;
|
||||
var gThreadClient;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
initTestDebuggerServer();
|
||||
gDebuggee = addTestGlobal("test-stack");
|
||||
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient.connect(function() {
|
||||
attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) {
|
||||
gThreadClient = aThreadClient;
|
||||
test_pause_frame();
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function test_pause_frame()
|
||||
{
|
||||
gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
|
||||
gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
|
||||
do_check_eq(aPacket.why.type, "exception");
|
||||
do_check_eq(aPacket.why.exception, "bar");
|
||||
gThreadClient.resume(function () {
|
||||
finishClient(gClient);
|
||||
});
|
||||
});
|
||||
gThreadClient.pauseOnExceptions(true, true);
|
||||
gThreadClient.resume();
|
||||
});
|
||||
|
||||
try {
|
||||
gDebuggee.eval("(" + function() {
|
||||
debugger;
|
||||
try {
|
||||
throw "foo";
|
||||
} catch (e) {}
|
||||
throw "bar";
|
||||
} + ")()");
|
||||
} catch (e) {}
|
||||
}
|
@ -26,7 +26,7 @@ function run_test()
|
||||
|
||||
function test_pause_frame()
|
||||
{
|
||||
gThreadClient.pauseOnExceptions(true, function () {
|
||||
gThreadClient.pauseOnExceptions(true, false, function () {
|
||||
gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
|
||||
do_check_eq(aPacket.why.type, "exception");
|
||||
do_check_eq(aPacket.why.exception, 42);
|
||||
|
@ -166,4 +166,5 @@ reason = bug 820380
|
||||
[test_trace_actor-04.js]
|
||||
[test_trace_actor-05.js]
|
||||
[test_trace_actor-06.js]
|
||||
[test_ignore_caught_exceptions.js]
|
||||
[test_trace_client-01.js]
|
||||
|
Loading…
Reference in New Issue
Block a user