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

__builtin_debugtrap viability #13

Closed
jimon opened this issue Nov 1, 2018 · 2 comments
Closed

__builtin_debugtrap viability #13

jimon opened this issue Nov 1, 2018 · 2 comments

Comments

@jimon
Copy link

jimon commented Nov 1, 2018

It seems like all compilers GCC 4.x+, clang 3+?, MSVC 2015+ (except for ARM, where it's MSVC 2018+) do support __builtin_debugtrap and generate, what looks like, a viable asm.

I'm trying https://go.godbolt.org/ with:

#include <stdio.h>
int main()
{
	__builtin_debugtrap();
	printf("hello world\n");
	return 0;
}

And it seems to work in vast majority of cases.

Do you think it is a viable solution to use?

@scottt
Copy link
Owner

scottt commented Nov 2, 2018

@jimon, I just played around with godbolt again and I'm pretty sure of the compiler it supports, __builtin_debugtrap only works on x86-64 clang.

If you see something like call __builtin_debugtrap, or bl __builtin_debugtrap in the output, where the compiler generates a call to an external function instead of the desired breakpoint instruction, you should interpret that as __builtin_debugtrap not working.

@scottt scottt closed this as completed Nov 2, 2018
@jimon
Copy link
Author

jimon commented Nov 2, 2018

@scottt thanks! Yeah, I get now why this was looking to good to be true :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants