visuald icon indicating copy to clipboard operation
visuald copied to clipboard

Evaluation of enums/constants seems to have stopped working?

Open TurkeyMan opened this issue 9 months ago • 6 comments

Once upon a time, debugger evaluation of enums/constants was working well, but since I returned from my hiatus, I've noticed that they don't seem to work at all. Is this a known issue, or is there any reason for this?

Image

TurkeyMan avatar Mar 07 '25 11:03 TurkeyMan

There is no debug information for enumerators, so there is no debug information to display the value from. With older versions of VS, the data tooltip is intercepted to replace it with intellisense information, but that seems to have broken with VS2022. I can workaround that by adding some text to trigger the "Quick Info", but that pollutes it a bit.

BTW: C++ has the same issue when hovering over a type. It does have debug information for enums, though.

rainers avatar Mar 08 '25 10:03 rainers

So debuginfo for enums is possible? Is there a reason we don't copy that?

TurkeyMan avatar Mar 08 '25 10:03 TurkeyMan

So debuginfo for enums is possible? Is there a reason we don't copy that?

It is possible to emit "constant" symbol records. Not sure if it is easy to decide which symbols to emit without polluting the object file. If an enumerator type is used to declare a variable that might be a possible indicator to also emit the values.

rainers avatar Mar 08 '25 11:03 rainers

You said that C++ has debuginfo for enums though, is that what it does?

TurkeyMan avatar Mar 08 '25 12:03 TurkeyMan

You said that C++ has debuginfo for enums though, is that what it does?

It seems msvc emits all the enumerator values of a declaration if any of its identifiers is referenced. This information might not be available anymore when dmd generates the debug information.

I just noticed that named enumerator types are already emitted with their identifiers and values by dmd/ldc, and the debugger displays identifiers for a variable of this type, but it doesn't understand it as part of an expression. This might have to do with needing the fully qualified name, which also fails for variable names :-/

rainers avatar Mar 09 '25 08:03 rainers

The tooltip from semantic analysis is back in https://github.com/dlang/visuald/releases/tag/v1.4.0 and the expression evaluator knows about named enums, e.g. Type.Name can be used in watch expressions. What's missing is debug information about constants without an explicit type name, e.g. enum { Name = 1 } or enum Name = 1.

rainers avatar Mar 14 '25 10:03 rainers