From b92a75db2aab1adffe08ae0103cafb080f9795e2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 14 Feb 2023 16:21:07 -0500 Subject: Preliminary debugBreak support (#2647) * #include an absolute path didn't work - because paths were taken to always be relative. * Preliminary support for debug break. * Add C++ debug break support. Add details about usage. * Improve debug break test details. * Make HLSL output a comment about no support. * Handle specialize for target assert, without a body if it has spv_instruction/target intrinsic --- prelude/slang-cpp-prelude.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'prelude') diff --git a/prelude/slang-cpp-prelude.h b/prelude/slang-cpp-prelude.h index b2a8dd6ac..84a61f929 100644 --- a/prelude/slang-cpp-prelude.h +++ b/prelude/slang-cpp-prelude.h @@ -207,6 +207,9 @@ Any platforms not detected by the above logic are now now explicitly zeroed out. // GCC Specific #if SLANG_GCC_FAMILY # define SLANG_ALIGN_OF(T) __alignof__(T) + +# define SLANG_BREAKPOINT(id) __builtin_trap() + // Use this macro instead of offsetof, because gcc produces warning if offsetof is used on a // non POD type, even though it produces the correct result # define SLANG_OFFSET_OF(T, ELEMENT) (size_t(&((T*)1)->ELEMENT) - 1) @@ -215,6 +218,9 @@ Any platforms not detected by the above logic are now now explicitly zeroed out. // Microsoft VC specific #if SLANG_VC # define SLANG_ALIGN_OF(T) __alignof(T) + +# define SLANG_BREAKPOINT(id) __debugbreak(); + #endif // SLANG_VC // Default impls @@ -223,6 +229,11 @@ Any platforms not detected by the above logic are now now explicitly zeroed out. # define SLANG_OFFSET_OF(X, Y) offsetof(X, Y) #endif +#ifndef SLANG_BREAKPOINT +// Make it crash with a write to 0! +# define SLANG_BREAKPOINT(id) (*((int*)0) = int(id)); +#endif + // If slang.h has been included we don't need any of these definitions #ifndef SLANG_H -- cgit v1.2.3