зеркало из https://github.com/mozilla/gecko-dev.git
Bug 583059: Make it possible to break on failed static-XPCOM-ctor/dtor checks and add an env var to make failed checks fatal. r=dbaron
This commit is contained in:
Родитель
eee78a9987
Коммит
23c9c84e52
|
@ -41,6 +41,7 @@
|
|||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsTArray.h"
|
||||
#include "prenv.h"
|
||||
#include "prprf.h"
|
||||
#include "prlog.h"
|
||||
#include "plstr.h"
|
||||
|
@ -156,10 +157,29 @@ struct nsTraceRefcntStats {
|
|||
};
|
||||
|
||||
// I hope to turn this on for everybody once we hit it a little less.
|
||||
#define ASSERT_ACTIVITY_IS_LEGAL \
|
||||
NS_WARN_IF_FALSE(gActivityTLS != BAD_TLS_INDEX && \
|
||||
NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0, \
|
||||
"XPCOM objects created/destroyed from static ctor/dtor");
|
||||
#ifdef DEBUG
|
||||
static const char kStaticCtorDtorWarning[] =
|
||||
"XPCOM objects created/destroyed from static ctor/dtor";
|
||||
|
||||
static void
|
||||
AssertActivityIsLegal()
|
||||
{
|
||||
if (gActivityTLS == BAD_TLS_INDEX ||
|
||||
NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) != 0) {
|
||||
if (PR_GetEnv("MOZ_FATAL_STATIC_XPCOM_CTORS_DTORS")) {
|
||||
NS_RUNTIMEABORT(kStaticCtorDtorWarning);
|
||||
} else {
|
||||
NS_WARNING(kStaticCtorDtorWarning);
|
||||
}
|
||||
}
|
||||
}
|
||||
# define ASSERT_ACTIVITY_IS_LEGAL \
|
||||
PR_BEGIN_MACRO \
|
||||
AssertActivityIsLegal(); \
|
||||
PR_END_MACRO
|
||||
#else
|
||||
# define ASSERT_ACTIVITY_IS_LEGAL PR_BEGIN_MACRO PR_END_MACRO
|
||||
#endif // DEBUG
|
||||
|
||||
// These functions are copied from nsprpub/lib/ds/plhash.c, with changes
|
||||
// to the functions not called Default* to free the serialNumberRecord or
|
||||
|
|
Загрузка…
Ссылка в новой задаче