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

gdb BTreeMap pretty printer is incorrect #55771

Closed
tromey opened this issue Nov 7, 2018 · 1 comment · Fixed by #56144
Closed

gdb BTreeMap pretty printer is incorrect #55771

tromey opened this issue Nov 7, 2018 · 1 comment · Fixed by #56144
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@tromey
Copy link
Contributor

tromey commented Nov 7, 2018

As noted here, the BTreeMap pretty-printer for gdb only works for a small number of elements.

For example, this works:

use std::collections::BTreeMap;

pub fn main() {
    let mut btree_map = BTreeMap::new();
    for i in 0..10 {
        btree_map.insert(i, i * 2);
    }
    let x = 72;
}

However, if you change the 10 to 15, it will stop working:

(gdb) p btree_map 
$1 = BTreeMap<i32, i32>(len: 15) = {
  [6] = 12,
  [0] = 32767,
  [1431906992] = 0,
  [21845] = 11,
  [1431907048] = 22,
  [21845] = 21845,
  [4] = -12448,
  [0] = 32767,
  [1431907004] = -11872,
  [21845] = 32767,
  [4] = 1431680491,
  [12] = 0,
  [32767] = 1431906880,
  [0] = 21845,
  [11] = 1431906992
}
@tromey tromey added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Nov 7, 2018
@artemmukhin
Copy link
Contributor

The problem is this pretty-printer gets the data only from the root node and doesn't take into account the structure of B-tree. It is necessary to implement the iteration over all tree, so the bug is not so easy to fix. I will try to do it in the near of future, together with the HashMap, but not sure if I can handle it.

@tromey tromey self-assigned this Nov 21, 2018
tromey added a commit to tromey/rust that referenced this issue Nov 21, 2018
The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code.  This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes rust-lang#55771
pietroalbini added a commit to pietroalbini/rust that referenced this issue Nov 25, 2018
…ichton

Fix BTreeSet and BTreeMap gdb pretty-printers

The BTreeSet and BTreeMap gdb pretty-printers did not take the node
structure into account, and consequently only worked for shallow sets.
This fixes the problem by iterating over child nodes when needed.

This patch avoids the current approach of implementing some of the
value manipulations in debugger-indepdendent code.  This was done for
convenience: a type lookup was needed for the first time, and there
currently are no lldb formatters for these types.

Closes rust-lang#55771
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.)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants