To encode CTF information from the DWARF one. Next patches will add
support for comparing the CTF and DWARF info.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
In the same fashion as DW_TAG_volatile_type, as we need to get to the
DW_TAG_base_type at the end of the chain.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
I'm using it using a directory with all debuginfo packages in fedora, so
that I can run a before and after with different tools (pahole, pfunct),
and check the differences after some change.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
If it is C++ add DW_TAG_member entries to cu->tags_table and at
imported_declaration__fprintf fallback to cu__tag() if cu__function()
fails.
The right thing tho, long term, is to have a class for
"DW_TAG_imported_declaration" to register to what kind of tag this
points, if for DW_TAG_subprogram or to DW_TAG_member, the info is in the
DWARF DW_AT_import attribute, but so far we're not decoding it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
It doesn't matter when using a traditional malloc/free allocator, but
with obstacks we need to do it in reverse order.
For the usual case where we successfully process an object this doesn't
matter, as when we started using obstacks we don't traverse all the tags
calling their destructors anymore, we just free the whole obstack in one
go.
Noticed when processing object files built from non-supported languages
such as FORTRAN and Pascal, where there are some DWARF tags that are not
supported, which makes the object file load to be prematurely aborted
and that calls destructors for things like classes and functions that in
turn free space for their parameter/member lists, which now have to be
done in reverse order.
We could just stop calling the destructors and then destroying the whole
obstack, but I think that partially processed files are a nice feature,
so keep the interface in a way that both obstacks and traditinal malloc
alocators can be used.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We can't always pad using the module of addr_size, we need to find the
minimum alignment requirement as a power of two < addr_size.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Where we end up with the same struct but class__size() returns off by
some bytes result. Investigating...
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
When we move fields from the tail to eliminate holes look if the struct
still correctly fits into a multiple of cu->addr_size.
Unless the struct is explicitely marked __attribute__((packed)) (and we
can't know that for sure) we have to add padding in that case.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
If conf_load.extra_dbg_info is false don't call those functions, that
way we reduce the number of page faults by not accessing the DWARF
sections that contains these informations.
Together with the previous optimization (don't delete everything on
exit), this shaves off 10% of a C++ test case (libgklayout.so)!
Thanks to 'perf record -g + perf report -c fractal' for telling me this
:-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Only when debugging leaks we need to be so judicious.
When not debugging we want to exit faster :-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
We really only need structures__add, that now returns an existing entry
or add a new one, the code that uses it just passes a bool to figure out
if this is a new entry or an existing one.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Adding an enum so that CTF doesn't have to include dwarf.h and
setting the language to LANG_C in the CTF loader.
Next csets will handle C++ in a different way, because we may need
to find class sizes in a different CU since ancestors sometimes
are only forward declared...
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
CMP0005
Preprocessor definition values are now escaped automatically.
This policy determines whether or not CMake should generate escaped
preprocessor definition values added via add_definitions.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Next we'll add a new kind of tag, DW_TAG_perf_counter, that will come
from perf.data generated by 'perf report'.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
That is used by cus__find_function_by_addr & cu__func_function_by_addr.
First user is pfunct --addr, but this is really for pfunct --annotate, that
will process a perf.data file generated by 'perf report', load the debugging
info and regenerate the functions (pfunct -TVi like) that had hits, using
libdisasm to show the assembly code, etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Replicating the comment added to the source code:
No sense in adding an anonymous struct to the list of structs already
printed, as we look for the name... The right fix probably will be to
call class__fprintf on a in-memory FILE, do a hash, and look it by full
contents, not by name. And this is needed for CTF as well, but its late
now and I'm sleepy, will leave for later...
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
I wasn't especifying the optimization level and the default, despite
using -Wall, was for this so simple case not to be warned about, so
now I'm using -O2.
Alexandre provided a patch initializing the variables to NULL, so that
when we called cus__delete it would bail out and not possibly act on
a random value, I preferred to add extra goto labels and do the exit
path only on the resources that were successfully allocated/initialized,
avoiding, for instance, to call dwarves_exit() if dwarves_init() wasn't
called, which wasn't a problem so far, but could be in the future.
Reported-by: Alexandre Vassalotti <alexandre@peadrop.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Fixing this comment,that only appears if one specifies -ON (N >= 2),
despite using -Wall:
strings.c: In function ‘strings__compare’:
strings.c:61: warning: dereferencing type-punned pointer will break strict-aliasing rules
strings.c stores a string_t on the are allocated by tsearch, so do it by
casting to unsigned long, that has a size > than string_t. No need for
the contortionism that was there before, that was plain silly.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Kinda brown paper bag one, and the thanks goes to C++ and the boost
library for providing such beautiful test cases as:
virtual int undefine(class
grammar_helper<boost::spirit::grammar<boost::detail::graph::dot_skipper,
boost::spirit::parser_context<boost::spirit::nil, class
grammar<boost::detail::graph::dot_skipper,
boost::spirit::parser_context<boost::spirit::nil_t> > *); /*
linkage=_ZN5boost6spirit4impl14grammar_helperINS0_7grammarINS_6detail5graph11dot_skipperENS0_14parser_contextINS0_5nil_tEEEEES6_NS0_7scannerINS0_10multi_passISt16istream_iteratorIccSt11char_traitsIcElENS0_19multi_pass_policies14input_iteratorENSH_11ref_countedENSH_12buf_id_checkENSH_9std_dequeEEENS0_16scanner_policiesINS0_27no_skipper_iteration_policyINS0_29inhibit_case_iteration_policyINS0_28skip_parser_iteration_policyIS6_NS0_16iteration_policyEEEEEEENS0_12match_policyENS0_13action_policyEEEEEE8undefineEPSA_
*/
;-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>