Commit Graph

79 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo dd15aa4b0a dwarves: Prep v1.19
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-11-23 09:52:44 -03:00
Arnaldo Carvalho de Melo 784c3dfbd6 dwarves: Switch from a string based version to major/minor numbers
Nothing changes now, this continues to work just the same:

  $ pahole --version
  v1.18
  $ pfunct --version
  v1.18
  $

This just paves the way for us to have a '--numeric-version' that will
do away with the dot and the leading 'v' and that can be used in
Makefiles to check if the required minimum version is available, to
avoid what we have now in the Linux kernel:

  config PAHOLE_HAS_SPLIT_BTF
         def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")

With the next cset we'll be able to do just:

	 test `$(PAHOLE) --numeric-version` -ge "119"

Cc: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-11-10 12:41:42 -03:00
Andrii Nakryiko ec3f944102 cmake: Make libbpf's Linux UAPI headers available to all binaries
Now that libbpf is used to implement deduplicated strings container, all
of the binaries will need linux/btf.h header to compile properly. libbpf
is distributed with its own copies of Linux UAPI headers, so use them
during compilation.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-26 16:50:08 -03:00
Arnaldo Carvalho de Melo 75f3520fed strings: Rename strings.h to avoid clashing with /usr/include/strings.h
This was detected with:

  In file included from /home/acme/git/pahole/strings.h:9,
                   from /usr/include/string.h:432,
                   from /home/acme/git/pahole/lib/bpf/src/libbpf_common.h:12,
                   from /home/acme/git/pahole/lib/bpf/src/libbpf.h:20,
                   from /home/acme/git/pahole/lib/bpf/src/ringbuf.c:20:
  /home/acme/git/pahole/lib/bpf/src/btf.h:33:11: error: expected ‘;’ before ‘void’
     33 | LIBBPF_API void btf__free(struct btf *btf);
        |           ^~~~~
        |           ;

libbpf_common.h has:

  #include <string.h>

  #ifndef LIBBPF_API
  #define LIBBPF_API __attribute__((visibility("default")))
  #endif

So before defining LIBBPF_API it includes libc's string.h that in turn
includes pahole's strings.h and now it includes:

  #include "lib/bpf/src/btf.h"

That will need the LIBBPF_API, b00m.

So lets just rename pahole's strings.h to pahole_strings.h to avoid this
pitfall.

This patch was moved to before this problem takes place so that we keep
everything bisectable.

Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-20 17:11:34 -03:00
Arnaldo Carvalho de Melo fdc639188c dwarves: Prep v1.18
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-02 17:29:59 -03:00
Arnaldo Carvalho de Melo 9f675e7fdb cmake: Use -O0 for debug builds
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-08-05 15:16:19 -03:00
Arnaldo Carvalho de Melo e709afe6a9 dwarves: Prep v1.17
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-03-13 16:36:02 -03:00
Andrii Nakryiko 081f3618a7 dwarves: Add -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 to build libbpf
We need that as the fix in upstream libbpf is in the
tools/lib/bpf/Makefile, that isn't used when building libbpf as part of
pahole, see:

  "Makefile: back-port _FILE_OFFSET_BITS=64 and _LARGEFILE64_SOURCE to Makefile"
  4a50ceb043

That refers to this in the kernel sources:

  71dd77fd4bf7 ("libbpf: use LFS (_FILE_OFFSET_BITS) instead of direct mmap2 syscall")

Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Julia Kartseva <hex@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-02-03 08:52:26 +01:00
Arnaldo Carvalho de Melo 1c1af2cd19 dwarves: Prep v1.16
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-12-16 11:43:53 -03:00
Alexei Starovoitov 69df73444c dwarves: Add -O2 to CFLAGS
Using the defaults, which uses no -O flags:

  [acme@quaco pahole]$ grep CMAKE_C_FLAGS_RELEASE CMakeLists.txt
  set(CMAKE_C_FLAGS_RELEASE "-Wall")
  [acme@quaco pahole]$ perf stat -r5 pahole -J vmlinux

   Performance counter stats for 'pahole -J vmlinux' (5 runs):

           18,516.09 msec task-clock:u              #    1.000 CPUs utilized            ( +-  0.55% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
             548,753      page-faults:u             #    0.030 M/sec                    ( +-  0.00% )
      68,498,897,915      cycles:u                  #    3.699 GHz                      ( +-  0.05% )
     123,209,200,210      instructions:u            #    1.80  insn per cycle           ( +-  0.00% )
      25,484,050,414      branches:u                # 1376.319 M/sec                    ( +-  0.00% )
         366,334,745      branch-misses:u           #    1.44% of all branches          ( +-  0.03% )

              18.518 +- 0.102 seconds time elapsed  ( +-  0.55% )

  [acme@quaco pahole]$

With this patch, using -O2:

  [acme@quaco pahole]$ grep CMAKE_C_FLAGS_RELEASE CMakeLists.txt
  set(CMAKE_C_FLAGS_RELEASE "-Wall -O2")
  [acme@quaco pahole]$ perf stat -r5 pahole -J vmlinux

   Performance counter stats for 'pahole -J vmlinux' (5 runs):

           12,645.96 msec task-clock:u              #    1.000 CPUs utilized            ( +-  0.61% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
             548,744      page-faults:u             #    0.043 M/sec                    ( +-  0.00% )
      45,359,248,873      cycles:u                  #    3.587 GHz                      ( +-  0.03% )
      84,051,005,257      instructions:u            #    1.85  insn per cycle           ( +-  0.00% )
      19,755,005,738      branches:u                # 1562.159 M/sec                    ( +-  0.00% )
         365,276,883      branch-misses:u           #    1.85% of all branches          ( +-  0.12% )

             12.6471 +- 0.0771 seconds time elapsed  ( +-  0.61% )

  [acme@quaco pahole]$

Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-12-16 11:19:47 -03:00
Arnaldo Carvalho de Melo ba27df9f2f CMakeLists: Use lib/bpf/include/uapi when building libdwarves
To avoid using /usr/include/linux/btf.h, as it has:

  [acme@quaco pahole]$ grep ^# /usr/include/linux/btf.h | head -2
  #ifndef __LINUX_BTF_H__
  #define __LINUX_BTF_H__
  [acme@quaco pahole]$

While:

  [acme@quaco pahole]$ grep ^# lib/bpf/include/uapi/linux/btf.h | head -2
  #ifndef _UAPI__LINUX_BTF_H__
  #define _UAPI__LINUX_BTF_H__
  [acme@quaco pahole]$

Then when both get included we get duplicate definitions, to avoid that
put lib/bpf/include/uapi/ first in the include path for libbdwarves.

Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-10-21 18:25:41 -03:00
Arnaldo Carvalho de Melo 93c3cdf897 cmake: Add -Wall to CFLAGS
And also -Werror for CMAKE_BUILD_TYPE=DEBUG, which is the default.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-07-02 12:33:29 -03:00
Arnaldo Carvalho de Melo 5299035710 v1.15: New release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-06-27 07:20:37 -03:00
Arnaldo Carvalho de Melo 989dc3f1ba cmake: Install missing devel headers
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-23 11:25:41 -03:00
Arnaldo Carvalho de Melo 92a4118812 v1.13: New release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-04-16 16:13:19 -03:00
Andrii Nakryiko e6c59bd11d libbpf: Build as PIC and statically link into libdwarves
As libbpf is not yet widely available, it's safer to statically link it
into libdwarves for now. Easiest way to define that in cmake is through
OBJECT library with PIC.

Committer testing:

  $ file build/pahole
  build/pahole: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=666c97e5763ac0f4c5eff229be1532f1e60195e6, with debug_info, not stripped
  $ ldd build/pahole
	linux-vdso.so.1 (0x00007ffe5fdf8000)
	libdwarves_reorganize.so.1 => /home/acme/git/pahole/build/libdwarves_reorganize.so.1 (0x00007f1c84fa4000)
	libdwarves.so.1 => /home/acme/git/pahole/build/libdwarves.so.1 (0x00007f1c84f5e000)
	libdw.so.1 => /lib64/libdw.so.1 (0x00007f1c84eee000)
	libelf.so.1 => /lib64/libelf.so.1 (0x00007f1c84ed4000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f1c84eba000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f1c84cf4000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f1c84cec000)
	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f1c84cc3000)
	libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f1c84cb0000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1c84fad000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1c84c8e000)
  $

  $ nm build/libdwarves.so.1.0.0  | grep b[pt]f__
  0000000000028aae T btf__dedup
  0000000000027d44 T btf__fd
  0000000000027a37 T btf__find_by_name
  0000000000027ad9 T btf__free
  0000000000027da8 T btf__get_from_id
  0000000000027f6c T btf__get_map_kv_tids
  0000000000027739 T btf__get_nr_types
  0000000000027d55 T btf__get_raw_data
  0000000000027c2e T btf__load
  0000000000027d77 T btf__name_by_offset
  0000000000027b36 T btf__new
  00000000000277eb T btf__resolve_size
  0000000000027960 T btf__resolve_type
  000000000002774a T btf__type_by_id
  $

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-02-19 10:21:29 -03:00
Andrii Nakryiko cf4f3e282d cmake: Bump miminum required version to use OBJECT feature
We need to link with libbpf, that is not yet generally available, so we
need to link it into libdwarves for now, to do that we need to use the
OBJECT library with PIC, and that requires we use at least cmake version
2.8.8, so bump the minimum required cmake version.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-02-19 10:20:42 -03:00
Andrii Nakryiko e6dfd10bcb libbpf: Build as shared lib
Change CMakeLists.txt to build libbpf as shared library to satisfy libdwarves
shared library compilation.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Cc: kernel-team@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-02-18 09:57:51 -03:00
Andrii Nakryiko 21507cd3e9 pahole: add libbpf as submodule under lib/bpf
This change allows to use libbpf definitions and APIs from pahole.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Cc: Yonghong Song <yhs@fb.com>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-02-11 12:56:40 -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 4a21c5c8db v1.12 - New Release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-08-16 16:15:27 -03:00
Martin KaFai Lau 68645f7fac btf: Add BTF support
This patch introduces BPF Type Format (BTF).

BTF (BPF Type Format) is the meta data format which describes
the data types of BPF program/map.  Hence, it basically focus
on the C programming language which the modern BPF is primary
using.  The first use case is to provide a generic pretty print
capability for a BPF map.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-07-25 14:42:06 -03:00
Arnaldo Carvalho de Melo 0b81b5ad47 Update version in CMakeLists.txt
The current release is v1.10, but CMakeLists.txt had just v1.9, fix it.

Reported-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-11-20 12:19:06 -03:00
Arnaldo Carvalho de Melo 79536f4f95 cmake: Use INTERFACE_LINK_LIBRARIES
LINK_INTERFACE_LIBRARIES was deprecated.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-09-16 11:31:40 -03:00
Arnaldo Carvalho de Melo dae032ea3f dwarves fprintf: Add extra GNU tags
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 22:23:14 -02:00
Arnaldo Carvalho de Melo 3a0f0df2e5 cmake: Add ${ELF_LIBRARY} to ctracer, scncopy and pfunct
Noticed on fedora 14, probably we were getting this indirectly, go figure.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-11-20 15:18:01 -02:00
Arnaldo Carvalho de Melo dfbb7dd53d cmake: fix DWARVES_VERSION definition, should be 1.8
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-04-13 18:02:24 -03:00
Peter Jones c9d1352dfe Add scncopy to CMakeLists.txt
Add scncopy to the build.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-01-12 14:23:54 -02:00
Herton Ronaldo Krzesinski 7bc0b0c656 cmake: Avoid uneeded linking/unused libraries in some dwarves libraries and executables
currently mandriva has a packaging script which checks for uneeded linking in
package built files. For dwarves, it displays:

Warning: unused libraries in /usr/lib64/libdwarves_reorganize.so.1.0.0: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/lib64/libdwarves_emit.so.1.0.0: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/ctracer: libz.so.1
 libdw.so.1

Warning: unused libraries in /usr/bin/syscse: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pglobal: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pdwtags: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/prefcnt: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/pfunct: libz.so.1
 libdw.so.1

Warning: unused libraries in /usr/bin/pahole: libz.so.1
 libdw.so.1
 libelf.so.1

Warning: unused libraries in /usr/bin/dtagnames: libdw.so.1
 libelf.so.1
 libz.so.1

Warning: unused libraries in /usr/bin/codiff: libdw.so.1
 libelf.so.1
 libz.so.1

The patch below fixes the issue (removing uneeded specified libraries and using
LINK_INTERFACE_LIBRARIES property, see
http://www.cmake.org/Wiki/CMake_FAQ#Why_are_libraries_linked_to_my_shared_library_included_when_something_links_to_it.3F)

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-12-17 15:20:27 -02:00
Arnaldo Carvalho de Melo ba928a23ee cmake: set policy for escaping preprocessor definitions to NEW
CMP0005

       Preprocessor definition values are now escaped automatically.
This policy determines whether or not CMake should generate escaped
preprocessor definition values added via add_definitions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-17 13:05:44 -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 a693b7fde9 cmake: move headers to /usr/include/dwarves/ and tag 1.8pre1
In reponse to https://bugzilla.redhat.com/show_bug.cgi?id=497285 I
included the header files that are needed by the dwarves*.h files
and moved them to /usr/include/dwarves.h.

The CTF work is not completed yet, but the non-CTF related improvements
(progressive loading of CUs, etc) are worth a release till I can get back to
dedicate solid time for developing these tools again.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-23 15:13:50 -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 0954d75152 elf_symtab: Introduce elf_symtab
We will need this when encoding the CTF functions section.  Things like lookup
a function by its address when converting from a DW_TAG_subprogram to a CTF
function, for instance.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-24 16:58:44 -03:00
Arnaldo Carvalho de Melo feab8aa5e3 ctf: Include the initial implementation of a ctf encoder
"pahole -Z foo" will create foo.SUNW_ctf, that if objcopy
--add-section'ed to the right word-sized object will work, sans VARARGS,
that will get fixed soon (as in, probably, tomorrow).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:16:07 -03:00
Arnaldo Carvalho de Melo ccc808b88e dutil: Move zalloc to dutil
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:08:23 -03:00
Arnaldo Carvalho de Melo 56be29c649 all: Add the --version
Using the argp tricks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 10:57:23 -02:00
Arnaldo Carvalho de Melo 7b6c135e7c pahole: finally the beginnings of a man page
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-11 12:19:46 -02:00
Arnaldo Carvalho de Melo d2a128b810 cmake: 2.4.8 is enough
Tested in RHEL5.2

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-20 13:54:39 -02:00
Arnaldo Carvalho de Melo 46a3bc4626 cmake: Add cmake_minimum_required
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-24 10:44:26 -02:00
Arnaldo Carvalho de Melo be30be91f5 gobuffer: Move the non string specific bits
Will be used while encoding the CTF sections.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 17:06:01 -03:00
Arnaldo Carvalho de Melo 212b994ab5 strings: Introduce the strings class
And make the dwarves use it, so that we can remove duplicate strings in
a multi-CU file (vmlinux anyone?) and have it ready for insertion in a
compressed DWARF format with just the types, or better, CTF or some new
compressed debugging info format.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 14:34:42 -03:00
Arnaldo Carvalho de Melo 993bcbde35 pfunct: Implement --expand_types
So that one can get an skeleton from where a function can be
reimplemented, or a probe can be written to attach to a tracepoint.

Right now it will only expand the types for
struct/union/typedef/enumeration types, but it is a good start.

[acme@doppio pahole]$ pfunct --expand_types --function inet6_ioctl ipv6.ko > a.c
[acme@doppio pahole]$ echo "int main(void) { return 0; }" >> a.c
[acme@doppio pahole]$ gcc -Wall -g a.c -o a
[acme@doppio pahole]$ grep ^#include a.c
[acme@doppio pahole]$

No errors, no includes.

This is present in ctracer, where we don't want to _require_ any header
files, just the object file with the function we want to probe. From
there we get the function signature, and reconstruct the types needed to
access members of structs passed as parameters.

We still need to add padding to reconstruct __attribute__ alignment
effects.

Also, if we can detect what are the exact members accessed in the probe,
we can reconstruct just what is needed to access those members,
hopefully reducing the time needed for gcc to digest the resulting
source code. And also reducing the size of the output, which can
hopefully be interesting to help focus on what the probe is doing.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-30 17:30:42 -03:00
Arnaldo Carvalho de Melo 2dfa5fe6ea [DWARVES]: Initial CTF support
Using a library written by David S. Miller.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 15:37:02 -03:00
Arnaldo Carvalho de Melo b3489e14eb [DWARVES]: Move all the DWARF specific loading routines to dwarf_loader.c
In libdwarves.so well continue using DW_TAG_ entries and types for now, but its
becoming non-DWARF specific as will be demonstrated with the introduction of
ctf_loader.c in the upcoming csets.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-03 13:50:44 -03:00
Arnaldo Carvalho de Melo 5444ebab1b [CMAKE]: Remove last reference to dwdb
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-27 23:00:07 -02:00
Arnaldo Carvalho de Melo 8ca5113571 [CMAKEFILE]: Remove references to sqlite3
Not yet ready, thanks to Otavio for pointing out my mistake.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-26 15:43:07 -02:00
Arnaldo Carvalho de Melo f7b1128d6f [CODIFF]: Show changes to a struct only on the first object file it appears
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-17 11:27:24 -02:00
Arnaldo Carvalho de Melo 66b7191c18 [DUTIL]: Generalise fstrlist
Now at creation time we specify if the strings must be allocated or if using
the pointer directly.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-16 14:55:50 -02:00
Arnaldo Carvalho de Melo 2c01420b51 [CMAKE]: Add linux.blacklist.cu to the install targets
Also updating the manifest and lib/Makefile to find it in
/usr/share/dwarves/runtime.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2007-12-06 17:43:20 -02:00