Commit Graph

334 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 7569e46d35 core: namespace__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo de4e8b7f17 core: {tag,function,lexblock}__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

They call each other, so do the three at once.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 789ed4e3a2 core: ftype__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 6340cb4627 core: enumeration__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 33e44f5295 core: type__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 0f54ca9c82 core: class__clone() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 2b2014187b core: class__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 50916756d5 core: class_member__delete() doesn't need a 'cu' arg
Since we stopped using per-cu obstacks we don't need it. If we ever
want to use it we can do per thread obstacks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo 63992cb02a core: Use namespace->name in class__clone()
Now that we stopped using string indexes, no need for that, just set
namespace->name with the new class name.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:13 -03:00
Arnaldo Carvalho de Melo ced4c34c37 core: Remove strings.c, unused
We were using this just for the ctf_encoder, that never really got
complete, so ditch it.

For BTF the strings table is done by libbpf, so we don't need it there
either.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:41:11 -03:00
Arnaldo Carvalho de Melo 2b9bd83e63 dwarf_loader: Make attr_suffix() handle kabi_prefix
Since we're going to get rid of strings.c.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 3d3b7b3287 core: Remove unused debug_fmt_ops->dwarf__strings_ptr()
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 05687c547e core: Remove unused cu__string() method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 6b7f1b72f9 core: No need for debug_fmt_ops->variable_name() anymore
Since we store a char pointer string in variable->name, we can use it
directly.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 9d0e3ab9a2 pahole: function__name() doesn't need a 'struct cu *' argument
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo a7d789a4f8 core: Make variable->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo b5694280ec core: Make label->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo f8d98eff75 core: Ditch unused enumeration__prefix_len() method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 5cc365164a core: Ditch unused enumeration__prefix() method
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 0947d6e795 core: enumeration__fprintf() doesn't need a 'cu' argument
With the conversion of ->name members to plain char strings, no need
to use 'cu' to get the old string_t index and find the per-cu string
table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo bb22f5bb0a core: Make enumeration__max_entry_name_len() static
As it is not used outside where it is defined.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo dc83336171 core: enumeration__max_entry_name_len() doesn't need a 'cu' argument
With the conversion of ->name members to plain char strings, no need
to use 'cu' to get the old string_t index and find the per-cu string
table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo ec1667c76d core: Make enumeration__calc_prefix() static
As it is not used outside where it is defined.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 45ec63ed20 core: enumeration__calc_prefix doesn't need a 'cu' argument
With the conversion of ->name members to plain char strings, no need
to use 'cu' to get the old string_t index and find the per-cu string
table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 96243fdd79 core: enumerator__name() doesn't need a 'cu' argument, ditch it
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 713239bc00 core: Make enumerator->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the enumerator->name case we get the bonus of removing the last user
of dwarves__active_loader in the btf_encoder class.

This covers unions, enums, structs and classes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo c127d25daf core: class__name() doesn't need a cu arg
Now that namespace->name is a real char string.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 00e8c5fe21 core: type__name() doesn't need a cu arg
Now that namespace->name is a real char string.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo b99c4008ac core: Make namespace->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the namespace->name case we get the bonus of removing another
user of dwarves__active_loader.

This covers unions, enums, structs and classes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 379a73c6eb core: Make class_member->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the class_member->name case we get the bonus of removing another
user of dwarves__active_loader.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 3280cb4176 core: Make parameter->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the parameter->name case we get the bonus of removing a user of
dwarves__active_loader.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo f009162fd1 core: Make base_type->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the base_type->name case we get the bonus of removing some more
functions related base types and a user of dwarves__active_loader.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-08-12 09:39:46 -03:00
Arnaldo Carvalho de Melo 0d13bc50ee core: Ditch unused cu__find_struct_by_sname()
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:17 -03:00
Arnaldo Carvalho de Melo 46f3f37241 core: Convert cu__find_base_type_by_sname_and_size to search for a string
It looked for an index into a string table, a string_t, but since for
multithreading we'd be growing the string table while looking up stuff,
we'd be looking at realloc'ed memory, so lets move to stable char
pointer strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo f84e8777ea core: Convert cu__find_enumeration_by_sname_and_size to search for a string
It looked for an index into a string table, a string_t, but since for
multithreading we'd be growing the string table while looking up stuff,
we'd be looking at realloc'ed memory, so lets move to stable char
pointer strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 82e5b5101a core: Make function->name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

For the function->name case we get the bonus of removing the need of a
debug_fmt_ops->function() callback receiving the 'cu', just access the
string directly.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 4f73cac853 core: Make function->linkage_name a real string
For the threaded code we want to access strings in tags at the same time
that the string table may grow in another thread making the previous
pointer invalid, so, to avoid excessive locking, use plain strings.

The way the tools work will either consume the just produced CU straight
away or keep just one copy of each data structure when we keep all CUs
in memory, so lets try stopping using strings_t for strings.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo a3fcbcacf7 pahole: Allow specifying the number of threads to use while loading files
Using the same command line option as 'make' and 'ninja': -j.
Unfortunately the argp parser in glibc expects a '=' for single letter
args, so it is:

  $ pahole -j=10

or, like with 'make':

  $ make --jobs=10

This is unwired at the moment, probably I'll reorder the patch, but for
testing, add it first.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 41a283c65d core: Protect cus->cus with a mutex
Paving the way for having multiple threads creating CUs and possibly
adding them to cus->cus.

The mutex will also be used to ask elfutils-libdwfl to read the next CU,
after a thread finishes reading one.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 972065482a core: Make 'struct cus' opaque, only visible in dwarves.c
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 3895b29060 core: Introduce helper to return number of cu entries in a 'struct cus'
Provide a helper so that we can make 'struct cus' opaque.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo 874e750fb8 core: Move cus__find_pair() from codiff to the core
To avoid touching 'struct cus' internal state outside dwarves.c

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo bf74fc1fcf core: Introduce helper to return if there is no cu entries in a 'struct cus'
Provide a helper so that we can make 'struct cus' opaque.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-28 15:18:16 -03:00
Arnaldo Carvalho de Melo b8255beb12 core: Allow passing the base_btf object via 'struct conf_load'
So that we can get rid of that global base_btf and use the right way
to pass load configuration to the format loaders.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-06-04 17:28:56 -03:00
Arnaldo Carvalho de Melo 505a1f5615 dwarves: Stop using obstacks
When the CTF and later the BTF loaders were implemented they didn't use
obstacks, and then over time some functions, like type__delete(),
class__delete(), enumeration__delete() were shared, which can lead to
crashes by corrupting the obstack by not following its requirements or
to leaks, to avoid such corruption, stop using it.

There is a penalty, but I think its not worth the complexity to keep
using it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-05-17 16:20:52 -03:00
Arnaldo Carvalho de Melo b91b19840b dwarf_loader: Support DW_AT_data_bit_offset
This appeared in DWARF4 but is supported only in gcc's -gdwarf-5,
support it in a way that makes the output be the same for both cases:

  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   a:1;                  /*     0: 0  8 */
  	long int                   b:1;                  /*     0: 1  8 */
  	long int                   c:1;                  /*     0: 2  8 */

  	/* XXX 29 bits hole, try to pack */
  	/* Bitfield combined with next fields */

  	int                        after_bitfield;       /*     4     4 */

  	/* size: 8, cachelines: 1, members: 4 */
  	/* sum members: 4 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* last cacheline: 8 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   a:1;                  /*     0: 0  8 */
  	long int                   b:1;                  /*     0: 1  8 */
  	long int                   c:1;                  /*     0: 2  8 */

  	/* XXX 29 bits hole, try to pack */
  	/* Bitfield combined with next fields */

  	int                        after_bitfield;       /*     4     4 */

  	/* size: 8, cachelines: 1, members: 4 */
  	/* sum members: 4 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* last cacheline: 8 bytes */
  };
  $

Now with an integer before the bitfield:

  $ cat examples/dwarf5/bf.c
  struct pea {
  	int before_bitfield;
  	long a:1, b:1, c:1;
  	int after_bitfield;
  } p;
  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	int                        before_bitfield;      /*     0     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*     0:32  8 */
  	long int                   b:1;                  /*     0:33  8 */
  	long int                   c:1;                  /*     0:34  8 */

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

  	int                        after_bitfield;       /*     8     4 */

  	/* size: 16, cachelines: 1, members: 5 */
  	/* sum members: 8 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 16 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	int                        before_bitfield;      /*     0     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*     0:32  8 */
  	long int                   b:1;                  /*     0:33  8 */
  	long int                   c:1;                  /*     0:34  8 */

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

  	int                        after_bitfield;       /*     8     4 */

  	/* size: 16, cachelines: 1, members: 5 */
  	/* sum members: 8 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 16 bytes */
  };
  $

And an array of long integers at the start, before the combination of an
integer with a long integer bitfield:

  $ cat examples/dwarf5/bf.c
  struct pea {
  	long array[3];
  	int before_bitfield;
  	long a:1, b:1, c:1;
  	int after_bitfield;
  } p;
  $ gcc -gdwarf-4 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   array[3];             /*     0    24 */
  	int                        before_bitfield;      /*    24     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*    24:32  8 */
  	long int                   b:1;                  /*    24:33  8 */
  	long int                   c:1;                  /*    24:34  8 */

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

  	int                        after_bitfield;       /*    32     4 */

  	/* size: 40, cachelines: 1, members: 6 */
  	/* sum members: 32 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 40 bytes */
  };
  $ gcc -gdwarf-5 -c examples/dwarf5/bf.c
  $ pahole bf.o
  struct pea {
  	long int                   array[3];             /*     0    24 */
  	int                        before_bitfield;      /*    24     4 */

  	/* Bitfield combined with previous fields */

  	long int                   a:1;                  /*    24:32  8 */
  	long int                   b:1;                  /*    24:33  8 */
  	long int                   c:1;                  /*    24:34  8 */

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

  	int                        after_bitfield;       /*    32     4 */

  	/* size: 40, cachelines: 1, members: 6 */
  	/* sum members: 32 */
  	/* sum bitfield members: 3 bits, bit holes: 1, sum bit holes: 29 bits */
  	/* padding: 4 */
  	/* last cacheline: 40 bytes */
  };
  $

Reported-by: Mark Wielaard <mark@klomp.org>
Tested-by: "Daniel P. Berrangé" <berrange@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1919965
Link: https://lore.kernel.org/dwarves/20210128121122.GA775562@kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-01-28 14:11:02 -03:00
Arnaldo Carvalho de Melo 89cf28228a fprintf: Add enumeration__max_entry_name_len()
Cache the results, will be used when pretty printing enumerations, to
align the entries.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-11-19 11:25:47 -03:00
Arnaldo Carvalho de Melo bc1afd4585 pahole: Introduce --numeric_version for use in scripts and Makefiles
In Makefiles we want to do purely numeric comparisions, such as in the
Linux kernel Makefiles and scripts, that have things like this at the
moment:

  $ grep PAHOLE */*.sh
  scripts/link-vmlinux.sh:	if ! [ -x "$(command -v ${PAHOLE})" ]; then
  scripts/link-vmlinux.sh:		echo >&2 "BTF: ${1}: pahole (${PAHOLE}) is not available"
  scripts/link-vmlinux.sh:	pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
  scripts/link-vmlinux.sh:		echo >&2 "BTF: ${1}: pahole version $(${PAHOLE} --version) is too old, need at least v1.16"
  scripts/link-vmlinux.sh:	LLVM_OBJCOPY=${OBJCOPY} ${PAHOLE} -J ${1}
  $

So just provide:

  $ pahole --numeric_version
  118
  $

While keeping the --version output for older Makefiles and scripts.

Cc: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-11-10 13:04:22 -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
Andrii Nakryiko 0a9b89910e dwarves: Expose and maintain active debug info loader operations
Maintain a pointer to debug_fmt_ops corresponding to currently used debug info
format loader (DWARF, BTF, or CTF), to allow various parts of libdwarves to do
things like resolve string offset to actual string pointer in
a format-agnostic format. This allows to, say, load DWARF debug info, and use
it for BTF generation, without either of them making assumptions about how
strings are actually stored internally.

This is going to be used in the next patch to allow BTF loader and encoder to
use a very different way of storing strings (not a global shared gobuffer).

Committer notes:

Since it is available in multiple object files, add a dwarves__ prefix
namespace and add an extern for it in dwarves.h.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-09 12:43:40 -03:00