Skip to content

lldb hashmap pretty printer broken #81814

Closed
@ehuss

Description

@ehuss

The LLDB provider for hash maps has been broken since #79234.

Repro:

use std::collections::*;
fn main() {
    let mut map = HashMap::new();
    map.insert(1, 2);
    eprintln!("{:?}", map);
}

Run this, notice that it doesn't print any values for the hash map:

rustc -g foo.rs
rust-lldb foo
(lldb) b 5
(lldb) r
(lldb) p map
(std::collections::hash::map::HashMap<int, int, std::collections::hash::map::RandomState>) $0 = size=1 {}

Using an older version works (1.49 or earler):

(lldb) p map
(std::collections::hash::map::HashMap<int, int, std::collections::hash::map::RandomState>) $0 = size=1 {
  [0] = {
    0 = 1
    1 = 2
  }
}

I don't understand the motivation for #79234, as you can see the older versions are able to display the type. @ortem can you clarify what is going on?

I did some debugging, and the pair_type_size and data_ptr values are invalid.


Another way to check this is to run the src/test/debuginfo/pretty-std-collections.rs test. Due to #81813 it hasn't been running on CI.

It has a check for the following output:

$2 = size=4 { [0] = { 0 = 1 1 = 10 } [1] = { 0 = 2 1 = 20 } [2] = { 0 = 3 1 = 30 } [3] = { 0 = 4 1 = 40 } }
$3 = size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 }

But the actual output is:

$2 = size=4 {}
$3 = size=4 {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions