Skip to content

No BTreeMap BTreeSet debug visualizers for lldb / macOS #111868

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

Open
alcroito opened this issue May 23, 2023 · 4 comments · May be fixed by #140130
Open

No BTreeMap BTreeSet debug visualizers for lldb / macOS #111868

alcroito opened this issue May 23, 2023 · 4 comments · May be fixed by #140130
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.

Comments

@alcroito
Copy link

It would be great if rust / lldb / codelldb (vscode) shipped with lldb visualizers / synthetic debug providers for BTreeSet and BTreeMap.

There exists a similar issue for Windows / natvis at #90520 , but not for lldb / macOS.

I guess the gdb providers https://github.com/rust-lang/rust/blob/1.69.0/src/etc/gdb_providers.py#L242 need to be ported for

https://github.com/rust-lang/rust/blob/1.69.0/src/etc/lldb_providers.py

@alcroito alcroito added the C-bug Category: This is a bug. label May 23, 2023
@jyn514 jyn514 added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label May 26, 2023
@jyn514
Copy link
Member

jyn514 commented May 26, 2023

This isn't specific to macOS, right? LLDB also has the same issue on linux and windows?

@alcroito
Copy link
Author

This isn't specific to macOS, right? LLDB also has the same issue on linux and windows?

I believe so, yes.

@werifu
Copy link
Contributor

werifu commented Dec 12, 2023

The hardest challenge to support this feature is the fact that lldb lacks the ability to print enum correctly, while BTreeMap.root has a type of Option<Root<K, V>> . After this commit [lldb] Add basic support to Rust enums in TypeSystemClang , lldb could print enum in Rust. But the latest release llvm 17.0.6 still does not contain this code.

When this feature is release, pretty print for BTreeMap and BTreeSet can be easily implemented by providing SynthesisProvider just like HashMap and HashSet and I'm willing to do this work. Please let me know when it's ready.

Related issue: #79530

Actually, codelldb supports presenting content of an enum value, I guess it is because of RustEnum which generates an FFI type enum in https://github.com/vadimcn/codelldb/blob/master/adapter/scripts/codelldb/codelldb.py
So it should be possible to support BTreeMap and BTreeSet now by adding synthesis providers in rust.py. But now I find it hard to build that project on my mac, I may do this work when I can successfully run codelldb...

Adjective-Object added a commit to Adjective-Object/good-fences-rs-core that referenced this issue Sep 25, 2024
…tector, clippy) (#80)

## Major Changes:
- updates the `devcontainer` definition to make things more usable:
  - Bases devcontainer off newer version of ubuntu (24.10)
- Fix locale issue causing spacing issue in zsh
(https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)
- Switches to `gdb` as the default debugger, as it supports hashmap
visualization (rust-lang/rust#111868)
- Caches rust packages in a persistent volume to avoid re-downloading
packages between container rebuilds.
- adds a resolver for SWC that is aware of package `exports, to support
custom `source` imports within a monorepo
- adds a deadlock detector for `dashmap` and wires it into the caching
resolver (this is temporary and should be removed in the future)
- Adds a CI job to ensure no unused dependencies are included (using
`cargo-udeps`). This is not included in the container build as it is
_exceptionally_ slow to build from source (~250s on my machine)
- Fixes issues discovered by `cargo clippy`

---------

Co-authored-by: Max Huang-Hobbs <[email protected]>
@ede1998
Copy link

ede1998 commented Apr 20, 2025

I got something working on Linux. Don't have macOS to cross test it though:

https://github.com/ede1998/btreemap-debug/compare/27851762d6a33e21223c5e811f1688a8bf20f9f7..master

Planning to turn it into a proper PR in the next few days.

It works on the terminal with rust-lldb (or my adaption for testing at least) and in VSCode with codelldb and some custom init commands to inject my changes.

Image

Output on command line
-> 27       println!("{movie_reviews:?}");
   28   }
   29
   30   /*
(lldb) p movie_reviews
(alloc::collections::btree::map::BTreeMap<&str, &str, alloc::alloc::Global>) size=12 {
  [0] = {
    0 = "A" {
      [0] = 'A'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [1] = {
    0 = "B" {
      [0] = 'B'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [2] = {
    0 = "C" {
      [0] = 'C'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [3] = {
    0 = "D" {
      [0] = 'D'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [4] = {
    0 = "E" {
      [0] = 'E'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [5] = {
    0 = "F" {
      [0] = 'F'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [6] = {
    0 = "G" {
      [0] = 'G'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [7] = {
    0 = "H" {
      [0] = 'H'
    }
    1 = "value" {
      [0] = 'v'
      [1] = 'a'
      [2] = 'l'
      [3] = 'u'
      [4] = 'e'
    }
  }
  [8] = {
    0 = "Office Space" {
      [0] = 'O'
      [1] = 'f'
      [2] = 'f'
      [3] = 'i'
      [4] = 'c'
      [5] = 'e'
      [6] = ' '
      [7] = 'S'
      [8] = 'p'
      [9] = 'a'
      [10] = 'c'
      [11] = 'e'
    }
    1 = "Deals with real issues in the workplace." {
      [0] = 'D'
      [1] = 'e'
      [2] = 'a'
      [3] = 'l'
      [4] = 's'
      [5] = ' '
      [6] = 'w'
      [7] = 'i'
      [8] = 't'
      [9] = 'h'
      [10] = ' '
      [11] = 'r'
      [12] = 'e'
      [13] = 'a'
      [14] = 'l'
      [15] = ' '
      [16] = 'i'
      [17] = 's'
      [18] = 's'
      [19] = 'u'
      [20] = 'e'
      [21] = 's'
      [22] = ' '
      [23] = 'i'
      [24] = 'n'
      [25] = ' '
      [26] = 't'
      [27] = 'h'
      [28] = 'e'
      [29] = ' '
      [30] = 'w'
      [31] = 'o'
      [32] = 'r'
      [33] = 'k'
      [34] = 'p'
      [35] = 'l'
      [36] = 'a'
      [37] = 'c'
      [38] = 'e'
      [39] = '.'
    }
  }
  [9] = {
    0 = "Pulp Fiction" {
      [0] = 'P'
      [1] = 'u'
      [2] = 'l'
      [3] = 'p'
      [4] = ' '
      [5] = 'F'
      [6] = 'i'
      [7] = 'c'
      [8] = 't'
      [9] = 'i'
      [10] = 'o'
      [11] = 'n'
    }
    1 = "Masterpiece." {
      [0] = 'M'
      [1] = 'a'
      [2] = 's'
      [3] = 't'
      [4] = 'e'
      [5] = 'r'
      [6] = 'p'
      [7] = 'i'
      [8] = 'e'
      [9] = 'c'
      [10] = 'e'
      [11] = '.'
    }
  }
  [10] = {
    0 = "The Blues Brothers" {
      [0] = 'T'
      [1] = 'h'
      [2] = 'e'
      [3] = ' '
      [4] = 'B'
      [5] = 'l'
      [6] = 'u'
      [7] = 'e'
      [8] = 's'
      [9] = ' '
      [10] = 'B'
      [11] = 'r'
      [12] = 'o'
      [13] = 't'
      [14] = 'h'
      [15] = 'e'
      [16] = 'r'
      [17] = 's'
    }
    1 = "Eye lyked it a lot." {
      [0] = 'E'
      [1] = 'y'
      [2] = 'e'
      [3] = ' '
      [4] = 'l'
      [5] = 'y'
      [6] = 'k'
      [7] = 'e'
      [8] = 'd'
      [9] = ' '
      [10] = 'i'
      [11] = 't'
      [12] = ' '
      [13] = 'a'
      [14] = ' '
      [15] = 'l'
      [16] = 'o'
      [17] = 't'
      [18] = '.'
    }
  }
  [11] = {
    0 = "The Godfather" {
      [0] = 'T'
      [1] = 'h'
      [2] = 'e'
      [3] = ' '
      [4] = 'G'
      [5] = 'o'
      [6] = 'd'
      [7] = 'f'
      [8] = 'a'
      [9] = 't'
      [10] = 'h'
      [11] = 'e'
      [12] = 'r'
    }
    1 = "Very enjoyable." {
      [0] = 'V'
      [1] = 'e'
      [2] = 'r'
      [3] = 'y'
      [4] = ' '
      [5] = 'e'
      [6] = 'n'
      [7] = 'j'
      [8] = 'o'
      [9] = 'y'
      [10] = 'a'
      [11] = 'b'
      [12] = 'l'
      [13] = 'e'
      [14] = '.'
    }
  }
}

The output on the command line is a bit lengthy but it should be the same as with a HashMap and rust-lldb (except ordering).

ede1998 added a commit to ede1998/rust that referenced this issue Apr 21, 2025
@ede1998 ede1998 linked a pull request Apr 21, 2025 that will close this issue
ede1998 added a commit to ede1998/rust that referenced this issue Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants