Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 105fd0f

Browse files
committed
VkDebug.hpp: Call abort() after assert(false)
For debug builds this should be a nop, as the assert should call abort(), however for NDEBUG + DCHECK_ALWAYS_ON builds, assert is a nop and we still want to terminate. Bug: b/126329018 Change-Id: I45291be05dfa2cce8ea5623c8af8900049d5e855 Reviewed-on: https://swiftshader-review.googlesource.com/c/25558 Tested-by: Ben Clayton <bclayton@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
1 parent f117291 commit 105fd0f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Vulkan/VkDebug.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef VK_DEBUG_H_
1818
#define VK_DEBUG_H_
1919

20+
#include <stdlib.h>
2021
#include <assert.h>
2122
#include <stdio.h>
2223

@@ -42,14 +43,14 @@ inline void trace() {}
4243
#if defined(SWIFTSHADER_DISABLE_TRACE)
4344
#define FIXME(message, ...) (void(0))
4445
#else
45-
#define FIXME(message, ...) do {vk::trace("fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false)
46+
#define FIXME(message, ...) do {vk::trace("fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
4647
#endif
4748

4849
// A macro to output a function call and its arguments to the debugging log, in case of error.
4950
#if defined(SWIFTSHADER_DISABLE_TRACE)
5051
#define ERR(message, ...) (void(0))
5152
#else
52-
#define ERR(message, ...) do {vk::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false);} while(false)
53+
#define ERR(message, ...) do {vk::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
5354
#endif
5455

5556
// A macro asserting a condition and outputting failures to the debug log
@@ -59,6 +60,7 @@ inline void trace() {}
5960
if(!(expression)) { \
6061
ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
6162
assert(expression); \
63+
abort(); \
6264
} } while(0)
6365
#else
6466
#define ASSERT(expression) (void(0))
@@ -72,6 +74,7 @@ inline void trace() {}
7274
vk::trace(__VA_ARGS__); \
7375
vk::trace("\n"); \
7476
assert(false); \
77+
abort(); \
7578
} while(0)
7679
#else
7780
#define UNIMPLEMENTED(...) FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
@@ -83,6 +86,7 @@ inline void trace() {}
8386
#define UNREACHABLE(value) do { \
8487
ERR("\t! Unreachable case reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value); \
8588
assert(false); \
89+
abort(); \
8690
} while(0)
8791
#else
8892
#define UNREACHABLE(value) ERR("\t! Unreachable reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value)

0 commit comments

Comments
 (0)