Skip to content

Add infallible primitive type lookups to template arg resolver#157289

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

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

Conversation

@Walnut356
Copy link
Copy Markdown
Contributor

@Walnut356 Walnut356 commented Jun 2, 2026

View all comments

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
@jieyouxu jieyouxu added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-debuggers-lldb Area: lldb and removed A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) labels Jun 3, 2026
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, this indeed improves the output for me locally (msvc, lldb 22).

Test case

Used a tiny test case

//@ compile-flags: -g
//@ lldb-command: run
//@ lldb-command: v vec_0
//@ lldb-check: [...] vec_0 { }
//@ lldb-command: continue

fn main() {
    let vec_0 = vec![1, 2, 3];
    vec_0; // #break
}

I do indeed observe the fixed ouput 👍

v vec_0
(alloc::vec::Vec<i32,alloc::alloc::Global>) vec_0 = size=3 { [0] = 1 [1] = 2 [2] = 3 }

Other remarks

Looks like the package change meant that lldb_batchmode/runner.py need to update the path in which breakpoint_callback is referenced (as discussed),

diff --git a/src/etc/lldb_batchmode/runner.py b/src/etc/lldb_batchmode/runner.py
index e9b106390f6..bdeee3f3458 100644
--- a/src/etc/lldb_batchmode/runner.py
+++ b/src/etc/lldb_batchmode/runner.py
@@ -98,7 +98,7 @@ def execute_command(command_interpreter, command):
                     "registering breakpoint callback, id = " + str(breakpoint_id)
                 )
                 callback_command = f"breakpoint command add -s python {str(breakpoint_id)} -o \
-                    'import lldb_batchmode; lldb_batchmode.breakpoint_callback'"
+                    'import lldb_batchmode; lldb_batchmode.runner.breakpoint_callback'"

                 command_interpreter.HandleCommand(callback_command, res)
                 if res.Succeeded():

We can just roll this into this PR, you can r=me after.

View changes since this review

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Jun 6, 2026

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 6, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks!

I confirm this achieves It Works On My Machine™️ status

@bors r+ rollup

View changes since this review

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

📌 Commit bde0008 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 6, 2026
@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu closed this Jun 6, 2026
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 6, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

This pull request was unapproved due to being closed.

@jieyouxu jieyouxu reopened this Jun 6, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 6, 2026
@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Jun 6, 2026

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

📌 Commit bde0008 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 6, 2026
…eyouxu

Add infallible primitive type lookups to template arg resolver

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
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r-
#157528 (comment)

Probably this pr?
@bors try jobs=aarch64-apple

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 6, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

This pull request was unapproved.

This PR was contained in a rollup (#157528), which was unapproved.

View changes since this unapproval

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
Add infallible primitive type lookups to template arg resolver


try-job: aarch64-apple
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

💔 Test for 824b465 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@Walnut356
Copy link
Copy Markdown
Contributor Author

cannot import name 'eBasicTypeFloat128' from 'lldb'

LLDB versioning strikes again =)

@Walnut356 Walnut356 force-pushed the msvc_template_args branch from bde0008 to c6945a5 Compare June 6, 2026 15:24
@Walnut356
Copy link
Copy Markdown
Contributor Author

should be good now, just gated the import behind a feature flag.

@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented Jun 6, 2026

@bors try jobs=aarch64-apple

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
Add infallible primitive type lookups to template arg resolver


try-job: aarch64-apple
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

☀️ Try build successful (CI)
Build commit: 1254eb0 (1254eb0c9c84b5a07df90159025acc3002590958, parent: 8954863c81df429ebf96ea38a16c76f209995833)

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Jun 7, 2026

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 7, 2026

📌 Commit c6945a5 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 7, 2026
@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented Jun 7, 2026

@bors rollup=iffy

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 7, 2026
…eyouxu

Add infallible primitive type lookups to template arg resolver

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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 7, 2026
…eyouxu

Add infallible primitive type lookups to template arg resolver

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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 7, 2026
…eyouxu

Add infallible primitive type lookups to template arg resolver

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
rust-bors Bot pushed a commit that referenced this pull request Jun 7, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #157447 (Move cross crate tests into the appropriate folder)
 - #145108 (Resolver: Batched Import Resolution)
 - #156119 (Further optimize `SliceIndex<str>` impl for `Range<usize>`)
 - #157289 (Add infallible primitive type lookups to template arg resolver)
 - #157540 (Cleanup and optimize `render_impls`)
 - #157543 (Reorganize `tests/ui/issues` [5/N])
 - #156188 (riscv: promote d, e, and f target_features to CfgStableToggleUnstable)
 - #157323 (Document Repeat::last panic behavior)
 - #157545 (Suggest using comma to separate valid attribute list items)
 - #157559 (chore: Update annotate-snippets to 0.12.16)
rust-bors Bot pushed a commit that referenced this pull request Jun 7, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #157447 (Move cross crate tests into the appropriate folder)
 - #145108 (Resolver: Batched Import Resolution)
 - #156119 (Further optimize `SliceIndex<str>` impl for `Range<usize>`)
 - #157289 (Add infallible primitive type lookups to template arg resolver)
 - #157540 (Cleanup and optimize `render_impls`)
 - #157543 (Reorganize `tests/ui/issues` [5/N])
 - #156188 (riscv: promote d, e, and f target_features to CfgStableToggleUnstable)
 - #157323 (Document Repeat::last panic behavior)
 - #157545 (Suggest using comma to separate valid attribute list items)
 - #157559 (chore: Update annotate-snippets to 0.12.16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-debuggers-lldb Area: lldb S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants