Re: [PATCH v2] gdb/dwarf: dump cooked index contents in cooked_index_functions::dump

Simon Marchi via Gdb-patches
2023-01-31T15:35:58Z

On 1/31/23 09:19, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> See the patch below for a quick prototype.
> Simon> quick_symbol_functions::read_partial_symbols now returns a bool, and if
> Simon> it returns false (failure), objfile::require_partial_symbols removes
> Simon> that quick symbol instance from the qf list.
>
> I'm working to get rid of this lazy symbol stuff. So I'd rather not add
> another meaning to it. You can see the WIP on t/bg-dwarf-reading, but
> the basic idea is that instead of delaying the reading of DWARF, start
> the reading early and just delay the completion of it. I haven't sent
> this yet because it currently crashes, I think it will benefit from
> being rebased on the write-index-in-background patch.
>
> All the other methods in cooked_index_functions already do:
>
> dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
> if (per_objfile->per_bfd->index_table == nullptr)
> return;

Ah ok, I had not seen that. Then it makes sense to follow that paradigm
in dump too.

> So maybe this would be an ok choice for dump.
>
> As an aside the code is doing:
>
> if (per_bfd->index_table == nullptr)
> return nullptr;
> cooked_index_vector *table
> = (gdb::checked_static_cast<cooked_index_vector *>
> (per_bfd->index_table.get ()));
>
> It seems to me that it would be fine if checked_static_cast passed
> through null in this case -- that is, do not assert when the result is
> null if the parameter is also null.

I think that would make sense. Both static_cast and dynamic_cast return
nullptr if passed nullptr, so checked_static_cast should too.

However, in my case it would have crashed anyway on the following line
dereferencing the table variable.

Simon