digitalmars.D.learn - How to debug and watch globals in windows debugger?
- ryuukk_ (7/7) Mar 26 2023 I tried to look around, what ever i try, nothing works
- ryuukk_ (11/11) Mar 27 2023 Anyone got an idea?
- ryuukk_ (6/6) Mar 27 2023 If anyone know what is the problem exactly, then please speak up,
- Richard (Rikki) Andrew Cattermole (1/1) Mar 27 2023 The person you need is WebFreak and they are not online right now.
- ryuukk_ (14/16) Mar 27 2023 On IRC earlier today
- ryuukk_ (14/14) Mar 27 2023 To clarify, i tested both dmd/ldc, they both doesn't work on
- ryuukk_ (5/5) Mar 27 2023 Two questions for the D team:
- ryuukk_ (9/9) Mar 27 2023 Fore more clarity, all syntax i have tried:
- ryuukk_ (3/3) Mar 27 2023 I've now waste an entire day trying to figure out what's wrong,
- WebFreak001 (41/44) Mar 28 2023 sorry to hear that, I haven't really been looking to much into
- Richard (Rikki) Andrew Cattermole (3/3) Mar 27 2023 Have you tried installing mago?
- Richard (Rikki) Andrew Cattermole (3/8) Mar 27 2023 Binaries are available in the installer of VisualD, they can be
- ryuukk_ (7/15) Mar 27 2023 what is: "Manual Installation of the Concord extension in VS
- Richard (Rikki) Andrew Cattermole (4/8) Mar 27 2023 Look in $1..\Packages\Debugger
- ryuukk_ (10/13) Mar 27 2023 I did not try mago, but it shouldn't be needed as pdb is
- Richard (Rikki) Andrew Cattermole (8/20) Mar 27 2023 Agreed, I would expect globals (including TLS) to work without a
- WebFreak001 (10/31) Mar 28 2023 I have looked into trying to get mago to work so far, but didn't
- ryuukk_ (10/31) Mar 28 2023 It is a workaround, it should work already out of the box with
- ryuukk_ (2/37) Mar 28 2023 Nevermind the godbolt link
- ryuukk_ (2/2) Mar 28 2023 I opened an issue on microsoft's github, let's see what they have
- ryuukk_ (44/44) Mar 28 2023 C program:
- ryuukk_ (6/6) Mar 28 2023 Ready to test folder:
- ryuukk_ (14/20) Mar 28 2023 I noticed in the pdb, there are no mention of the ``app_d`` module
- ryuukk_ (13/13) Mar 28 2023 On linux everything works properly out of the box, i tested with
- Steven Schveighoffer (17/20) Mar 29 2023 I'm not one to use a debugger often, but it is very helpful for many
- ryuukk_ (35/60) Mar 29 2023 I only use windows because i'm making a game and i have to test
- Richard (Rikki) Andrew Cattermole (5/6) Mar 29 2023 Making noise about problems in D.learn is not the place to do it, I
- Salih Dincer (5/9) Mar 29 2023 I agree with you because it's such a simple problem and it's
I tried to look around, what ever i try, nothing works There is a mention of "fully qualified" here: https://forum.dlang.org/post/peb1jj$tr$1 digitalmars.com But what does that mean? I tried this: ![screenshot](https://i.imgur.com/JZooIic.pngg) But it doesn't work
Mar 26 2023
Anyone got an idea? Executable built with : ``dmd -g -debug`` on windows On Visual Studio with the visuald addon i can debug the executable and inspect the globals On VSCode i can debug the executable and inspect locals, but not globals What does visuald does under the hood to be able to inspect globals? No, i don't want to use the slow and bloated multi gigabytes Visual Studio just to inspect a variable I'm starting to loose hope
Mar 27 2023
If anyone know what is the problem exactly, then please speak up, this problem needs to be reported to the right place fixed so it can be fixed, all languages i tested don't have this issue (c, rust, zig, odin) D is not a toy language, let's take this issue seriously, shall we? or is it?..
Mar 27 2023
The person you need is WebFreak and they are not online right now.
Mar 27 2023
On Monday, 27 March 2023 at 19:31:24 UTC, Richard (Rikki) Andrew Cattermole wrote:The person you need is WebFreak and they are not online right now.On IRC earlier today ``` [6:43:29 pm] <WebFreak[m]> nope, I haven't gotten globals to work in debugger before [6:43:33 pm] <WebFreak[m]> I don't think they are emitted [6:44:02 pm] <WebFreak[m]> on linux I think it might work with CodeLLDB, depending on what compiler you used to compile the executable ``` I asked about mode details (who didn't emit what?) and where to report the issue, so far question left unanswered My list of "gripes and wishes" grows larger and larger everyday
Mar 27 2023
To clarify, i tested both dmd/ldc, they both doesn't work on windows To clarify even more: I am a mere user who wants to debug its program on windows using vscode's debugger wich uses msvc I can debug a c/rust/zig executable without issue and see globals The problem only happens with dmd/ldc Is it broken by design for decade and nothing should and could be done about it? Is the only solution to inspect a global variable is to use visual studio and install visuald plugin? If i tell you what i'm trying to debug i bet you'll laugh (loading dll compiled using dmd), but that's a story for another day, 1 frustration a day is plenty
Mar 27 2023
Two questions for the D team: Does globals have a special syntax? as you can see above i also tried the mangled name inside the PDB (using hex viewer https://github.com/WerWolv/ImHex) Walter, how do you debug your programs written in D?
Mar 27 2023
Fore more clarity, all syntax i have tried: ``` type_to_tiledef kshared.defs.type_to_tiledef _D7kshared4defs15type_to_tiledef kshared:defs:type_to_tiledef kshared::defs::type_to_tiledef kshared->defs->type_to_tiledef ```
Mar 27 2023
I've now waste an entire day trying to figure out what's wrong, perhaps trusted D for my projects was a bad idea, i now look like a fool
Mar 27 2023
On Tuesday, 28 March 2023 at 01:04:19 UTC, ryuukk_ wrote:I've now waste an entire day trying to figure out what's wrong, perhaps trusted D for my projects was a bad idea, i now look like a foolsorry to hear that, I haven't really been looking to much into the debugging problems here yet. My extension mostly just integrates the existing tools here (Visual Studio Debugger / GDB + whatever is emitted in the pdb files) What I was talking about is that it's possible dmd didn't emit the globals information in any way that the GDB / Visual Studio Debugger understand right now. I'm not a debugger expert myself, looking into this is probably something that would take a bit of research about the DWARF / PDB formats and checking how DMD / LDC emit it. I think you can probably get some great help here from Martin Kinkelin. (I think the windows and linux debug info emission works differently / are different modules, so there might be discrepancies here) I can help you point towards where to check and who to ask here, but I don't think I can help you actually solve this issue right now. I haven't really been focusing too much on the debugger, especially not on the implementation of debug symbol emissions and the debugger itself. I have only been adding a few scripts here to get the best out the debugger that we currently have. More things require more investment into actually improving the project. I'm quite glad about your contributions you have been doing so far and I think the issues you are opening are good to find stuff to work on. (the DCD PRs you have open right now are very nice and appreciated, but need a bit of work still done to them before they can be merged. I have reviewed them, but didn't have time to actually make the changes and test them yet - if you want to get these changes in faster you can also implement or reply to my review comments) Further people you could ask about here: - Iain Buclaw (GDC developer), can probably tell you about what gcc does here and possibly has insights into the D backend code that generates debug info - Martin Kinkelin (LDC developer), ditto - Luís Ferreira (ljmf00 on discord) - has been working on LLDB for SAoC and implementing a bunch of things - if things are missing on the debugger side, he can probably help you with LLDB implementations (you probably only need to go this far if we want to add support for new custom data structure things that D has - most things can already be realized with the debug symbols)
Mar 28 2023
Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.
Mar 27 2023
On 28/03/2023 2:06 PM, Richard (Rikki) Andrew Cattermole wrote:Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.Binaries are available in the installer of VisualD, they can be extracted by 7zip (I've checked everything is in there).
Mar 27 2023
On Tuesday, 28 March 2023 at 01:21:02 UTC, Richard (Rikki) Andrew Cattermole wrote:On 28/03/2023 2:06 PM, Richard (Rikki) Andrew Cattermole wrote:what is: "Manual Installation of the Concord extension in VS Code", i can't find it anywhere what are: "MagoNatCC.dll, MagoNatCC.vsdconfig and .vsdbg-config.json"? i can only find: "MagoNatDE.dll" So far no buenoHave you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.Binaries are available in the installer of VisualD, they can be extracted by 7zip (I've checked everything is in there).
Mar 27 2023
On 28/03/2023 2:33 PM, ryuukk_ wrote:what is: "Manual Installation of the Concord extension in VS Code", i can't find it anywhereExtension is mago, but don't forget: cpptools-1.4.0 or later needed.what are: "MagoNatCC.dll, MagoNatCC.vsdconfig and .vsdbg-config.json"? i can only find: "MagoNatDE.dll"Look in $1..\Packages\Debugger https://github.com/rainers/mago/blob/0b2ce787114a71b4088ebf14eb922c5b3c46f5be/EED/MagoNatCC/.vsdbg-config.json#L4
Mar 27 2023
On Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.I did not try mago, but it shouldn't be needed as pdb is universally understood by tools It also doesn't work with remedybg for example: https://i.imgur.com/P1Ph3Jh.png While i will try with mago, it shouldn't satisfy us, workarounds are temporary solutions This issue being fixed should be the goal, i opened a ticket for it: https://issues.dlang.org/show_bug.cgi?id=23811
Mar 27 2023
On 28/03/2023 2:25 PM, ryuukk_ wrote:On Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Agreed, I would expect globals (including TLS) to work without a debugger extension.Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.I did not try mago, but it shouldn't be needed as pdb is universally understood by toolsWhile i will try with mago, it shouldn't satisfy us, workarounds are temporary solutionsIts not a workaround, mago (in this case) is an extension to MS's debugger framework which provides D specific features, you'd want it regardless if you work with the debugger with D a lot. Debuggers typically have language specific features to make them easier to work with. Jan should be shipping this I think.
Mar 27 2023
On Tuesday, 28 March 2023 at 04:22:24 UTC, Richard (Rikki) Andrew Cattermole wrote:On 28/03/2023 2:25 PM, ryuukk_ wrote:I have looked into trying to get mago to work so far, but didn't have any working state yet, which is why that is currently stuck. (+ I don't personally use Windows for development, so I don't have much usage experience for code-d / debugging integration, outside when I actively develop Windows fixes on it) If you get mago to work with vscode feel free to tell me how you did it so we can add a debug configuration preset for code-d users / other users who want to manually use it.On Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Agreed, I would expect globals (including TLS) to work without a debugger extension.Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.I did not try mago, but it shouldn't be needed as pdb is universally understood by toolsWhile i will try with mago, it shouldn't satisfy us, workarounds are temporary solutionsIts not a workaround, mago (in this case) is an extension to MS's debugger framework which provides D specific features, you'd want it regardless if you work with the debugger with D a lot. Debuggers typically have language specific features to make them easier to work with. Jan should be shipping this I think.
Mar 28 2023
On Tuesday, 28 March 2023 at 04:22:24 UTC, Richard (Rikki) Andrew Cattermole wrote:On 28/03/2023 2:25 PM, ryuukk_ wrote:It is a workaround, it should work already out of the box with existing tools It works for other languages, why not for D? problem Check here: https://godbolt.org/z/nYGfMTqYY int global; on C++ has !dbg int global; on D doesn't have !dbg This is a bug in D, therefore it should be fixedOn Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Agreed, I would expect globals (including TLS) to work without a debugger extension.Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.I did not try mago, but it shouldn't be needed as pdb is universally understood by toolsWhile i will try with mago, it shouldn't satisfy us, workarounds are temporary solutionsIts not a workaround, mago (in this case) is an extension to MS's debugger framework which provides D specific features, you'd want it regardless if you work with the debugger with D a lot. Debuggers typically have language specific features to make them easier to work with. Jan should be shipping this I think.
Mar 28 2023
On Tuesday, 28 March 2023 at 11:07:02 UTC, ryuukk_ wrote:On Tuesday, 28 March 2023 at 04:22:24 UTC, Richard (Rikki) Andrew Cattermole wrote:Nevermind the godbolt linkOn 28/03/2023 2:25 PM, ryuukk_ wrote:It is a workaround, it should work already out of the box with existing tools It works for other languages, why not for D? problem Check here: https://godbolt.org/z/nYGfMTqYY int global; on C++ has !dbg int global; on D doesn't have !dbg This is a bug in D, therefore it should be fixedOn Tuesday, 28 March 2023 at 01:06:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Agreed, I would expect globals (including TLS) to work without a debugger extension.Have you tried installing mago? https://github.com/rainers/mago There are instructions for vs-code in README.I did not try mago, but it shouldn't be needed as pdb is universally understood by toolsWhile i will try with mago, it shouldn't satisfy us, workarounds are temporary solutionsIts not a workaround, mago (in this case) is an extension to MS's debugger framework which provides D specific features, you'd want it regardless if you work with the debugger with D a lot. Debuggers typically have language specific features to make them easier to work with. Jan should be shipping this I think.
Mar 28 2023
I opened an issue on microsoft's github, let's see what they have to say: https://github.com/microsoft/vscode-cpptools/issues/10751
Mar 28 2023
C program: ```C int notice_me_global = -1; void main() { notice_me_global = -5; } ``` ``cl app_c.c /DEBUG /Zi /EHsc /std:c11 /link /DEBUG /out:app_c.exe`` ``llvm-pdbutil.exe dump --globals app_c.pdb > dump_c`` ``` 688476 | S_GDATA32 [size = 32] `notice_me_global` type = 0x0074 (int), addr = 0003:0040 ``` D program: ```D __gshared int notice_me_global = -1; extern(C) void main() { notice_me_global = 5; int* a; *a = 1; } ``` ``dmd -betterC -m64 -g -debug app_d.d`` ``llvm-pdbutil.exe dump --globals app_d.pdb > dump_d`` ``` 0 | S_GDATA32 [size = 40] `app_d.notice_me_global` type = 0x0074 (int), addr = 0003:3504 ``` Open question: Why is it: For D: ``0 |`` For C: ``688476 |`` Potential issue: Debugger doesn't understand: the ``.`` in the name ``app_d.notice_me_global``, mangled name also doesn't work That's the info i provided in the microsoft tracker, maybe some people here can notice something else that's wrong dump_c: https://gist.github.com/ryuukk/40c6d7d1cd3d6a010242d505380fe233 dump_d: https://gist.github.com/ryuukk/38f43383025907a8f44049503887206c
Mar 28 2023
Ready to test folder: https://github.com/microsoft/vscode-cpptools/issues/10751#issuecomment-1486948783 Contains simple source to reproduce the issue + build script Also contains binaries + dump in case you just want to see the data Hopefully we can figure that out
Mar 28 2023
On Tuesday, 28 March 2023 at 14:02:39 UTC, ryuukk_ wrote:Ready to test folder: https://github.com/microsoft/vscode-cpptools/issues/10751#issuecomment-1486948783 Contains simple source to reproduce the issue + build script Also contains binaries + dump in case you just want to see the data Hopefully we can figure that outI noticed in the pdb, there are no mention of the ``app_d`` module I can only find: ``` 40 | S_PROCREF [size = 28] `app_d.main` module = 1, sum name = 0, offset = 40 ``` and ``` 0 | S_GDATA32 [size = 40] `app_d.notice_me_global` type = 0x0074 (int), addr = 0003:3504 ``` Is that why the debugger can't inspect global variables? Why doesn't the pdb contain anything about ``app_d``?
Mar 28 2023
On linux everything works properly out of the box, i tested with gdb and i can inspect globals More info + linux dump on my comment: https://github.com/microsoft/vscode-cpptools/issues/10751#issuecomment-1487694435 So it's a problem either with msvc, or the way dmd/ldc write information for the linker? Anyways.. linux: working out of the box Windows: poop Not a good outlook, then we wonder why people move away, debugging is essential Am i the only want who want to improve things, is it a lost cause? Should i move on?
Mar 28 2023
On 3/28/23 6:42 PM, ryuukk_ wrote:Am i the only want who want to improve things, is it a lost cause?I'm not one to use a debugger often, but it is very helpful for many people. I lament that the Windows debugging situation out of the box is dreadful. The students I teach D to I don't show the debugger because I'm worried it would confuse them more than help. I both don't use Windows and mostly do debugging via writeln, so for something that doesn't affect me much, I tend not to put effort in. I'm hoping someone who is motivated enough will do it. If I recall correctly, visual studio debugging is better than the other solutions. But I don't know having never got debugging to work. I've heard that mago is supposed to work better, and was written for D, but is Visual Studio dependent: https://github.com/rainers/mago I wonder if there isn't some way to make this work well for other IDEs? I couldn't get it to work on VSCode.Should i move on?In any case, the debugging experience isn't perfect, but seems like a drastic measure to leave D altogether if you can't debug globals. -Steve
Mar 29 2023
On Wednesday, 29 March 2023 at 15:26:21 UTC, Steven Schveighoffer wrote:On 3/28/23 6:42 PM, ryuukk_ wrote:I only use windows because i'm making a game and i have to test on that platformAm i the only want who want to improve things, is it a lost cause?I'm not one to use a debugger often, but it is very helpful for many people. I lament that the Windows debugging situation out of the box is dreadful. The students I teach D to I don't show the debugger because I'm worried it would confuse them more than help.I both don't use Windows and mostly do debugging via writeln, so for something that doesn't affect me much, I tend not to put effort in. I'm hoping someone who is motivated enough will do it.I am motivated, hopefully someone more knowledgeable can join me figure that outIf I recall correctly, visual studio debugging is better than the other solutions. But I don't know having never got debugging to work. I've heard that mago is supposed to work better, and was written for D, but is Visual Studio dependent: https://github.com/rainers/mago I wonder if there isn't some way to make this work well for other IDEs? I couldn't get it to work on VSCode.That's unfortunate that the solution is bound to a proprietary editor that requires a license Effort should be made in the open and be universal, so it's easy to port/adapt to other tools/platforms Coordinated efforts is the way to go, Go/Rust/Zig people are demonstrating this very well and it helped their growthI exaggerate a little bit i must admit it, but I'm trying to raise awareness, when other languages have no problem with debugging out of the box on popular IDEs, why should it have problems only with D? Currently, at least on windows, there are 2 problems with debugging: - global variables - extern(C) variables I'm willing to find the cause for the 1st one, then i'll attempt the 2nd one, so expect more frustrated posts I should emphasis again that the reason why i'm into this mess is due to a bug i'm trying to debug related to loading a shared DLL built using DMD on windows, wich apparently is known to be broken for YEARS.. great, more people should voice their complains, D is not a new language.. So what to expect other than frustration? specially when people keep recommending to use "workarounds", well, if the fix is a workaround, one shouldn't be surprised to see people getting frustrated every so often Also it's more of an accumulation of problems that makes me very annoyed https://issues.dlang.org/show_bug.cgi?id=20737 This for example shouldn't be a thing in 2023, periodShould i move on?In any case, the debugging experience isn't perfect, but seems like a drastic measure to leave D altogether if you can't debug globals. -Steve
Mar 29 2023
On 30/03/2023 10:09 AM, ryuukk_ wrote:more people should voice their complainsMaking noise about problems in D.learn is not the place to do it, I don't think compiler developers tend to monitor it much. Show your analysis of the situation in General, that is monitored. Especially since the fix for this stuff is probably pretty simple for TLS.
Mar 29 2023
On Wednesday, 29 March 2023 at 21:09:57 UTC, ryuukk_ wrote:Also it's more of an accumulation of problems that makes me very annoyed https://issues.dlang.org/show_bug.cgi?id=20737 This for example shouldn't be a thing in 2023, periodI agree with you because it's such a simple problem and it's surprising if it exists. I've never used -betterC though, but it's a pity. SDB 79
Mar 29 2023