Remove unnecessary call to dwarf_diecu
Correctly handle DW_FORM_flag and add DW_FORM_flag_present support

Before this patch, running pahole on an executable compiled
with -gdwarf-4 gave:

DW_AT_<0x3c>=0x19

0x19 is DW_FORM_flag_present.
Also, DW_FORM_flag takes an argument.
Changing attr_numeric to call dwarf_formflag fixes both problems.
Remove unused field from debug_fmt_ops

Nothing seemed to use the 'tag__orig_type' method in debug_fmt_ops.
It was simpler to remove it than to try to fix it for the next patch.
Add support for .debug_types sections.

.debug_types is a new DWARF 4 feature that adds some simple
compression to DWARF.  The basic idea is that identical type
definitions are merged by the linker and put into a new .debug_types
section.

This introduces 'dwarf_off_ref', which is like Dwarf_Off, but carries
a flag indicating if the DIE came from .debug_types.  This allows
future uses to find the DIE properly.

Type units are read a little differently from ordinary CUs.  All type
units are read at once, then types are recoded for them.  (I think
something like this is needed more generally, to support inter-CU
references, but I have not tried that.)

The type unit is also kept around longer, because any other CU may
refer to it.  This necessitated a change to load_steal_kind to replace
the notion of a "stolen" CU with a request by the "stealer" for the
caller to delete the CU when appropriate.

I need elfutils patch 581c3f60e2b1fc7ddaf4260bb5a9cb59f8e3f0d0
to make this work properly; without it I see crashes.

You can make test cases by compiling with '-gdwarf-4 -fdebug-types-section'.
dwarf_loader: Add stub for DW_TAG_GNU_call_site{_parameter}

Need to study http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open
to implement proper support.

Reported-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Merge branch 'remove-unneeded-call' of https://github.com/tromey/dwarves
Merge branch 'debug-types' of https://github.com/tromey/dwarves
regtest: Accept --diff instad of plain 'diff' as long option

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarf loader: Fix some type/tag searches

The 2938a70 changeset incorectly changed some searches that needed to be
done on the all tags hashtable to the type only one.

This lead to problems such as:

[acme@sandy pahole]$ build/pahole /usr/lib/debug/usr/libexec/pt_chown.debug > /dev/null
tag__recode_dwarf_type: couldn't find 0xf7a type for 0x1133 (inlined_subroutine)!
tag__recode_dwarf_type: couldn't find 0x1047 type for 0x1166 (inlined_subroutine)!
tag__recode_dwarf_type: couldn't find 0xf7a type for 0x11a8 (inlined_subroutine)!
lexblock__recode_dwarf_types: couldn't find 0xf7a type for 0x1133 (inlined_subroutine)!
lexblock__recode_dwarf_types: couldn't find 0x1047 type for 0x1166 (inlined_subroutine)!
lexblock__recode_dwarf_types: couldn't find 0xf7a type for 0x11a8 (inlined_subroutine)!
[acme@sandy pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarf_loader: Stub for DW_TAG_GNU_call_site{_parameter} in inline expansion too

Need to study
http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open to
implement proper support.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
v1.10

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarf_loader: Don't stop processing after finding unsupported tag

After emitting a warning that a tag is not supported __die__process_tag
was returning NULL, making die__process_unit think that the problem
was insufficient memory.

Introduce a global variable 'unsupported_tag' and return it instead,
that way die__process_unit can distinguish ENOMEM from unsupported tags.

Reported-by: Thiago Macieira <thiago.macieira@intel.com>
Tested-by: Thiago Macieira <thiago.macieira@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
rpm: Add missing BuildRequires: zlib-devel

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarves: Stop using 'self'

As Thomas Gleixner wisely pointed out, using 'self' is stupid, it
doesn't convey useful information, so use sensible names.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarves: Support static class data members

Fixes the following BFA:

[acme@sandy pahole]$ pahole brainfart.o
class ios_base {
	enum _Ios_Openmodeconst    in;                   /*     0     4 */
	typedef enum _Ios_Fmtflags fmtflags;

	/* size: 1, cachelines: 1, members: 1 */
	/* padding: 65533 */
	/* last cacheline: 1 bytes */

	/* BRAIN FART ALERT! 1 != 4 + 0(holes), diff = -3 */

};

That now produces:

[acme@sandy pahole]$ build/pahole brainfart.o
class ios_base {
	static enum _Ios_Openmodeconst    in = 8;        /*     0     0 */
	typedef enum _Ios_Fmtflags fmtflags;

	/* size: 1, cachelines: 0, members: 0, static members: 1 */
	/* last cacheline: 1 bytes */
};
[acme@sandy pahole]$

Reported-by: Nicolas <nikos42@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>