Skip to content

Add infallible primitive type lookups to template arg resolver#157289

Open
Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:msvc_template_args
Open

Add infallible primitive type lookups to template arg resolver#157289
Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:msvc_template_args

Conversation

@Walnut356
Copy link
Copy Markdown
Contributor

Fixes a regression that seem to come from LLDB 22 where looking up primitive types by name on MSVC no longer works. Container types use type name lookups to resolve generics, so it causes container types (e.g. Vec<i32>) to fail to create their child values.

Before:

(lldb) v vec_v
(alloc::vec::Vec<i32,alloc::alloc::Global>) vec_v = size=5 {}
(lldb) v vec_v[0]
error: <user expression 0>:1:6: array index 0 is not valid for "(Vec<i32,alloc::alloc::Global>) vec_v"
   1 | vec_v[0]
     | ^

After:

(lldb) v vec_v
(alloc::vec::Vec<i32,alloc::alloc::Global>) vec_v = size=5 {
  [0] = 10
  [1] = 20
  [2] = 30
  [3] = 40
  [4] = 50
}
(lldb) v vec_v[0]
(long) vec_v[0] = 10

This patch maps the type name to its eBasicType equivalent (i.e. the LLDB enum for primitive types) and looks up the type based on that. AFAIK, eBasicType lookups are 100% infallible. Even if the primitive type somehow isn't in the debug info, TypeSystemClang will invent the appropriate SBType object for it.

This isn't a major blocker for the test suite rework, but it does prevent me from blessing tests with container types on MSVC unless I downgrade to LLDB 21.

r? @jieyouxu, @Kobzol

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 2, 2026

jieyouxu is not on the review rotation at the moment.
They may take a while to respond.

Comment thread src/etc/lldb_providers.py
equivalent = f"{arg_name[0]}{target.GetAddressByteSize() * 8}"
return target.GetBasicType(PRIMITIVE_TYPES[equivalent])

if (basic_type := PRIMITIVE_TYPES.get(arg_name)) is not None:
Copy link
Copy Markdown
Member

@Kobzol Kobzol Jun 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Walnut using Walrus, fancy 😆 I assume we don't need to support Python < 3.8? Based on https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731/3 it seems like 3.8 should be safe.

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC previously we need Python 3.10 (exactly; and its DLL in PATH on Windows) to even run the setup on Windows MSVC at all.

I'm also 100% fine (and supportive) if we want to set a minimum (or even exact) Python version required to run debuginfo test suite!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll hunt down the link, but I think the minimum as of is 3.11 because they wanted a consistent version between x64 windows and arm windows

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, that was just for the python version they build against for the pre-built distributions. In any case, 3.8 should definitely be safe

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! That become 3.11 now TIL

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants