mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #2046 from PeterCrozier/trap
Extend YS_DEBUGTRAP to MacOS.
This commit is contained in:
commit
026fed3135
|
@ -86,7 +86,7 @@ YOSYS_NAMESPACE_BEGIN
|
||||||
# endif
|
# endif
|
||||||
# if __has_builtin(__builtin_debugtrap)
|
# if __has_builtin(__builtin_debugtrap)
|
||||||
# define YS_DEBUGTRAP __builtin_debugtrap()
|
# define YS_DEBUGTRAP __builtin_debugtrap()
|
||||||
# elif defined(__unix__)
|
# elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
# define YS_DEBUGTRAP raise(SIGTRAP)
|
# define YS_DEBUGTRAP raise(SIGTRAP)
|
||||||
# else
|
# else
|
||||||
# define YS_DEBUGTRAP do {} while(0)
|
# define YS_DEBUGTRAP do {} while(0)
|
||||||
|
@ -97,11 +97,11 @@ YOSYS_NAMESPACE_BEGIN
|
||||||
// if a debugger is attached, and does nothing otherwise.
|
// if a debugger is attached, and does nothing otherwise.
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# define YS_DEBUGTRAP_IF_DEBUGGING do { if (IsDebuggerPresent()) DebugBreak(); } while(0)
|
# define YS_DEBUGTRAP_IF_DEBUGGING do { if (IsDebuggerPresent()) DebugBreak(); } while(0)
|
||||||
#elif defined(__unix__)
|
# elif defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
// There is no reliable (or portable) *nix equivalent of IsDebuggerPresent(). However,
|
// There is no reliable (or portable) *nix equivalent of IsDebuggerPresent(). However,
|
||||||
// debuggers will stop when SIGTRAP is raised, even if the action is set to ignore.
|
// debuggers will stop when SIGTRAP is raised, even if the action is set to ignore.
|
||||||
# define YS_DEBUGTRAP_IF_DEBUGGING do { \
|
# define YS_DEBUGTRAP_IF_DEBUGGING do { \
|
||||||
sighandler_t old = signal(SIGTRAP, SIG_IGN); raise(SIGTRAP); signal(SIGTRAP, old); \
|
auto old = signal(SIGTRAP, SIG_IGN); raise(SIGTRAP); signal(SIGTRAP, old); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#else
|
#else
|
||||||
# define YS_DEBUGTRAP_IF_DEBUGGING do {} while(0)
|
# define YS_DEBUGTRAP_IF_DEBUGGING do {} while(0)
|
||||||
|
|
Loading…
Reference in New Issue