| Issue |
233346
|
| Summary |
[LLDB] Type lookups fail with type name provided by `SBValue.GetTypeName()`
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Walnut356
|
This is when using `llvm-project/master` from ~1 week ago, but it probably also occurs in LLDB 23 and 22.
Simple rust program, compiled on linux:
```rust
use std::hint::black_box;
fn main() {
let x = vec![0u8]; // type is Vec<u8>, which desugars to alloc::vec::Vec<u8, alloc::alloc::Global>
black_box(x);
}
```
lldb commands and output:
```
(lldb) b main.rs:5
Breakpoint 1: where = z`z::main + 241 at main.rs:5:5, address = 0x0000000000014c21
(lldb) run
Process 188450 launched: '/home/walnut356/notmycode/llvm-project/z/target/debug/z' (x86_64)
Process 188450 stopped
* thread #1, name = 'z', stop reason = breakpoint 1.1
frame #0: 0x0000555555568c21 z`z::main at main.rs:5:5
2
3 fn main() {
4 let x = vec![0u8];
-> 5 black_box(x);
6 }
warning: this version of LLDB has no plugin for the language "rust". Inspection of frame variables will be limited
(lldb) script lldb.frame.var("x").GetType()
template<> struct Vec<unsigned char, alloc::alloc::Global> {
alloc::raw_vec::RawVec<unsigned char, alloc::alloc::Global> buf;
unsigned long len;
}
(lldb) script lldb.frame.var("x").GetTypeName()
'alloc::vec::Vec<unsigned char, alloc::alloc::Global>'
(lldb) script lldb.target.FindFirstType(lldb.frame.var("x").GetTypeName())
No value
(lldb) script lldb.target.FindFirstType("Vec<unsigned char, alloc::alloc::Global>")
No value
(lldb) script lldb.target.FindFirstType("alloc::vec::Vec<u8, alloc::alloc::Global>")
No value
(lldb) script lldb.target.FindFirstType("Vec<u8, alloc::alloc::Global>")
No value
```
I tried both `u8` and `unsigned char` due to `TypeSystemClang`'s primitive type normalization. I also tried both qualified and unqualified paths.
The results are the same when using the `type lookup` command.
I set a breakpoint in LLDB and stepped through the lookup behavior a bit (though I don't fully understand how it works). One thing that definitely struck me as odd was here:
https://github.com/llvm/llvm-project/blob/aa673fae32d57e8d9bd65dabc48eb361439aa55f/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp#L457
Inspecting `m_set` further, it absolutely contains nodes with the appropriate name (sorry for the godawful list comprehension, we're essentially just checking checking every `m_set.types.m_map.m_map` value to see if the `cstring` field contains what we're looking for):
```
script [x for x in lldb.frame.var("this").GetChildMemberWithName("m_set").GetChildMemberWithName("types").GetChildMemberWithName("m_map").GetChildMemberWithName("m_map").children if (y := x.GetChildAtIndex(0).GetChildAtIndex(0).GetPointeeData(0, 100).GetString(lldb.SBError(), 0)) is not None and y == "Vec<unsigned char, alloc::alloc::Global>" or y == "Vec<u8, alloc::alloc::Global>"]
[(lldb_private::UniqueCStringMap<lldb_private::plugin::dwarf::DIERef>::Entry) [81] = {
cstring = (m_string = "Vec<u8, alloc::alloc::Global>")
value = {
m_die_offset = 517
m_file_index = 0
m_file_index_valid = 0
m_section = 0
}
}, (lldb_private::UniqueCStringMap<lldb_private::plugin::dwarf::DIERef>::Entry) [82] = {
cstring = (m_string = "Vec<u8, alloc::alloc::Global>")
value = {
m_die_offset = 1195
m_file_index = 0
m_file_index_valid = 0
m_section = 0
}
}, (lldb_private::UniqueCStringMap<lldb_private::plugin::dwarf::DIERef>::Entry) [83] = {
cstring = (m_string = "Vec<u8, alloc::alloc::Global>")
value = {
m_die_offset = 8139
m_file_index = 0
m_file_index_valid = 0
m_section = 0
}
}]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs