What is D's "__debugbreak()" equivalent?
bauss
jj_1337 at live.dk
Fri Oct 29 09:32:07 UTC 2021
On Thursday, 28 October 2021 at 09:54:44 UTC, Dennis wrote:
> On Wednesday, 27 October 2021 at 16:54:49 UTC, Simon wrote:
>> What is the equivalent in D?
>
> With LDC, you have:
>
> ```D
> import ldc.intrinsics: llvm_debugtrap;
> ```
>
> Combining that with previous answers, you can make something
> like this:
> ```D
> void debugbreak() nothrow @nogc @trusted {
> version(D_InlineAsm_X86_64) {
> asm nothrow @nogc {
> int 3;
> }
> } else version(LDC) {
> import ldc.intrinsics: llvm_debugtrap;
> llvm_debugtrap();
> } else {
> assert(0); // No `breakPoint` for this compiler configuration
> }
> }
> ```
Shouldn't it be this instead, unless D_InlineAsm_X86_64 isn't
available for ldc?
There's also D_InlineAsm_X86 btw.
```D
void debugbreak() nothrow @nogc @trusted {
version(LDC) {
import ldc.intrinsics: llvm_debugtrap;
llvm_debugtrap();
} else version(D_InlineAsm_X86_64) {
asm nothrow @nogc {
int 3;
}
} else {
assert(0); // No `breakPoint` for this compiler configuration
}
}
```
More information about the Digitalmars-d-learn
mailing list