This is an archive of the discontinued LLVM Phabricator instance.

Add an LLVM_BUILTIN_DEBUGTRAP macro.
ClosedPublic

Authored by rudkx on Mar 9 2016, 11:11 AM.

Details

Summary

This provides a macro that expands to builtin_debugtrap() for clang,
and
debugbreak() for MSVC.

It intentionally expands to nothing for compilers that do not support a
similar mechanism that halts the debugger without otherwise crashing the
process.

Diff Detail

Repository
rL LLVM

Event Timeline

rudkx updated this revision to Diff 50164.Mar 9 2016, 11:11 AM
rudkx retitled this revision from to Add an LLVM_BUILTIN_DEBUGTRAP macro..
rudkx updated this object.
rudkx added a reviewer: dblaikie.
rudkx added a subscriber: llvm-commits.
echristo accepted this revision.Mar 9 2016, 3:08 PM
echristo added a reviewer: echristo.
echristo added a subscriber: echristo.

Sure. That we have the same for MS for LLVM_BUILTIN_TRAP and LLVM_BUILTIN_DEBUGTRAP is a bit weird, but we'll go with it.

-eric

This revision is now accepted and ready to land.Mar 9 2016, 3:08 PM
rudkx added a comment.Mar 9 2016, 4:05 PM

Thanks for taking a look!

I agree that it's a bit odd that both do the same for MSVC, but it seems like the right fix for that issue is to change LLVM_BUILTIN_TRAP to fail differently than using __debugbreak (either RaiseException which appears to be deliberately avoided, or inline asm with ud2 perhaps?).

This revision was automatically updated to reflect the committed changes.

No disagreements. Just commenting. :)