Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand RE_BREAKPOINT macro on ARM64 #961

Merged
merged 3 commits into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion include/re_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ typedef SSIZE_T ssize_t;
/** Defines a soft breakpoint */
#if (defined(__i386__) || defined(__x86_64__))
#define RE_BREAKPOINT __asm__("int $0x03")
#else
#elif defined(__has_builtin)
#if __has_builtin(__builtin_debugtrap)
#define RE_BREAKPOINT __builtin_debugtrap()
Copy link
Member

@sreimers sreimers Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this more generic with:

#elif defined(__has_builtin) && __has_builtin(__builtin_debugtrap)
#define RE_BREAKPOINT __builtin_debugtrap()

Since __builtin_debugtrap() is clang only I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's much better. I've changed it accordingly.

Copy link
Member

@sreimers sreimers Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like MSVC does not like this, can you try:

#if (defined(__i386__) || defined(__x86_64__))
#define RE_BREAKPOINT __asm__("int $0x03")
#elif defined(__has_builtin) 
#if __has_builtin(__builtin_debugtrap)
#define RE_BREAKPOINT __builtin_debugtrap()
#endif
#endif

#ifndef RE_BREAKPOINT
#define RE_BREAKPOINT
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have an eye on the validation run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

#endif
#endif

#ifndef RE_BREAKPOINT
#define RE_BREAKPOINT
#endif

Expand Down
Loading