Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No/missing debug information for const variables. #20259

Open
Srekel opened this issue Jun 11, 2024 · 3 comments
Open

No/missing debug information for const variables. #20259

Srekel opened this issue Jun 11, 2024 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior debug-info Debug information of binary generated by Zig is not as expected.
Milestone

Comments

@Srekel
Copy link

Srekel commented Jun 11, 2024

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

I'm on Windows 11 Home.

Please see attached image - this is using the latest (as of today) VS Code, All extensions up to date and using corresponding ZLS version as far as I can tell.

image

Expected Behavior

In this case I expected helloconst to show up under Locals or at least that I can inspect it under Watch. In this case it is of course a trivial value but as we all know consts can be significantly more complex.

I also expected lolconst to resolve OK under Watch.

Even when consts are just a little bit complex, like in the case below, it can be quite useful when debuugging to immediately be able to check that, say, max_patch_int is the value you expect it to be.

const lod_0_patch_size = config.patch_size;
const max_world_size = 4 * 1024; // 512 * 1024; // 500 km
const max_patch = max_world_size / lod_0_patch_size; // 8k patches
const max_patch_int_bits = 16; // 2**13 = 8k
const max_patch_int = std.meta.Int(.unsigned, max_patch_int_bits);

Related: #20258.
Related: #15095

@Srekel Srekel added the bug Observed behavior contradicts documented or intended behavior label Jun 11, 2024
@ni-vzavalishin
Copy link

In your example helloconst doesn't seem to be referenced anywhere. I'd accept the fact that unreferenced entities are not really compiled in or present in anyway. However I also regularly had debug visibility issues with referenced constants, which is a totally different story IMHO. Not sure if there's an existing bug for that.

@mlugg
Copy link
Member

mlugg commented Jun 11, 2024

Indeed, unreferenced values won't show up in debuggers, because of Zig's lazy analysis, so that explains helloconst. However, lol and lolconst definitely ought to be shown.

@mlugg mlugg added the debug-info Debug information of binary generated by Zig is not as expected. label Jun 11, 2024
@Srekel
Copy link
Author

Srekel commented Jun 11, 2024

Ah, fair! Here is what it looks like when it's referenced. It still doesn't show up in Locals, which I would assume it would, but it does show up in watch.

image

(Globals not showing up in Locals may of course be a VS Code issue or design choice on their part, but if Zig has the choice of listing variables that are on level higher that would at least be my preference. )

@Vexu Vexu added this to the 0.15.0 milestone Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior debug-info Debug information of binary generated by Zig is not as expected.
Projects
None yet
Development

No branches or pull requests

4 participants