Debug-only logging code to track down bug 469514.
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Tue, 21 Apr 2009 11:32:07 -0400
changeset 27570 92791a422f0a4cb0adfd054f1fe90c866d6be949
parent 27569 54a5878ac36828732bdb5af4497afccd6ebef376
child 27579 30ac20416be4c46eb323f0f4a6ffe1c840c85d93
push id6622
push usersdwilsh@shawnwilsher.com
push dateTue, 21 Apr 2009 15:32:40 +0000
treeherdermozilla-central@92791a422f0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs469514
milestone1.9.2a1pre
Debug-only logging code to track down bug 469514. r=ted
xpcom/io/nsStreamUtils.cpp
xpcom/threads/nsThreadManager.cpp
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -93,16 +93,21 @@ public:
     NS_IMETHOD OnInputStreamReady(nsIAsyncInputStream *stream)
     {
         mStream = stream;
 
         nsresult rv =
             mTarget->Dispatch(this, NS_DISPATCH_NORMAL);
         if (NS_FAILED(rv)) {
             NS_WARNING("Dispatch failed");
+#ifdef DEBUG
+            (void)fprintf(stdout,
+                          "### mTarget (%p) may not be accepting events!\n",
+                          mTarget);
+#endif
             return NS_ERROR_FAILURE;
         }
 
         return NS_OK;
     }
 
     NS_IMETHOD Run()
     {
@@ -172,16 +177,21 @@ public:
     NS_IMETHOD OnOutputStreamReady(nsIAsyncOutputStream *stream)
     {
         mStream = stream;
 
         nsresult rv =
             mTarget->Dispatch(this, NS_DISPATCH_NORMAL);
         if (NS_FAILED(rv)) {
             NS_WARNING("PostEvent failed");
+#ifdef DEBUG
+            (void)fprintf(stdout,
+                          "### mTarget (%p) may not be accepting events!\n",
+                          mTarget);
+#endif
             return NS_ERROR_FAILURE;
         }
 
         return NS_OK;
     }
 
     NS_IMETHOD Run()
     {
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -38,16 +38,31 @@
 
 #include "nsThreadManager.h"
 #include "nsThread.h"
 #include "nsIClassInfoImpl.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsAutoLock.h"
 
+#ifdef DEBUG
+#include "nsStackWalk.h"
+
+static void
+thread_stack_callback(void *aPC, void *)
+{
+  char buf[1024];
+  nsCodeAddressDetails details;
+
+  (void)NS_DescribeCodeAddress(aPC, &details);
+  (void)NS_FormatCodeAddressDetails(aPC, &details, buf, sizeof(buf));
+  (void)fprintf(stdout, buf);
+}
+#endif
+
 typedef nsTArray< nsRefPtr<nsThread> > nsThreadArray;
 
 //-----------------------------------------------------------------------------
 
 static void
 ReleaseObject(void *data)
 {
   static_cast<nsISupports *>(data)->Release();
@@ -227,16 +242,21 @@ nsThreadManager::NewThread(PRUint32 crea
   if (NS_FAILED(rv)) {
     NS_RELEASE(thr);
     return rv;
   }
 
   // At this point, we expect that the thread has been registered in mThread;
   // however, it is possible that it could have also been replaced by now, so
   // we cannot really assert that it was added.
+#ifdef DEBUG
+  (void)fprintf(stdout, "### Creating thread with address %p\n", thr);
+  (void)NS_StackWalk(thread_stack_callback, 0, nsnull);
+  (void)fprintf(stdout, "\n\n");
+#endif
 
   *result = thr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsThreadManager::GetThreadFromPRThread(PRThread *thread, nsIThread **result)
 {