Commit Graph

1064 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo e429f8efbb dwarves: Add an rbtree for the functions in a cu
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>
2009-06-04 14:56:44 -03:00
Arnaldo Carvalho de Melo dd8c983b40 dwarves: addresses are now uint64_t, no more Dwarf_ types in the core
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-03 15:40:38 -03:00
Arnaldo Carvalho de Melo 0b9d022fb1 dwarf_loader: Move the specification Dwarf_Off from the core
This field is resolved now entirely by the dwarf loader, no sense in having it
in the core.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-03 15:33:57 -03:00
Arnaldo Carvalho de Melo e2b7d1a5f5 dwarves: types are uint16_t now
Remove one more DWARF specific detail.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-06-03 14:56:53 -03:00
Arnaldo Carvalho de Melo 2f7ffdb088 pahole: Don't add anonymous structs to the list of known structs
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>
2009-05-08 01:05:31 -03:00
Arnaldo Carvalho de Melo 73548f6be3 all: Fix possible uninitialized variable uses
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>
2009-05-04 15:50:06 -03:00
Arnaldo Carvalho de Melo 044dceac85 strings: Fix stupid pointer deref
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>
2009-05-04 15:40:44 -03:00
Arnaldo Carvalho de Melo 188cacfe5e gobuffer: Fix buffer expansion algorithm
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>
2009-04-25 12:13:14 -03:00
Arnaldo Carvalho de Melo 0a2a9e03c7 dwarf_loader: DW_AT_name can be NULL in DW_TAG_compile_unit
So pass "" in this case so that cu__new doesn't segfaults on strdup'ing
it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-25 11:41:47 -03:00
Arnaldo Carvalho de Melo 071cb5fd75 fprintf: Print "interface" in class__fprintf for Java Interfaces
JAVA support needs to be checked, but from a very quick skim it
looks ok'ish.

First detected with /usr/bin/fstack from frysk.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-25 01:54:21 -03:00
Arnaldo Carvalho de Melo 8cdd311538 dwarf_loader: Load JAVA interfaces as a struct/class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-25 01:53:59 -03:00
Arnaldo Carvalho de Melo ca783c4a58 dwarf_loader: die__create_new_subroutine_type default to die__process_tag
As we can have more than typedefs inside functions, we also can have
structs, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-25 00:45:16 -03:00
Arnaldo Carvalho de Melo da3123adea dwarf_loader: DW_TAG_inlined_subroutine can have lexblocks, etc
So far all of these tags had just an abstract origin, so we only needed
to print the function it pointed to, but we need to treat it as an
DW_TAG_subprogram... fix it later, after 1.8, for now just dive in and
collect the types.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-24 22:28:54 -03:00
Arnaldo Carvalho de Melo c722f0e29b dwarf_loader: die__create_new_typedef should print the offset
To help identify with readelf -wi file.o where is the problem.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-24 22:27:31 -03:00
Arnaldo Carvalho de Melo 00ecd85798 dwarf_loader: Handle volatile typedef bitfields
I.e. like these:

struct _GClosure {
        volatile guint ref_count:15;    /* 0:17  4 */
        volatile guint meta_marshal:1;  /* 0:16  4 */
        volatile guint n_guards:1;      /* 0:15  4 */
<SNIP>

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-24 14:24:34 -03:00
Arnaldo Carvalho de Melo 21f97592ef rpm: Add %{?dist} to Release tag
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-23 15:28:51 -03:00
Arnaldo Carvalho de Melo a693b7fde9 cmake: move headers to /usr/include/dwarves/ and tag 1.8pre1
In reponse to https://bugzilla.redhat.com/show_bug.cgi?id=497285 I
included the header files that are needed by the dwarves*.h files
and moved them to /usr/include/dwarves.h.

The CTF work is not completed yet, but the non-CTF related improvements
(progressive loading of CUs, etc) are worth a release till I can get back to
dedicate solid time for developing these tools again.

Reported-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-23 15:13:50 -03:00
Arnaldo Carvalho de Melo 602e02fc28 MANIFEST: add missing files
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-23 14:49:44 -03:00
Arnaldo Carvalho de Melo 29e67fce58 dwarf_loader: Add containing_type to dwarf_tag
Sharing the same space with abstract_origin, so that we can remove the last
Dwarf_Off in dwarf_fprintf.c.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-19 14:04:59 -03:00
Arnaldo Carvalho de Melo f84bf73d54 dwarves: Move the fprintf code to a new source file.
$ wc -l dwarves.c dwarves_fprintf.c
 1468 dwarves.c
 1554 dwarves_fprintf.c
 3022 total
$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-19 13:48:51 -03:00
Arnaldo Carvalho de Melo e148f93418 code: Combine the debugging_formats and debug_fmt_ops structs
Paving the way for pluggable debugging formats via dlopen.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-04 14:56:39 -03:00
Arnaldo Carvalho de Melo 7cfe6f22e3 ctracer: blacklist functions in .init.text (__init marked)
We do this by just creating a strlist with all the functions that are in
section ".init.text", as found out by looking at the symtab.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:56:52 -03:00
Arnaldo Carvalho de Melo f74ad7eb4c elf_symtab: Add elf_sym__section helper
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:56:03 -03:00
Arnaldo Carvalho de Melo 0e56f5e562 core: Be more strict with the return of __name() routines
In the past we did integer testing, and testing against 0 was no problem, but
now they return NULL and we are back using strcmp, oops.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:55:02 -03:00
Arnaldo Carvalho de Melo 1701b6d68d dutil: Allow returning the section index in elf_section_by_name
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:53:05 -03:00
Arnaldo Carvalho de Melo 08d41fb4d2 strlist: Return false if NULL is passed to strlist__has_entry
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:49:46 -03:00
Arnaldo Carvalho de Melo 57ae9740d8 strlist: Allow strlist__add to distinguish ENOMEM from EEXIST
I.e. the operation may fail because the string is already there or
because there wasn't enough memory.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 11:47:28 -03:00
Arnaldo Carvalho de Melo 1d7bea33b7 libctf: ctf__delete must call elf_symtab__delete
Its used when loading a CTF file, not when encoding.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:45:15 -03:00
Arnaldo Carvalho de Melo 33d73f990a pahole: remove the alloc_detective include, it is not included yet :-\
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:43:38 -03:00
Arnaldo Carvalho de Melo 33ed25d5cd elf_symtab: elf_symtab__delete must free ->name too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:41:09 -03:00
Arnaldo Carvalho de Melo 4f5e2226de ctf_encoder: ctf__encode has to free the buf when compressing
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:25:48 -03:00
Arnaldo Carvalho de Melo bd68f6bbc1 ctf_encoder: We have to free the gobuffer entries for the sections
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:22:48 -03:00
Arnaldo Carvalho de Melo 38b7f8aecf core: list__for_all_tags should delete shared enumerations
Its just the enumerator list (enum entries) that are shared.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:19:19 -03:00
Arnaldo Carvalho de Melo 58f29607a2 core: Add ->init and ->exit hooks to be called at dwarves__{init,exit}
So that we can more early return if we can't process files for some supported
debugging format and as well release all resources allocated when dwarves__exit
is called.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:05:36 -03:00
Arnaldo Carvalho de Melo db9774f38e core: cu__delete must delete ->filename too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:05:11 -03:00
Arnaldo Carvalho de Melo 89afe150ea pahole: structure__delete should free ->name too.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:04:26 -03:00
Arnaldo Carvalho de Melo 87f3f634f2 dwarf_loader: tag__recode_dwarf_bitfield should use cu__add_tag
So that it gets linked in the cu tags list to be deleted at cu__delete ->
tag__delete time.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-03 09:02:50 -03:00
Arnaldo Carvalho de Melo 4d619ac4cb core: Only DWARF uses the global strings table, so move it there
There is still the problem of handing the strings table to the CTF encoder, but
that will be fixed another day.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 18:46:54 -03:00
Arnaldo Carvalho de Melo 486299a359 ctf: Plug debug_fmt_ops->strings__ptr
So that we can use the strings in ".strtab" directly, without duplicating them
on the global strings table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 17:55:17 -03:00
Arnaldo Carvalho de Melo 870afee9ce core: Stop using strings__ptr(strings, i) directly
Instead pass thru cu__strings(cu, i) so that we can figure out if the
underlying debugging format handler can do that more efficiently, such as by
looking up directly the ELF section ".strtab".

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 17:54:43 -03:00
Arnaldo Carvalho de Melo 83a2b3bb60 pahole: Don't assume all strings are in the global strings table
It ain't gonna be like that soon, when every cu that comes from a CTF file will
have all its strings_t pointing to strings in .strtab.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:46:37 -03:00
Arnaldo Carvalho de Melo e6ed526926 core: tag__name can't assume all cus use the global string table
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:45:30 -03:00
Arnaldo Carvalho de Melo 9bb29daac4 base_type: Don't combine names with attributes
Such as signed, etc. This is in preparation for using directly ctf_strings.
Instead of duplicating it in the global strings table.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 16:12:36 -03:00
Arnaldo Carvalho de Melo 9a5678904b reorganize: class__demote_bitfield_members should update member->byte_size
That became cached when we moved to CTF like bitfields, i.e. each bit size
creates a new type so that the encoding for class members can have just the
name, type and bit_offset.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 15:57:21 -03:00
Arnaldo Carvalho de Melo 50844b5f25 dwarf_loader: Handle volatile bitfields in class_member__cache_byte_size
Reported-by: Breno Leitão <leitao@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 13:58:46 -03:00
Arnaldo Carvalho de Melo 7fc7148be7 core: Fix thinko in type__find_first_biggest_size_base_type_member
ctracer was segfaulting due to this problem.

Reported-by: Breno Leitão <leitao@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 13:33:05 -03:00
Arnaldo Carvalho de Melo 495c70ae14 ctf_encoder: Add void entries for variables not found on DWARF
Temporary hack till I figure out how to do more filtering on the variables on
the symtab that aren't in the DWARF info.

Problem is that if we don't put something on the table at encode time, we won't
find it at decode time, when we don't have DWARF to notice that its not there
because its not in DWARF.

We then discard it at load time, as "void foo;" doesn't make sense.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:41:01 -03:00
Arnaldo Carvalho de Melo c93fff6743 core: Add variable__name to struct debug_fmt_ops
Same reason as for function__name

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:40:33 -03:00
Arnaldo Carvalho de Melo 3b3388cb78 pdwtags: Allow specifying the debug format to be decoded
Just like the other dwarves.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:38:41 -03:00
Arnaldo Carvalho de Melo ea4ff04f8e core: class__vtable_fprintf should use function__name
Same reason as for last commit.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-04-02 12:10:33 -03:00