[CLASSES]: Add backpointer to class in inline_expansion
And several assorted tidy-ups. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
c49c7c8bee
commit
d3b9b9bfcf
13
classes.c
13
classes.c
|
@ -126,7 +126,7 @@ static const char *tag_name(const unsigned int tag)
|
|||
return "";
|
||||
}
|
||||
|
||||
struct class *cu__find_class_by_name(struct cu *self, const char *name)
|
||||
struct class *cu__find_class_by_name(const struct cu *self, const char *name)
|
||||
{
|
||||
struct class *pos;
|
||||
|
||||
|
@ -140,7 +140,7 @@ struct class *cu__find_class_by_name(struct cu *self, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct class *cus__find_class_by_name(struct cus *self, const char *name)
|
||||
struct class *cus__find_class_by_name(const struct cus *self, const char *name)
|
||||
{
|
||||
struct cu *pos;
|
||||
|
||||
|
@ -154,7 +154,7 @@ struct class *cus__find_class_by_name(struct cus *self, const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct cu *cus__find_cu_by_name(struct cus *self, const char *name)
|
||||
struct cu *cus__find_cu_by_name(const struct cus *self, const char *name)
|
||||
{
|
||||
struct cu *pos;
|
||||
|
||||
|
@ -454,6 +454,7 @@ static void class__add_inline_expansion(struct class *self,
|
|||
struct inline_expansion *exp)
|
||||
{
|
||||
++self->nr_inline_expansions;
|
||||
exp->class = self;
|
||||
self->size_inline_expansions += exp->size;
|
||||
list_add_tail(&exp->node, &self->inline_expansions);
|
||||
}
|
||||
|
@ -521,7 +522,7 @@ struct class_member *class__find_member_by_name(const struct class *self,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void class__account_inline_expansions(struct class *self, struct cu *cu)
|
||||
static void class__account_inline_expansions(struct class *self)
|
||||
{
|
||||
struct class *class_type;
|
||||
struct inline_expansion *pos;
|
||||
|
@ -530,7 +531,7 @@ void class__account_inline_expansions(struct class *self, struct cu *cu)
|
|||
return;
|
||||
|
||||
list_for_each_entry(pos, &self->inline_expansions, node) {
|
||||
class_type = cu__find_class_by_id(cu, pos->type);
|
||||
class_type = cu__find_class_by_id(self->cu, pos->type);
|
||||
if (class_type != NULL) {
|
||||
class_type->cu_total_nr_inline_expansions++;
|
||||
class_type->cu_total_size_inline_expansions += pos->size;
|
||||
|
@ -544,7 +545,7 @@ void cu__account_inline_expansions(struct cu *self)
|
|||
struct class *pos;
|
||||
|
||||
list_for_each_entry(pos, &self->classes, node) {
|
||||
class__account_inline_expansions(pos, self);
|
||||
class__account_inline_expansions(pos);
|
||||
self->nr_inline_expansions += pos->nr_inline_expansions;
|
||||
self->size_inline_expansions += pos->size_inline_expansions;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ struct variable {
|
|||
|
||||
struct inline_expansion {
|
||||
struct list_head node;
|
||||
struct class *class;
|
||||
uint64_t type;
|
||||
uint64_t size;
|
||||
};
|
||||
|
@ -101,17 +102,19 @@ extern void class__print(struct class *self);
|
|||
|
||||
extern struct cus *cus__new(const char *filename);
|
||||
extern int cus__load(struct cus *self);
|
||||
extern struct cu *cus__find_cu_by_name(struct cus *self, const char *name);
|
||||
extern struct cu *cus__find_cu_by_name(const struct cus *self,
|
||||
const char *name);
|
||||
extern struct class *cu__find_class_by_id(const struct cu *cu,
|
||||
const uint64_t type);
|
||||
extern struct class *cu__find_class_by_name(struct cu *cu, const char *name);
|
||||
extern struct class *cu__find_class_by_name(const struct cu *cu,
|
||||
const char *name);
|
||||
extern int class__is_struct(const struct class *self,
|
||||
struct class **typedef_alias);
|
||||
extern void cus__print_classes(struct cus *cus,
|
||||
const unsigned int tag);
|
||||
extern void class__print_inline_expansions(struct class *self);
|
||||
extern void class__print_variables(struct class *self);
|
||||
extern struct class *cus__find_class_by_name(struct cus *self,
|
||||
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,
|
||||
|
|
25
codiff.c
25
codiff.c
|
@ -57,7 +57,7 @@ static void usage(void)
|
|||
" without options all diffs are shown\n");
|
||||
}
|
||||
|
||||
static void diff_function(struct cu *new_cu, struct class *function)
|
||||
static void diff_function(const struct cu *new_cu, struct class *function)
|
||||
{
|
||||
struct class *new_function;
|
||||
|
||||
|
@ -86,9 +86,7 @@ static void diff_function(struct cu *new_cu, struct class *function)
|
|||
}
|
||||
|
||||
static int check_print_change(const struct class_member *old,
|
||||
const struct class_member *new,
|
||||
const struct cu *old_cu,
|
||||
const struct cu *new_cu, int print)
|
||||
const struct class_member *new, int print)
|
||||
{
|
||||
char old_class_name[128];
|
||||
char new_class_name[128];
|
||||
|
@ -156,14 +154,13 @@ static int check_print_members_changes(const struct class *structure,
|
|||
struct class_member *twin =
|
||||
class__find_member_by_name(new_structure, member->name);
|
||||
if (twin != NULL)
|
||||
if (check_print_change(member, twin, structure->cu,
|
||||
new_structure->cu, print))
|
||||
if (check_print_change(member, twin, print))
|
||||
changes = 1;
|
||||
}
|
||||
return changes;
|
||||
}
|
||||
|
||||
static void diff_struct(struct cu *new_cu, struct class *structure)
|
||||
static void diff_struct(const struct cu *new_cu, struct class *structure)
|
||||
{
|
||||
struct class *new_structure;
|
||||
size_t len;
|
||||
|
@ -216,7 +213,7 @@ static int cu_diff_iterator(struct cu *cu, void *new_cus)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void show_diffs_function(struct class *class)
|
||||
static void show_diffs_function(const struct class *class)
|
||||
{
|
||||
printf(" %-*.*s | %+4d\n",
|
||||
class->cu->max_len_changed_item,
|
||||
|
@ -224,9 +221,7 @@ static void show_diffs_function(struct class *class)
|
|||
class->name, class->diff);
|
||||
}
|
||||
|
||||
static void show_changed_member(char change,
|
||||
const struct class_member *member,
|
||||
const struct cu *cu)
|
||||
static void show_changed_member(char change, const struct class_member *member)
|
||||
{
|
||||
char class_name[128];
|
||||
char member_name[128];
|
||||
|
@ -248,7 +243,7 @@ static void show_nr_members_changes(const struct class *structure,
|
|||
struct class_member *twin =
|
||||
class__find_member_by_name(new_structure, member->name);
|
||||
if (twin == NULL)
|
||||
show_changed_member('-', member, structure->cu);
|
||||
show_changed_member('-', member);
|
||||
}
|
||||
|
||||
/* Find the new ones */
|
||||
|
@ -256,11 +251,11 @@ static void show_nr_members_changes(const struct class *structure,
|
|||
struct class_member *twin =
|
||||
class__find_member_by_name(structure, member->name);
|
||||
if (twin == NULL)
|
||||
show_changed_member('+', member, new_structure->cu);
|
||||
show_changed_member('+', member);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_terse_type_changes(struct class *structure)
|
||||
static void print_terse_type_changes(const struct class *structure)
|
||||
{
|
||||
const char *sep = "";
|
||||
|
||||
|
@ -292,7 +287,7 @@ static void print_terse_type_changes(struct class *structure)
|
|||
putchar('\n');
|
||||
}
|
||||
|
||||
static void show_diffs_structure(struct class *structure)
|
||||
static void show_diffs_structure(const struct class *structure)
|
||||
{
|
||||
const struct class *new_structure = structure->class_to_diff;
|
||||
int diff = new_structure->size - structure->size;
|
||||
|
|
4
pfunct.c
4
pfunct.c
|
@ -124,8 +124,8 @@ static void usage(void)
|
|||
" -V, --verbose be verbose\n");
|
||||
}
|
||||
|
||||
static int class__has_parameter_of_type(struct class *self,
|
||||
struct class *target)
|
||||
static int class__has_parameter_of_type(const struct class *self,
|
||||
const struct class *target)
|
||||
{
|
||||
struct class_member *pos;
|
||||
|
||||
|
|
24
prefcnt.c
24
prefcnt.c
|
@ -31,30 +31,31 @@ static void usage(void)
|
|||
|
||||
static void refcnt_class(struct class *class);
|
||||
|
||||
static void refcnt_member(struct class *class, struct class_member *member)
|
||||
static void refcnt_member(struct class_member *member)
|
||||
{
|
||||
if (member->visited)
|
||||
return;
|
||||
member->visited = 1;
|
||||
if (member->type != 0) { /* if not void */
|
||||
struct class *type = cu__find_class_by_id(class->cu, member->type);
|
||||
|
||||
struct class *type = cu__find_class_by_id(member->class->cu,
|
||||
member->type);
|
||||
if (type != NULL)
|
||||
refcnt_class(type);
|
||||
}
|
||||
}
|
||||
|
||||
static void refcnt_parameter(struct cu *cu, struct class_member *member)
|
||||
static void refcnt_parameter(const struct class_member *member)
|
||||
{
|
||||
if (member->type != 0) { /* if not void */
|
||||
struct class *type = cu__find_class_by_id(cu, member->type);
|
||||
struct class *type = cu__find_class_by_id(member->class->cu,
|
||||
member->type);
|
||||
|
||||
if (type != NULL)
|
||||
refcnt_class(type);
|
||||
}
|
||||
}
|
||||
|
||||
static void refcnt_variable(struct variable *variable)
|
||||
static void refcnt_variable(const struct variable *variable)
|
||||
{
|
||||
if (variable->type != 0) { /* if not void */
|
||||
struct class *type = cu__find_class_by_id(variable->cu,
|
||||
|
@ -64,10 +65,11 @@ static void refcnt_variable(struct variable *variable)
|
|||
}
|
||||
}
|
||||
|
||||
static void refcnt_inline_expansion(struct cu *cu, struct inline_expansion *exp)
|
||||
static void refcnt_inline_expansion(const struct inline_expansion *exp)
|
||||
{
|
||||
if (exp->type != 0) { /* if not void */
|
||||
struct class *type = cu__find_class_by_id(cu, exp->type);
|
||||
struct class *type = cu__find_class_by_id(exp->class->cu,
|
||||
exp->type);
|
||||
assert(type != NULL);
|
||||
refcnt_class(type);
|
||||
}
|
||||
|
@ -91,17 +93,17 @@ static void refcnt_class(struct class *class)
|
|||
if (class->tag == DW_TAG_structure_type ||
|
||||
class->tag == DW_TAG_union_type) {
|
||||
list_for_each_entry(member, &class->members, node)
|
||||
refcnt_member(class, member);
|
||||
refcnt_member(member);
|
||||
} else if (class->tag == DW_TAG_subprogram) {
|
||||
list_for_each_entry(member, &class->members, node)
|
||||
refcnt_parameter(class->cu, member);
|
||||
refcnt_parameter(member);
|
||||
}
|
||||
|
||||
list_for_each_entry(variable, &class->variables, class_node)
|
||||
refcnt_variable(variable);
|
||||
|
||||
list_for_each_entry(exp, &class->inline_expansions, node)
|
||||
refcnt_inline_expansion(class->cu, exp);
|
||||
refcnt_inline_expansion(exp);
|
||||
}
|
||||
|
||||
static void refcnt_function(struct class *function)
|
||||
|
|
Loading…
Reference in New Issue