Commit Graph

2001 Commits

Author SHA1 Message Date
Arnaldo Carvalho de Melo 042c51dc1f Support DW_AT_low_pc and DW_AT_high_pc, now pfunct is able to do this:
[acme@newtoy net-2.6]$ pfunct kernel/sched.o schedule
/* /pub/scm/linux/kernel/git/acme/net-2.6/kernel/sched.c 3317 */
void schedule(void);
/* size: 1492 */

Cute, huh? :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-30 14:22:39 -03:00
Arnaldo Carvalho de Melo f204c370ed Move the attr functions that are needed only by class__new or class_member__new
to where they are needed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-30 13:37:04 -03:00
Arnaldo Carvalho de Melo 3dfd363868 Add getopt support in pfunct, options implemented should be self explaining,
except for --classes, that asks that all non-inlined functions that receive as
one of its parameter a pointer to the specified class be printed, just the name
if --verbose is not used, or its complete prototype and where it is in the
source code:

[acme@newtoy net-2.6]$ pfunct --verbose --class=inode fs/ext3/built-in.o
/* /pub/scm/linux/kernel/git/acme/net-2.6/fs/ext3/balloc.c 606 */
void ext3_free_blocks(handle_t * handle, struct inode * inode, ext3_fsblk_t block, long unsigned int count);

/* /pub/scm/linux/kernel/git/acme/net-2.6/fs/ext3/balloc.c 1404 */
ext3_fsblk_t ext3_new_blocks(handle_t * handle, struct inode * inode, ext3_fsblk_t goal, long unsigned int * count, int * errp);

/* /pub/scm/linux/kernel/git/acme/net-2.6/fs/ext3/balloc.c 1668 */
ext3_fsblk_t ext3_new_block(handle_t * handle, struct inode * inode, ext3_fsblk_t goal, int * errp);

/* /pub/scm/linux/kernel/git/acme/net-2.6/fs/ext3/balloc.c 346 */
void ext3_init_block_alloc_info(struct inode * inode);

/* /pub/scm/linux/kernel/git/acme/net-2.6/fs/ext3/balloc.c 388 */
void ext3_discard_reservation(struct inode * inode);

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-29 00:41:48 -03:00
Arnaldo Carvalho de Melo 6b32c8362b Introduce classes__for_each, that receives an iterator function and a cookie,
so that one can traverse all the classes loaded by classes__load.

Also export classes__find_by_id().

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 23:55:56 -03:00
Arnaldo Carvalho de Melo 67b12e237c Support DW_AT_inline, that only makes sense on functions, where now we
see that the function was indeed inlined:

[acme@newtoy net-2.6]$ pfunct kernel/sched.o task_running
/* /pub/scm/linux/kernel/git/acme/net-2.6/kernel/sched.c 304 */
inline int task_running(struct rq * rq, struct task_struct * p);

[acme@newtoy net-2.6]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 21:40:35 -03:00
Arnaldo Carvalho de Melo d23a3a6e64 Print the decl file and line at class__print, not at class__print_struct, that
way we get it for free for the upcoming types, as class__print_function got
now.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 19:13:27 -03:00
Arnaldo Carvalho de Melo e038f068b1 New dwarf: pfunct, see it in action:
[acme@newtoy net-2.6]$ pfunct ~acme/work/atag/atag | grep LRMI
void * LRMI_alloc_real(int size);
void LRMI_free_real(void * m);
int LRMI_init(void);
void set_regs(struct LRMI_regs * r);
void get_regs(struct LRMI_regs * r);
int LRMI_call(struct LRMI_regs * r);
int LRMI_int(int i, struct LRMI_regs * r);
[acme@newtoy net-2.6]$

[acme@newtoy net-2.6]$ pfunct kernel/sched.o task_running
int task_running(struct rq * rq, struct task_struct * p);
[acme@newtoy net-2.6]$

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 19:07:45 -03:00
Arnaldo Carvalho de Melo d0df41c935 Support DW_TAG_formal_parameter, that gets into the struct class members list,
i.e. the list of parameters of a function (DW_TAG_subprogram).

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 19:04:40 -03:00
Arnaldo Carvalho de Melo f9ed05bd42 Initial implementation of class__print_function, now to get the list
of DW_AT_formal_parameters and then print it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:49:27 -03:00
Arnaldo Carvalho de Melo e61005ee82 Only structs have holes, not, for instance, DW_AT_subprogram entries,
aka functions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:37:38 -03:00
Arnaldo Carvalho de Melo 35e87417f9 Move the classes methods out of pahole.c and into classes.c,
that will be used by other new dwarves 8)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:22:42 -03:00
Arnaldo Carvalho de Melo f4cc126c11 Separate finding the holes from printing the class, so that we are able to
print just the structs with holes, that indeed is what we do now if no class
name is passed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 18:10:47 -03:00
Arnaldo Carvalho de Melo 01f021b2a7 Prefix the functions that create the classes list with "classes__",
in preparation to moving them to a library.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 14:16:29 -03:00
Arnaldo Carvalho de Melo 06672633cb Move the top level dwarf traversal of the CUs to a new function,
classes__load().

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 14:08:46 -03:00
Arnaldo Carvalho de Melo 13ec307479 Move the global 'bf' buffer to the only place still using it.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:51:34 -03:00
Arnaldo Carvalho de Melo 3593eb45a6 Move the class and class_member structs to a new header file,
classes.h.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:45:59 -03:00
Arnaldo Carvalho de Melo 5c3d14ac09 Renane class__print to class__print_struct and make class__print
call it if the class ->tag is DW_TAG_structure_type, and do a basic
print for the other tags.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:37:20 -03:00
Arnaldo Carvalho de Melo 7f5ce05961 Initialize struct class->name in the constructor if no name was
informed.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 13:16:59 -03:00
Arnaldo Carvalho de Melo 23cc5e41cb Get the file and line where the classes were declared and use it
in the printout.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-28 09:52:08 -03:00
Arnaldo Carvalho de Melo 98295e3fd2 Improve attr_numeric to handle more form types, convering DW_AT_type,
etc, so ditch attr_type().

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-27 17:51:18 -03:00
Arnaldo Carvalho de Melo 7dbb993d8b Rename attr_unsigned to attr_numeric, simplifying it to not require a
Dwarf_Attribute to work on, as we just return a integer and it handles more
than just unsigned ints.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-27 15:04:18 -03:00
Arnaldo Carvalho de Melo 0c707643d7 Print the number of holes
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-26 03:31:58 -03:00
Arnaldo Carvalho de Melo d36e7147f0 Stop using libdwarf from SGI, use the one in elfutils instead, the code got
much cleaner and now uses what seems to be a better maintained DWARF library
that hopefully works well on 64bit platforms, well see.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-26 03:06:32 -03:00
Arnaldo Carvalho de Melo e5e7c6fc8b Initialize nr_entries in class__new
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 15:21:34 -03:00
Arnaldo Carvalho de Melo 17025a38f2 Handle multi CU (Compile Unit) files, like vmlinux :-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 14:33:59 -03:00
Arnaldo Carvalho de Melo aac0259cc0 Use return for consistency in main.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 14:03:44 -03:00
Arnaldo Carvalho de Melo 3acc236241 Support void pointers, i.e. DW_TAG_pointer_type with no DW_AT_type.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:47:54 -03:00
Arnaldo Carvalho de Melo 4881c2f0d2 Add a .gitignore file
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:32:07 -03:00
Arnaldo Carvalho de Melo 134120b796 Ditch the program_name variable, use "pahole" directly
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:29:38 -03:00
Arnaldo Carvalho de Melo e01a32fddc Remove leftover check_error variable.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:20:18 -03:00
Arnaldo Carvalho de Melo 2338691b42 Show the sum of the members sizeof only if there are holes, and if so print the
sum of all holes too.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 13:18:43 -03:00
Arnaldo Carvalho de Melo 031b291d9a Add a copyright notice.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:49:47 -03:00
Arnaldo Carvalho de Melo 51a8d81527 bitfields, ugh, if you have, say:
struct foo {
        char    c:1;
        int     b:1;
        short   a:1;
};

the first byte_size for the first member (c) will be 1, as the "type"
is char, but the compiler combines all of them into a single 4 byte
bitfield, and the '4' only appear when the bit field has type int, in
the above case on the second member.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:46:26 -03:00
Arnaldo Carvalho de Melo 96ef1165ae Add support for enum printing.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:42:53 -03:00
Arnaldo Carvalho de Melo a4e260fc1a Grr, another fix for bitfields, this time for a sequence of
bitfields, i.e. the offset changes from one bitfield to another.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:14:27 -03:00
Arnaldo Carvalho de Melo e45d94f9de Fix bitfield accounting, as I was assuming that the first field would be
at the 0 offset, but its not, so just look if the last member was in a
bitfield.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 12:01:18 -03:00
Arnaldo Carvalho de Melo d4c95e9b49 Remove more dead code, we don't use the srcfile table.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:55:36 -03:00
Arnaldo Carvalho de Melo 9b15e948e4 Remove dead code
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:42:57 -03:00
Arnaldo Carvalho de Melo 23971435ad Fix the struct declaration case.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 02:37:21 -03:00
Arnaldo Carvalho de Melo e748ac69c3 Print the diff when the sum of the member sizeofs + the sum of the
holes is not equal to the size of the struct:

struct task_struct {
<SNIP>
}; /* sizeof struct: 1312, sum sizeof members: 1279 */

/* BRAIN FART ALERT! 1312 != 1279 + 25(holes), diff = 8 */

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 01:18:15 -03:00
Arnaldo Carvalho de Melo 99dd25f7f6 More output layout changes, this time for the elusive task_struct
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 01:04:26 -03:00
Arnaldo Carvalho de Melo f517a01b6e Support DW_TAG_volatile_type and DW_TAG_const_type.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:54:57 -03:00
Arnaldo Carvalho de Melo 668aec0284 Cosmetic, output layout tidyup to have struct sock output perfect,
its our supermodel 8)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:40:06 -03:00
Arnaldo Carvalho de Melo 034dafb614 Handle the case where DW_TAG_subroutine_type has no DW_AT_type, meaning
it doesn't have a return value, i.e. it "returns" void.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:27:29 -03:00
Arnaldo Carvalho de Melo 3e4d70ad47 Support bitfields, still not checking if there are bits available at
the end of it.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-25 00:18:05 -03:00
Arnaldo Carvalho de Melo d07bbf65fc Just some output layout changes.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 23:28:37 -03:00
Arnaldo Carvalho de Melo cc701e54a3 Check if the sum of the struct member sizeofs plus the sum of all the holes
found is equal to the sizeof of the structure and emit a "BRAIN FART ALERT!" if
this assertion fails, good news is that no such brain farts ocurred so far :-)

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 23:09:46 -03:00
Arnaldo Carvalho de Melo 00a86e1267 For now don't print the "nameless structs", aka "typedef struct { } foo".
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 22:45:43 -03:00
Arnaldo Carvalho de Melo 1bbfd30eea Basic function pointer support, parameter list will come next, using a struct
class instance for the DW_TAG_subroutine_type tag and class->members for the
list of DW_TAG_formal_parameter, if any.

Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 22:43:33 -03:00
Arnaldo Carvalho de Melo 7246a223a2 Add support for arrays
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-10-24 22:02:51 -03:00