The Python API gdb.lookup_type fails for Rust. From jrmuizel: struct Foo { g: u32, h: u32 } fn main() { let f = Foo{ g: 8, h: 9 }; println!("Hello, world!"); } gives: (gdb) python print(gdb.lookup_type(str(gdb.parse_and_eval("f").type))) Traceback (most recent call last): File "<string>", line 1, in <module> gdb.error: No type named tmp::Foo. Error while executing Python code. (gdb)
The issue seems to be that lookup_typename looks in VAR_DOMAIN, but the symbol in question is in STRUCT_DOMAIN. Two possible fixes come to mind. One is to attempt to put all Rust types into VAR_DOMAIN. This arguably even makes sense because VAR_DOMAIN is defined as holding typedefs (which seems weird -- having a real "types" domain might be preferable, but much harder). This change could probably be done just in dwarf2read.c, though patching rust_lookup_type would be good to do as well. It's unclear what other issues this might introduce. The second possible fix is to have typy_lookup_typename also search STRUCT_DOMAIN if the VAR_DOMAIN search fails.
Actually the simplest is just adding to the special case in symbol_matches_domain. I sort of hate to do this but...
Testing a patch.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=65547233e04b32e087f74f8f5e9d3ffb6fe2c198 commit 65547233e04b32e087f74f8f5e9d3ffb6fe2c198 Author: Tom Tromey <tom@tromey.com> Date: Thu Jul 13 15:03:27 2017 -0600 Make gdb.lookup_typename work for Rust types PR rust/21763 points out that gdb.lookup_typename does not work properly for (some) Rust types. I tracked this down to a missing case in symbol_matches_domain. Tested by the buildbot. 2017-07-14 Tom Tromey <tom@tromey.com> PR rust/21763: * symtab.c (symbol_matches_domain): Add language_rust to special case. * rust-exp.y (convert_ast_to_expression) <OP_VAR_VALUE>: Don't treat LOC_TYPEDEF symbols as variables. 2017-07-14 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Add regression test for PR rust/21763.
Fix checked in.