]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/dwarf: print DWARF CUs/TUs in "maint print objfiles"
authorSimon Marchi <simon.marchi@polymtl.ca>
Tue, 18 Feb 2025 19:31:28 +0000 (14:31 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 10 Mar 2025 20:09:02 +0000 (16:09 -0400)
commite9386435c94f10c3d047142fdb9b85f1486e2f14
treef8d56b686a21baa6a1951121344c280c7cab177f
parent6cbd64aa3eb0e6749c7b75dbaac334b369912c15
gdb/dwarf: print DWARF CUs/TUs in "maint print objfiles"

This was useful to me, to debug some problems.

Before printing cooked index entries, print a list of CUs and TUs.  The
information printed for each is a bit arbitrary, I took a look at the
types and printed what seemed relevant.

An example of output for a CU:

    [0] ((dwarf2_per_cu_data *) 0x50f000007840)
    type:       DW_UT_compile
    offset:     0x0
    size:       0x1bff
    artificial: false
    GDB lang:   c++
    DWARF lang: DW_LANG_C_plus_plus

And for a TU:

    [2] ((signatured_type *) 0x511000040000)
    type:      DW_UT_type
    offset:    0x0
    size:      0x94
    signature: 0x2e966c0dc94b065b

I moved the call to cooked_index_functions::wait before printing the
CU/TU list, otherwise trying to call "maint print objfiles" quickly,
like this, would lead to an internal error:

  $ ./gdb  -nx -q --data-directory=data-directory testsuite/outputs/gdb.dwarf2/struct-with-sig/struct-with-sig -ex "maint print objfiles"

This is because dwarf2_per_cu_data::m_unit_type was not yet set, when
trying to read it.  Waiting for the index to be built ensures that it is
set, since setting the unit type is done as a side-effect somewhere.

Change-Id: Ic810ec3bb4d3f5abb481cf1cee9b2954ff4f0874
gdb/dwarf2/cooked-index.h
gdb/dwarf2/read.c