Fix gdb.lookup_type for function-local types

Looking for a type defined locally in a function doesn't work
any more since the introduction of TYPE_DOMAIN:
```
(gdb) python print (gdb.lookup_type ('main()::Local'))
Python Exception <class 'gdb.error'>: No type named main()::Local.
Error occurred in Python: No type named main()::Local.
```

cp_search_static_and_baseclasses was simply missing a check for
SEARCH_TYPE_DOMAIN, now it works again:
```
(gdb) python print (gdb.lookup_type ('main()::Local'))
Local
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31922
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Hannes Domani
2024-06-24 18:45:37 +02:00
parent a6e529673a
commit 5ae5974d60
3 changed files with 13 additions and 2 deletions

View File

@@ -287,10 +287,10 @@ cp_search_static_and_baseclasses (const char *name,
struct type *scope_type = scope_sym.symbol->type ();
/* If the scope is a function/method, then look up NESTED as a local
static variable. E.g., "print 'function()::static_var'". */
static variable or type. E.g., "print 'function()::static_var'". */
if ((scope_type->code () == TYPE_CODE_FUNC
|| scope_type->code () == TYPE_CODE_METHOD)
&& (domain & SEARCH_VAR_DOMAIN) != 0)
&& (domain & (SEARCH_VAR_DOMAIN | SEARCH_TYPE_DOMAIN)) != 0)
return lookup_symbol (nested, scope_sym.symbol->value_block (),
domain, NULL);