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

When debugging on windows-msvc, closure environments cannot be inspected #83709

Closed
wesleywiser opened this issue Mar 31, 2021 · 1 comment · Fixed by #83941
Closed

When debugging on windows-msvc, closure environments cannot be inspected #83709

wesleywiser opened this issue Mar 31, 2021 · 1 comment · Fixed by #83941
Labels
A-closures Area: Closures (`|…| { … }`) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wesleywiser
Copy link
Member

I compiled the following program and started debugging in Windbg:

fn main() {
    let x: i32 = 123;
    let y: i32 = x * 2;
    let closure = || {
        x   y
    };

    std::process::exit(closure());
}

but after stepping inside closure, it's not possible to inspect the x or y variables.

image

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
binary: rustc
commit-hash: 4a8b6f708c38342a6c74aa00cf4323774c7381a6
commit-date: 2021-03-11
host: x86_64-pc-windows-msvc
release: 1.52.0-nightly
LLVM version: 12.0.0

Windbg 1.2103.01004.0

@wesleywiser wesleywiser added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-windows-msvc Toolchain: MSVC, Operating system: Windows C-bug Category: This is a bug. labels Mar 31, 2021
@jonas-schievink jonas-schievink added the A-closures Area: Closures (`|…| { … }`) label Mar 31, 2021
@wesleywiser
Copy link
Member Author

Running cvdump.exe on the pdb shows the function is missing local variable information entirely:

(000178) S_LPROC32: [0001:00000100], Cb: 00000042, Type:             0x1021, async_stack::main::{{closure}}
         Parent: 00000000, End: 000001E0, Next: 00000000
         Debug start: 00000000, Debug end: 00000000

(0001C0)  S_FRAMEPROC:
          Frame size = 0x00000038 bytes
          Pad size = 0x00000000 bytes
          Offset of pad in frame = 0x00000000
          Size of callee save registers = 0x00000000
          Address of exception handler = 0000:00000000
          Function info: inl_specified invalid_pgo_counts Local=rsp Param=rsp (0x00014020)

(0001E0) S_END

where as the DWARF info is generated correctly:

0x00000323:     DW_TAG_namespace
                  DW_AT_name    ("main")

0x00000328:       DW_TAG_subprogram
                    DW_AT_low_pc        (0x00000000000052c0)
                    DW_AT_high_pc       (0x0000000000005307)
                    DW_AT_frame_base    (DW_OP_reg7 RSP)
                    DW_AT_linkage_name  ("_ZN11async_stack4main28_$u7b$$u7b$closure$u7d$$u7d$17h80799f1c76fc13d8E")
                    DW_AT_name  ("{{closure}}")
                    DW_AT_decl_file     ("/mnt/d/code/temp/async_stack/src/main.rs")
                    DW_AT_decl_line     (6)
                    DW_AT_type  (0x00000388 "i32")

0x00000345:         DW_TAG_variable
                      DW_AT_location    (DW_OP_fbreg  16, DW_OP_deref, DW_OP_deref)
                      DW_AT_name        ("x")
                      DW_AT_decl_file   ("/mnt/d/code/temp/async_stack/src/main.rs")
                      DW_AT_decl_line   (4)
                      DW_AT_type        (0x00000388 "i32")

0x00000355:         DW_TAG_variable
                      DW_AT_location    (DW_OP_fbreg  16, DW_OP_deref, DW_OP_plus_uconst 0x8, DW_OP_deref)
                      DW_AT_name        ("y")
                      DW_AT_decl_file   ("/mnt/d/code/temp/async_stack/src/main.rs")
                      DW_AT_decl_line   (5)
                      DW_AT_type        (0x00000388 "i32")

0x00000367:         NULL

So this is an issue with the debug info generation itself and not a bug in Windbg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants