Bug 692722 - implement xpcshell -d for running in debug mode (r=mrbkap)
authorSteve Fink <sfink@mozilla.com>
Thu, 06 Oct 2011 23:34:21 -0700
changeset 80550 7742dd3cab64a91d8aa8f39061e551f62733c05e
parent 80549 7b1567ef9a576c900bc86d155f402c4f0c0ef211
child 80551 4e829c32aa121d43a2b0f43c309f950bed2ca589
push id21505
push usermbrubeck@mozilla.com
push dateMon, 21 Nov 2011 16:45:45 +0000
treeherdermozilla-central@9276e3274f18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs692722
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 692722 - implement xpcshell -d for running in debug mode (r=mrbkap)
js/xpconnect/shell/xpcshell.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
--- a/js/xpconnect/shell/xpcshell.cpp
+++ b/js/xpconnect/shell/xpcshell.cpp
@@ -1228,16 +1228,19 @@ ProcessArgs(JSContext *cx, JSObject *obj
         case 'S':
             JS_ToggleOptions(cx, JSOPTION_WERROR);
         case 's':
             JS_ToggleOptions(cx, JSOPTION_STRICT);
             break;
         case 'x':
             JS_ToggleOptions(cx, JSOPTION_XML);
             break;
+        case 'd':
+            xpc_ActivateDebugMode();
+            break;
         case 'P':
             if (JS_GET_CLASS(cx, JS_GetPrototype(cx, obj)) != &global_class) {
                 JSObject *gobj;
 
                 if (!JS_DeepFreezeObject(cx, obj))
                     return JS_FALSE;
                 gobj = JS_NewGlobalObject(cx, &global_class);
                 if (!gobj || !JS_SplicePrototype(cx, gobj, obj))
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -2573,16 +2573,24 @@ fail:
      * always safe to turn debug mode off, since DeactivateDebugger prevents
      * debugger callbacks from having any effect.
      */
     if (gDesiredDebugMode)
         JS_SetRuntimeDebugMode(rt, JS_FALSE);
     gDesiredDebugMode = gDebugMode = JS_FALSE;
 }
 
+NS_EXPORT_(void)
+xpc_ActivateDebugMode()
+{
+    XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
+    nsXPConnect::GetXPConnect()->SetDebugModeWhenPossible(true, true);
+    nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
+}
+
 /* JSContext Pop (); */
 NS_IMETHODIMP
 nsXPConnect::Pop(JSContext * *_retval)
 {
     XPCPerThreadData* data = XPCPerThreadData::GetData(nsnull);
 
     if (!data) {
         if (_retval)
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -590,16 +590,18 @@ public:
                                     bool showThisProps);
 
 
     static bool ReportAllJSExceptions()
     {
       return gReportAllJSExceptions > 0;
     }
 
+    static void CheckForDebugMode(JSRuntime *rt);
+
 protected:
     nsXPConnect();
 
 private:
     static PRThread* FindMainThread();
 
 private:
     // Singleton instance
@@ -619,17 +621,16 @@ private:
 
     typedef nsBaseHashtable<nsVoidPtrHashKey, nsISupports*, nsISupports*> ScopeSet;
     ScopeSet mScopes;
     nsCOMPtr<nsIXPCScriptable> mBackstagePass;
 
     static PRUint32 gReportAllJSExceptions;
     static JSBool gDebugMode;
     static JSBool gDesiredDebugMode;
-    static inline void CheckForDebugMode(JSRuntime *rt);
 
 public:
     static nsIScriptSecurityManager *gScriptSecurityManager;
 };
 
 /***************************************************************************/
 
 class XPCRootSetElem
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -177,16 +177,21 @@ xpc_UnmarkGrayObjectRecursive(JSObject* 
 // be reached through it.
 inline void
 xpc_UnmarkGrayObject(JSObject *obj)
 {
     if (obj && xpc_IsGrayGCThing(obj))
         xpc_UnmarkGrayObjectRecursive(obj);
 }
 
+// No JS can be on the stack when this is called. Probably only useful from
+// xpcshell.
+NS_EXPORT_(void)
+xpc_ActivateDebugMode();
+
 class nsIMemoryMultiReporterCallback;
 
 namespace mozilla {
 namespace xpconnect {
 namespace memory {
 
 struct CompartmentStats
 {