Commit Graph

316 Commits

Author SHA1 Message Date
Domenico Andreoli e714d2eaa1 Adopt SPDX-License-Identifier
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-01-18 15:41:48 -03:00
Yonghong Song b79db4cab4 dwarves: add __int128 types in base_type_name_to_size
Added int128 types to dwarf base_type_name_to_size table
so that the correct base type size can be retrieved in certain
cases. Note that for type "unsigned __int128", the dwarf in gcc
has type name "__int128 unsigned" while clang has
"unsigned __int128".

  -bash-4.4$ cat t.c
  struct t {
        __int128 si128a;
        __int128 si128b;
        unsigned __int128 bits3:3;
        unsigned __int128 bits80:80;
        unsigned __int128 ui128;
  } g;
  -bash-4.4$ clang -O2 -c -g -target bpf -Xclang -target-feature -Xclang +dwarfris t.c
  -bash-4.4$ pahole -F dwarf t.o
  struct t {
        __int128                   si128a;               /*     0    16 */
        __int128                   si128b;               /*    16    16 */
        unsigned __int128          bits3:3;              /*    32:125 16 */
        unsigned __int128          bits80:80;            /*    32:45 16 */

        /* XXX 45 bits hole, try to pack */

        unsigned __int128          ui128;                /*    48    16 */

        /* size: 64, cachelines: 1, members: 5 */
        /* bit holes: 1, sum bit holes: 45 bits */
  };
  -bash-4.4$ pahole -F btf t.o
  struct t {
        __int128                   si128a;               /*     0    16 */
        __int128                   si128b;               /*    16    16 */
        unsigned __int128          bits3:3;              /*    32:125 16 */
        unsigned __int128          bits80:80;            /*    32:45 16 */

        /* XXX 45 bits hole, try to pack */

        unsigned __int128          ui128;                /*    48    16 */

        /* size: 64, cachelines: 1, members: 5 */
        /* bit holes: 1, sum bit holes: 45 bits */
  };
  -bash-4.4$ pahole -JV t.o
  File t.o:
  [1] STRUCT t kind_flag=1 size=64 vlen=5
        si128a type_id=2 bitfield_size=0 bits_offset=0
        si128b type_id=2 bitfield_size=0 bits_offset=128
        bits3 type_id=3 bitfield_size=3 bits_offset=256
        bits80 type_id=3 bitfield_size=80 bits_offset=259
        ui128 type_id=3 bitfield_size=0 bits_offset=384
  [2] INT __int128 size=16 bit_offset=0 nr_bits=128 encoding=SIGNED
  [3] INT unsigned __int128 size=16 bit_offset=0 nr_bits=128 encoding=(none)
  [4] INT (anon) size=4 bit_offset=0 nr_bits=32 encoding=(none)
  -bash-4.4$

Committer testing:

Before:

  $ cat __int128.c
    struct t {
          __int128 si128a;
          __int128 si128b;
          unsigned __int128 bits3:3;
          unsigned __int128 bits80:80;
          unsigned __int128 ui128;
    } g;
  $ clang -O2 -c -g -target bpf -Xclang -target-feature -Xclang +dwarfris __int128.c
  $ pahole __int128.o
  base_type__name_to_size: base_type unsigned __int128
  base_type__name_to_size: base_type unsigned __int128
  struct t {
  	__int128                   si128a;               /*     0    16 */
  	__int128                   si128b;               /*    16    16 */
  	unsigned __int128          bits3:3;              /*    32:125  0 */
  	unsigned __int128          bits80:80;            /*    32:45  0 */

  	/* XXX 173 bits hole, try to pack */
  	/* XXX 16 bytes hole, try to pack */

  	unsigned __int128          ui128;                /*    48    16 */

  	/* size: 64, cachelines: 1, members: 5 */
  	/* sum members: 48, holes: 1, sum holes: 16 */
  	/* bit holes: 1, sum bit holes: 173 bits */
  };
  $ pahole -J __int128.o
  base_type__name_to_size: base_type unsigned __int128
  base_type__name_to_size: base_type unsigned __int128

After:

  $ pahole -F dwarf __int128.o
  struct t {
  	__int128                   si128a;               /*     0    16 */
  	__int128                   si128b;               /*    16    16 */
  	unsigned __int128          bits3:3;              /*    32:125 16 */
  	unsigned __int128          bits80:80;            /*    32:45 16 */

  	/* XXX 45 bits hole, try to pack */

  	unsigned __int128          ui128;                /*    48    16 */

  	/* size: 64, cachelines: 1, members: 5 */
  	/* bit holes: 1, sum bit holes: 45 bits */
  };
  $
  $ pahole -J __int128.o
  $ pahole -F btf __int128.o
  struct t {
  	__int128                   si128a;               /*     0    16 */
  	__int128                   si128b;               /*    16    16 */
  	unsigned __int128          bits3:3;              /*    32:125 16 */
  	unsigned __int128          bits80:80;            /*    32:45 16 */

  	/* XXX 45 bits hole, try to pack */

  	unsigned __int128          ui128;                /*    48    16 */

  	/* size: 64, cachelines: 1, members: 5 */
  	/* bit holes: 1, sum bit holes: 45 bits */
  };
  $

Signed-off-by: Yonghong Song <yhs@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-01-10 16:58:56 -03:00
Arnaldo Carvalho de Melo da18bb340b dwarves: Check if the tag is a 'struct class' in class__find_holes()
In pahole we started showing 'union' tags as well, and those are
represented by 'struct type', so be defensive in class__find_holes(),
checking if the tag is represented with a 'struct class'.

Tested-by: Andrii Nakryiko <andriin@fb.com>
Fixes: 31664d60ad ("pahole: Show tagged enums as well when no class is specified")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-01-10 15:26:13 -03:00
Arnaldo Carvalho de Melo 472256d3c5 btf_loader: Introduce a loader for the BTF format
Show 'struct list_head' from DWARF info:

  $ pahole -C list_head ~/git/build/v4.20-rc5+/net/ipv4/tcp.o
  struct list_head {
	  struct list_head *         next;                 /*     0     8 */
	  struct list_head *         prev;                 /*     8     8 */

	  /* size: 16, cachelines: 1, members: 2 */
	  /* last cacheline: 16 bytes */
  };

Try to show it from BTF, on a file without it:

  $ pahole -F btf -C list_head ~/git/build/v4.20-rc5+/net/ipv4/tcp.o
  pahole: /home/acme/git/build/v4.20-rc5+/net/ipv4/tcp.o: No debugging information found

Encode BTF from the DWARF info:

  $ pahole -J ~/git/build/v4.20-rc5+/net/ipv4/tcp.o

Check that it is there:
  $ readelf -SW ~/git/build/v4.20-rc5+/net/ipv4/tcp.o  | grep BTF
  readelf: /home/acme/git/build/v4.20-rc5+/net/ipv4/tcp.o: Warning: possibly corrupt ELF header - it has a non-zero program header offset, but no program headers
    [136] .BTF              PROGBITS        0000000000000000 101d0e 042edf 00      0   0  1

Now try again printing 'struct list_head' from the BTF info just
encoded:

  $ pahole -F btf -C list_head ~/git/build/v4.20-rc5+/net/ipv4/tcp.o  2> /dev/null
  struct list_head {
	  struct list_head *         next;                 /*     0     8 */
	  struct list_head *         prev;                 /*     8     8 */

	  /* size: 16, cachelines: 1, members: 2 */
	  /* last cacheline: 16 bytes */
  };
  $

There is the bitfields case that BTF desn't have the bit_size info for
bitfield members that makes the output from dwarf to be different than
the one from BTF:

  $ pahole -F btf -C sk_buff ~/git/build/v4.20-rc5+/net/ipv4/tcp.o > /tmp/sk_buff.btf
  $ pahole -F dwarf -C sk_buff ~/git/build/v4.20-rc5+/net/ipv4/tcp.o > /tmp/sk_buff.dwarf
  $ diff -u /tmp/sk_buff.dwarf /tmp/sk_buff.btf
  --- /tmp/sk_buff.dwarf	2018-12-20 14:50:51.428653046 -0300
  +++ /tmp/sk_buff.btf	2018-12-20 14:50:46.302601516 -0300
  @@ -38,45 +38,45 @@
   	__u16                      hdr_len;              /*   138     2 */
   	__u16                      queue_mapping;        /*   140     2 */
   	__u8                       __cloned_offset[0];   /*   142     0 */
  -	__u8                       cloned:1;             /*   142: 7  1 */
  -	__u8                       nohdr:1;              /*   142: 6  1 */
  -	__u8                       fclone:2;             /*   142: 4  1 */
  -	__u8                       peeked:1;             /*   142: 3  1 */
  -	__u8                       head_frag:1;          /*   142: 2  1 */
  -	__u8                       xmit_more:1;          /*   142: 1  1 */
  -	__u8                       pfmemalloc:1;         /*   142: 0  1 */
  +	__u8                       cloned;               /*   142     1 */
  +	__u8                       nohdr;                /*   142     1 */
  +	__u8                       fclone;               /*   142     1 */
  +	__u8                       peeked;               /*   142     1 */
  +	__u8                       head_frag;            /*   142     1 */
  +	__u8                       xmit_more;            /*   142     1 */
  +	__u8                       pfmemalloc;           /*   142     1 */

   	/* XXX 1 byte hole, try to pack */

   	__u32                      headers_start[0];     /*   144     0 */
   	__u8                       __pkt_type_offset[0]; /*   144     0 */
  -	__u8                       pkt_type:3;           /*   144: 5  1 */
  -	__u8                       ignore_df:1;          /*   144: 4  1 */
  -	__u8                       nf_trace:1;           /*   144: 3  1 */
  -	__u8                       ip_summed:2;          /*   144: 1  1 */
  -	__u8                       ooo_okay:1;           /*   144: 0  1 */
  -	__u8                       l4_hash:1;            /*   145: 7  1 */
  -	__u8                       sw_hash:1;            /*   145: 6  1 */
  -	__u8                       wifi_acked_valid:1;   /*   145: 5  1 */
  -	__u8                       wifi_acked:1;         /*   145: 4  1 */
  -	__u8                       no_fcs:1;             /*   145: 3  1 */
  -	__u8                       encapsulation:1;      /*   145: 2  1 */
  -	__u8                       encap_hdr_csum:1;     /*   145: 1  1 */
  -	__u8                       csum_valid:1;         /*   145: 0  1 */
  -	__u8                       csum_complete_sw:1;   /*   146: 7  1 */
  -	__u8                       csum_level:2;         /*   146: 5  1 */
  -	__u8                       csum_not_inet:1;      /*   146: 4  1 */
  -	__u8                       dst_pending_confirm:1; /*   146: 3  1 */
  -	__u8                       ndisc_nodetype:2;     /*   146: 1  1 */
  -	__u8                       ipvs_property:1;      /*   146: 0  1 */
  -	__u8                       inner_protocol_type:1; /*   147: 7  1 */
  -	__u8                       remcsum_offload:1;    /*   147: 6  1 */
  -	__u8                       offload_fwd_mark:1;   /*   147: 5  1 */
  -	__u8                       offload_mr_fwd_mark:1; /*   147: 4  1 */
  -	__u8                       tc_skip_classify:1;   /*   147: 3  1 */
  -	__u8                       tc_at_ingress:1;      /*   147: 2  1 */
  -	__u8                       tc_redirected:1;      /*   147: 1  1 */
  -	__u8                       tc_from_ingress:1;    /*   147: 0  1 */
  +	__u8                       pkt_type;             /*   144     1 */
  +	__u8                       ignore_df;            /*   144     1 */
  +	__u8                       nf_trace;             /*   144     1 */
  +	__u8                       ip_summed;            /*   144     1 */
  +	__u8                       ooo_okay;             /*   144     1 */
  +	__u8                       l4_hash;              /*   145     1 */
  +	__u8                       sw_hash;              /*   145     1 */
  +	__u8                       wifi_acked_valid;     /*   145     1 */
  +	__u8                       wifi_acked;           /*   145     1 */
  +	__u8                       no_fcs;               /*   145     1 */
  +	__u8                       encapsulation;        /*   145     1 */
  +	__u8                       encap_hdr_csum;       /*   145     1 */
  +	__u8                       csum_valid;           /*   145     1 */
  +	__u8                       csum_complete_sw;     /*   146     1 */
  +	__u8                       csum_level;           /*   146     1 */
  +	__u8                       csum_not_inet;        /*   146     1 */
  +	__u8                       dst_pending_confirm;  /*   146     1 */
  +	__u8                       ndisc_nodetype;       /*   146     1 */
  +	__u8                       ipvs_property;        /*   146     1 */
  +	__u8                       inner_protocol_type;  /*   147     1 */
  +	__u8                       remcsum_offload;      /*   147     1 */
  +	__u8                       offload_fwd_mark;     /*   147     1 */
  +	__u8                       offload_mr_fwd_mark;  /*   147     1 */
  +	__u8                       tc_skip_classify;     /*   147     1 */
  +	__u8                       tc_at_ingress;        /*   147     1 */
  +	__u8                       tc_redirected;        /*   147     1 */
  +	__u8                       tc_from_ingress;      /*   147     1 */
   	__u16                      tc_index;             /*   148     2 */

   	/* XXX 2 bytes hole, try to pack */
  $

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-20 15:23:35 -03:00
Arnaldo Carvalho de Melo 93d6d00165 dwarves: No need to print the "signed ", the name has it already
So avoid duplicating, i.e. "signed signed int" was being used.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-20 14:55:38 -03:00
Arnaldo Carvalho de Melo 0a9bac9a3e dwarves: Relookup when searching for signed base types
Sometimes we lookup "signed int" and fail, try again with just "int",
which is equivalent.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-20 14:53:50 -03:00
Arnaldo Carvalho de Melo da632a3686 dwarves: Introduce {cu,cus}__find_struct_or_union_by_name() methods
Since tools like 'pahole' now shows unions in addition to structs.

Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-03 13:13:51 -03:00
Arnaldo Carvalho de Melo 2a092d6145 dwarves: Fix cus__load_files() success return value
If we processed at least one file we should return 0 to mean success.

Fixes: 02a456f5f5 ("pahole: Search and use running kernel vmlinux when no file is passed")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-12-14 14:14:56 -03:00
Arnaldo Carvalho de Melo 02a456f5f5 pahole: Search and use running kernel vmlinux when no file is passed
Seems like a nice shortcut for kernel hackers, and one that makes sure
the right vmlinux file is used, as it reads the running kernel build id
from /sys/kernel/notes and then searches the well known path for vmlinux
files:

vmlinux
/boot/vmlinux
/boot/vmlinux-4.14.0+
/usr/lib/debug/boot/vmlinux-`uname -r`
/lib/modules/`uname -r`/build/vmlinux
/usr/lib/debug/lib/modules/`uname -r`/vmlinux
/usr/lib/debug/boot/vmlinux-`uname -r`.debug

To find one with a matching build id (.notes ELF section, then
nhdr->n_type == NT_GNU_BUILD_ID), just like the Linux kernel 'perf
tools', where this code comes from, with some minor modifications to
cope with not having symbol_conf, symfs, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-11-24 11:24:16 -03:00
Arnaldo Carvalho de Melo 103e89bb25 dwarves_fprintf: Find holes on structs embedded in other structs
Take 'struct task_struct' in the Linux kernel, these fields:

        /* --- cacheline 2 boundary (128 bytes) --- */
        struct sched_entity        se;                   /*   128   448 */

        /* XXX last struct has 24 bytes of padding */

        /* --- cacheline 9 boundary (576 bytes) --- */
        struct sched_rt_entity     rt;                   /*   576    48 */

The sched_entity struct has 24 bytes of padding, and that info would
only appear when printing 'struct task_struct' if class__find_holes()
had previously been run on 'struct sched_entity' which wasn't always the
case, make sure that happens.

This results in this extra stat being printed for 'struct task_struct':

	/* paddings: 4, sum paddings: 38 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-30 16:18:11 -03:00
Arnaldo Carvalho de Melo 44130bf70e dwarves: Update e-mail address
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-06-28 14:24:41 -03:00
Arnaldo Carvalho de Melo 9df42c6826 dwarves: Initial support for rvalue_reference_type
Need to read more on http://www.artima.com/cppsource/rvalue.html, but
handling it mostly like DW_TAG_typedef so that at least references to it
are resolved, we can get its byte size, etc.

FIXME: look at the vtable parameters, some are resolving to "(null)".

Reported-by: Benjamin Kosnik <bkoz@redhat.com>
Reported-by: Mark Wieelard <mjw@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=962571
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-15 16:37:48 -03:00
Arnaldo Carvalho de Melo 10515a7c4d dwarves: Introduce cus__fprintf_load_files_err()
Out of code in pdwtags and pahole, will be used in the other tools.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-15 14:25:58 -03:00
Arnaldo Carvalho de Melo 9f3f67e786 dwarves: Fix cus__load_files() error return
Silly bug, it was trying to return a negative index stating what file
had problems in the provided array, but if the first had problems it was
return -0, duh, fix it by returning the first as 1, etc.

With this, calling 'pdwtags non-existent-file' would return no errors
via $?.

Next csets will provide proper error messages, using what is in errno
and this index to tell what file has problems.

Reported-by: Eric Blake <eblake@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=949034
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-03-15 12:24:38 -03:00
Arnaldo Carvalho de Melo 8c6378fd88 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>
2012-08-20 14:42:17 -03:00
Arnaldo Carvalho de Melo a54515fa6e 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>
2012-08-17 18:47:15 -03:00
Arnaldo Carvalho de Melo e1e7fc2f53 dwarves: Add missing #include <sys/stat.h>
Needed because it uses S_ISDIR. In the past this header probably was
being indirectly included. Noticed while building on RHEL6 Beta.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-06-04 09:26:13 -03:00
Arnaldo Carvalho de Melo 0c50ef3a60 dwarves: class_member__clone need to allocate from the obstack
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-20 16:20:06 -03:00
Arnaldo Carvalho de Melo f001b9f688 dwarves: Add a newline to __tag__id_not_found_fprintf output
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:55:20 -03:00
Arnaldo Carvalho de Melo 5be2291b14 dwarves: Teach base_type__name_to_size about "long double"
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:50:14 -03:00
Arnaldo Carvalho de Melo b4977b20e0 dwarves: __tag__has_type_loop has to handle a NULL type (void)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:39:52 -03:00
Arnaldo Carvalho de Melo 9720415091 dwarf: Detect type loops
[acme@doppio pahole]$ pahole -F ctf /media/tb/debuginfo/usr/lib/debug/usr/bin/greycstoration4integration.debug > /tmp/bla
<ERROR(tag__size:837): detected type loop: type=572, tag=const_type>
<ERROR(tag__size:837): detected type loop: type=572, tag=const_type>
[acme@doppio pahole]$

These type loops are problems in the CTF encoding, that should be fixed, but
should not cause the core code to segfault on an infinite recursion.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-14 17:07:02 -03:00
Arnaldo Carvalho de Melo 7e5b39f944 dwarves_fprintf: Make tag__id_not_found_(f|sn)printf print __LINE__
Helps debugging.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-09-11 15:10:43 -03:00
Arnaldo Carvalho de Melo fc1269af2f pahole: Introduce --classes_as_structs
That asks dwarf_fprintf to always use "struct" in places where it would
use "class", because CTF doesn't have the "class" concept, so for
'regtest diffctf' sake, we use this.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-24 17:22:43 -03:00
Arnaldo Carvalho de Melo 3de722e9ab dwarves: Delete list entries in reverse order
It doesn't matter when using a traditional malloc/free allocator, but
with obstacks we need to do it in reverse order.

For the usual case where we successfully process an object this doesn't
matter, as when we started using obstacks we don't traverse all the tags
calling their destructors anymore, we just free the whole obstack in one
go.

Noticed when processing object files built from non-supported languages
such as FORTRAN and Pascal, where there are some DWARF tags that are not
supported, which makes the object file load to be prematurely aborted
and that calls destructors for things like classes and functions that in
turn free space for their parameter/member lists, which now have to be
done in reverse order.

We could just stop calling the destructors and then destroying the whole
obstack, but I think that partially processed files are a nice feature,
so keep the interface in a way that both obstacks and traditinal malloc
alocators can be used.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-19 10:32:49 -03:00
Arnaldo Carvalho de Melo 19bbecf668 dwarves: Pass the cu to destructors to free memory on the obstack
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-18 18:21:20 -03:00
Arnaldo Carvalho de Melo dffd3d4ee7 dwarves: Fix cu__find_base_type_by_name when the base_type name is NULL
This shouldn't happen, but if it does, don't return it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-08-16 12:13:38 -03:00
Arnaldo Carvalho de Melo 932a884ed9 dwarves: Use an obstack for all the tags
We got it down from:

15.733210256  seconds time elapsed   ( +-   0.197% )

as reported in the previous changeset to:

[acme@doppio pahole]$ perf stat -r 5 pahole object_samples/zweinberg\@mozilla.com/libgklayout.so > /dev/null

 Performance counter stats for 'pahole object_samples/zweinberg@mozilla.com/libgklayout.so' (5 runs):

   12293.726462  task-clock-msecs         #      0.969 CPUs    ( +-   0.189% )
           2663  context-switches         #      0.000 M/sec   ( +-  18.994% )
             40  CPU-migrations           #      0.000 M/sec   ( +-  34.146% )
         127003  page-faults              #      0.010 M/sec   ( +-   0.000% )
    24417854522  cycles                   #   1986.204 M/sec   ( +-   0.174% )
    29007002413  instructions             #      1.188 IPC     ( +-   0.009% )
      297872959  cache-references         #     24.230 M/sec   ( +-   0.529% )
       21440854  cache-misses             #      1.744 M/sec   ( +-   0.321% )

   12.680530119  seconds time elapsed   ( +-   1.042% )

[acme@doppio pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-07-08 16:37:37 -03:00
Arnaldo Carvalho de Melo 570dd1ea55 dwarves: constify filename parm of cus__load_file
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-08 14:17:23 -03:00
Arnaldo Carvalho de Melo 27f4f0afb1 dwarves: Make cus__load_file really use the format path
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-04 23:15:52 -03:00
Arnaldo Carvalho de Melo 7c6603189e dwarves: Make all the tags that have an IP to be derived from ip_tag
Next we'll add a new kind of tag, DW_TAG_perf_counter, that will come
from perf.data generated by 'perf report'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-04 17:30:06 -03:00
Arnaldo Carvalho de Melo e429f8efbb dwarves: Add an rbtree for the functions in a cu
That is used by cus__find_function_by_addr & cu__func_function_by_addr.

First user is pfunct --addr, but this is really for pfunct --annotate, that
will process a perf.data file generated by 'perf report', load the debugging
info and regenerate the functions (pfunct -TVi like) that had hits, using
libdisasm to show the assembly code, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-04 14:56:44 -03:00
Arnaldo Carvalho de Melo e2b7d1a5f5 dwarves: types are uint16_t now
Remove one more DWARF specific detail.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-03 14:56:53 -03:00
Arnaldo Carvalho de Melo f84bf73d54 dwarves: Move the fprintf code to a new source file.
$ wc -l dwarves.c dwarves_fprintf.c
 1468 dwarves.c
 1554 dwarves_fprintf.c
 3022 total
$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-19 13:48:51 -03:00
Arnaldo Carvalho de Melo e148f93418 code: Combine the debugging_formats and debug_fmt_ops structs
Paving the way for pluggable debugging formats via dlopen.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-04 14:56:39 -03:00
Arnaldo Carvalho de Melo 0e56f5e562 core: Be more strict with the return of __name() routines
In the past we did integer testing, and testing against 0 was no problem, but
now they return NULL and we are back using strcmp, oops.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:55:02 -03:00
Arnaldo Carvalho de Melo 38b7f8aecf core: list__for_all_tags should delete shared enumerations
Its just the enumerator list (enum entries) that are shared.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:19:19 -03:00
Arnaldo Carvalho de Melo 58f29607a2 core: Add ->init and ->exit hooks to be called at dwarves__{init,exit}
So that we can more early return if we can't process files for some supported
debugging format and as well release all resources allocated when dwarves__exit
is called.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:05:36 -03:00
Arnaldo Carvalho de Melo db9774f38e core: cu__delete must delete ->filename too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:05:11 -03:00
Arnaldo Carvalho de Melo 4d619ac4cb core: Only DWARF uses the global strings table, so move it there
There is still the problem of handing the strings table to the CTF encoder, but
that will be fixed another day.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 18:46:54 -03:00
Arnaldo Carvalho de Melo 870afee9ce core: Stop using strings__ptr(strings, i) directly
Instead pass thru cu__strings(cu, i) so that we can figure out if the
underlying debugging format handler can do that more efficiently, such as by
looking up directly the ELF section ".strtab".

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 17:54:43 -03:00
Arnaldo Carvalho de Melo e6ed526926 core: tag__name can't assume all cus use the global string table
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:45:30 -03:00
Arnaldo Carvalho de Melo 9bb29daac4 base_type: Don't combine names with attributes
Such as signed, etc. This is in preparation for using directly ctf_strings.
Instead of duplicating it in the global strings table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:12:36 -03:00
Arnaldo Carvalho de Melo 7fc7148be7 core: Fix thinko in type__find_first_biggest_size_base_type_member
ctracer was segfaulting due to this problem.

Reported-by: Breno Leitão <leitao@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 13:33:05 -03:00
Arnaldo Carvalho de Melo c93fff6743 core: Add variable__name to struct debug_fmt_ops
Same reason as for function__name

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:40:33 -03:00
Arnaldo Carvalho de Melo ea4ff04f8e core: class__vtable_fprintf should use function__name
Same reason as for last commit.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:10:33 -03:00
Arnaldo Carvalho de Melo d5d45ab5af core: cu__find_function_by_name must use function__name()
And not compare by string_t, as now it may not be on the global strings table,
so we have to give a chance to the underlying debug format to translate that to
a string for us.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:07:53 -03:00
Arnaldo Carvalho de Melo 0837979e09 core: function__name in CTF gets the name from .strtab
That is done by adding some new struct debug_fmt_ops methods:

->function__name()

This one, if specified, will be called by function__name(), giving a chance to
formats such as CTF to get this from some other place than the global strings
table. CTF does this by storing GElf_Sym->st_name in function->name, and by
providing a dfops->function__name() that uses function->name as an index into
the .strtab ELF section.

->cu__delete()

This is needed because we can't anymore call ctf__delete at the end of
ctf__load_file, as we will need at least the .strstab ELF section to be
available till we're done with the cu, i.e. till we call cu__delete(), that now
calls dfops->cu__delete() if it is available.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 11:46:26 -03:00
Arnaldo Carvalho de Melo 6b4aec4a73 core: Rename cu_orig_info to debug_fmt_ops
There are more things that should be handled differently, such as function
names coming from the .strtab ELF section instead of from the global strings_t
table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 11:12:02 -03:00
Arnaldo Carvalho de Melo db741ee3fc core: Hasta la vista cu__for_each_tag
build/libdwarves.so.1.0.0:
 1 function changed, 169 bytes removed, diff: -169

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-01 13:49:58 -03:00