Commit Graph

948 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 415b9d1e28 dwarves: Introduce tag__has_namespace
This open coded sequence appears two times already, with more to come.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-03 09:38:27 -03:00
Arnaldo Carvalho de Melo bf14e0d220 reorganize: cu__find_base_type_of_size should look for alternative CTF base type names
Unfortunately the most common DWARF and CTF encoders don't agree on how
the names of base types are formed, so look for an alternative name.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-02 16:07:43 -03:00
Arnaldo Carvalho de Melo bff71347bc ctf: No need to concat "char " if attrs & CTF_TYPE_INT_CHAR is true
As most of the types comes with it already. Perhaps this was an
oversight and we will have to look if the name already has "char",
concat'ing only if it doesn't. We'll see...

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-02 16:06:15 -03:00
Arnaldo Carvalho de Melo 0e9e194cf0 ctf_loader: Fix up bitfields
The dwarves were implemented first for DWARF, so all the algorithms work
with class_member ->bit_size, ->bit_offset and expect the ->offset field
to be the same for all members of a bitfield, so fixup these fields
after loading a CTF section.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-02 12:24:35 -03:00
Arnaldo Carvalho de Melo 659611ee2f dwarves: Implement cu__find_base_type_by_name_and_size
Needed for CTF, where we can have many base types with name "unsigned",
but with different bit sizes, to implement bitfields.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-02 12:22:37 -03:00
Arnaldo Carvalho de Melo c3c942d730 ctf: Find out word size on the ELF header
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-03-01 20:02:14 -03:00
Arnaldo Carvalho de Melo a20b498dcd rpm: Own %{_datadir}/dwarves/
Fixing #473645

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-16 11:04:49 -03:00
Arnaldo Carvalho de Melo 3d2692a2b7 rpm: 1.7 changelog
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 11:53:28 -02:00
Arnaldo Carvalho de Melo f9d24098fc man-pages: Add URL for dwarves paper and info about where it is useful
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 11:52:58 -02:00
Arnaldo Carvalho de Melo 2a5d435053 man-pages: Add comments about CONFIG_DEBUG_INFO to pahole.1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 11:35:24 -02:00
Arnaldo Carvalho de Melo 56be29c649 all: Add the --version
Using the argp tricks.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-13 10:57:23 -02:00
Arnaldo Carvalho de Melo 7b6c135e7c pahole: finally the beginnings of a man page
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-11 12:19:46 -02:00
Arnaldo Carvalho de Melo 698b8c136a pahole: Tell the user if no debugging information was found
Reported-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-10 19:11:32 -02:00
Arnaldo Carvalho de Melo 138cc4739c dwarves: Don't pass argp to dwarf_loadfl
Now we just pass a NULL terminated array of filenames, since we got rid
of that ugly -e insertion hack.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09 21:43:56 -02:00
Arnaldo Carvalho de Melo 3bbd1342b2 dwarf_loader: remove old ugly with_executable_option hack
Now we use dwfl_report_offline directly, having more control about the
whole process, not using anymore dwfl_standard_argp.

This also, semi magicly, makes it work with the built-in.o files
in the Linux kernel, that aggregates multiple object files and that
previously were failing with relocation problems.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2009-02-09 16:30:06 -02:00
Arnaldo Carvalho de Melo 5c398cb582 Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/acme/pahole 2008-12-26 12:20:16 -02:00
Arnaldo Carvalho de Melo a16e38d336 Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/acme/pahole 2008-12-05 10:37:02 -02:00
Arnaldo Carvalho de Melo f890ae7cc1 loaders: Process argp only once
This is still ugly, as the processing of argp was done on the loader so
that we can use the libdwfl argp processing, doing the tool argp
processing as a child. But then when we find out that there is no DWARF
info we fall back to another debugging format, with CTF being the only
other one supported as of now.

I used this scheme as when developing the CTF decoder and using pahole
on a binary with both CTF and DWARF info I would like to get the CTF
processed first.

So we still need some good refactoring here to get this sorted out in a
way that the user can specify the order of decoding, and perhaps even
ask for decoding _both_ and comparing if the results are the same, i.e.
if the (potentially subset of) information decoded from the first (that
may have less information: CTF) is the same as decoded from the second
(DWARF, more verbose).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-12-01 13:47:52 -02:00
Arnaldo Carvalho de Melo 01db5b1374 cmake: check if in RHEL and ask for the same packages as in fedora if so
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-20 13:55:05 -02:00
Arnaldo Carvalho de Melo d2a128b810 cmake: 2.4.8 is enough
Tested in RHEL5.2

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-20 13:54:39 -02:00
Arnaldo Carvalho de Melo ce2219915d argp: check if child_inputs is NULL
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-18 14:09:13 -02:00
Arnaldo Carvalho de Melo bcf1c15d8b pahole: Fix structures__find, tfind returns a pointer, not the object we want
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-03 14:47:56 -02:00
Arnaldo Carvalho de Melo adb9d370d6 cmake: Check if distro is fedora and if so tell the package names that are missing
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-11-03 12:21:06 -02:00
Arnaldo Carvalho de Melo 943a241ea2 ctracer: update README.ctracer, f9 has the dwarves
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-29 08:54:53 -02:00
Arnaldo Carvalho de Melo 02b0f811b1 pahole: speed up structure lookup by name
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-28 18:56:47 -02:00
Arnaldo Carvalho de Melo 4d615b9e01 strings: Add strings__find and strings__cmp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-24 14:20:37 -02:00
Arnaldo Carvalho de Melo 46a3bc4626 cmake: Add cmake_minimum_required
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-24 10:44:26 -02:00
Arnaldo Carvalho de Melo d4812cadd6 ctf_loader: hack to minimally use the argp passed
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-08 10:46:34 -03:00
Arnaldo Carvalho de Melo 19704cf67e pahole: Add new structures to the end of the list
So that they appear on the output in the same order as they
come from the original debugging info.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-08 10:03:58 -03:00
Arnaldo Carvalho de Melo cdf547f418 pdwtags: print pointers and base types too
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-07 21:18:29 -03:00
Arnaldo Carvalho de Melo 79f6c3fe40 ctf_loader: parse function type parameters
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-07 21:13:56 -03:00
Arnaldo Carvalho de Melo ede353e099 ctf_loader: ctf_array_nelems should be used directly
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-07 21:06:44 -03:00
Arnaldo Carvalho de Melo be30be91f5 gobuffer: Move the non string specific bits
Will be used while encoding the CTF sections.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 17:06:01 -03:00
Arnaldo Carvalho de Melo 212b994ab5 strings: Introduce the strings class
And make the dwarves use it, so that we can remove duplicate strings in
a multi-CU file (vmlinux anyone?) and have it ready for insertion in a
compressed DWARF format with just the types, or better, CTF or some new
compressed debugging info format.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-02 14:34:42 -03:00
Arnaldo Carvalho de Melo 964c6b0666 dwarves_emit: Adopt type_emissions
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 12:51:58 -03:00
Arnaldo Carvalho de Melo efa997ed40 dwarves: Remove type_emissions fields from cus
Now only when one wants to emit this struct is needed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 12:47:42 -03:00
Arnaldo Carvalho de Melo f07b4e8047 dwarves_emit: Move the __emit_definitions methods from cus to the emitted classes
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 12:43:01 -03:00
Arnaldo Carvalho de Melo c3f6f8b79f dwarves_emit: Introduce type_emissions
We may want to work on just one object file, not on a multi cu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-10-01 11:26:51 -03:00
Arnaldo Carvalho de Melo 993bcbde35 pfunct: Implement --expand_types
So that one can get an skeleton from where a function can be
reimplemented, or a probe can be written to attach to a tracepoint.

Right now it will only expand the types for
struct/union/typedef/enumeration types, but it is a good start.

[acme@doppio pahole]$ pfunct --expand_types --function inet6_ioctl ipv6.ko > a.c
[acme@doppio pahole]$ echo "int main(void) { return 0; }" >> a.c
[acme@doppio pahole]$ gcc -Wall -g a.c -o a
[acme@doppio pahole]$ grep ^#include a.c
[acme@doppio pahole]$

No errors, no includes.

This is present in ctracer, where we don't want to _require_ any header
files, just the object file with the function we want to probe. From
there we get the function signature, and reconstruct the types needed to
access members of structs passed as parameters.

We still need to add padding to reconstruct __attribute__ alignment
effects.

Also, if we can detect what are the exact members accessed in the probe,
we can reconstruct just what is needed to access those members,
hopefully reducing the time needed for gcc to digest the resulting
source code. And also reducing the size of the output, which can
hopefully be interesting to help focus on what the probe is doing.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-30 17:30:42 -03:00
Arnaldo Carvalho de Melo 515c87c72a dwarves: Use tag__is_{struct,union} where applicable
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-30 14:43:22 -03:00
Arnaldo Carvalho de Melo 0614c1d53e dwarves: Introduce tag__is_typedef()
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-30 14:21:03 -03:00
Arnaldo Carvalho de Melo 7dfd45ffea libctf: The constructor should load only if a buffer is passed
So that we can create a ctf object and then populate it, to do the
encoding.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-25 16:25:06 -03:00
Arnaldo Carvalho de Melo 36f454820e libctf: Use the same coding style as the dwarves
Use __ as a separator for the method names, self, new/delete, use
stdint.h types, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-09-25 16:01:26 -03:00
Arnaldo Carvalho de Melo aa22f16f56 codiff: Detect changes in the prototype even when function size doesn't changes
[acme@doppio pahole]$ codiff -V examples/tag-v6 examples/tag
tag.c:
   |   +0 # 42 -> 42, prototype: int (struct tag * self, int bar) -> unsigned int (struct tag * self, int bar)
 1 function changed, diff: +0
[acme@doppio pahole]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-08-06 13:48:28 -03:00
Arnaldo Carvalho de Melo 51bcb5f9e5 dwarves: Introduce function__prototype
Basically a wrapper for ftype__fprintf(&function__proto, ...) for the
cases we want the prototype rendered to a buffer, not to a file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-07-30 18:33:33 -04:00
Arnaldo Carvalho de Melo 33ba723280 dwarves: handle the empty base optimization trick
Thanks to Dennis Lubert for bringing this to my attention, now tons of BRAIN
FART ALERTs are gone.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-07-04 12:09:28 -03:00
Arnaldo Carvalho de Melo ad635812a0 dwarves: Print the number of members in class__fprintf
Example:

struct foo {
	void xxx(class foo *); /* linkage=_ZN4tonk3foo3xxxEv */

	/* size: 1, cachelines: 1, members: 0 */
	/* padding: 1 */
	/* last cacheline: 1 bytes */
};

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-07-03 14:44:03 -03:00
Arnaldo Carvalho de Melo 39a2b29115 ctracer: use list_first_entry
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-28 10:03:59 -03:00
Pavel Emelianov 041f60ec0d list: Introduce a handy list_first_entry macro
From: Pavel Emelianov <xemul@sw.ru>

There are many places where the construction like

   foo = list_entry(head->next, struct foo_struct, list);

are used.

The code might look more descriptive and neat if using the macro

   list_first_entry(head, type, member) \
             list_entry((head)->next, type, member)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-28 09:59:54 -03:00
Arnaldo Carvalho de Melo a7d599c203 dwarves: Handle DW_TAG_typedef in DW_TAG_subroutine_type
By just adding the typedefs to the CU where the subroutine type is defined.

Reported-by: Diego 'Flameeyes' Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-06-16 15:11:25 -03:00