digitalmars.D.learn - What is D's "__debugbreak()" equivalent?
- Simon (5/5) Oct 27 2021 Microsofts C++ compiler provides the __debugbreak function, which
- H. S. Teoh (8/13) Oct 27 2021 Why not just:
- Adam D Ruppe (2/3) Oct 27 2021 yeah that's how i do it in dmd too
- Steven Schveighoffer (4/9) Oct 27 2021 SIGINT is not an interrupt, it's a POSIX signal.
- Dennis (21/22) Oct 28 2021 With LDC, you have:
- bauss (18/40) Oct 29 2021 Shouldn't it be this instead, unless D_InlineAsm_X86_64 isn't
- Adam D Ruppe (2/3) Oct 29 2021 just fyi but `int 3;` works just as well in 32 bit as 64
- bauss (3/6) Oct 29 2021 Yeah, that's why I noted that there's also D_InlineAsm_X86 but I
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).
Oct 27 2021
On Wed, Oct 27, 2021 at 04:54:49PM +0000, 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!
Oct 27 2021
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
Oct 27 2021
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
Oct 27 2021
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 } } ```
Oct 28 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: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 } } ```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 } } ```
Oct 29 2021
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
Oct 29 2021
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:Yeah, that's why I noted that there's also D_InlineAsm_X86 but I just didn't bother adding it.} else version(D_InlineAsm_X86_64) {just fyi but `int 3;` works just as well in 32 bit as 64
Oct 29 2021