Global variables not accessible with Visual Studio debugger

Rainer Schuetze r.sagitario at gmx.de
Sat Apr 23 11:38:11 UTC 2022


On 21/04/2022 21:37, pdgr wrote:
> Hello,
> 
> I have a program that I want to debug on Windows 10 using Visual Studio 
> 2022. I'm debugging the built .exe directly (not using VisualD or 
> anything).

Without Visual D (or to be more precise: without the mago debugger 
extension that comes with Visual D), you are rather limited when 
debugging D code.

> 
> The program is compiled with dmd ver v2.099.0 using the following flags:
>    dmd main.d -debug -g -gf -gs -m64
> 
> In Visual Studio when I type the name of my global variable in the watch 
> window it can't find it.. any way to solve this? I found some old thread 
> that suggested using {module-name}.{global-var-name} but that doesn't 
> work either.
> 

It might work to use the mangled name, e.g. _D3mod4namei. You can find 
the exact speelling in the disassembly of an access to the variable.

An alternative might be to use extern(C) when declaring the variable.


More information about the Digitalmars-d-debugger mailing list