[PFUNCT]: Implement --nr_parameters
[acme@newtoy net-2.6]$ pfunct --nr_parameters vmlinux | sort -k 2 -nr | head -5 __ide_add_setting: 13 ide_add_setting: 12 fib_dump_info: 12 __blockdev_direct_IO: 10 vma_merge: 9 [acme@newtoy net-2.6]$ Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
4a6117a912
commit
09bb5df8aa
|
@ -266,6 +266,7 @@ static struct class *class__new(const unsigned int tag,
|
|||
self->decl_line = decl_line;
|
||||
self->nr_holes = 0;
|
||||
self->nr_labels = 0;
|
||||
self->nr_members = 0;
|
||||
self->nr_variables = 0;
|
||||
self->padding = 0;
|
||||
self->inlined = inlined;
|
||||
|
@ -278,6 +279,7 @@ static struct class *class__new(const unsigned int tag,
|
|||
|
||||
static void class__add_member(struct class *self, struct class_member *member)
|
||||
{
|
||||
++self->nr_members;
|
||||
list_add_tail(&member->node, &self->members);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ struct class {
|
|||
uintmax_t high_pc;
|
||||
const char *decl_file;
|
||||
unsigned int decl_line;
|
||||
unsigned short nr_members;
|
||||
unsigned short nr_holes;
|
||||
unsigned short nr_labels;
|
||||
unsigned short nr_variables;
|
||||
|
|
36
pfunct.c
36
pfunct.c
|
@ -17,12 +17,13 @@
|
|||
static int verbose;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{ "class", required_argument, NULL, 'c' },
|
||||
{ "goto_labels", no_argument, NULL, 'g' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "sizes", no_argument, NULL, 's' },
|
||||
{ "variables", no_argument, NULL, 'S' },
|
||||
{ "verbose", no_argument, NULL, 'V' },
|
||||
{ "class", required_argument, NULL, 'c' },
|
||||
{ "goto_labels", no_argument, NULL, 'g' },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "nr_parameters", no_argument, NULL, 'p' },
|
||||
{ "sizes", no_argument, NULL, 's' },
|
||||
{ "variables", no_argument, NULL, 'S' },
|
||||
{ "verbose", no_argument, NULL, 'V' },
|
||||
{ NULL, 0, NULL, 0, }
|
||||
};
|
||||
|
||||
|
@ -142,6 +143,21 @@ static int cu_function_iterator(struct cu *cu, void *cookie)
|
|||
return cu__for_each_class(cu, function_iterator, cookie);
|
||||
}
|
||||
|
||||
static int nr_parameters_iterator(struct cu *cu, struct class *class, void *cookie)
|
||||
{
|
||||
if (class->tag != DW_TAG_subprogram || class->inlined)
|
||||
return 0;
|
||||
|
||||
if (class->nr_members > 0)
|
||||
printf("%s: %u\n", class->name, class->nr_members);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu_nr_parameters_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, nr_parameters_iterator, cookie);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int option, option_index;
|
||||
|
@ -151,13 +167,15 @@ int main(int argc, char *argv[])
|
|||
int show_sizes = 0;
|
||||
int show_variables = 0;
|
||||
int show_goto_labels = 0;
|
||||
int show_nr_parameters = 0;
|
||||
|
||||
while ((option = getopt_long(argc, argv, "c:gsSV",
|
||||
while ((option = getopt_long(argc, argv, "c:gpsSV",
|
||||
long_options, &option_index)) >= 0)
|
||||
switch (option) {
|
||||
case 'c': class_name = optarg; break;
|
||||
case 's': show_sizes = 1; break;
|
||||
case 'S': show_variables = 1; break;
|
||||
case 'p': show_nr_parameters = 1; break;
|
||||
case 'g': show_goto_labels = 1; break;
|
||||
case 'V': verbose = 1; break;
|
||||
case 'h': usage(); return EXIT_SUCCESS;
|
||||
|
@ -179,7 +197,9 @@ int main(int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (show_variables)
|
||||
if (show_nr_parameters)
|
||||
cus__for_each_cu(cu_nr_parameters_iterator, NULL);
|
||||
else if (show_variables)
|
||||
cus__for_each_cu(cu_variables_iterator, NULL);
|
||||
else if (show_goto_labels)
|
||||
cus__for_each_cu(cu_goto_labels_iterator, NULL);
|
||||
|
|
Loading…
Reference in New Issue