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

Simon Marchi via Gdb-patches
2023-01-30T16:08:32Z

On 1/30/23 11:03, Simon Marchi wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> New in v2:
>
> - move the implementation to the cooked_index_vector class
> - use the gdbarch from the objfile
> - add some QUIT macro calls
> - add call to wait, to ensure the index is finished
>
> As I am investigating a crash I see with the cooked index, I thought it
> would be useful to have a way to dump the index contents. For those not
> too familiar with it (that includes me), it can help get a feel of what
> it contains and how it is structured.
>
> The cooked_index_functions::dump function is called as part of the
> "maintenance print objfiles" command. I tried to make the output
> well structured and indented to help readability, as this prints a lot
> of text.
>
> The dump function first dumps all cooked index entries, like this:
>
> [25] ((cooked_index_entry *) 0x621000121220)
> name: __ioinit
> canonical: __ioinit
> DWARF tag: DW_TAG_variable
> flags: 0x2 [IS_STATIC]
> DIE offset: 0x21a4
> parent: ((cooked_index_entry *) 0x6210000f9610) [std]
>
> Then the information about the main symbol:
>
> main: ((cooked_index_entry *) 0x621000123b40) [main]
>
> And finally the address map contents:
>
> [1] ((addrmap *) 0x6210000f7910)
>
> [0x0] ((dwarf2_per_cu_data *) 0)
> [0x118a] ((dwarf2_per_cu_data *) 0x60c000007f00)
> [0x1cc7] ((dwarf2_per_cu_data *) 0)
> [0x1cc8] ((dwarf2_per_cu_data *) 0x60c000007f00)
> [0x1cdf] ((dwarf2_per_cu_data *) 0)
> [0x1ce0] ((dwarf2_per_cu_data *) 0x60c000007f00)
>
> The display of address maps above could probably be improved, to show it
> more as ranges, but I think this is a reasonable start.
>
> Note that this patch depends on Pedro Alves' patch "enum_flags
> to_string" [1]. If my patch is to be merged before Pedro's series, I
> will cherry-pick this patch from his series and merge it before mine.
>
> [1] https://inbox.sourceware.org/gdb-patches/20221212203101.1034916-8-pedro@palves.net/

I just realized, this patch also depends on the following patch:

[PATCH v2] Make addrmap const-correct in cooked index
https://inbox.sourceware.org/gdb-patches/20230130152936.41750-1-simon.marchi@efficios.com/T/#u

Simon