[CLASSES]: Rename the find_class_by_name to find_struct_by_name
As they already look just for DW_TAG_structure_type. Also make it return a struct tag to avoid having to cast it back and forth too much. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
This commit is contained in:
parent
5deeded578
commit
a200508985
34
classes.c
34
classes.c
@ -491,7 +491,7 @@ struct tag *cu__find_tag_by_id(const struct cu *self, const Dwarf_Off id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct class *cu__find_class_by_name(const struct cu *self, const char *name)
|
||||
struct tag *cu__find_struct_by_name(const struct cu *self, const char *name)
|
||||
{
|
||||
struct tag *pos;
|
||||
|
||||
@ -499,32 +499,31 @@ struct class *cu__find_class_by_name(const struct cu *self, const char *name)
|
||||
return NULL;
|
||||
|
||||
list_for_each_entry(pos, &self->tags, node) {
|
||||
struct class *class;
|
||||
struct type *type;
|
||||
|
||||
if (pos->tag != DW_TAG_structure_type)
|
||||
continue;
|
||||
|
||||
class = tag__class(pos);
|
||||
if (class->type.name != NULL &&
|
||||
strcmp(class->type.name, name) == 0)
|
||||
return class;
|
||||
type = tag__type(pos);
|
||||
if (type->name != NULL && strcmp(type->name, name) == 0)
|
||||
return pos;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct class *cus__find_class_by_name(const struct cus *self,
|
||||
struct cu **cu, const char *name)
|
||||
struct tag *cus__find_struct_by_name(const struct cus *self,
|
||||
struct cu **cu, const char *name)
|
||||
{
|
||||
struct cu *pos;
|
||||
|
||||
list_for_each_entry(pos, &self->cus, node) {
|
||||
struct class *class = cu__find_class_by_name(pos, name);
|
||||
struct tag *tag = cu__find_struct_by_name(pos, name);
|
||||
|
||||
if (class != NULL) {
|
||||
if (tag != NULL) {
|
||||
if (cu != NULL)
|
||||
*cu = pos;
|
||||
return class;
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2359,8 +2358,7 @@ static int cus__emit_typedef_definitions(struct cus *self, struct cu *cu,
|
||||
const struct type *ctype = tag__type(type);
|
||||
|
||||
if (ctype->name == NULL)
|
||||
cus__emit_struct_definitions(self, cu,
|
||||
tag__class(type),
|
||||
cus__emit_struct_definitions(self, cu, type,
|
||||
"typedef", def->name);
|
||||
else
|
||||
printf("typedef struct %s %s;\n",
|
||||
@ -2453,7 +2451,7 @@ next_indirection:
|
||||
case DW_TAG_structure_type:
|
||||
if (pointer)
|
||||
return cus__emit_fwd_decl(self, tag__type(type));
|
||||
return cus__emit_struct_definitions(self, cu, ctype, NULL, NULL);
|
||||
return cus__emit_struct_definitions(self, cu, type, NULL, NULL);
|
||||
case DW_TAG_subroutine_type:
|
||||
return cus__emit_tag_definitions(self, cu, type);
|
||||
}
|
||||
@ -2479,10 +2477,11 @@ int cus__emit_ftype_definitions(struct cus *self, struct cu *cu,
|
||||
}
|
||||
|
||||
int cus__emit_struct_definitions(struct cus *self, struct cu *cu,
|
||||
struct class *class,
|
||||
struct tag *tag,
|
||||
const char *prefix, const char *suffix)
|
||||
{
|
||||
struct type *ctype = &class->type;
|
||||
struct class *class;
|
||||
struct type *ctype = tag__type(tag);
|
||||
struct class_member *pos;
|
||||
int printed = 0;
|
||||
|
||||
@ -2497,6 +2496,7 @@ int cus__emit_struct_definitions(struct cus *self, struct cu *cu,
|
||||
|
||||
cus__add_definition(self, ctype);
|
||||
|
||||
class = tag__class(tag);
|
||||
list_for_each_entry(pos, &class->members, tag.node)
|
||||
if (cus__emit_tag_definitions(self, cu, &pos->tag))
|
||||
printed = 1;
|
||||
@ -2505,7 +2505,7 @@ int cus__emit_struct_definitions(struct cus *self, struct cu *cu,
|
||||
putchar('\n');
|
||||
|
||||
class__find_holes(class, cu);
|
||||
tag__print(&ctype->tag, cu, prefix, suffix);
|
||||
tag__print(tag, cu, prefix, suffix);
|
||||
ctype->definition_emitted = 1;
|
||||
putchar('\n');
|
||||
return 1;
|
||||
|
13
classes.h
13
classes.h
@ -242,24 +242,23 @@ extern int cus__load_dir(struct cus *self, const char *dirname,
|
||||
const char *filename_mask, const int recursive);
|
||||
extern struct cu *cus__find_cu_by_name(const struct cus *self,
|
||||
const char *name);
|
||||
extern struct class *cus__find_class_by_name(const struct cus *self,
|
||||
struct cu **cu,
|
||||
const char *name);
|
||||
extern struct tag *cus__find_struct_by_name(const struct cus *self,
|
||||
struct cu **cu,
|
||||
const char *name);
|
||||
extern struct function *cus__find_function_by_name(const struct cus *self,
|
||||
struct cu **cu,
|
||||
const char *name);
|
||||
extern int cus__emit_ftype_definitions(struct cus *self, struct cu *cu,
|
||||
struct ftype *ftype);
|
||||
extern int cus__emit_struct_definitions(struct cus *self, struct cu *cu,
|
||||
struct class *class,
|
||||
const char *prefix,
|
||||
struct tag *tag, const char *prefix,
|
||||
const char *suffix);
|
||||
extern int cus__emit_fwd_decl(struct cus *self, struct type *ctype);
|
||||
|
||||
extern struct tag *cu__find_tag_by_id(const struct cu *self,
|
||||
const Dwarf_Off id);
|
||||
extern struct class *cu__find_class_by_name(const struct cu *cu,
|
||||
const char *name);
|
||||
extern struct tag *cu__find_struct_by_name(const struct cu *cu,
|
||||
const char *name);
|
||||
extern int tag__is_struct(const struct tag *self, struct tag **typedef_alias,
|
||||
const struct cu *cu);
|
||||
extern void cu__account_inline_expansions(struct cu *self);
|
||||
|
8
codiff.c
8
codiff.c
@ -204,6 +204,7 @@ static int check_print_members_changes(const struct class *structure,
|
||||
static void diff_struct(const struct cu *new_cu, struct class *structure,
|
||||
struct cu *cu)
|
||||
{
|
||||
struct tag *new_tag;
|
||||
struct class *new_structure;
|
||||
size_t len;
|
||||
int32_t diff;
|
||||
@ -213,12 +214,13 @@ static void diff_struct(const struct cu *new_cu, struct class *structure,
|
||||
if (structure->size == 0 || class__name(structure) == NULL)
|
||||
return;
|
||||
|
||||
new_structure = cu__find_class_by_name(new_cu, class__name(structure));
|
||||
if (new_structure == NULL) {
|
||||
new_tag = cu__find_struct_by_name(new_cu, class__name(structure));
|
||||
if (new_tag == NULL) {
|
||||
diff = 1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
new_structure = tag__class(new_tag);
|
||||
if (new_structure->size == 0)
|
||||
return;
|
||||
|
||||
@ -303,7 +305,7 @@ static int find_new_classes_iterator(struct tag *tag, struct cu *cu, void *old_c
|
||||
if (class->size == 0)
|
||||
return 0;
|
||||
|
||||
if (cu__find_class_by_name(old_cu, class__name(class)) != NULL)
|
||||
if (cu__find_struct_by_name(old_cu, class__name(class)) != NULL)
|
||||
return 0;
|
||||
|
||||
class->priv = diff_info__new(NULL, NULL, 1);
|
||||
|
12
ctracer.c
12
ctracer.c
@ -52,7 +52,7 @@ static int find_methods_iterator(struct tag *tag, struct cu *cu, void *cookie)
|
||||
|
||||
static int cu_find_methods_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
struct class *target = cu__find_class_by_name(cu, cookie);
|
||||
struct tag *target = cu__find_struct_by_name(cu, cookie);
|
||||
|
||||
if (target == NULL)
|
||||
return 0;
|
||||
@ -113,12 +113,12 @@ static int function__emit_kprobes(const struct function *self,
|
||||
|
||||
static int cu_emit_kprobes_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
struct class *target = cu__find_class_by_name(cu, cookie);
|
||||
struct tag *target = cu__find_struct_by_name(cu, cookie);
|
||||
struct function *pos;
|
||||
|
||||
list_for_each_entry(pos, &cu->tool_list, tool_node) {
|
||||
cus__emit_ftype_definitions(cus, cu, &pos->proto);
|
||||
function__emit_kprobes(pos, cu, class__tag(target));
|
||||
function__emit_kprobes(pos, cu, target);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -184,7 +184,7 @@ static void emit_function_defs(const char *fn)
|
||||
static void emit_struct_defs(const char *name)
|
||||
{
|
||||
struct cu *cu;
|
||||
struct class *c = cus__find_class_by_name(kprobes_cus, &cu, name);
|
||||
struct tag *c = cus__find_struct_by_name(kprobes_cus, &cu, name);
|
||||
if (c != NULL)
|
||||
cus__emit_struct_definitions(kprobes_cus, cu, c, NULL, NULL);
|
||||
}
|
||||
@ -192,9 +192,9 @@ static void emit_struct_defs(const char *name)
|
||||
static void emit_class_fwd_decl(const char *name)
|
||||
{
|
||||
struct cu *cu;
|
||||
struct class *c = cus__find_class_by_name(kprobes_cus, &cu, name);
|
||||
struct tag *c = cus__find_struct_by_name(kprobes_cus, &cu, name);
|
||||
if (c != NULL)
|
||||
cus__emit_fwd_decl(kprobes_cus, &c->type);
|
||||
cus__emit_fwd_decl(kprobes_cus, tag__type(c));
|
||||
}
|
||||
|
||||
static void emit_module_preamble(void)
|
||||
|
2
pfunct.c
2
pfunct.c
@ -254,7 +254,7 @@ static int class_iterator(struct tag *tag, struct cu *cu, void *cookie)
|
||||
|
||||
static int cu_class_iterator(struct cu *cu, void *cookie)
|
||||
{
|
||||
struct class *target = cu__find_class_by_name(cu, cookie);
|
||||
struct tag *target = cu__find_struct_by_name(cu, cookie);
|
||||
|
||||
if (target == NULL)
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user