Bug 632343 - Run debug tests under -d since debug mode is now asynchronous (r=luke)
authorSteve Fink <sfink@mozilla.com>
Tue, 15 Feb 2011 13:39:45 -0800
changeset 62780 a17596187c713ef8c249a68bbdbb4410c59667a6
parent 62779 af9658ce7993e7808024de395f5f40a84b8a1c5f
child 62781 5e18294f6a9b294d93df1330f5211b9a80b47006
push idunknown
push userunknown
push dateunknown
reviewersluke
bugs632343
milestone2.0b12pre
Bug 632343 - Run debug tests under -d since debug mode is now asynchronous (r=luke)
js/src/jit-test/jit_test.py
js/src/jit-test/tests/basic/testBug552248.js
js/src/jit-test/tests/jaeger/bug563000/eif-call-newvar.js
js/src/jit-test/tests/jaeger/bug563000/eif-call-typechange.js
js/src/jit-test/tests/jaeger/bug563000/eif-call.js
js/src/jit-test/tests/jaeger/bug563000/eif-getter-newvar.js
js/src/jit-test/tests/jaeger/bug563000/eif-getter-typechange.js
js/src/jit-test/tests/jaeger/bug563000/eif-getter.js
js/src/jit-test/tests/jaeger/bug563000/eif-trap-newvar.js
js/src/jit-test/tests/jaeger/bug563000/eif-trap-typechange.js
js/src/jit-test/tests/jaeger/bug563000/eif-trap.js
js/src/jit-test/tests/jaeger/bug563000/simple-trap-1.js
js/src/jit-test/tests/jaeger/bug563000/simple-trap-2.js
js/src/jit-test/tests/jaeger/bug563000/simple-untrap.js
js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js
js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js
js/src/jit-test/tests/jaeger/bug563000/test-throwhook-1.js
js/src/jit-test/tests/jaeger/bug563000/test-throwhook-2.js
js/src/jit-test/tests/jaeger/bug563000/trap-force-return-1.js
js/src/jit-test/tests/jaeger/bug563000/trap-force-return-2.js
js/src/jit-test/tests/jaeger/bug563000/trap-from-add-inline.js
js/src/jit-test/tests/jaeger/bug563000/trap-from-add-ool.js
js/src/jit-test/tests/jaeger/bug563000/trap-own-callsite.js
js/src/jit-test/tests/jaeger/bug563000/trap-parent-from-trap.js
js/src/jit-test/tests/jaeger/bug563000/trap-parent.js
js/src/jit-test/tests/jaeger/bug563000/trap-self-as-parent.js
js/src/jit-test/tests/jaeger/bug563000/trap-self-from-trap.js
js/src/jit-test/tests/jaeger/bug563000/trap-self.js
js/src/jit-test/tests/jaeger/bug563000/untrap-own-trapsite.js
js/src/jit-test/tests/jaeger/bug563000/untrap-self.js
js/src/jsdbgapi.cpp
js/src/shell/js.cpp
--- a/js/src/jit-test/jit_test.py
+++ b/js/src/jit-test/jit_test.py
@@ -90,16 +90,18 @@ class Test:
                     if name == 'slow':
                         test.slow = True
                     elif name == 'allow-oom':
                         test.allow_oom = True
                     elif name == 'valgrind':
                         test.valgrind = options.valgrind
                     elif name == 'mjitalways':
                         test.jitflags.append('-a')
+                    elif name == 'debug':
+                        test.jitflags.append('-d')
                     else:
                         print('warning: unrecognized |jit-test| attribute %s'%part)
 
         if options.valgrind_all:
             test.valgrind = True
 
         return test
 
--- a/js/src/jit-test/tests/basic/testBug552248.js
+++ b/js/src/jit-test/tests/basic/testBug552248.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 var a = new Array();
 
 function i(save) {
     var x = 9;
     evalInFrame(0, "a.push(x)", save);
     evalInFrame(1, "a.push(z)", save);
     evalInFrame(2, "a.push(z)", save);
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-call-newvar.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-call-newvar.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function callee() {
   assertJit();
   evalInFrame(1, "var x = 'success'");
 }
 function caller() {
   assertJit();
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-call-typechange.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-call-typechange.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function callee() {
   assertJit();
   evalInFrame(1, "x = 'success'");
 }
 function caller() {
   assertJit();
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-call.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-call.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function callee() {
   assertJit();
   evalInFrame(1, "x = 'success'");
 }
 function caller() {
   assertJit();
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-getter-newvar.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-getter-newvar.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 this.__defineGetter__("someProperty", function () { evalInFrame(1, "var x = 'success'"); });
 function caller(obj) {
   assertJit();
   obj.someProperty;
   return x;
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-getter-typechange.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-getter-typechange.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 this.__defineGetter__("someProperty", function () { evalInFrame(1, "var x = 'success'"); });
 function caller(obj) {
   assertJit();
   var x = ({ dana : 'zuul' });
   obj.someProperty;
   return x;
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-getter.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-getter.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 this.__defineGetter__("someProperty", function () { evalInFrame(1, "x = 'success'"); });
 function caller(obj) {
   assertJit();
   var x = "failure";
   obj.someProperty;
   return x;
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-trap-newvar.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-trap-newvar.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function nop(){}
 function caller(obj) {
   assertJit();
   return x;
 }
 trap(caller, 7, "var x = 'success'; nop()");
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-trap-typechange.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-trap-typechange.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function nop(){}
 function caller(obj) {
   assertJit();
   var x = ({ dana : "zuul" });
   return x;
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/eif-trap.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/eif-trap.js
@@ -1,9 +1,9 @@
-// |jit-test| mjitalways
+// |jit-test| mjitalways;debug
 setDebug(true);
 
 function nop(){}
 function caller(obj) {
   assertJit();
   var x = "failure";
   return x;
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/simple-trap-1.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/simple-trap-1.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 var x = "failure";
 function main() { x = "success"; }
 
 /* The JSOP_STOP in a. */
 trap(main, 11, "");
 main();
 
--- a/js/src/jit-test/tests/jaeger/bug563000/simple-trap-2.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/simple-trap-2.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 var x = "notset";
 function main() { x = "failure"; }
 function success() { x = "success"; }
 
 /* The JSOP_STOP in a. */
 trap(main, 10, "success()");
 main();
--- a/js/src/jit-test/tests/jaeger/bug563000/simple-untrap.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/simple-untrap.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 var x = "notset";
 function main() { x = "success"; }
 function failure() { x = "failure"; }
 
 /* The JSOP_STOP in a. */
 trap(main, 8, "failure()");
 untrap(main, 8);
--- a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/test-debugger-1.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 var result = "unset";
 function main() {
   result = "failure";
   debugger;
 }
 function nop() { }
 
 setDebuggerHandler("result = 'success'; nop()");
--- a/js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/test-debugger-2.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 function main() {
   debugger;
   return "failure";
 }
 
 setDebuggerHandler("'success'");
 setDebug(true);
 
--- a/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-1.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-1.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 var result1 = "unset";
 var result2 = "failure";
 function main() {
   result1 = "failure";
   try {
     throw "something";
   } catch(e) {
     result2 = "success";
--- a/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-2.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-2.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 function main() {
   try {
     throw "something";
   } catch(e) {
     return "failure";
   }
   return "unset";
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-force-return-1.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-force-return-1.js
@@ -1,7 +1,8 @@
+// |jit-test| debug
 setDebug(true);
 function main() {
   return "failure";
 }
 /* JSOP_RETURN in main. */
 trap(main, 3, "'success'");
 assertEq(main(), "success");
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-force-return-2.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-force-return-2.js
@@ -1,7 +1,8 @@
+// |jit-test| debug
 setDebug(true);
 function main() {
   return 1;
 }
 /* JSOP_RETURN in main. */
 trap(main, 1, "0");
 assertEq(main(), 0);
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-from-add-inline.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-from-add-inline.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function main() {
   /* The JSOP_STOP in a. */
   a = { valueOf: function () { trap(main, 36, "success()"); } };
   a + "";
   x = "failure";
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-from-add-ool.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-from-add-ool.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function main() {
   /* The JSOP_STOP in a. */
   a = { valueOf: function () { trap(main, 57, "success()"); } };
   b = "";
   eval();
   a + b;
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-own-callsite.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-own-callsite.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function myparent(nested) {
   if (nested) {
     /* myparent call in myparent. */
     trap(myparent, 39, "failure()");
   } else {
     x = "success";   
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-parent-from-trap.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-parent-from-trap.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 
 function child() {
   x = "failure1";
   /* JSOP_STOP in parent. */
   trap(parent, 10, "success()");
 }
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-parent.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-parent.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function child() {
   /* JSOP_STOP in parent. */
   trap(parent, 17, "success()");
 }
 function parent() {
   child();
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-self-as-parent.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-self-as-parent.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 
 function myparent(nested) {
   if (nested) {
     /* noop call in myparent */
     trap(myparent, 50, "success()");
   } else {
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-self-from-trap.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-self-from-trap.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 
 function doNothing() { }
 
 function myparent(nested) {
   if (nested) {
     /* JSOP_CALL to doNothing in myparent with nested = true. */
--- a/js/src/jit-test/tests/jaeger/bug563000/trap-self.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/trap-self.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function main() {
   /* The JSOP_STOP in a. */
   trap(main, 25, "success()");
   x = "failure";
 }
 function success() { x = "success"; }
--- a/js/src/jit-test/tests/jaeger/bug563000/untrap-own-trapsite.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/untrap-own-trapsite.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function child() {
   /* JSOP_STOP in parent */
   untrap(parent, 10);
   x = "success";
 }
 function parent() {
--- a/js/src/jit-test/tests/jaeger/bug563000/untrap-self.js
+++ b/js/src/jit-test/tests/jaeger/bug563000/untrap-self.js
@@ -1,8 +1,9 @@
+// |jit-test| debug
 setDebug(true);
 x = "notset";
 function main() {
   /* JSOP_STOP in main. */
   untrap(main, 23);
   x = "success";
 }
 function failure() { x = "failure"; }
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -140,16 +140,19 @@ CompartmentHasLiveScripts(JSCompartment 
 
     return JS_FALSE;
 }
 #endif
 
 JS_FRIEND_API(JSBool)
 JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug)
 {
+    if (comp->debugMode == debug)
+        return JS_TRUE;
+
     // This should only be called when no scripts are live. It would even be
     // incorrect to discard just the non-live scripts' JITScripts because they
     // might share ICs with live scripts (bug 632343).
     JS_ASSERT(!CompartmentHasLiveScripts(comp));
 
     // All scripts compiled from this point on should be in the requested debugMode.
     comp->debugMode = debug;
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1740,19 +1740,26 @@ static JSBool
 SetDebug(JSContext *cx, uintN argc, jsval *vp)
 {
     jsval *argv = JS_ARGV(cx, vp);
     if (argc == 0 || !JSVAL_IS_BOOLEAN(argv[0])) {
         JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL,
                              JSSMSG_NOT_ENOUGH_ARGS, "setDebug");
         return JS_FALSE;
     }
+
+    /*
+     * Debug mode can only be set when there is no JS code executing on the
+     * stack. Unfortunately, that currently means that this call will fail
+     * unless debug mode is already set to what you're trying to set it to.
+     * In the future, this restriction may be lifted.
+     */
     
-    JS_SetDebugMode(cx, JSVAL_TO_BOOLEAN(argv[0]));
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
+    JSBool rv = JS_SetDebugMode(cx, JSVAL_TO_BOOLEAN(argv[0]));
+    JS_SET_RVAL(cx, vp, rv ? JSVAL_TRUE : JSVAL_FALSE);
     return JS_TRUE;
 }
 
 static JSBool
 GetTrapArgs(JSContext *cx, uintN argc, jsval *argv, JSScript **scriptp,
             int32 *ip)
 {
     jsval v;