Re: Using Windbg to debug D applications and unittests
On Saturday, 4 March 2023 at 19:19:26 UTC, Chris Piker wrote: On Monday, 27 February 2023 at 12:09:50 UTC, Basile B. wrote: At least this is what is done for the Dexed GDB widget, so that gdb breaks automatically when an Error or an Exception is new'd (https://gitlab.com/basile.b/dexed/-/blob/master/src/u_gdb.pas#L2072). Glad you mentioned Dexed. I Had been meaning to try it out but forgot about it. I just downloaded the deb and will give it a go. Thanks! The GDB widget wont work on windows I think. The point of my first answer was just to show you how to automatically break when something is thrown.
Re: Using Windbg to debug D applications and unittests
On Monday, 27 February 2023 at 12:09:50 UTC, Basile B. wrote: At least this is what is done for the Dexed GDB widget, so that gdb breaks automatically when an Error or an Exception is new'd (https://gitlab.com/basile.b/dexed/-/blob/master/src/u_gdb.pas#L2072). Glad you mentioned Dexed. I Had been meaning to try it out but forgot about it. I just downloaded the deb and will give it a go. Thanks!
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 15:55:33 UTC, solidstate1991 wrote: I had a lot of trouble trying to get Visual Studio to catch handled exceptions, which would have been mandatory for debugging unittests, but I either forgot how to do it, or something have changed in either the newer versions of VS or the D compilers I use (LDC, DMD). [...] You must break on `_d_throwc` (windows), `_d_throwdwarf` (linux), `_d_throw_exception` (ldc). They are defined in - https://github.com/dlang/dmd/blob/master/druntime/src/rt/deh.d - https://github.com/dlang/dmd/blob/master/druntime/src/rt/deh_win32.d - https://github.com/dlang/dmd/blob/master/druntime/src/rt/deh_win64_posix.d At least this is what is done for the Dexed GDB widget, so that gdb breaks automatically when an Error or an Exception is new'd (https://gitlab.com/basile.b/dexed/-/blob/master/src/u_gdb.pas#L2072).
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 19:55:27 UTC, evilrat wrote: Nothing happens without a reason, check your project settings and make sure that for debugging you have correct paths, command, and arguments. Even with no debug info and no project you can just drop an executable to an empty VS window and start debugging it, at the very least it can show disassembly. If there is .pdb files with debug info next to your executable you can just drag and drop your D source files and then add breakpoints in that source files and it will work. Well, it was that. I'll try to get GDB running, since I got so fed up with MS's own debuggers.
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 19:31:10 UTC, solidstate1991 wrote: Well, VS turned to be even less cooperative than before. Now it only loads and runs a specific old version of an EXE file. I'm asking around for other debuggers, I'm definitely moving to another. Nothing happens without a reason, check your project settings and make sure that for debugging you have correct paths, command, and arguments. Even with no debug info and no project you can just drop an executable to an empty VS window and start debugging it, at the very least it can show disassembly. If there is .pdb files with debug info next to your executable you can just drag and drop your D source files and then add breakpoints in that source files and it will work.
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 18:08:57 UTC, evilrat wrote: Turn on exception settings panel in top menu bar: Debug->Windows->Exceptions Settings (Crtl+Alt+E) My settings for D is full "D exceptions", under Win32 check "D Exception", or just click "Restore to default settings" in there on top of that panel. Well, VS turned to be even less cooperative than before. Now it only loads and runs a specific old version of an EXE file. I'm asking around for other debuggers, I'm definitely moving to another.
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 16:58:44 UTC, solidstate1991 wrote: I used to use Visual Studio, but I forgot how to set it up properly to break on handled throws. Now it doesn't do anything if throws are handled in any fashion, and I can't find an option to change it (it was removed maybe?). Turn on exception settings panel in top menu bar: Debug->Windows->Exceptions Settings (Crtl+Alt+E) My settings for D is full "D exceptions", under Win32 check "D Exception", or just click "Restore to default settings" in there on top of that panel.
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 16:22:49 UTC, evilrat wrote: VisualD for Visual Studio provides some extra help with displaying your data in debugger and on Windows is the best you can get for D. You can use Visual Studio Code + code-d to debug, but it is not as good as full Visual Studio counterpart. Anyway you can use LDC with -gc flag to improve this situation a bit as it will mimic C++ debug info that is more compatible with said debuggers than D one. I used to use Visual Studio, but I forgot how to set it up properly to break on handled throws. Now it doesn't do anything if throws are handled in any fashion, and I can't find an option to change it (it was removed maybe?).
Re: Using Windbg to debug D applications and unittests
On Saturday, 25 February 2023 at 15:55:33 UTC, solidstate1991 wrote: I had a lot of trouble trying to get Visual Studio to catch handled exceptions VisualD for Visual Studio provides some extra help with displaying your data in debugger and on Windows is the best you can get for D. You can use Visual Studio Code + code-d to debug, but it is not as good as full Visual Studio counterpart. Anyway you can use LDC with -gc flag to improve this situation a bit as it will mimic C++ debug info that is more compatible with said debuggers than D one.