Corrupted variable view in the debugger on Windows

7832b22
Opened by Andrey at 2018-02-19 20:59:34

I am not sure if it belongs to this project. Please advise if it should be moved somewhere else.

I have got sample code from Hyper project (code sample is below), which I compiled using stable MSVC toolchain on Windows (stable-x86_64-pc-windows-msvc, rustc 1.21.0 (3b72af97e 2017-10-09)). Next I launched it under a debugger and played with breakpoints and variable inspections. I can see that the debugger shows correct view of local variables like adr and strin inside of call function.

image

However, the inspection of the req variable is corrupted:

image

I am observing the same with Visual Studio Code + cppvsdbg and with Visual Studio 2017 debugger.

I am not sure if the issue is inferred by incomplete debug information or incorrect visualization settings for the debugger. I understand debugger visualization extensions (natvis) are embedded into PDB files now (?). Although, I have configured VS Code debugger visualization extensions (not sure if it was done correctly ?). Could you please advise what I should try / check to resolve the issue?

Debugger launch config in VS Code:

     {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${workspaceFolder}/target/debug/hello_cargo.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }

Code sample used:

extern crate hyper;
extern crate futures;

use futures::future::Future;

use hyper::header::ContentLength;
use hyper::server::{Http, Request, Response, Service};

struct HelloWorld;

const PHRASE: &'static str = "Hello, World!";

impl HelloWorld {
    fn callee(&self, str: String) {

    }
}

impl Service for HelloWorld {
    // boilerplate hooking up hyper's server types
    type Request = Request;
    type Response = Response;
    type Error = hyper::Error;
    // The future representing the eventual Response your call will
    // resolve to. This can change to whatever Future you need.
    type Future = Box<Future<Item=Self::Response, Error=Self::Error>>;

    fn call(&self, req: Request) -> Self::Future {
        let strin = String::from("aaaaaaa");
        let adr = req.remote_addr().unwrap();
        println!("{}", adr);
        println!("{}", strin);
        self.callee(strin.clone());
        self.callee(strin);
        // We're currently ignoring the Request
        // And returning an 'ok' Future, which means it's ready
        // immediately, and build a Response with the 'PHRASE' body.
        Box::new(futures::future::ok(
            Response::new()
                .with_header(ContentLength(PHRASE.len() as u64))
                .with_body(PHRASE)
        ))
    }
}

fn main() {
    let addr = "127.0.0.1:3000".parse().unwrap();
    let server = Http::new().bind(&addr, || Ok(HelloWorld)).unwrap();
    server.run().unwrap();
}

but I observed the same issue happening with VS Code + cppvsdbg extension and Visual Studio 2017 debuggers. I guess it is related to incomplete PDB infromation

  1. Was the code compiled with optimisations enabled? It is plausible that enough of the code gets optimised out that there is simply nothing to show anymore.

    Simonas Kazlauskas at 2017-11-14 20:59:22

  2. I have run debug build of it. I have not changed any of the build settings explicitly, everything was setup by cargo init --bin hello_cargo by default.

    Andrey at 2017-11-14 21:11:20