Skip to content

debugger_visualizer: natvis files are accumulated instead of replaced on incremental builds #120913

Open
@MaulingMonkey

Description

@MaulingMonkey

Changes to my natvis files (e.g. replacing the DisplayString 1 → 2 below) aren't always being reflected in my debugger.

// src/lib.rs
#![debugger_visualizer(natvis_file = "my.natvis")]
#[derive(Debug)] pub struct Type(u32);
<!-- src/my.natvis -->
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="my::Type"><DisplayString>1</DisplayString></Type>
</AutoVisualizer>
// examples/basic.rs
#[no_mangle] #[inline(never)] fn __break() {}
fn main() {
    let my = my::Type(42);
    __break();
    dbg!(my);
}

After enabling Visual Studio 2017's natvis diagnostic messages and stepping out of __break, I've started to accumulate many warnings, with one warning per build after the 1st (starting with no warnings for the first build after a cargo clean):

Natvis: basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6): Warning: Conflicting <Type> entries detected for type 'my::Type' at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' and 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)'.  The <Type> entry at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' will have priority.
Natvis: basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6): Warning: Conflicting <Type> entries detected for type 'my::Type' at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' and 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)'.  The <Type> entry at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' will have priority.
Natvis: basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6): Warning: Conflicting <Type> entries detected for type 'my::Type' at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' and 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)'.  The <Type> entry at 'basic-0.natvis (from ...\debug\examples\basic.pdb)(4,6)' will have priority.

I believe that for every build, the new contents of my.natvis are accumulated... and then conflict with the stale contents of previous my.natvis contents. These stale contents then, presumably, frequently win / take priority, resulting in not seeing the updated visualizer. Adding insult to injury, switching from stable to nightly, I ended up getting warnings for what I believe to be every type in {intrinsic, libcore, liballoc, libstd}.natvis until I cargo cleaned - you might have stale stdlib visualizers after a toolchain upgrade.

Meta

rustc --version --verbose:

rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-pc-windows-msvc
release: 1.76.0
LLVM version: 17.0.6
cargo 1.78.0-nightly (ccc84ccec 2024-02-07)
release: 1.78.0-nightly
commit-hash: ccc84ccec4b7340eb916aefda1cb3e2fe17d8e7b
commit-date: 2024-02-07
host: x86_64-pc-windows-msvc
libgit2: 1.7.2 (sys:0.18.2 vendored)
libcurl: 8.6.0-DEV (sys:0.4.71+curl-8.6.0 vendored ssl:Schannel)
os: Windows 10.0.19045 (Windows 10 Pro) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsC-bugCategory: This is a bug.F-debugger_visualizer`#![feature(debugger_visualizer)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions