mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
dawn: Make ASSERT() breakpoint on all supported platforms.
This moves the implementation of DAWN_BREAKPOINT() in the only file that uses it and completes it for all supported architectures. If in the future breakpoints are needed in other places, it would be possible to expose the function in a header. Add DAWN_PLATFORM_IS macros for all supported architectures so they can be used for implementing Breakpoint() and add support for RISCV. Bug: dawn:1506 Change-Id: Ib1b92c2d0c119cfc1b348fe905029fe366f5ad04 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/98121 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
66fbd2c1ec
commit
af908a3267
@@ -17,6 +17,38 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include "dawn/common/Log.h"
|
||||
#include "dawn/common/Platform.h"
|
||||
|
||||
#if DAWN_COMPILER_IS(CLANG) || DAWN_COMPILER_IS(GCC)
|
||||
void BreakPoint() {
|
||||
#if DAWN_PLATFORM_IS(X86)
|
||||
__asm__ __volatile__("int $3\n\t");
|
||||
#elif DAWN_PLATFORM_IS(ARM32)
|
||||
__asm__ __volatile__("bkpt 0");
|
||||
#elif DAWN_PLATFORM_IS(ARM64)
|
||||
__asm__ __volatile__("brk 0");
|
||||
#elif DAWN_PLATFORM_IS(RISCV)
|
||||
__asm__ __volatile__("ebreak");
|
||||
#elif DAWN_PLATFORM_IS(MIPS)
|
||||
__asm__ __volatile__("break");
|
||||
#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS_(S390X)
|
||||
__asm__ __volatile__(".word 0x0001");
|
||||
#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS_(PPC64)
|
||||
__asm__ __volatile__("twge 2,2");
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif DAWN_COMPILER_IS(MSVC)
|
||||
extern void __cdecl __debugbreak(void);
|
||||
void BreakPoint() {
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
#else
|
||||
#error "Unsupported compiler"
|
||||
#endif
|
||||
|
||||
void HandleAssertionFailure(const char* file,
|
||||
const char* function,
|
||||
@@ -27,6 +59,6 @@ void HandleAssertionFailure(const char* file,
|
||||
#if defined(DAWN_ABORT_ON_ASSERT)
|
||||
abort();
|
||||
#else
|
||||
DAWN_BREAKPOINT();
|
||||
BreakPoint();
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user