This patch improves the error seen by the user by setting errno in
cus__load_files(). Otherwise, we get a "No such file or directory" error
which might be confusing.
Before the patch, using a bogus file:
$ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
pahole: ./vmlinux-5.3.18-24.102-default.debug: No such file or directory
$ ls ./vmlinux-5.3.18-24.102-default.debug
/home/kkourt/src/hubble-fgs/vmlinux-5.3.18-24.102-default.debug
$
After the patch:
$ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
pahole: ./vmlinux-5.3.18-24.102-default.debug: Unknown error -22
$
Which is not very helpful, but less confusing.
Committer notes:
We need to turn the returned negative error to positive when setting it
to 'errno', that way the error message will be:
$ ./pahole -J ./vmlinux-5.3.18-24.102-default.debug
pahole: ./vmlinux-5.3.18-24.102-default.debug: Invalid argument
$
Because:
$ grep -w 22 /usr/include/*/errno*
/usr/include/asm-generic/errno-base.h:#define EINVAL 22 /* Invalid argument */
$
Signed-off-by: Kornilios Kourtis <kornilios@isovalent.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Cc: bpf@vger.kernel.org
Cc: dwarves@vger.kernel.org
Link: http://lore.kernel.org/lkml/20220316132354.3226908-1-kkourt@kkourt.io
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We can't have on the same compilation unit more than one of struct,
union, enum, class type with the same name, so when trying to create a
file with all types in a multi compilation unit binary debug
information we must disambiguate, do it by addint a __N prefix to the
type name.
This is the same strategy adopted by the bpftool when generating a
vmlinux file using:
$ bpftool btf dump file vmlinux format c > vmlinux.h
Testing it:
$ cat a.c
#include "vmlinux.h"
int main(void)
{
struct saved_context bla;
bla.ds = 1;
return bla.ds + 1;
}
$
$ rm -f a ; make a
cc a.c -o a
$
With an upcoming patch this will be possible using:
$ pahole --compile > vmlinux.h
$ rm -f a ; make a
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Remove the global variable and turn it into a member in struct
conf_fprintf, so that it can be used by other parts of the code.
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
Cc: dwarves@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We'll use it in the BTF loader.
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
[ Split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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>
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>
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>
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>
In 3f8aad340b ("elf_symtab: Handle SHN_XINDEX index in
elf_section_by_name()") we stopped using that argument as we switched to
using elf_getshdrstrndx() to get SHN_XINDEX.
So just remove that argument and fixup its callers, this will allow
removing a good chunk of calls and variables.
Cc: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
So that loaders such as the DWARF one can store there the DWARF handler
(Dwfl) that needs to stay live while tools use the core tags (struct
class, struct union, struct tag, etc) because they point to strings that
are managed by Dwfl, so we have to defer dwfl_end() to after tools are
done processing the core tags.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Another simplification made possible by using a plain char string
instead of string_t, that was only needed in the core as prep work
for CTF encoding.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Another simplification made possible by using a plain char string
instead of string_t, that was only needed in the core as prep work
for CTF encoding.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>