<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65076>65076</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            lldb: print formatters format inconsistently
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          davidtwco
      </td>
    </tr>
</table>

<pre>
    One of rustc's debuginfo tests is failing with newer versions of lldb. I'm testing locally with a build of d43f324f6de40f81001e4105fe99305ac3b1c875.

When printing an instance of `std::num::NonZeroI8` (which has a trivial pretty printer in our test suite, included below):

```text
(lldb) print/d nz_i8
(core::num::nonzero::NonZeroI8) $0 = '\v' { __0 = 11 }
```

The `/d` suffix seems to only apply to the printing of `11` but not the `'\v`. I can confirm this by requesting a different formatting and see it only change the `11`. 

As far as I can tell, it used to apply to both in previous versions (as our test expects `$0 = 11` and passes with earlier versions of lldb). Using `print` or `frame variable` or any other command I've found doesn't seem to make a difference.

You should be able to reproduce it using the following:

```rust
// numeric-types.rs
use std::num::*;

fn main() {
    let nz_i8 = NonZeroI8::new(11).unwrap();
    zzz(); // #break
}

fn zzz() { }
```
([original](https://github.com/rust-lang/rust/blob/master/tests/debuginfo/numeric-types.rs))

```python
# lldb_lookup.py
import re

class RustType(object):
    OTHER = "Other"
    STRUCT = "Struct"
    STD_NONZERO_NUMBER = "StdNonZeroNumber"

STD_NONZERO_NUMBER_REGEX = re.compile(r"^core::num::([a-z_]+::)*NonZero.+$")

STD_TYPE_TO_REGEX = {
    RustType.STD_NONZERO_NUMBER: STD_NONZERO_NUMBER_REGEX,
}

def classify_rust_type(type):
 type_class = type.GetTypeClass()
    if type_class == lldb.eTypeClassStruct:
        return classify_struct(type.name, type.fields)
    return RustType.OTHER

def classify_struct(name, fields):
    for ty, regex in STD_TYPE_TO_REGEX.items():
        if regex.match(name):
            return ty

    return RustType.STRUCT

def summary_lookup(valobj, dict):
    # type: (SBValue, dict) -> str
    """Returns the summary provider for the given value"""
    rust_type = classify_rust_type(valobj.GetType())

    if rust_type == RustType.STD_NONZERO_NUMBER:
        return StdNonZeroNumberSummaryProvider(valobj, dict)

    return ""

def StdNonZeroNumberSummaryProvider(valobj, _dict):
    # type: (SBValue, dict) -> str
    objtype = valobj.GetType()
    field = objtype.GetFieldAtIndex(0)
    element = valobj.GetChildMemberWithName(field.name)
    return element.GetValue()
```
([original providers](https://github.com/rust-lang/rust/blob/master/src/etc/lldb_providers.py#L740) and [original lookup](https://github.com/rust-lang/rust/blob/master/src/etc/lldb_lookup.py#L59) and [original types](https://github.com/rust-lang/rust/blob/master/src/etc/rust_types.py))


```
(lldb) type summary add -F -F lldb_lookup.summary_lookup  -e -x -h '^core::num::([a-z_]+::)*NonZero.+$' --category Rust
(lldb) type category enable Rust
(lldb) breakpoint set --file 'numeric-types.rs' --line 5
(lldb) print/d nz_i8
```
([original](https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/runtest.rs#L1339))

You can also just clone the [rust-lang/rust repository](https://github.com/rust-lang/rust) and run `./x.py test tests/debuginfo --test-args numeric-types`. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0WF9v4zgO_zTqCxHDlvP3IQ_9l70BZttF27m93ZdAtulYM7Lkk-S06ac_UHYSp8kM7m5nCyOJJZH8kfxRoiqckxuNuGSTGza5uxKtr4xdFmIrC_-am6vMFLvlo0YwJdjW-ZzxmYMCs3YjdWnAo_MOpINSSCX1Bl6lr0DjK1rYonXSaEeyShVZBJ8Yn9VBhpYqkwuldp2IgKyVqqC1xTgtUz4upwWO43KexHGC4ySelLhYpPFE5GmW5PPZJGLxHYuvu8_fK9TQWKmDaqFBaueFzgNyNo2dL1h6zdJr3dbdjwej_0RrPs3ZNAbG56-VzCuohAMB3sqtFAoai97vOr1oQWowrQ0OgGulR8ZvQepctQUWkKEyr4wvSP0AGZvG3ePxzfd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