Bug 1496503 - Move MOZ_CrashOOL to Assertions.h. r=froydnj

Ideally, we'd want the function to stay in Assertions.cpp, but that's
only part of MFBT proper, and that doesn't have access to WalkTheStack
like MOZ_CRASH has from being in Assertion.h, when included from Gecko
code. Moving WalkTheStack to mozglue, putting it close together with
MozStackWalk would be prefered, but that causes problems linking MFBT
tests (which don't have access to mozglue), and other things.

Overall, this was too deep a rabbit hole, and moving MOZ_CrashOOL to
Assertions.h is much simpler. Since it's essentially the same as
MOZ_CRASH, except it allows non-literal strings, we can make it inlined,
and leave it to the compiler to drop the filename argument when it's not
used.

Differential Revision: https://phabricator.services.mozilla.com/D11718

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Hommey 2018-11-14 22:35:23 +00:00
Родитель 9cabbb0b47
Коммит b60c5c12e4
2 изменённых файлов: 9 добавлений и 23 удалений

Просмотреть файл

@ -18,21 +18,6 @@ MOZ_BEGIN_EXTERN_C
*/ */
MFBT_DATA const char* gMozCrashReason = nullptr; MFBT_DATA const char* gMozCrashReason = nullptr;
#ifndef DEBUG
MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
MOZ_CrashOOL(int aLine, const char* aReason)
#else
MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason)
#endif
{
#ifdef DEBUG
MOZ_ReportCrash(aReason, aFilename, aLine);
#endif
gMozCrashReason = aReason;
MOZ_REALLY_CRASH(aLine);
}
static char sPrintfCrashReason[sPrintfCrashReasonSize] = {}; static char sPrintfCrashReason[sPrintfCrashReasonSize] = {};
// Accesses to this atomic are not included in web replay recordings, so that // Accesses to this atomic are not included in web replay recordings, so that

Просмотреть файл

@ -301,15 +301,16 @@ MOZ_NoReturn(int aLine)
* to crash-stats and are publicly visible. Firefox data stewards must do data * to crash-stats and are publicly visible. Firefox data stewards must do data
* review on usages of this macro. * review on usages of this macro.
*/ */
#ifndef DEBUG static inline MOZ_COLD MOZ_NORETURN void
MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason)
MOZ_CrashOOL(int aLine, const char* aReason); {
# define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__LINE__, reason) #ifdef DEBUG
#else MOZ_ReportCrash(aReason, aFilename, aLine);
MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE void
MOZ_CrashOOL(const char* aFilename, int aLine, const char* aReason);
# define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__FILE__, __LINE__, reason)
#endif #endif
MOZ_CRASH_ANNOTATE(aReason);
MOZ_REALLY_CRASH(aLine);
}
#define MOZ_CRASH_UNSAFE_OOL(reason) MOZ_CrashOOL(__FILE__, __LINE__, reason)
static const size_t sPrintfMaxArgs = 4; static const size_t sPrintfMaxArgs = 4;
static const size_t sPrintfCrashReasonSize = 1024; static const size_t sPrintfCrashReasonSize = 1024;