So that we get rid of all the buffer limits, if we need to format into strings
we can use string streams, like we're doing now in just one case, tag__name for
DW_TAG_subroutine_type, that is bogus as it is, as we need to have the name of
the type inside the type declaration (void (*type_name)(parameters)) and not
after (void (*)(parameters) type_name)), but leave this for an upcoming cset.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
And use it in a new tool, pglobal, that shows global variables and functions.
Signed-off-by: Davi Arnaut <davi@haxent.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
So that in tools like ctracer we can print to a file, most of the tools just
pass stdout, keeping the previous behaviour.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Will be used in ctracer to create a struct subset with just the types for which
we have "collectors", i.e. functions that reduce complex types to base types
that will be put in the mini-struct, that will be as tightly packed as it can
be.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Using export CFLAGS="-Wall -Wfatal-errors -Wformat=2 -Wsequence-point -Wextra
-Wno-parentheses -g", suggested by Davi Arnault, amazing how cruft piles up
when one is not looking ;)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Some are just typedefs, others are inside structs and in some cases its
useful to see the statistics for them, so add two new cmd line options:
-a, --anon_include include anonymous classes\
-A, --nested_anon_include include nested (inside other structs) anonymous classes
Commiter note: I've reworked several aspects of the patch, but mostly to
give better names for the new find_first_typedef_of_type function, adding
a clarifying comment and introducing --nested_anon_include so that we
can select just the typedef'ed anonymous structs.
Signed-off-by: Davi Arnaut <davi@haxent.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Previously it was being added to the CU tag list.
This also fixes a problem in cu__find_parameter_by_id where the second test in
the loop was actually outside the loop due to lack of {}.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Better, to match the readelf (binutils) and eu-readelf (elfutils) tools,
that on multi CU blobs is the way to go.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
That was preventing the correct printing of anonymous struct typedefs.
Signed-off-by: Davi Arnaut <davi@haxent.com.br>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Recheck if the typedef was emitted as part of the emission of its target, as
there are cases, like wait_queue_t in the Linux kernel, that is against struct
__wait_queue, that has a wait_queue_func_t member, a function typedef that has
as one of its parameters a... wait_queue_t, that will thus be emitted before
the function typedef, making a no go to redefine the typedef after struct
__wait_queue.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
And it even shrinks the lib a bit :-)
[acme@filo pahole]$ codiff build/libdwarves.so.before build/libdwarves.so
/home/acme/git/pahole/dwarves.c:
cus__emit_tag_definitions | -68
1 function changed, 68 bytes removed
[acme@filo pahole]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Now the functions that call cus__emit_enumeration_definitions should call
tag__print_decl_info, so that if it is a typedef we can just print "typedef ",
then call the enum printing routines.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
I.e. things like
typedef struct foo bar;
will emit the definition for struct foo before emitting the above line.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Where the 'if' should be just one of of the cases in the 'switch', and guess
what:
This:
diff --git a/dwarves.c b/dwarves.c
index c0ae7c8..34f29a1 100644
--- a/dwarves.c
+++ b/dwarves.c
@@ -2580,10 +2580,10 @@ static int cus__emit_typedef_definitions
}
type = cu__find_tag_by_id(cu, tdef->type);
- if (type->tag == DW_TAG_typedef)
- cus__emit_typedef_definitions(self, cu, type);
-
switch (type->tag) {
+ case DW_TAG_typedef:
+ cus__emit_typedef_definitions(self, cu, type);
+ break;
case DW_TAG_pointer_type:
ptr_type = cu__find_tag_by_id(cu, type->type);
if (ptr_type->tag != DW_TAG_subroutine_type)
Results in this:
[acme@newtoy pahole]$ codiff -V build/libdwarves.so.orig build/libdwarves.so
/home/acme/pahole/dwarves.c:
cus__emit_typedef_definitions | -18 # 466 -> 448
1 function changed, 18 bytes removed
[acme@newtoy pahole]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
tag__print on a DW_TAG_subprogram tag prints just the function prototype,
without the ending ";\", so if a user wants to print the whole function its
just a matter of calling tag__print + lexblock__(tag__function(tag), cu,
indent).
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This should not happen, but right now happens as we don't support all the C++
tags, so some types are not being collected when inside DW_TAG_namespace dies.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
And since there are no external users now, just unexport it, ditto
for tag__print_decl_info.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>