Fix printing of global variable stubs if no inferior is running

Since 3c45e9f915 gdb crashes when trying
to print a global variable stub without a running inferior, because of
a missing nullptr-check (the block_scope function took care of that
check before it was converted to a method).

With this check it works again:
```
(gdb) print s
$1 = <incomplete type>
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31128
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Hannes Domani
2023-12-08 19:06:14 +01:00
parent cff7135813
commit 576745e26c
3 changed files with 68 additions and 1 deletions

View File

@@ -1027,7 +1027,11 @@ cp_lookup_transparent_type (const char *name)
/* If that doesn't work and we're within a namespace, look there
instead. */
scope = get_selected_block (0)->scope ();
const block *block = get_selected_block (0);
if (block == nullptr)
return nullptr;
scope = block->scope ();
if (scope[0] == '\0')
return NULL;