2006-10-28 18:45:59 +02:00
|
|
|
#ifndef _PAHOLE_CLASSES_H_
|
|
|
|
#define _PAHOLE_CLASSES_H_ 1
|
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Mandriva Conectiva S.A.
|
|
|
|
Copyright (C) 2006 Arnaldo Carvalho de Melo <acme@mandriva.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of version 2 of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "list.h"
|
|
|
|
|
2006-10-31 20:12:42 +01:00
|
|
|
struct cu {
|
|
|
|
struct list_head node;
|
|
|
|
struct list_head classes;
|
2006-11-03 18:38:43 +01:00
|
|
|
const char *name;
|
2006-10-31 20:12:42 +01:00
|
|
|
unsigned int id;
|
2006-11-03 18:38:43 +01:00
|
|
|
unsigned long nr_inline_expansions;
|
|
|
|
unsigned long size_inline_expansions;
|
2006-10-28 18:45:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct class {
|
|
|
|
struct list_head node;
|
|
|
|
struct list_head members;
|
2006-11-03 16:41:19 +01:00
|
|
|
struct list_head inline_expansions;
|
2006-11-02 17:48:35 +01:00
|
|
|
const char *name;
|
2006-11-03 18:32:32 +01:00
|
|
|
uint64_t size;
|
2006-10-31 20:12:42 +01:00
|
|
|
unsigned int id;
|
|
|
|
unsigned int type;
|
2006-10-28 18:45:59 +02:00
|
|
|
unsigned int tag; /* struct, union, base type, etc */
|
|
|
|
uintmax_t nr_entries; /* For arrays */
|
2006-11-03 18:32:32 +01:00
|
|
|
uint64_t low_pc;
|
|
|
|
uint64_t high_pc;
|
2006-10-28 18:45:59 +02:00
|
|
|
const char *decl_file;
|
|
|
|
unsigned int decl_line;
|
2006-11-01 14:34:42 +01:00
|
|
|
unsigned short nr_members;
|
2006-10-28 23:10:47 +02:00
|
|
|
unsigned short nr_holes;
|
2006-11-01 14:18:01 +01:00
|
|
|
unsigned short nr_labels;
|
|
|
|
unsigned short nr_variables;
|
2006-10-28 23:10:47 +02:00
|
|
|
unsigned short padding;
|
2006-10-29 02:40:35 +02:00
|
|
|
unsigned short inlined;
|
2006-11-03 16:41:19 +01:00
|
|
|
unsigned short nr_inline_expansions;
|
|
|
|
unsigned int size_inline_expansions;
|
[PFUNCT]: Improve --cu_inline_expansions_stats
Now it shows the number that each of the inline functions were expanded in an
object file:
Top 10 inline functions expanded more than once in kernel/sched.o, by total
size of inline expansions:
[acme@newtoy guinea_pig-2.6]$ pfunct --cu_inline_expansions_stats kernel/sched.o | sort -k3 -nr | grep -v ': 1 ' | head -11
kernel/sched.c: 318 10217
get_current: 38 325
finish_task_switch: 2 238
normal_prio: 2 167
__cpus_and: 14 164
find_process_by_pid: 6 152
current_thread_info: 21 149
sched_find_first_bit: 2 148
update_cpu_clock: 2 140
task_rq_unlock: 14 137
variable_test_bit: 14 121
[acme@newtoy guinea_pig-2.6]$
Now we have these options:
[acme@newtoy guinea_pig-2.6]$ pfunct --help
usage: pfunct [options] <file_name> {<function_name>}
where:
-c, --class=<class> functions that have <class> pointer parameters
-g, --goto_labels show number of goto labels
-i, --show_inline_expansions show inline expansions
-C, --cu_inline_expansions_stats show CU inline expansions stats
-s, --sizes show size of functions
-N, --function_name_len show size of functions
-p, --nr_parameters show number or parameters
-S, --variables show number of variables
-V, --verbose be verbose
[acme@newtoy guinea_pig-2.6]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
2006-11-03 19:22:12 +01:00
|
|
|
unsigned int cu_total_nr_inline_expansions;
|
|
|
|
unsigned long cu_total_size_inline_expansions;
|
2006-10-28 18:45:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct class_member {
|
|
|
|
struct list_head node;
|
2006-11-02 17:48:35 +01:00
|
|
|
char *name;
|
2006-10-31 20:12:42 +01:00
|
|
|
unsigned int type;
|
2006-10-28 18:45:59 +02:00
|
|
|
unsigned int offset;
|
|
|
|
unsigned int bit_size;
|
|
|
|
unsigned int bit_offset;
|
2006-10-28 23:10:47 +02:00
|
|
|
unsigned short hole; /* If there is a hole before the next
|
|
|
|
one (or the end of the struct) */
|
2006-10-28 18:45:59 +02:00
|
|
|
};
|
|
|
|
|
2006-11-03 16:41:19 +01:00
|
|
|
struct inline_expansion {
|
|
|
|
struct list_head node;
|
|
|
|
unsigned int type;
|
2006-11-03 18:32:32 +01:00
|
|
|
uint64_t size;
|
2006-11-03 16:41:19 +01:00
|
|
|
};
|
|
|
|
|
2006-10-31 20:12:42 +01:00
|
|
|
extern void class__find_holes(struct class *self, const struct cu *cu);
|
|
|
|
extern void class__print(struct class *self, const struct cu *cu);
|
2006-10-28 23:22:42 +02:00
|
|
|
|
|
|
|
extern int classes__load(const char *filename);
|
2006-10-31 21:23:16 +01:00
|
|
|
extern struct cu *cus__find_cu_by_id(const unsigned int type);
|
|
|
|
extern struct class *cu__find_class_by_id(const struct cu *cu,
|
|
|
|
const unsigned int type);
|
|
|
|
extern struct class *cu__find_class_by_name(struct cu *cu, const char *name);
|
2006-10-28 23:22:42 +02:00
|
|
|
extern void classes__print(const unsigned int tag);
|
2006-11-03 16:41:19 +01:00
|
|
|
extern void class__print_inline_expansions(struct class *self,
|
|
|
|
const struct cu *cu);
|
2006-10-31 21:23:16 +01:00
|
|
|
extern struct class *cus__find_class_by_name(struct cu **cu, const char *name);
|
2006-11-03 18:38:43 +01:00
|
|
|
extern void cu__account_inline_expansions(struct cu *self);
|
2006-10-31 21:23:16 +01:00
|
|
|
extern int cu__for_each_class(struct cu *cu,
|
|
|
|
int (*iterator)(struct cu *cu,
|
|
|
|
struct class *class,
|
|
|
|
void *cookie),
|
|
|
|
void *cookie);
|
|
|
|
extern void cus__for_each_cu(int (*iterator)(struct cu *cu,
|
|
|
|
void *cookie),
|
2006-10-29 03:55:56 +01:00
|
|
|
void *cookie);
|
2006-10-28 23:22:42 +02:00
|
|
|
|
2006-10-28 18:45:59 +02:00
|
|
|
#endif /* _PAHOLE_CLASSES_H_ */
|