Commit Graph

1115 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 347e70f4d8 cus: Allow passing a debugging format path to cus__load
So that the user can specify what is the order it wants for decodind, as
we can have several debugging formats encoded in different ELF sections.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-19 12:13:00 -03:00
Arnaldo Carvalho de Melo eb0284c619 enumeration: type->size for enumerations is in bits, not in bytes
I have to normalize this so that we don't have this special case, but
since we can have enum bitfields....

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 23:01:32 -03:00
Arnaldo Carvalho de Melo bcf24ef40f base_type__name_to_size: Complain when not finding the requested type name
Fragile interface, but its the best I have for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:49:33 -03:00
Arnaldo Carvalho de Melo 7397fab08e base_type_name_to_size: Add "long double long double"
Looks like a stupid glitch, but lets leave this for later for now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:47:48 -03:00
Arnaldo Carvalho de Melo da37c56c26 cu: Add a filename member
Will later be used when generating the CTF info, be it in a separate
file, be it on a new ELF section inserted into this filename.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:35:54 -03:00
Arnaldo Carvalho de Melo 0449febc4e gobuffer: Introduce gobuffer__allocate
So that we can also reserve space for things that will be added in
several steps, such as CTF structs, where we first add a struct for the
name, size, nr_members, then several ones for the members.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 22:14:55 -03:00
Arnaldo Carvalho de Melo 140712f06a cu: Rename cu__find_{type,tag}_by_id to cu__{type,tag}
To shorten the name and to reflect the fact that we're no longer
"finding" a type, but merely accessing an array with a bounds check in
this function.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 12:17:07 -03:00
Arnaldo Carvalho de Melo a56a9a6cfe class_member: Reencode DWARF bitfield types
We now create a new integral type (enum or base_types), creating typedef
chains if needed, while caching the bit_size and bit_offset, so that we
can easily reencode the whole file into CTF.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:58:32 -03:00
Arnaldo Carvalho de Melo dfdfcbbb5c cu: Introduce cu__find_enumeration_by_sname_and_size
Needed for reencoding DWARF bitfields, where we need to create a new
enum that has a bitfield_size bits size.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:52:29 -03:00
Arnaldo Carvalho de Melo 83e389677e base_type: Move base_type__name_to_size from the ctf loader to the core
Will be used in more parts.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:48:40 -03:00
Arnaldo Carvalho de Melo ccc808b88e dutil: Move zalloc to dutil
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-18 11:08:23 -03:00
Arnaldo Carvalho de Melo 61219b0c3b class_member: cache the byte size of the member
This is the full byte size of the type or the bitfield it is in.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 14:31:18 -03:00
Arnaldo Carvalho de Melo 93eefc6cfb class_member: cache byte_size
This will help us in the next csets when we need to know both the full
size of the base_type used in an bitfield _and_ the size in bits of the
bitfield member.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 13:57:40 -03:00
Arnaldo Carvalho de Melo f879394b87 ctf: improve base_type__name_to_size
Now it does integer comparisions (strings_t) and also covers all the so
far seen base type names in CTF and DWARF land.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 13:47:31 -03:00
Arnaldo Carvalho de Melo ef6c1c63d6 dwarves: Rename the class_member bitfields size and offset members
Because we will need the "bit_offset" and "bit_size" names when converting the
representation of offset and size everywhere to be in bits, not bytes.

At the same time we will keep bitfield_size and bitfield_offset when we convert
from DWARF to CTF and will calculate them when loading CTF, so that the
conversion of the algorithms in dwarves_reorganize, that have all sorts of
subtle issues, can be left for later.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-17 11:43:17 -03:00
Arnaldo Carvalho de Melo f25af978bf pdwtags: cu->types_tables can have some NULL slots
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-16 15:55:48 -03:00
Arnaldo Carvalho de Melo 3ccd3e57b7 ctf: ctf_load can receive a NULL conf_load
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-16 15:53:26 -03:00
Arnaldo Carvalho de Melo 6443161c76 dwarves: Move abstract_origin to dwarf_tag
So that yet another DWARFism is nicely hidden in the DWARF specific
loader.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 22:42:34 -03:00
Arnaldo Carvalho de Melo b9a9b048d4 dwarves: Don't double free vtable entries
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 22:40:56 -03:00
Arnaldo Carvalho de Melo 865e259012 dwarves: the variable abstract_origin is resolved at load time too
It makes no sense to try to lookup the abstract_origin (a Dwarf_Off)
after we recode the types just after load.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 15:19:33 -03:00
Arnaldo Carvalho de Melo 5c204b5036 dwarf_loader: conf_load can be NULL
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 15:00:11 -03:00
Arnaldo Carvalho de Melo 80374a4e27 dwarves: Remove some unused functions
Namely cus__find_function_by_name and cus__find_tag_by_id.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 14:52:30 -03:00
Arnaldo Carvalho de Melo 5589f1af67 dwarves: reorganize dwarves.h to group classes with its methods
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 14:48:20 -03:00
Arnaldo Carvalho de Melo 4d44276d85 coding style: remove trailing whitespaces, etc
Amazing how many crept up over time, should have set the
execute bit of .git/hooks/pre-commit already, duh.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 13:50:36 -03:00
Arnaldo Carvalho de Melo 5a0113c615 headers: remove not needed 'extern' noise from function prototypes
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 13:37:14 -03:00
Arnaldo Carvalho de Melo 839ab493c9 dwarves: Introduce cu__find_base_type_by_sname_and_size
From cu__find_base_type_by_name_and_size, so that one can do a string_t
based lookup.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-14 13:36:45 -03:00
Arnaldo Carvalho de Melo 286c7740fd pahole: Use the new progressive processing scheme
So that we can, for instance, go from:

[acme@doppio pahole]$ time pahole -C sk_buff
/usr/lib/debug/lib/modules/2.6.27.19-170.2.35.fc10.x86_64/vmlinux | head
-3
struct sk_buff {
	struct sk_buff *  next;      /*     0     8 */
	struct sk_buff *  prev;      /*     8     8 */

real	0m11.071s
user	0m10.627s
sys	0m0.359s
[acme@doppio pahole]$

To a mere:

[acme@doppio pahole]$ time pahole -C sk_buff
/usr/lib/debug/lib/modules/2.6.27.19-170.2.35.fc10.x86_64/vmlinux | head
-3
struct sk_buff {
	struct sk_buff *  next;      /*     0     8 */
	struct sk_buff *  prev;      /*     8     8 */

real	0m1.464s
user	0m1.431s
sys	0m0.016s
[acme@doppio pahole]$

And also results go appearing much quicker for other options, etc.

The other tools will be converted too, but the old way of working will
always be there, as it is possible that we may need all the types in
memory for some future tool.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 15:05:19 -03:00
Arnaldo Carvalho de Melo 18e9ad4936 dwarves: Allow the apps to steal compile units as they are created
So that we immensely reduce the memory footprint by doing filtering and
other processing/pretty printing as the cus are loaded, discarding them
right away.

The next cset will use this scheme in pahole.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 14:59:32 -03:00
Arnaldo Carvalho de Melo 489e3b585c dwarves: Introduce cu__find_struct_by_sname
Out of cu__find_struct_by_name so that we can do a string__find
once and lookup the string id on multiple cus.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 14:57:53 -03:00
Arnaldo Carvalho de Melo 2d01f5adb1 dwarves: Fix cu__for_each_function when there are no functions
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 13:49:27 -03:00
Arnaldo Carvalho de Melo 991c6a3ebb dwarves: Rename cus__loadfl with cus__load_files
Also introducing cus__load, that load just one file.

The new cus__load_files routine now iterates thru the provided array
calling cus__load for each, and that in turn will try first dwarf__load,
and if that fail, i.e. if no DWARF info is found, call ctf__load.

This now allows loading DWARF _and_ CTF files at the same time. This
will be useful in the future when we, from DWARF generate CTF and at the
same time do a codiff, comparing the freshly generated CTF file with the
DWARF it came from.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 10:49:01 -03:00
Arnaldo Carvalho de Melo ade3f44269 dwarves: Ditch old cus__load and cus__load_filename
Not used anymore now that cus__loadfl is sanitized. Now we can even
remove the fl (historically comes from libdwfl, when we used to pass an
argp, argh!).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-13 09:31:48 -03:00
Arnaldo Carvalho de Melo 152277f667 dwarves: cu__find_struct_by_name should set id for non declarations
Bug introduced recently, fixed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-12 20:34:07 -03:00
Arnaldo Carvalho de Melo 41b1554715 ctracer: skip object files that don't have the target class
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-12 20:33:09 -03:00
Arnaldo Carvalho de Melo 8cc4949b00 dwarves: Add destructors
So that at program exit we can verify, using tools, that no memory was
leaked.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-11 12:31:17 -03:00
Arnaldo Carvalho de Melo f62770c4a2 Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/acme/pahole 2009-03-09 16:37:24 -03:00
Arnaldo Carvalho de Melo 9f05162b3f Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/acme/pahole 2009-03-09 15:56:19 -03:00
Arnaldo Carvalho de Melo 250dded466 dwarf: separate dwarf_tag from tag
So that, when not needing the DWARF info, the apps can tell that at load
time, and then the dwarf loader can just free all the dwarf_tags
allocated, reducing memory usage.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-09 14:43:47 -03:00
Arnaldo Carvalho de Melo 822f8b675e dwarves: Introduce cu__for_all_tags
To visit all parms, lexblocks, namespaces, i.e. not just the top level
tags listed in cu->tags.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-08 10:36:24 -03:00
Arnaldo Carvalho de Melo 702485234a dwarves: replace high_pc by size in struct lex_block
So that we can save 8 bytes in lexblock and in function instances:

$ codiff /tmp/libdwarves.so.1.0.0 build/libdwarves.so.1.0.0
/home/acme/git/pahole/dwarves.c:
  struct lexblock               |   -8
  struct function               |   -8
 2 structs changed
  cu__account_inline_expansions |   -3
  lexblock__fprintf             |  -26
  function__fprintf_stats       |   -4
  function__size                |  -18
 4 functions changed, 51 bytes removed, diff: -51

/home/acme/git/pahole/dwarf_loader.c:
 2 structs changed
  lexblock__init  |  +20
 1 function changed, 20 bytes added, diff: +20

build/libdwarves.so.1.0.0:
 5 functions changed, 20 bytes added, 51 bytes removed, diff: -31

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-07 17:37:33 -03:00
Arnaldo Carvalho de Melo 20464ba7f0 dwarves: Reduce the size of some data structures
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-07 16:45:09 -03:00
Arnaldo Carvalho de Melo 46ec8897a8 reorganize: Fix bug in cu__find_base_type_of_size alternate type names
c'n'paste error for the two bytes case, the alternate name was also
being set to the type_name variable, duh.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-07 16:35:17 -03:00
Arnaldo Carvalho de Melo c550aea11c pahole, lib: Do more strings__find + integer comparisions
Replacing strcmp calls

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 12:41:29 -03:00
Arnaldo Carvalho de Melo cf20eaec3a dwarf__loader: optimize tag__init a bit more
No need to initialize hash_node, as we don't use hlist__unhashed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:53:27 -03:00
Arnaldo Carvalho de Melo b902f563b3 dwarves: find holes when adding a fresh compile unit
To take advantage of cache effects and to avoid calling cu__find_holes
more than once on the same struct.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:48:33 -03:00
Arnaldo Carvalho de Melo 5f606ab5e3 ctracer: Remove superfluous calls to class__find_holes in class__clone_base_types
The first isn't needed because class__clone will do a memcpy for
the whole class struct, and that will get the hosts calculated
previously for the classe beind cloned.

The second isn't needed because class__reorganize will call
class__find_holes at every iteration of its algorithm.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:23:00 -03:00
Arnaldo Carvalho de Melo 9fadbfffba dwarves: use tag__is_function in the tools
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:14:26 -03:00
Arnaldo Carvalho de Melo b19ac641ba dwarves: Introduce tag__is_function()
Removing more dwarf specific knowledge (DW_TAG_subprogram) from the
tools.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:12:00 -03:00
Arnaldo Carvalho de Melo 7cf49c14e7 dwarves: check if the current pos is NULL in cu__for_each_function
To match cu__for_each_type handling of entries set with
cu__table_nullify_type_entry.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 11:02:16 -03:00
Arnaldo Carvalho de Melo fa82c1b623 dwarves: remove now unused 'cu' argument to {type,class}__name
And also make then pure functions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-06 10:57:41 -03:00