visuald icon indicating copy to clipboard operation
visuald copied to clipboard

Another debug issue?

Open TurkeyMan opened this issue 1 year ago • 8 comments

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?

TurkeyMan avatar Oct 17 '24 11:10 TurkeyMan

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 avatar Oct 17 '24 16:10 rainers

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.

rainers avatar Oct 17 '24 20:10 rainers

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.

TurkeyMan avatar Oct 18 '24 01:10 TurkeyMan

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 avatar Oct 18 '24 07:10 rainers

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.

rainers avatar Oct 18 '24 12:10 rainers

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!

TurkeyMan avatar Oct 19 '24 11:10 TurkeyMan

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.

rainers avatar Oct 19 '24 12:10 rainers

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

TurkeyMan avatar Oct 20 '24 10:10 TurkeyMan

fix released in https://github.com/dlang/visuald/releases/tag/v1.4.0-rc3

rainers avatar Nov 14 '24 14:11 rainers