Enable Int3 as d_debugbreak

Change Int3 from a no-op to a platform-specific trap to debugger.

Requested by btb: https://github.com/dxx-rebirth/dxx-rebirth/pull/18
This commit is contained in:
Kp 2014-12-07 23:43:51 +00:00
parent 6798c8410b
commit 33c118f999

View file

@ -23,8 +23,7 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
* *
*/ */
#ifndef _ERROR_H #pragma once
#define _ERROR_H
#include <stdio.h> #include <stdio.h>
#include "dxxsconf.h" #include "dxxsconf.h"
@ -51,21 +50,42 @@ void Error_puts(const char *func, unsigned line, const char *str) __noreturn __a
void Error(const char *func, unsigned line, const char *fmt,...) __noreturn __attribute_format_printf(3, 4); //exit with error code=1, print message void Error(const char *func, unsigned line, const char *fmt,...) __noreturn __attribute_format_printf(3, 4); //exit with error code=1, print message
#define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__func__, __LINE__),(F),##__VA_ARGS__) #define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__func__, __LINE__),(F),##__VA_ARGS__)
#define Assert assert #define Assert assert
/* Compatibility with x86-specific name */
#define Int3() d_debugbreak()
#ifndef d_debugbreak
#ifndef NDEBUG //macros for debugging #ifndef NDEBUG //macros for debugging
# if defined __unix__
/* for raise */
# include <signal.h>
# endif
#endif
# if defined(__APPLE__) || defined(macintosh) /* Allow macro override */
extern void Debugger(void); // Avoids some name clashes static inline void d_debugbreak()
# define Int3 Debugger {
# else /* If NDEBUG, expand to nothing */
# define Int3() ((void)0) #ifndef NDEBUG
# endif // Macintosh
#else //macros for real game #if defined __clang__
/* Must be first, since clang also defines __GNUC__ */
//Changed Assert and Int3 because I couldn't get the macros to compile -KRB __builtin_debugtrap();
#define Int3() ((void)0) #elif defined __GNUC__
# if defined(__i386__) || defined(__amd64__)
__asm__ __volatile__("int3" ::: "cc", "memory");
# elif defined __unix__
raise(SIGTRAP);
# else
/* May terminate execution */
__builtin_trap();
# endif
#elif defined _MSC_VER
__debugbreak();
#endif #endif
#endif
}
#endif #endif
#endif /* _ERROR_H */ #endif