Files
rust/tests/debuginfo
Jacob Pratt 682cbc4124 Rollup merge of #163098 - Walnut356:rc_usize, r=Mark-Simulacrum
[debugger visualizers] Add workaround to read `Rc` strong/weak counts

Implements a fix with the same goal as https://github.com/rust-lang/rust/pull/162725 of removing the infinite loop. Since `RcInner` is `#[repr(C)]`, we can just directly read the values from their known offsets. Worth noting that LLDB fails to even populate the fields and offsets when this bug occurs, so `#[repr(C)]` is a required invariant to retrieve the values from addresses like this:

```
(lldb) script lldb.frame.var("holder").GetNonSyntheticValue().GetChildAtIndex(0).GetChildAtIndex(0).GetChildAtIndex(0).GetType().GetPointeeType()

template<> struct RcInner<unsigned int> {
private:
    unsigned int value;
}
```

That `RcInner` should have a `strong` and `weak` field, but because LLDB can't read the type node, it omits them entirely. Thankfully, the `value` field is still read correctly and has an accurate offset.

This change has 1 small side effect, which is that the `weak` count is not decremented before it is displayed to the user. We can easily do that in the summary function, but imo it feels weird to lie about the value in memory? The `weak` count starts at 1 because the original `Rc` instance "holds" both a strong and a weak reference. It's mostly an artifact of `Rc`'s implementation, but if you're debugging, that seems like something that might matter.
2026-09-27 21:51:41 -04:00
..
…
…
…
…
…
…
…
2026-09-07 04:08:12 -05:00
…