debug.h 718 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright 2010-2012 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #ifndef __BX_DEBUG_H__
  6. #define __BX_DEBUG_H__
  7. #include "bx.h"
  8. namespace bx
  9. {
  10. inline void debugBreak()
  11. {
  12. #if BX_COMPILER_MSVC
  13. __debugbreak();
  14. #elif BX_CPU_ARM
  15. asm("bkpt 0");
  16. #elif !BX_PLATFORM_NACL && BX_CPU_X86 && (BX_COMPILER_GCC || BX_COMPILER_CLANG)
  17. // NaCl doesn't like int 3:
  18. // NativeClient: NaCl module load failed: Validation failure. File violates Native Client safety rules.
  19. __asm__ ("int $3");
  20. #else // cross platform implementation
  21. int* int3 = (int*)3L;
  22. *int3 = 3;
  23. #endif // BX
  24. }
  25. } // namespace bx
  26. #endif // __BX_DEBUG_H__