Skip to content

Add wide pointer visualizer for LLDB - #164975

Open
Walnut356 wants to merge 2 commits into
rust-lang:mainfrom
Walnut356:unsized_vis
Open

Walnut356 wants to merge 2 commits into
rust-lang:mainfrom
Walnut356:unsized_vis

Conversation

@Walnut356

Copy link
Copy Markdown
Contributor

This visualizer handles wide pointers to ?Sized types, e.g.

struct S {
    a: u8,
    b: [i16]
}

These were undecidable not too long ago, but we now have enough information to reliably visualize these properly.

lldb 23 added the ability for an SBValue object to acquire its parent, which is very helpful for this so we can retrieve the length. Prior to lldb 22, the best option we have is to store a reference to the parent wide pointer within python itself and retrieve them in the child's visualizer (this happens via WidePtrSyntheticProvider.WIDE_PTR_BY_UNSIZED_CHILD_ID. I know it's maybe a bit hack-y, but this is semi-canonical and CodeLLDB did it pretty extensively in their visualizers). Using that method, we are thankfully able to get identical output between lldb 22 and 23.

As a note, this visualizer does not work for MSVC at the moment because LLDB pretends zero-sized fields in PDB debug info don't exist =)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 26, 2026
@rustbot

rustbot commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 22 candidates

@Walnut356

Copy link
Copy Markdown
Contributor Author

lol that must be from the rollup that got merged 3 minutes ago. Whoops. I'll fix that when I get home

@nnethercote

Copy link
Copy Markdown
Contributor

I don't know anything about this stuff, let's pick a better reviewer:

r? @davidtwco

@rustbot rustbot assigned davidtwco and unassigned nnethercote Oct 26, 2026
@rustbot

rustbot commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-22-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [debuginfo-lldb] tests/debuginfo/vec_visualizer/main.rs ... ok

failures:

---- [debuginfo-lldb] tests/debuginfo/wideptr_visualizer/main.rs stdout ----
NOTE: compiletest thinks it is using LLDB version: Llvm(Version { major: 22, minor: 1, patch: 2 })
------lldb-22 stdout------------------------------
(lldb) script --language python -- import debugger_tester; debugger_tester.main()
LLDBFeature.StaticFields|TypeRecognizers|Float128
LLDB batch-mode script
----------------------
Python version: 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0]
Debugger commands script is '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/main.debugger.script'.
Target executable is '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/a'.
Current working directory is '/checkout/obj'
Creating a target for '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/a'
(lldb) settings set auto-confirm true

(lldb) version
lldb version 22.1.2 
(lldb) command script import /checkout/src/etc/lldb_lookup.py
(lldb) script print(lldb_lookup.FEATURE_FLAGS)
(lldb) breakpoint set --file 'main.rs' --line 130
DEBUG: breakpoint added, id = 1
Breakpoint 1: where = a`main::main + 1256 at main.rs:130:9, address = 0x0000000000001868 
DEBUG: registering breakpoint callback, id = 1
DEBUG: successfully registered breakpoint callback, id = 1
(lldb) run
(lldb) type category disable system

(lldb) repr a
Traceback (most recent call last):
  File "/checkout/src/etc/debugger_tester/lldb/batchmode.py", line 300, in main
    all_ok &= dispatch_repr(var_name, breakpoint_index, frame)
              ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/checkout/src/etc/debugger_tester/lldb/batchmode.py", line 185, in dispatch_repr
    return check(var_name, breakpoint_index, frame) == Result.Ok
           ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 69, in check
    result = var_matches(var, expected, valobj)
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 258, in var_matches
    children_ok = children_match(
        var.children, expected.children, valobj.GetName(), valobj
    )
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 441, in children_match
    result &= children_match(
              ~~~~~~~~~~~~~~^
        got.children,
        ^^^^^^^^^^^^^
    ...<2 lines>...
        valobj.GetChildAtIndex(i),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 411, in children_match
    missing.append(exp.name)
                   ^^^^^^^^
AttributeError: 'ArrayChild' object has no attribute 'name'

------lldb-22 stderr------------------------------
warning: This version of LLDB has no plugin for the language "rust". Inspection of frame variables will be limited.
error: The current driver doesn't allow custom exit codes for the quit command.

------------------------------------------

error: Error while running LLDB
status: signal: 15 (SIGTERM)
command: DEBUGGER_TESTER_BLESS_TEST_DATA="0" DEBUGGER_TESTER_DEBUGGER="lldb" DEBUGGER_TESTER_INPUT_DATA_PATH="/checkout/tests/debuginfo/wideptr_visualizer/lldb_input/non_windows.json" DEBUGGER_TESTER_SCRIPT_PATH="/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/main.debugger.script" DEBUGGER_TESTER_TARGET_PATH="/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/a" DEBUGGER_TESTER_TARGET_TRIPLE="aarch64-unknown-linux-gnu" PATH="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PYTHONPATH="/checkout/src/etc" PYTHONUNBUFFERED="1" "lldb-22" "--batch" "--one-line" "script --language python -- import debugger_tester; debugger_tester.main()"
--- stdout -------------------------------
(lldb) script --language python -- import debugger_tester; debugger_tester.main()
LLDBFeature.StaticFields|TypeRecognizers|Float128
LLDB batch-mode script
----------------------
Python version: 3.14.4 (main, Aug 20 2026, 10:41:58) [GCC 15.2.0]
Debugger commands script is '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/main.debugger.script'.
Target executable is '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/a'.
Current working directory is '/checkout/obj'
Creating a target for '/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/wideptr_visualizer/main.lldb/a'
(lldb) settings set auto-confirm true

(lldb) version
lldb version 22.1.2 
(lldb) command script import /checkout/src/etc/lldb_lookup.py
(lldb) script print(lldb_lookup.FEATURE_FLAGS)
(lldb) breakpoint set --file 'main.rs' --line 130
DEBUG: breakpoint added, id = 1
Breakpoint 1: where = a`main::main + 1256 at main.rs:130:9, address = 0x0000000000001868 
DEBUG: registering breakpoint callback, id = 1
DEBUG: successfully registered breakpoint callback, id = 1
(lldb) run
(lldb) type category disable system

(lldb) repr a
Traceback (most recent call last):
  File "/checkout/src/etc/debugger_tester/lldb/batchmode.py", line 300, in main
    all_ok &= dispatch_repr(var_name, breakpoint_index, frame)
              ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/checkout/src/etc/debugger_tester/lldb/batchmode.py", line 185, in dispatch_repr
    return check(var_name, breakpoint_index, frame) == Result.Ok
           ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 69, in check
    result = var_matches(var, expected, valobj)
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 258, in var_matches
    children_ok = children_match(
        var.children, expected.children, valobj.GetName(), valobj
    )
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 441, in children_match
    result &= children_match(
              ~~~~~~~~~~~~~~^
        got.children,
        ^^^^^^^^^^^^^
    ...<2 lines>...
        valobj.GetChildAtIndex(i),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/checkout/src/etc/debugger_tester/lldb/check_lldb.py", line 411, in children_match
    missing.append(exp.name)
                   ^^^^^^^^
AttributeError: 'ArrayChild' object has no attribute 'name'
------------------------------------------
--- stderr -------------------------------
warning: This version of LLDB has no plugin for the language "rust". Inspection of frame variables will be limited.
error: The current driver doesn't allow custom exit codes for the quit command.
------------------------------------------

---- [debuginfo-lldb] tests/debuginfo/wideptr_visualizer/main.rs stdout end ----

failures:
    [debuginfo-lldb] tests/debuginfo/wideptr_visualizer/main.rs

test result: FAILED. 241 passed; 1 failed; 322 ignored; 0 measured; 0 filtered out; finished in 17.15s

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants