1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

AK: Always use our assertion failure method, and add backtrace to it

On platforms that support it, enable using ``<execinfo.h>`` to get
backtrace(3) to dump a backtrace on assertion failure. This should make
debugging things like WebContent crashes in Lagom much easier.
This commit is contained in:
Andrew Kaster 2023-08-30 16:54:33 +02:00 committed by Andrew Kaster
parent 3056ff6b11
commit 4641af7873
3 changed files with 65 additions and 10 deletions

View file

@ -11,16 +11,12 @@
#else
# include <assert.h>
extern "C" __attribute__((noreturn)) void ak_verification_failed(char const*);
# if !defined(NDEBUG) && !defined(WIN32)
# define VERIFY assert
# else
# define __stringify_helper(x) #x
# define __stringify(x) __stringify_helper(x)
# define VERIFY(expr) \
(__builtin_expect(!(expr), 0) \
? ak_verification_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)) \
: (void)0)
# endif
# define __stringify_helper(x) #x
# define __stringify(x) __stringify_helper(x)
# define VERIFY(expr) \
(__builtin_expect(!(expr), 0) \
? ak_verification_failed(#expr " at " __FILE__ ":" __stringify(__LINE__)) \
: (void)0)
# define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */
static constexpr bool TODO = false;
# define TODO() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */