dlang / visuald

Visual D - Visual Studio extension for the D programming language
http://rainers.github.io/visuald/visuald/StartPage.html
Boost Software License 1.0
288 stars 70 forks source link

Another debug issue? #281

Open TurkeyMan opened 5 days ago

TurkeyMan commented 5 days ago

My colleague reported this one to me:

module WindowsApp1;

import std.stdio;

void textLength(const(char)[] text)
{
    writeln("length: ", text.length); // breakpoint here, can't inspect .length
}

int main()
{
    const(char)[] str = "Hello D World!\n";
    textLength(str);
    return 0;
}

This is just a tweak of the wizard app. In this code, break on that line, you can't inspect length. I feel like I used to be able to inspect the length of arrays?

rainers commented 5 days ago

Indeed, it seems that it should work. I suspect that it is masked by he string visualization, you can still see the length value if you use text,! to show the raw data. It also works for other array types.

rainers commented 4 days ago

The problem here is that the text argument is actually passed by reference ABI-wise, and that's typed as a pointer in the debug info. The expression evaluator fails to crawl this additional indirection. If you assign the text to a local variable txt, then txt.length is evaluated correctly.

TurkeyMan commented 4 days ago

Is there any way to correct this? Can it be typed as a reference instead of a pointer? I suspect this particular situation is causing a great many cases I've been seeing to fail in a similar way.

rainers commented 4 days ago

It should be possible to fix it in the compiler (LDC seems to work better), but in this case, the evaluator should also support the indirection when using '.' with a pointer as it is valid syntax. BTW: (*text).length works, too.

rainers commented 4 days ago

You can find a preliminary version of the fixed debugger plugin in the artifacts of the CI builds here: https://ci.appveyor.com/project/rainers/mago/build/artifacts

You just need to replace this file: "c:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\Packages\Debugger\MagoNatCC.dll" where "Preview" is probably something else on your system.

TurkeyMan commented 3 days ago

I tried that DLL and this particular problem was resolved. I'll run for a while and see if any of my other issues are also resolved... Cheers!

rainers commented 3 days ago

If it still stalls/takes forever (no changes with respect to that), you can also use the pdb-file to get an idea where it is wasting all the time when attaching a debugger to devenv.exe.

TurkeyMan commented 2 days ago

I'll definitely do that next time I notice it locking up.