mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[common] debug: add DEBUG_UNREACHABLE() macro
This lets us mark code as unreachable and signals the compiler that this is the case with __builtin_unreachable(). We also mark DEBUG_FATAL as unreachable.
This commit is contained in:
parent
be1306f91a
commit
a9241f6710
@ -57,6 +57,14 @@ void printBacktrace(void);
|
|||||||
#define DIRECTORY_SEPARATOR '/'
|
#define DIRECTORY_SEPARATOR '/'
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define DEBUG_UNREACHABLE_MARKER() __builtin_unreachable()
|
||||||
|
#elif __defined__(_MSC_VER)
|
||||||
|
#define DEBUG_UNREACHABLE_MARKER() __assume(0)
|
||||||
|
#else
|
||||||
|
#define DEBUG_UNREACHABLE_MARKER()
|
||||||
|
#endif
|
||||||
|
|
||||||
#define STRIPPATH(s) ( \
|
#define STRIPPATH(s) ( \
|
||||||
sizeof(s) > 2 && (s)[sizeof(s)- 3] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 2 : \
|
sizeof(s) > 2 && (s)[sizeof(s)- 3] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 2 : \
|
||||||
sizeof(s) > 3 && (s)[sizeof(s)- 4] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 3 : \
|
sizeof(s) > 3 && (s)[sizeof(s)- 4] == DIRECTORY_SEPARATOR ? (s) + sizeof(s) - 3 : \
|
||||||
@ -95,6 +103,7 @@ void printBacktrace(void);
|
|||||||
DEBUG_PRINT(DEBUG_LEVEL_FATAL, fmt, ##__VA_ARGS__); \
|
DEBUG_PRINT(DEBUG_LEVEL_FATAL, fmt, ##__VA_ARGS__); \
|
||||||
DEBUG_PRINT_BACKTRACE(); \
|
DEBUG_PRINT_BACKTRACE(); \
|
||||||
abort(); \
|
abort(); \
|
||||||
|
DEBUG_UNREACHABLE_MARKER(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define DEBUG_ASSERT_PRINT(...) DEBUG_ERROR("Assertion failed: %s", #__VA_ARGS__)
|
#define DEBUG_ASSERT_PRINT(...) DEBUG_ERROR("Assertion failed: %s", #__VA_ARGS__)
|
||||||
@ -114,6 +123,8 @@ void printBacktrace(void);
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEBUG_UNREACHABLE() DEBUG_FATAL("Unreachable code reached")
|
||||||
|
|
||||||
#if defined(DEBUG_SPICE) | defined(DEBUG_IVSHMEM)
|
#if defined(DEBUG_SPICE) | defined(DEBUG_IVSHMEM)
|
||||||
#define DEBUG_PROTO(fmt, args...) DEBUG_PRINT("[P]", fmt, ##args)
|
#define DEBUG_PROTO(fmt, args...) DEBUG_PRINT("[P]", fmt, ##args)
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user