Bug 941739 - Print the current process and thread information on XPCOM assertions and string leaks stats; r=froydnj

This commit is contained in:
Ehsan Akhgari 2013-11-21 14:17:35 -05:00
parent 98b0297834
commit 83e2251f24
2 changed files with 18 additions and 10 deletions

View File

@ -77,7 +77,6 @@ Break(const char *aMsg);
using namespace mozilla;
static bool sIsMultiprocess = false;
static const char *sMultiprocessDescription = nullptr;
static Atomic<int32_t> gAssertionCount;
@ -180,7 +179,6 @@ nsDebugImpl::GetIsDebuggerAttached(bool* aResult)
/* static */ void
nsDebugImpl::SetMultiprocessMode(const char *aDesc)
{
sIsMultiprocess = true;
sMultiprocessDescription = aDesc;
}
@ -315,15 +313,12 @@ NS_DebugBreak(uint32_t aSeverity, const char *aStr, const char *aExpr,
# define PrintToBuffer(...) PR_sxprintf(StuffFixedBuffer, &buf, __VA_ARGS__)
// If we're multiprocess, print "[PID]" or "[Desc PID]" at the beginning of
// the message.
if (sIsMultiprocess) {
PrintToBuffer("[");
if (sMultiprocessDescription) {
PrintToBuffer("%s ", sMultiprocessDescription);
}
PrintToBuffer("%d] ", base::GetCurrentProcId());
// Print "[PID]" or "[Desc PID]" at the beginning of the message.
PrintToBuffer("[");
if (sMultiprocessDescription) {
PrintToBuffer("%s ", sMultiprocessDescription);
}
PrintToBuffer("%d] ", base::GetCurrentProcId());
PrintToBuffer("%s: ", sevString);

View File

@ -25,6 +25,17 @@
#include "nsStaticAtom.h"
#include "nsCOMPtr.h"
#include "mozilla/IntegerPrintfMacros.h"
#ifdef XP_WIN
#include <windows.h>
#include <process.h>
#define getpid() _getpid()
#define pthread_self() GetCurrentThreadId()
#else
#include <pthread.h>
#include <unistd.h>
#endif
using mozilla::Atomic;
// ---------------------------------------------------------------------------
@ -66,6 +77,8 @@ class nsStringStats
printf(" -- LEAKED %d !!!\n", mAdoptCount - mAdoptFreeCount);
else
printf("\n");
printf(" => Process ID: %" PRIuPTR ", Thread ID: %" PRIuPTR "\n",
uintptr_t(getpid()), uintptr_t(pthread_self()));
}
Atomic<int32_t> mAllocCount;