Commit Graph

1987 Commits

Author SHA1 Message Date
Yonghong Song 38fad22d66 libbpf: Get latest libbpf
Latest upstream LLVM now supports to emit btf_tag to dwarf ([1]) and the
kernel support for btf_tag is also landed ([2]). Sync with latest libbpf
which has btf_tag support. Next step will be to implement dwarf -> btf
conversion for btf_tag.

 [1] https://reviews.llvm.org/D106621
 [2] https://lore.kernel.org/bpf/20210914223015.245546-1-yhs@fb.com

Signed-off-by: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
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>
2021-09-18 18:29:39 -03:00
Matteo Croce 8843109995 CMakeList.txt: Make python optional
ostra-cg, which requires python, is installed in the destination dir.
Make it optional for embedded distributions which doesn't have the
python interpreter available.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-30 15:57:14 -03:00
Arnaldo Carvalho de Melo f02af2553e pahole: Prep 1.22
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-23 09:48:58 -03:00
Arnaldo Carvalho de Melo 40a40df961 core: Bump the chunk size for ptr_table uses in types, tags, functions tables
On a:

  $ grep "model name" /proc/cpuinfo
  model name	: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  model name	: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  model name	: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  model name	: Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  $

Before, using 256 as the chunk size:

  $ perf stat -r5 pahole -j --btf_encode vmlinux

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

         8,336.57 msec task-clock:u        # 2.649 CPUs utilized   ( +-  0.19% )
                0      context-switches:u  # 0.000 /sec
                0      cpu-migrations:u    # 0.000 /sec
           69,028      page-faults:u       # 8.260 K/sec           ( +-  0.03% )
   28,799,380,143      cycles:u            # 3.446 GHz             ( +-  0.06% )
   66,068,272,802      instructions:u      # 2.29  insn per cycle  ( +-  0.00% )
   15,801,729,716      branches:u          # 1.891 G/sec           ( +-  0.00% )
      134,370,099      branch-misses:u     # 0.85% of all branches ( +-  0.07% )

          3.14696 +- 0.00527 seconds time elapsed  ( +-  0.17% )

  $

After bumping it to 1024:

  $ perf stat -r5 pahole -j --btf_encode vmlinux

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

         8,255.93 msec task-clock:u        # 2.635 CPUs utilized   ( +-  0.03% )
                0      context-switches:u  # 0.000 /sec
                0      cpu-migrations:u    # 0.000 /sec
           68,597      page-faults:u       # 8.312 K/sec           ( +-  0.04% )
   28,504,209,806      cycles:u            # 3.454 GHz             ( +-  0.03% )
   66,067,020,098      instructions:u      # 2.32  insn per cycle  ( +-  0.00% )
   15,802,624,183      branches:u          # 1.915 G/sec           ( +-  0.00% )
      133,542,603      branch-misses:u     # 0.85% of all branches ( +-  0.13% )

          3.13324 +- 0.00205 seconds time elapsed  ( +-  0.07% )

  $

And 2048:

  $ perf stat -r10 pahole -j --btf_encode vmlinux

   Performance counter stats for 'pahole -j --btf_encode vmlinux' (10 runs):

         8,237.37 msec task-clock:u        # 2.635 CPUs utilized   ( +-  0.02% )
                0      context-switches:u  # 0.000 /sec
                0      cpu-migrations:u    # 0.000 /sec
           68,643      page-faults:u       # 8.331 K/sec           ( +-  0.06% )
   28,447,701,874      cycles:u            # 3.453 GHz             ( +-  0.02% )
   66,077,728,879      instructions:u      # 2.32  insn per cycle  ( +-  0.00% )
   15,806,113,927      branches:u          # 1.918 G/sec           ( +-  0.00% )
      132,811,965      branch-misses:u     # 0.84% of all branches ( +-  0.11% )

         3.125675 +- 0.000905 seconds time elapsed  ( +-  0.03% )

  $

Value chosen using:

  $ pahole --ptr_table_stats --btf_encode vmlinux

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 9f0809e6a8 pahole: Introduce --ptr_table_stats
Useful while developing to help in tuning the ptr tables (types, tags,
functions, maybe some more in the future).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo f035871495 core: Add CU stats printer
To help sizing some tables, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo c59e996c97 pahole: Fix races in accessing type information in live CUs
When using multithreaded DWARF loading we can't really freely access
some tables, as they may grow and lead to stale data accesses generating
segfaults.

So use a type comparision that takes into account just the immutable
information for structs, unions.

This isn't enough to discern if two types with the same name are really
the same, as we need to look at the member types to figure that out.

So if there are types for which member types need to be checked, leave
it for when all CUs were processed and are thus completely immutable to
resort and fully compare such types.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo c34b6c6cc9 pahole: Add missing limits.h include to get ULLONG_MAX definition
Found while compiling on a musl libc system.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 5e8ad60d1f CMakeList.txt: Look for obstack outside libc
As in Alpine Linux.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 739bc50b90 cmake: Add a module to find if obstack is in a separate library
The main musl libc, used in Alpine Linux, doesn't have argp support, so
check if it is somewhere else, maybe in the musl-obstack package.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 5244b47a88 CMakeList.txt: Look for argp outside libc
As in Alpine Linux.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 3f70d31571 cmake: Add a module to find if argp is in a separate library
The musl libc, used in Alpine Linux, doesn't have argp support, so check
if it is somewhere else, maybe in the argp-standalone package.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 9f9588dc2b fprintf: Add alternative method for reading the data cacheline size
Systems such as Alpine Linux don't have support for obtaining _SC_LEVEL1_DCACHE_LINESIZE
via sysconf(), provide altenative method reading it from sysfs.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 71867afd66 core: Include missing limits.h to get PATH_MAX definition
Works in most places, by luck, doesn't on Alpine Linux, fix it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 0d8d457fa3 dutil: Include linux/stddef.h to build on Alpine Linux systems
To get __always_inline to work.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo bb02fec203 README.tarball: Overcome --transform problem with symlinks
By doing the tarball using the parent directory ('pahole') and then
replacing ^pahole/ with dwarves-${version} we avoid tar replacing the
symlink destination, i.e. before we were getting:

  $ ls -la dwarves-1.22/lib/include/
  total 8
  drwxr-xr-x. 2 acme acme 4096 Aug 12 15:54 .
  drwxr-xr-x. 4 acme acme 4096 Aug 12 15:54 ..
  lrwxrwxrwx. 1 acme acme   23 Jun 18 17:56 bpf -> dwarves-1.22/../bpf/src
  $

Now we get:

  $ v=1.$(($(git tag | sort -V | tail -1 | cut -d. -f2) + 1)) ; tar cvfJ ~/rpmbuild/SOURCES/dwarves-${v}.tar.xz --transform "s,^pahole/,dwarves-${v}/," `sed s%^%../pahole/%g MANIFEST`
  $ tar tvf ~/rpmbuild/SOURCES/dwarves-1.22.tar.xz  | tail -3
  -rwxr-xr-x acme/acme      1132 2021-06-14 15:51 dwarves-1.22/lib/bpf/travis-ci/vmtest/run_vmtest.sh
  -rw-r--r-- acme/acme   2904227 2021-06-14 15:51 dwarves-1.22/lib/bpf/travis-ci/vmtest/vmlinux.h
  lrwxrwxrwx acme/acme         0 2021-08-11 08:55 dwarves-1.22/lib/include/bpf -> ../bpf/src
  $

And building from the resulting tarball succeeds.

See the references in the threads and bug reportgs in the Link tags
below for more details.

Link: https://lore.kernel.org/dwarves/YRVxNEPEspmuHcKr@kernel.org/
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=775247
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 9fed416b38 MANIFEST: Add lib/include/bpf
The tarball wasn't working without this file:

  [ 32%] Building C object CMakeFiles/dwarves.dir/btf_encoder.c.o
  /tmp/dwarves-1.22/btf_encoder.c:18:10: fatal error: bpf/btf.h: No such file or directory
   #include <bpf/btf.h>
            ^~~~~~~~~~~
  compilation terminated.

Cc: Luca Boccassi <bluca@debian.org>
Fixes: 82756ea3ea ("libbpf: Fixup patch to allow to use packaged version")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo cb1cf16676 spec: Remove deleted libbtf.h from the RPM file list
It should have been removed from the specfile when it was deleted from
the source tree, fix it.

Fixes: 743f2536d8 ("btf_encoder: Move libbtf.c to btf_encoder.c, the only user of its functions")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo d0c3dd18c7 README.tarball: Remove hardcoded version, get it from 'git tag'
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo b5140d5e6c MANIFEST: Remove long gone strings header files
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 02fd228f6a MANIFEST: Add buildcmd.sh
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 06e41eccc2 buildcmd.sh: Add single build script for use in CI
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo eba3e874ad pahole: Consider type members's names when comparing unions, structs
The last one was:

  $ btfdiff vmlinux
  --- /tmp/btfdiff.dwarf.VUXlsB	2021-08-06 18:11:51.371012024 -0300
  +++ /tmp/btfdiff.btf.CeZ7hA	2021-08-06 18:11:51.604017029 -0300
  @@ -48226,8 +48226,8 @@ struct intel_ir_data {
   	/* last cacheline: 56 bytes */
   };
   struct intel_pad_context {
  -	u32                        padctrl0;             /*     0     4 */
  -	u32                        padctrl1;             /*     4     4 */
  +	u32                        conf0;                /*     0     4 */
  +	u32                        val;                  /*     4     4 */

   	/* size: 8, cachelines: 1, members: 2 */
   	/* last cacheline: 8 bytes */
  $

That now is covered as well. Please report if you see some other corner
case (some attribute(__aligned__(N)))) perhaps? :)).

Now 'btfdiff vmlinux' is clean.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo f61d458c91 pahole: Consider type members's types when comparing unions, structs
But this still doesn't cover all types in the kernel, at least not for
btfdiff's needs, which is to have the output of pahole for BTF and DWARF
to be the same, so if we have two types that are ABI equal, it will
still complain if...

  $ btfdiff vmlinux
  --- /tmp/btfdiff.dwarf.VUXlsB	2021-08-06 18:11:51.371012024 -0300
  +++ /tmp/btfdiff.btf.CeZ7hA	2021-08-06 18:11:51.604017029 -0300
  @@ -48226,8 +48226,8 @@ struct intel_ir_data {
   	/* last cacheline: 56 bytes */
   };
   struct intel_pad_context {
  -	u32                        padctrl0;             /*     0     4 */
  -	u32                        padctrl1;             /*     4     4 */
  +	u32                        conf0;                /*     0     4 */
  +	u32                        val;                  /*     4     4 */

   	/* size: 8, cachelines: 1, members: 2 */
   	/* last cacheline: 8 bytes */
  $

The name of some members are different :-\ Consider it in the next
patch and possibly add a knob to consider both types equal, i.e. don't
compare member names, just size, number of members and types of pairs of
members (at each offset in both types).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 589a298829 core: Introduce helpers for getting the first and next members of a type
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 815041d6dc pahole: Improve the type sorting routine to consider multiple types with same name
Out of these different Linux kernel types with the same name (in different object files):

  $ pahole --sizes | sed -r 's/([^\t]+)\t.*/\1/g' | sort | uniq -c | grep -v ' 1 '
        2 chksum_desc_ctx
        2 controller
        2 debug_buffer
        2 dir_entry
        2 disklabel
        2 dma_chan
        2 dma_heap_attachment
        2 d_partition
        2 elf_thread_core_info
        2 intel_community_context
        2 intel_pad_context
        3 irq_info
        2 irte
        2 map_info
        2 mm_slot
        2 netlbl_domhsh_walk_arg
        2 node
        2 pci_root_info
        2 perf_aux_event
        2 pmc_dev
        2 pmc_reg_map
        2 remap_data
        2 slot
        2 sw842_param
        2 syscall_tp_t
        3 urb_priv
        2 walk_control
        3 workspace
  $

Only this one needs a more involved type comparision:

  $ btfdiff vmlinux
  --- /tmp/btfdiff.dwarf.Pksrlr	2021-08-06 16:42:34.823259365 -0300
  +++ /tmp/btfdiff.btf.KOAuwd	2021-08-06 16:42:35.032264038 -0300
  @@ -31035,7 +31035,7 @@ struct elf_note_info {
   	struct memelfnote          auxv;                 /*    56    24 */
   	/* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
   	struct memelfnote          files;                /*    80    24 */
  -	compat_siginfo_t           csigdata;             /*   104   128 */
  +	siginfo_t                  csigdata;             /*   104   128 */
   	/* --- cacheline 3 boundary (192 bytes) was 40 bytes ago --- */
   	size_t                     size;                 /*   232     8 */
   	int                        thread_notes;         /*   240     4 */
  $

It has the same size, number of members.

And this is not always, it all depends on the order in which the btf
encoder gets it from one of the DWARF loading threads:

  $ pahole -j12 --btf_encode vmlinux
  $ btfdiff vmlinux
  $

No changes, but then:

  $ btfdiff vmlinux
  $ perf stat pahole -j12 --btf_encode vmlinux

   Performance counter stats for 'pahole -j12 --btf_encode vmlinux':

           17,920.75 msec task-clock:u              #    2.995 CPUs utilized
                   0      context-switches:u        #    0.000 /sec
                   0      cpu-migrations:u          #    0.000 /sec
              78,004      page-faults:u             #    4.353 K/sec
      42,677,746,170      cycles:u                  #    2.381 GHz                      (83.37%)
         480,920,924      stalled-cycles-frontend:u #    1.13% frontend cycles idle     (83.33%)
       6,470,001,379      stalled-cycles-backend:u  #   15.16% backend cycles idle      (83.39%)
      96,468,468,147      instructions:u            #    2.26  insn per cycle
                                                    #    0.07  stalled cycles per insn  (83.33%)
      19,757,801,968      branches:u                #    1.103 G/sec                    (83.27%)
         143,118,731      branch-misses:u           #    0.72% of all branches          (83.32%)

         5.984348164 seconds time elapsed

        17.234929000 seconds user
         0.398715000 seconds sys

  $ btfdiff vmlinux
  --- /tmp/btfdiff.dwarf.b9FEZI	2021-08-06 16:46:08.810043718 -0300
  +++ /tmp/btfdiff.btf.IawvDY	2021-08-06 16:46:09.026048548 -0300
  @@ -31035,7 +31035,7 @@ struct elf_note_info {
   	struct memelfnote          auxv;                 /*    56    24 */
   	/* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */
   	struct memelfnote          files;                /*    80    24 */
  -	compat_siginfo_t           csigdata;             /*   104   128 */
  +	siginfo_t                  csigdata;             /*   104   128 */
   	/* --- cacheline 3 boundary (192 bytes) was 40 bytes ago --- */
   	size_t                     size;                 /*   232     8 */
   	int                        thread_notes;         /*   240     4 */
  $

Next cset will take that into account by traversing both types looking
for differences in the type for a field.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 93e2669869 core: Remove extra ; in 'print_numeric_version' extern declaration
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 19798784d7 btf_loader: Mark the 'level' arg to the libbpf error callback as __maybe_unused
As it is not being used.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 22763a8fc7 btf_loader: Mark create_new_datasec() args as __maybe_unused
As it is just a stub for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 38df86db2b dwarf_loader: cus__load_debug_types() doesn't use its 'cus' arg, remove it
But since it is still related to cus processing, remove that arg and
rename it to __cus__load_debug_types().

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 16d646c07e dwarf_loader: Rename finalize_cu_immediately() to cus__finalize() to follow convention
Follow convention by renaming it  to cu__finalize() as it operates on a
'cus' instance.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 90599e6177 dwarf_loader: Remove unused 'dcu' argument from finalize_cu_immediately()
Not used at all, ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 6fd4377a0d dwarf_loader: Remove unused 'dcus' argument from cu__finalize()
Not used at all, ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 2bb04ecf79 dwarf_loader: Remove unused 'cus' argument from finalize_cu()
And follow convention and rename it to cu__finalize() as it operates on
a 'cu' instance.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 9ada372a21 dwarf_loader: Fix signed/unsigned comparision in tag__recode_dwarf_bitfield()
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo e4e9267c3a core: cus__fprintf_load_files_err() doesn't use its 'cus' argument
So just make it have the '__maybe_unused' attribute, to avoid having to
change all callers.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo df92cb6b8e core: Change last_seen_bit to uint32_t in class__find_holes()
And it is being compared against uint32_t variables, resulting in this
clang warning:

  /var/home/acme/git/pahole/dwarves.c: In function ‘class__find_holes’:
  /var/home/acme/git/pahole/dwarves.c:1439:43: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
   1439 |                         if (last_seen_bit < aligned_start && aligned_start <= bit_start) {
        |                                           ^

Since it can't be less than zero, just make then uint32_t.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 789d8b3e1a core: Change aligned_start to uint32_t in class__find_holes()
And it is being compared against uint32_t variables, resulting in this
clang warning:

  /var/home/acme/git/pahole/dwarves.c: In function ‘class__find_holes’:
  /var/home/acme/git/pahole/dwarves.c:1439:76: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
   1439 |                         if (last_seen_bit < aligned_start && aligned_start <= bit_start) {
        |                                                                            ^~

Since it can't be less than zero, just make then uint32_t.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 182cdcaed9 core: Change cur_bitfield_end to uint32_t in class__find_holes()
And it is being compared against uint32_t variables, resulting in this
clang warning:

  /var/home/acme/git/pahole/dwarves.c:1430:44: note: in expansion of macro ‘min’
   1430 |                         int bitfield_end = min(bit_start, cur_bitfield_end);
        |                                            ^~~

Since it can't be less than zero, just make then uint32_t.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 5900f43f10 core: Change bit_start and bit_end to uint32_t in class__find_holes()
And they were being compared against uint32_t variables, resulting in
this clang warning:

  /var/home/acme/git/pahole/dwarves.c: In function ‘class__find_holes’:
  /var/home/acme/git/pahole/dwarves.c:1453:73: warning: comparison of integer expressions of different signedness: ‘uint32_t’ {aka ‘unsigned int’} and ‘int’ [-Wsign-compare]
   1453 |                         if (bit_end > cur_bitfield_end || pos->bit_size > cur_bitfield_size) {
        |

Since they can't be less than zero, just make then uint32_t.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 8634d8535f btf_encoder: Fix signed/unsigned comparision
Since the 'int' variable, 'err' was just checked for < 0, cast it to
uint32_t and compare with the 'uint32_t' one.

Fixes this clang warning:

  /var/home/acme/git/pahole/btf_encoder.c: In function ‘btf_encoder__write_raw_file’:
  /var/home/acme/git/pahole/btf_encoder.c:890:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
    890 |         if (err != raw_btf_size) {
        |                 ^~

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 8d2efa2b6c btf_encoder: has_arg_names() doesn't need the 'cu' pointer
Since we don't need the cu to get the strings table anymore, all tags
have a char pointer for strings.

Also rename it to ftype__has_arg_names() and simplify a bit it by
removing a needless one-type use 'name' variable.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 05f737076f btf_encoder: btf_encoder__encode_tag() doesn't need the 'core_id' pointer
Not being used at all, ditch it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo dc30e82b26 btf_encoder: btf_encoder__encode_tag() doesn't need the 'cu' pointer
Since we don't need the cu to get the strings table anymore, all tags
have a char pointer for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 4360359e43 btf_encoder: btf_encoder__add_struct_type() doesn't need the 'cu' pointer
Since we don't need the cu to get the strings table anymore, all tags
have a char pointer for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 6e1e4881a5 btf_encoder: btf_encoder__add_func_proto() doesn't need the 'cu' pointer
Since we don't need the cu to get the strings table anymore, all tags
have a char pointer for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 9fbfcee7d9 btf_encoder: No need to read the ehdr in btf_encoder__write_elf(), ditch it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 898cc49027 ctracer: No need to read the ehdr, ditch it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo dee83e27dd btf_encoder: No need to store the ehdr in the instance
We need it only in btf_encoder__new(), so just use a local variable for
that.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00
Arnaldo Carvalho de Melo 24404190b8 elf_symtab: Remove needless GElf_Ehdr pointer argument from the constructor
We don't need it as we used it only for calling elf_section_by_name(),
that doesn't need it anymore.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-20 16:40:27 -03:00