[CLASSES]: Make cu__for_each_class receive a filter
Same semantic as in the cus__for_each_cu filter. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
e5a400d01f
commit
5c777371cd
19
classes.c
19
classes.c
|
@ -973,16 +973,23 @@ void class__print(struct class *self)
|
|||
putchar('\n');
|
||||
}
|
||||
|
||||
int cu__for_each_class(struct cu *cu,
|
||||
int (*iterator)(struct class *class, void *cookie),
|
||||
void *cookie)
|
||||
int cu__for_each_class(struct cu *self,
|
||||
int (*iterator)(struct class *class, void *cookie),
|
||||
void *cookie,
|
||||
struct class *(*filter)(struct class *class))
|
||||
{
|
||||
|
||||
struct class *pos;
|
||||
|
||||
list_for_each_entry(pos, &cu->classes, tag.node)
|
||||
if (iterator(pos, cookie))
|
||||
list_for_each_entry(pos, &self->classes, tag.node) {
|
||||
struct class *class = pos;
|
||||
if (filter != NULL) {
|
||||
class = filter(pos);
|
||||
if (class == NULL)
|
||||
continue;
|
||||
}
|
||||
if (iterator(class, cookie))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -151,10 +151,11 @@ extern void cus__print_functions(struct cus *cus);
|
|||
extern struct class *cus__find_class_by_name(const struct cus *self,
|
||||
const char *name);
|
||||
extern void cu__account_inline_expansions(struct cu *self);
|
||||
extern int cu__for_each_class(struct cu *cu,
|
||||
extern int cu__for_each_class(struct cu *self,
|
||||
int (*iterator)(struct class *class,
|
||||
void *cookie),
|
||||
void *cookie);
|
||||
void *cookie,
|
||||
struct class *(*filter)(struct class *class));
|
||||
extern int cu__for_each_function(struct cu *cu,
|
||||
int (*iterator)(struct function *func,
|
||||
void *cookie),
|
||||
|
|
8
codiff.c
8
codiff.c
|
@ -208,7 +208,7 @@ static int cu_diff_iterator(struct cu *cu, void *new_cus)
|
|||
struct cu *new_cu = cus__find_cu_by_name(new_cus, cu->name);
|
||||
|
||||
if (new_cu != NULL) {
|
||||
cu__for_each_class(cu, diff_class_iterator, new_cu);
|
||||
cu__for_each_class(cu, diff_class_iterator, new_cu, NULL);
|
||||
cu__for_each_function(cu, diff_function_iterator, new_cu);
|
||||
}
|
||||
|
||||
|
@ -353,12 +353,14 @@ static int cu_show_diffs_iterator(struct cu *cu, void *cookie)
|
|||
printf("%s:\n", cu->name);
|
||||
|
||||
if (show_terse_type_changes) {
|
||||
cu__for_each_class(cu, show_structure_diffs_iterator, NULL);
|
||||
cu__for_each_class(cu, show_structure_diffs_iterator,
|
||||
NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cu->nr_structures_changed != 0 && show_struct_diffs) {
|
||||
cu__for_each_class(cu, show_structure_diffs_iterator, NULL);
|
||||
cu__for_each_class(cu, show_structure_diffs_iterator,
|
||||
NULL, NULL);
|
||||
printf(" %u struct%s changed\n", cu->nr_structures_changed,
|
||||
cu->nr_structures_changed > 1 ? "s" : "");
|
||||
}
|
||||
|
|
55
pahole.c
55
pahole.c
|
@ -107,10 +107,12 @@ struct class *class__filter(struct class *class)
|
|||
if (class == NULL) /* Not a structure */
|
||||
return NULL;
|
||||
|
||||
if (class->name == NULL)
|
||||
return NULL;
|
||||
|
||||
if (class__exclude_prefix != NULL &&
|
||||
(class->name == NULL ||
|
||||
strncmp(class__exclude_prefix, class->name,
|
||||
class__exclude_prefix_len) == 0))
|
||||
strncmp(class__exclude_prefix, class->name,
|
||||
class__exclude_prefix_len) == 0)
|
||||
return NULL;
|
||||
|
||||
return class;
|
||||
|
@ -118,15 +120,14 @@ struct class *class__filter(struct class *class)
|
|||
|
||||
static int total_structure_iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL && class->name != NULL)
|
||||
structures__add(class);
|
||||
structures__add(class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu_total_structure_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, total_structure_iterator, cookie);
|
||||
return cu__for_each_class(cu, total_structure_iterator, cookie,
|
||||
class__filter);
|
||||
}
|
||||
|
||||
static struct option long_options[] = {
|
||||
|
@ -161,21 +162,20 @@ static void usage(void)
|
|||
|
||||
static int nr_members_iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL && class->name == NULL && class->nr_members > 0)
|
||||
if (class->nr_members > 0)
|
||||
printf("%s: %u\n", class->name, class->nr_members);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu_nr_members_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, nr_members_iterator, cookie);
|
||||
return cu__for_each_class(cu, nr_members_iterator, cookie,
|
||||
class__filter);
|
||||
}
|
||||
|
||||
static int sizes_iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL && class->name != NULL && class->size > 0) {
|
||||
if (class->size > 0) {
|
||||
class__find_holes(class);
|
||||
printf("%s: %llu %u\n",
|
||||
class->name, class->size, class->nr_holes);
|
||||
|
@ -185,52 +185,45 @@ static int sizes_iterator(struct class *class, void *cookie)
|
|||
|
||||
static int cu_sizes_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, sizes_iterator, cookie);
|
||||
return cu__for_each_class(cu, sizes_iterator, cookie, class__filter);
|
||||
}
|
||||
|
||||
static int holes_iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL && class->name != NULL) {
|
||||
class__find_holes(class);
|
||||
if (class->nr_holes > 0)
|
||||
class__print(class);
|
||||
}
|
||||
class__find_holes(class);
|
||||
if (class->nr_holes > 0)
|
||||
class__print(class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu_holes_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, holes_iterator, NULL);
|
||||
return cu__for_each_class(cu, holes_iterator, NULL, class__filter);
|
||||
}
|
||||
|
||||
static int class_name_len_iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL && class->name != NULL)
|
||||
printf("%s: %u\n", class->name, strlen(class->name));
|
||||
|
||||
printf("%s: %u\n", class->name, strlen(class->name));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu_class_name_len_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, class_name_len_iterator, NULL);
|
||||
return cu__for_each_class(cu, class_name_len_iterator, NULL,
|
||||
class__filter);
|
||||
}
|
||||
|
||||
static int class__iterator(struct class *class, void *cookie)
|
||||
{
|
||||
class = class__filter(class);
|
||||
if (class != NULL) {
|
||||
class__find_holes(class);
|
||||
class__print(class);
|
||||
}
|
||||
class__find_holes(class);
|
||||
class__print(class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cu__iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, class__iterator, NULL);
|
||||
return cu__for_each_class(cu, class__iterator, NULL,
|
||||
class__filter);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
@ -126,7 +126,7 @@ static int refcnt_class_iterator(struct class *class, void *cookie)
|
|||
|
||||
static int cu_refcnt_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
cu__for_each_class(cu, refcnt_class_iterator, cookie);
|
||||
cu__for_each_class(cu, refcnt_class_iterator, cookie, NULL);
|
||||
cu__for_each_function(cu, refcnt_function_iterator, cookie);
|
||||
return 0;
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ static int lost_iterator(struct class *class, void *cookie)
|
|||
|
||||
static int cu_lost_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
return cu__for_each_class(cu, lost_iterator, cookie);
|
||||
return cu__for_each_class(cu, lost_iterator, cookie, NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
Loading…
Reference in New Issue