Sortof, mostly works, but still has a problem where the abstract origin is not
being found, but for now its ok to keep the bandaid, everything works as
before, there are more important things to do right now.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
We have to check for a possible alias (abstract origin attribute) and handle
that when we want the function name, if it is an alias, do the lookup and cache
the result in ->name, that after all doesn't have a value in the first place.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
As they already look just for DW_TAG_structure_type. Also make it return a
struct tag to avoid having to cast it back and forth too much.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Out of struct typedef_tag, that now becomes the superclass of struct class, and
that also will be for struct enumeration, struct union_type and then finally
for struct struct_type, when struct class finally dies.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
By having its own class, struct typedef_tag.
As it, as structs, unions and enums have a common part, the node and visited
fields, required when emitting its definitions there is an opportunity for
consolidation, that will be explored when adding the specific classes for
DW_TAG_enumeration & DW_TAG_union.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
And don't create a struct case as default, instead emit a warning that the tag
is not being handled.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
My favourite guinea pig (linux's vmlinux) has not one pointer to a function
that has unspecified parameters (...), but a new guinea pig, also a kernel,
has, openbsd's kernel, example:
/* /usr/home/leonardo/openbsd/src/sys/sys/protosw.h:63 */
struct protosw {
short int pr_type; /* 0 2 */
<SNIP>
void (*pr_input)(struct mbuf *, ...); /* 12 4 */
int (*pr_output)(struct mbuf *, ...); /* 16 4 */
<SNIP>
So fix it!
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This has to be reworked as it doesn't do the right thing, it has to be a mask
as function pointers needs, but variables are not something so heavily used in
the more interesting tools, so leave this for later.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Almost mirroring the DWARF on-disk linkage on memory, more to come before
getting over these simplification refactorings.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
All the cu__create_new_foo functions are now being normalised, will provide
opportunies for further consolidation/cleaning up, lets do this now before
moving on to libelf work.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Now that we have its parameter list we must call cus__emit_ftype_definitions in
cus__emit_typedef_definitions when we find DW_TAG_subroutine tags.
This fixes this problem with ctracer:
[acme@newtoy ctracer_example]$ make
<SNIP>
CC [M] /home/acme/pahole/ctracer_example/ctracer.o
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: 'struct pt_regs' declared inside parameter list
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: its scope is only this definition or declaration, which is probably not what you want
/home/acme/pahole/ctracer_example/ctracer.c:21: warning: 'struct kprobe' declared inside parameter list
<SNIP>
I.e. the struct pt_regs and kprobe forward declarations are done earlier.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
To preserve ordering, even with DW_tag_label tags not being kept in order by
gcc its better to have just one list, uses less space and keeps what is in the
dwarf sections.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
And make cu__process_function use a real loop for the siblings, not calling
itself again like in the code pahole was initially based of.
This causes tags below DW_TAG_lexical_block tags to be discarded, will be fixed
in the next csets, with proper lex block support.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This is very hackish, see the previous cset comment, without this hack
unrelated, deeper DW_TAG_formal_parameter tags were being attributed to the
function being processed, proper fix is described in previous comment, for now
this is enough as a bandaid.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
There are cases where just a declaration is emitted, such as in
blk_rq_map_user_iov's iov parameter:
<2><dc04>: Abbrev Number: 29 (DW_TAG_structure_type)
DW_AT_name : (indirect string, offset: 0x3be8): sg_iovec
DW_AT_declaration : 1
<2><dc0a>: Abbrev Number: 88 (DW_TAG_formal_parameter)
DW_AT_name : iov
DW_AT_decl_file : 1
DW_AT_decl_line : 2472
DW_AT_type : <dc60>
DW_AT_location : 0x4288 (location list)
I.e. the DW_TAG_structure_type tag is emitted at the same level as the
DW_TAG_formal_parameter tags, so handled inside the cu__process_function
method.
This and the next cset only shows that a normalization in the parsing routines
is in real demand and will be done, normalization because what needs to be done
is similar to what is already done in places like cu__create_new_array, i.e.
process all the siblings in a level in tag specific cu methods.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Will be reused when handling DW_TAG_subprogram_type more comprehensively, in
the upcoming csets.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This reduces by 8MB the dtagnames memory footprint when processing a qemu
vmlinux, that now uses ~79MB.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
So far struct class was being used as the main data structure, switch to struct
tag, that already was the top of the tag hierarchy, being a struct class
ancestor, so reflect that and stop using struct class as the catch all class,
as a started DW_TAG_array_type tags are now represented by a new class, struct
array_type, reducing the size of struct class and reducing DW__TAG_array_type
instance memory usage.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Only needed, so far, when processing functions, have to reenable this in the
future when we got to handle it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>