dwarf_loader: Initial support for DW_TAG_partial_unit

This allows processing DW_TAG_partial_unit sections, which gets us from
no tags processed in files contained such tags to at least showing the
tags present in those sections.

Further work is required to support DW_TAG_compile_unit sections using
DW_TAG_imported_unit to import those DW_TAG_partial_unit sections, which
will be done by basically readding the contents of the
DW_TAG_partial_unit sections to the DW_TAG_compile_unit sections
importing them and then recoding as if all the tags in the partial units
were in the compile units.

This will make sure we have a contiguous series of types used in a
compile unit so that the converting routines to CTF and BTF can work
just as before.

On a fedora 27 system:

Before:

  $ pahole /usr/lib/debug/usr/lib64/libgtk-3.so.0.2200.19.debug
  die__process: DW_TAG_compile_unit or DW_TAG_type_unit expected got partial_unit!
  $

After:

  $ pahole /usr/lib/debug/usr/lib64/libgtk-3.so.0.2200.19.debug
  struct _GTimeVal {
          glong                      tv_sec;         /*     0     8 */
          glong                      tv_usec;        /*     8     8 */

          /* size: 16, cachelines: 1, members: 2 */
          /* last cacheline: 16 bytes */
  };
  struct _GError {
          GQuark                     domain;         /*     0     4 */
          gint                       code;           /*     4     4 */
          gchar *                    message;        /*     8     8 */

          /* size: 16, cachelines: 1, members: 3 */
          /* last cacheline: 16 bytes */
  };
  struct _GCond {
          gpointer                   p;              /*     0     8 */
          guint                      i[2];           /*     8     8 */

          /* size: 16, cachelines: 1, members: 2 */
          /* last cacheline: 16 bytes */
  };
<SNIP some more structs found in DW_TAG_partial unit sections...>
  struct _GSourceFuncs {
          gboolean                   (*prepare)(GSource *, gint *); /*     0     8 */
          gboolean                   (*check)(GSource *);  /*     8     8 */
          gboolean                   (*dispatch)(GSource *, GSourceFunc, gpointer); /*    16     8 */
          void                       (*finalize)(GSource *); /*    24     8 */
          GSourceFunc                closure_callback;     /*    32     8 */
          GSourceDummyMarshal        closure_marshal;      /*    40     8 */

          /* size: 48, cachelines: 1, members: 6 */
          /* last cacheline: 48 bytes */
  };
  struct _GThreadFunctions {
          GMutex *                   (*mutex_new)(void);   /*     0     8 */
          void                       (*mutex_lock)(GMutex *); /*     8     8 */
          gboolean                   (*mutex_trylock)(GMutex *)tag__recode_dwarf_type: couldn't find 0x74 type for 0x7fc (typedef)!
  tag__recode_dwarf_type: couldn't find 0x7e type for 0x829 (pointer_type)!
  tag__recode_dwarf_type: couldn't find 0x829 type for 0x844 (variable)!
  tag__recode_dwarf_type: couldn't find 0x7e type for 0x850 (variable)!
  tag__recode_dwarf_type: couldn't find 0x22 type for 0x85b (variable)!
  tag__recode_dwarf_type: couldn't find 0x22 type for 0x866 (variable)!
  tag__recode_dwarf_type: couldn't find 0x22 type for 0x871 (variable)!
  namespace__recode_dwarf_types: couldn't find 0x7fc type for 0x8a4 (member)!
  tag__recode_dwarf_type: couldn't find 0xfa type for 0x8e8 (volatile_type)!
  namespace__recode_dwarf_types: couldn't find 0x8b2 type for 0x90d (member)!
  tag__recode_dwarf_type: couldn't find 0x1b type for 0x941 (typedef)!
<SNIP>
  $

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2018-08-13 16:03:33 -03:00
parent e975ff247a
commit f727c22191
1 changed files with 2 additions and 2 deletions

View File

@ -2056,8 +2056,8 @@ static int die__process(Dwarf_Die *die, struct cu *cu)
Dwarf_Die child;
const uint16_t tag = dwarf_tag(die);
if (tag != DW_TAG_compile_unit && tag != DW_TAG_type_unit) {
fprintf(stderr, "%s: DW_TAG_compile_unit or DW_TAG_type_unit expected got %s!\n",
if (tag != DW_TAG_compile_unit && tag != DW_TAG_type_unit && tag != DW_TAG_partial_unit) {
fprintf(stderr, "%s: DW_TAG_compile_unit, DW_TAG_type_unit or DW_TAG_partial_unit expected got %s!\n",
__FUNCTION__, dwarf_tag_name(tag));
return -EINVAL;
}