Commit Graph

712 Commits

Author SHA1 Message Date
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
Arnaldo Carvalho de Melo 5488b1dbde [DWARVES]: Check if any cu was found
Reported-by: Diego 'Flameeyes' Pettenò <flameeyes@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-05-12 15:25:45 -03:00
Arnaldo Carvalho de Melo f71ee6d306 [DWARVES]: Add support to DW_TAG_ptr_to_member_type
Another C++ism:

- regtest/before/libQtGui.so.4.3.4.debug.pahole -A.c  2008-04-21 16:09:30.000000000 -0300
+ regtest/after/libQtGui.so.4.3.4.debug.pahole -A.c   2008-04-21 17:25:17.000000000 -0300
@@ -115443,7 +115443,7 @@

        void init(classQGridLayoutPrivate *); /* linkage=_ZN18QGridLayoutPrivate4initEv */

-       class QSize findSize(const classQGridLayoutPrivate  *, <ERROR>, int, int); /* linkage=_ZNK18QGridLayoutPrivate8findSizeEM13QLayoutStructiii */
+       class QSize findSize(const classQGridLayoutPrivate  *, int QLayoutStruct::*, int, int); /* linkage=_ZNK18QGridLayoutPrivate8findSizeEM13QLayoutStructiii */

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-21 17:28:06 -03:00
Arnaldo Carvalho de Melo 23a8c85ae8 [DWARVES]: Normalise the reporting of IDs not found
By inlining them in the output when possible, that way we get context on where
the problem is, etc.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-21 15:57:34 -03:00
Arnaldo Carvalho de Melo 0dc85894dd [DWARVES]: Fix ftype__fprintf_parms goto label
If we don't find the type it should spill an <ERROR>, not print 'void'.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-21 13:09:26 -03:00
Dave Rigby de393c4670 [PAHOLE]: Add support for filtering classes based on name
While pahole allows you to exclude classes with a specified prefix (using
--exclude), it doesn't appear to be able to do the opposite - only show classes
with a specific prefix. I found I needed this for my own use of it, so here is
a patch to add this functionality.

Signed-off-by: Dave Rigby <davidr@transitive.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-21 12:41:44 -03:00
Arnaldo Carvalho de Melo 4ab5153b8a [DWARVES]: Handle DW_TAG_class_type
Basically the same as DW_TAG_structure_type.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-20 22:12:03 -03:00
Arnaldo Carvalho de Melo fb809733cc [DWARVES]: Introduce tag__assert_search_result
For correctly created and completely parsed debugging information the type will
always be found, but as we still need to parse more tags and expecting
debugging information to be always correctly built is not sane... sprinkle some
asserts.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-20 18:56:36 -03:00
Arnaldo Carvalho de Melo e288817933 [DWARVES]: Check if ancestor classes were found in class__fprintf
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-04-19 12:12:13 -03:00
Arnaldo Carvalho de Melo f061c18406 [CTF]: Remove the "file has no CTF" message
Confusing, just follow the previous behaviour of not emitting messages
when debugging information is not found. Scripts should just look at $?

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-25 13:36:51 -03:00
Arnaldo Carvalho de Melo f8c943bfe5 [DWARVES] base_type: store the size in bits
This is trying to get CTF friendly, where bitfields are not stored in the
equivalent to the DW_TAG_member dwarf TAG, but on "base types" with bit sizes
different than the real in the DWARF sense, base types (char, long, etc).

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 18:38:21 -03:00
Arnaldo Carvalho de Melo 0d9d41b23b [CTF_LOADER]: Fixup enumeration size
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 16:41:39 -03:00
Arnaldo Carvalho de Melo 0c807b72be [CTF_LOADER]: We store the max index, not the number of array entries
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 15:55:04 -03:00
Arnaldo Carvalho de Melo 2dfa5fe6ea [DWARVES]: Initial CTF support
Using a library written by David S. Miller.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 15:37:02 -03:00
Arnaldo Carvalho de Melo 03a653048e [DWARVES]: Check if type was found for members in union__fprintf
As we already do in class__fprintf.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-04 12:44:40 -03:00
Arnaldo Carvalho de Melo b3489e14eb [DWARVES]: Move all the DWARF specific loading routines to dwarf_loader.c
In libdwarves.so well continue using DW_TAG_ entries and types for now, but its
becoming non-DWARF specific as will be demonstrated with the introduction of
ctf_loader.c in the upcoming csets.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-03-03 13:50:44 -03:00
Felipe Kellermann 414595651d [DWARVES] Fixes a FIXME relating to a missing elf (libdw) symbol check.
Signed-off-by: Felipe Kellermann <felipek@socksarmor.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-12 21:08:49 -02:00
Hagen Paul Pfeifer 030f1871aa [DWARVES]: define memdup() static
memdup() is only referenced from dwarves.c. This patch defines them
static. Further symbol hiding can be accomplished via GCC attributes:

Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-11 22:08:29 -02:00
Arnaldo Carvalho de Melo 833ac2782c [RPM]: 1.6 release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-11 12:04:14 -02:00
Arnaldo Carvalho de Melo c83d935a4f [DWARVES]: Use a hash table for the tags in a CU
Almost halves the time spent on processing a x86_64 vmlinux. Good, we
have features, now lets have performance ;-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-11 11:47:17 -02:00
Arnaldo Carvalho de Melo d2a3a13e84 [RPM]: 1.5 release
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-07 11:48:10 -02:00
Arnaldo Carvalho de Melo c4e49add9e [PAHOLE]: Introduce --defined_in
This will print which object files have a struct definition, i.e. not just a
forward declaration.

There are many cases in the Linux kernel where just a fwd decl would suffice or outright
unneeded includes that end up bloating the DWARF sessions and consequently making everybody
suffer with humongous kernel-debuginfo packages.

More automation is needed here, this time something like sparse seems to be
needed to check what is that a header file "provides" and what is that the C
files "requires", doing some depsolving to discover unneeded Requires, i.e.
include directives and some that are required but are only satisfied
indirectly, which is a recipe for problems down the line.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-07 09:16:22 -02:00
Arnaldo Carvalho de Melo 11282eafb4 [DWARVES]: Another fix for DW_TAG_base_type entries without DW_AT_name
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-01 20:00:07 -02:00
Arnaldo Carvalho de Melo 7eeb0368a8 [PAHOLE]: Cope with DW_TAG_basic_type entries without DW_AT_name
Found in at least a file (tcp_ipv6.c in the Linux kernel) built with gcc
version 4.3.0 20080130 (Red Hat 4.3.0-0.7).

Which seems to be in violation with DWARF3, but better be defensive and handle
that.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-02-01 19:53:47 -02:00
Arnaldo Carvalho de Melo ac6a9a6745 [CODIFF]: Allow passing /dev/null as one of the files to compare
If passed as the old file, all functions in the new file will appear as being
new, etc.

Suggested by Ilpo Järvinen.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 10:05:02 -02:00
Arnaldo Carvalho de Melo 0a9cbf6ef6 [DWARVES]: Allow passing NULL as self to cu__find_
It will return NULL, this will be useful for codiff to use /dev/null as one of
the files being compared. And if you look for something in NULL, you better
get NULL, seems like a useful convention, huh?

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 10:03:54 -02:00
Arnaldo Carvalho de Melo 46d63102eb [DWARVES]: Fixup usage messages
Thanks to Ilpo Järvinen for getting this to my attention.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-31 09:30:55 -02:00
Arnaldo Carvalho de Melo 9a47906767 [DWARVES]: Find holes in inner, nameless structs
Long standing bug, fixed!

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 21:46:25 -02:00
Arnaldo Carvalho de Melo a1abd424a5 [DWARVES]: Adopt tag__follow_typedef from pahole
Useful for other cases, such as class__fixup_alignment in dwarves_reorganize.c.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 21:36:30 -02:00
Arnaldo Carvalho de Melo a2eb3ea774 [DWARVES]: Add some destructors: tag, cu, namespace
To be used later.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 20:04:57 -02:00
Arnaldo Carvalho de Melo 0a7fabf304 [CODIFF]: Check if the objects are the same when we have build-id
Speeding up the process, no need to check for changes in the same object file,
be it standalone or part of a multi-cu file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 15:48:03 -02:00
Arnaldo Carvalho de Melo 48f5b0d824 [DWARVES]: Introduce cu__same_build_id
So that we can speed up codiff when just some object files changed in a
multi-cu file.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-14 15:39:41 -02:00
Arnaldo Carvalho de Melo 8aa8c0b571 [DWARVES_REORGANIZE]: Proper tail padding fixup
Using type__find_first_biggest_size_base_type_member in class__fixup_alignment.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-13 16:04:59 -02:00
Arnaldo Carvalho de Melo 0e09769bb4 [DWARVES]: Don't search in empty structs
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-13 16:04:09 -02:00
Arnaldo Carvalho de Melo b32024f7f6 [DWARVES]: Follow const and volatile tags to its ultimate types
In type__find_first_biggest_size_base_type_member.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-13 15:42:33 -02:00
Arnaldo Carvalho de Melo e9fbc24b13 [PAHOLE]: Add a newline after the --class_dwarf_offset output
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-13 15:34:59 -02:00
Arnaldo Carvalho de Melo 0a6cf28e7a [PAHOLE]: Expose type__find_first_biggest_size_base_type_member
Thru -l command line option:

struct e1000_host_mng_command_header {
	uint8_t                    command_id;           /*     0     1 */
	uint8_t                    checksum;             /*     1     1 */
	uint16_t                   reserved1;            /*     2     2 */
	uint16_t                   reserved2;            /*     4     2 */
	uint16_t                   command_length;       /*     6     2 */

	/* size: 8, cachelines: 1 */
	/* last cacheline: 8 bytes */
	/* first biggest size base type member: reserved1 2 2 */
};	/* definitions: 1 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2008-01-13 15:20:06 -02:00