Re: What is D's "__debugbreak()" equivalent?

2021-10-29 Thread bauss via Digitalmars-d-learn

On Friday, 29 October 2021 at 11:36:13 UTC, Adam D Ruppe wrote:

On Friday, 29 October 2021 at 09:32:07 UTC, bauss wrote:

} else version(D_InlineAsm_X86_64) {


just fyi but `int 3;` works just as well in 32 bit as 64


Yeah, that's why I noted that there's also D_InlineAsm_X86 but I 
just didn't bother adding it.


Re: What is D's "__debugbreak()" equivalent?

2021-10-29 Thread Adam D Ruppe via Digitalmars-d-learn

On Friday, 29 October 2021 at 09:32:07 UTC, bauss wrote:

} else version(D_InlineAsm_X86_64) {


just fyi but `int 3;` works just as well in 32 bit as 64


Re: What is D's "__debugbreak()" equivalent?

2021-10-29 Thread bauss via Digitalmars-d-learn

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
}
}
```


Re: What is D's "__debugbreak()" equivalent?

2021-10-28 Thread Dennis via Digitalmars-d-learn

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
}
}
```


Re: What is D's "__debugbreak()" equivalent?

2021-10-27 Thread Adam D Ruppe via Digitalmars-d-learn

On Wednesday, 27 October 2021 at 17:07:31 UTC, H. S. Teoh wrote:

asm { int 3; }


yeah that's how i do it in dmd too


Re: What is D's "__debugbreak()" equivalent?

2021-10-27 Thread Steven Schveighoffer via Digitalmars-d-learn

On 10/27/21 12:54 PM, Simon wrote:
Microsofts C++ compiler provides the __debugbreak function, which on x86 
emits interrupt 3, which will cause the debugger to halt. What is the 
equivalent in D? I tried using raise(SIGINT) from core.stdc.signal, but 
that just closes the debugger (I thought that was the same, seems like I 
was wrong).


SIGINT is not an interrupt, it's a POSIX signal.

Inline asm maybe?  https://dlang.org/spec/iasm.html

-Steve


Re: What is D's "__debugbreak()" equivalent?

2021-10-27 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 27, 2021 at 04:54:49PM +, Simon via Digitalmars-d-learn wrote:
> Microsofts C++ compiler provides the __debugbreak function, which on
> x86 emits interrupt 3, which will cause the debugger to halt. What is
> the equivalent in D? I tried using raise(SIGINT) from
> core.stdc.signal, but that just closes the debugger (I thought that
> was the same, seems like I was wrong).

Why not just:

asm { int 3; }

?

Just tested in gdb, it worked.


T

-- 
MASM = Mana Ada Sistem, Man!


What is D's "__debugbreak()" equivalent?

2021-10-27 Thread Simon via Digitalmars-d-learn
Microsofts C++ compiler provides the __debugbreak function, which 
on x86 emits interrupt 3, which will cause the debugger to halt. 
What is the equivalent in D? I tried using raise(SIGINT) from 
core.stdc.signal, but that just closes the debugger (I thought 
that was the same, seems like I was wrong).