Bug 1814600 - Annotate abort calls as __attribute__((nomerge)) to get clearer line number when crashing on assertion failure. r=gsvelto,yjuglaret

Differential Revision: https://phabricator.services.mozilla.com/D168960
This commit is contained in:
Paul Adenot 2023-11-10 13:54:54 +00:00
Родитель 6a82880fac
Коммит 643afe2840
2 изменённых файлов: 18 добавлений и 2 удалений

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

@ -210,13 +210,13 @@ MOZ_NoReturn(int aLine) {
# define MOZ_REALLY_CRASH(line) \
do { \
*((volatile int*)MOZ_CRASH_WRITE_ADDR) = line; /* NOLINT */ \
::abort(); \
MOZ_NOMERGE ::abort(); \
} while (false)
# else
# define MOZ_REALLY_CRASH(line) \
do { \
*((volatile int*)MOZ_CRASH_WRITE_ADDR) = line; /* NOLINT */ \
abort(); \
MOZ_NOMERGE abort(); \
} while (false)
# endif
#endif

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

@ -88,6 +88,22 @@
# endif
#endif
/**
* Per clang's documentation:
*
* If a statement is marked nomerge and contains call expressions, those call
* expressions inside the statement will not be merged during optimization. This
* attribute can be used to prevent the optimizer from obscuring the source
* location of certain calls.
*
* This is useful to have clearer information on assertion failures.
*/
#if defined(__clang__) && __has_attribute(nomerge)
# define MOZ_NOMERGE __attribute__((nomerge))
#else
# define MOZ_NOMERGE
#endif
/*
* MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
* method decorated with it must never be inlined, even if the compiler would