Skip to content

Instantly share code, notes, and snippets.

@aras-p
Created December 3, 2013 08:23
Show Gist options
  • Save aras-p/7765792 to your computer and use it in GitHub Desktop.
Save aras-p/7765792 to your computer and use it in GitHub Desktop.
Assert break implementations
#if defined(__ppc__)
#define DEBUG_BREAK __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" : : : "memory","r0","r3","r4" )
#elif UNITY_OSX
#if defined(__clang__)
#define DEBUG_BREAK if (IsDebuggerPresent ()) __builtin_trap ()
#else
#define DEBUG_BREAK if (IsDebuggerPresent ()) __asm { int 3 }
#endif
#elif UNITY_WIN
#define DEBUG_BREAK if (IsDebuggerPresent ()) __debugbreak()
#elif (UNITY_IPHONE && !TARGET_IPHONE_SIMULATOR)
#define DEBUG_BREAK __asm__ __volatile__ ( "bkpt #0\n\t bx lr\n\t" : : : )
#elif UNITY_ANDROID || UNITY_BB10
#define DEBUG_BREAK __builtin_trap()
#elif UNITY_LINUX
#define DEBUG_BREAK if (IsDebuggerPresent ()) raise(SIGTRAP)
#else
/* a bunch of NDA platforms that I've removed /*
#endif
@djg
Copy link

djg commented Dec 3, 2013

I knew there was a reason I disliked PPC

@bionicbeagle
Copy link

You should maybe put a do { ... } while(false) around those conditionals, or you can get unexpected results if someone should use them in an if...else statement

@aras-p
Copy link
Author

aras-p commented Dec 3, 2013

@bionicbeagle: sure, and we do have a do..while around most of these macros, but not around this one. Maybe someday someone will fix it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment