[DWARVES]: Tell cu__find_struct_by_name if struct declarations are wanted

When we are looking for members of some type in all CUs it may be that in
some CU we don't have the full type, but just a declaration.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2007-11-16 18:16:56 -02:00
parent 7631b1869b
commit 6c7a1721ec
5 changed files with 25 additions and 17 deletions

View File

@ -188,7 +188,7 @@ static void diff_struct(const struct cu *new_cu, struct class *structure,
if (class__size(structure) == 0 || class__name(structure, cu) == NULL)
return;
new_tag = cu__find_struct_by_name(new_cu, class__name(structure, cu));
new_tag = cu__find_struct_by_name(new_cu, class__name(structure, cu), 0);
if (new_tag == NULL)
return;
@ -264,7 +264,7 @@ static int find_new_classes_iterator(struct tag *tag, struct cu *cu, void *old_c
if (class__size(class) == 0)
return 0;
if (cu__find_struct_by_name(old_cu, class__name(class, cu)) != NULL)
if (cu__find_struct_by_name(old_cu, class__name(class, cu), 0) != NULL)
return 0;
class->priv = diff_info__new(NULL, NULL, 1);

View File

@ -179,7 +179,7 @@ static int find_methods_iterator(struct tag *tag, struct cu *cu,
*/
static int cu_find_methods_iterator(struct cu *cu, void *cookie)
{
struct tag *target = cu__find_struct_by_name(cu, cookie);
struct tag *target = cu__find_struct_by_name(cu, cookie, 0);
if (target == NULL)
return 0;
@ -583,7 +583,7 @@ static int find_aliases_iterator(struct tag *tag, struct cu *cu,
*/
static int cu_find_aliases_iterator(struct cu *cu, void *class_name)
{
struct tag *target = cu__find_struct_by_name(cu, class_name);
struct tag *target = cu__find_struct_by_name(cu, class_name, 0);
if (target == NULL)
return 0;
@ -696,7 +696,7 @@ static int function__emit_probes(struct function *self, const struct cu *cu,
*/
static int cu_emit_probes_iterator(struct cu *cu, void *cookie)
{
struct tag *target = cu__find_struct_by_name(cu, cookie);
struct tag *target = cu__find_struct_by_name(cu, cookie, 0);
struct function *pos;
list_for_each_entry(pos, &cu->tool_list, tool_node) {
@ -858,7 +858,7 @@ failure:
/*
* See if the specified struct exists:
*/
class = cus__find_struct_by_name(methods_cus, &cu, class_name);
class = cus__find_struct_by_name(methods_cus, &cu, class_name, 0);
if (class == NULL) {
fprintf(stderr, "ctracer: struct %s not found!\n", class_name);
return EXIT_FAILURE;

View File

@ -752,7 +752,8 @@ struct tag *cu__find_base_type_by_name(const struct cu *self, const char *name)
return NULL;
}
struct tag *cu__find_struct_by_name(const struct cu *self, const char *name)
struct tag *cu__find_struct_by_name(const struct cu *self, const char *name,
const int include_decls)
{
struct tag *pos;
@ -766,23 +767,28 @@ struct tag *cu__find_struct_by_name(const struct cu *self, const char *name)
continue;
type = tag__type(pos);
if (!type->declaration &&
type__name(type, self) != NULL &&
strcmp(type__name(type, self), name) == 0)
return pos;
if (type__name(type, self) != NULL &&
strcmp(type__name(type, self), name) == 0) {
if (type->declaration) {
if (include_decls)
return pos;
} else
return pos;
}
}
return NULL;
}
struct tag *cus__find_struct_by_name(const struct cus *self,
struct cu **cu, const char *name)
struct cu **cu, const char *name,
const int include_decls)
{
struct cu *pos;
list_for_each_entry(pos, &self->cus, node) {
struct tag *tag = cu__find_struct_by_name(pos, name);
struct tag *tag = cu__find_struct_by_name(pos, name,
include_decls);
if (tag != NULL) {
if (cu != NULL)
*cu = pos;

View File

@ -470,7 +470,8 @@ extern struct tag *cu__find_base_type_by_name(const struct cu *self,
const char *name);
extern struct tag *cus__find_struct_by_name(const struct cus *self,
struct cu **cu,
const char *name);
const char *name,
const int include_decls);
extern struct tag *cus__find_function_by_name(const struct cus *self,
struct cu **cu,
const char *name);
@ -482,7 +483,8 @@ extern struct tag *cu__find_tag_by_id(const struct cu *self,
extern struct tag *cu__find_first_typedef_of_type(const struct cu *self,
const Dwarf_Off type);
extern struct tag *cu__find_struct_by_name(const struct cu *cu,
const char *name);
const char *name,
const int include_decls);
extern void cu__account_inline_expansions(struct cu *self);
extern int cu__for_each_tag(struct cu *self,
int (*iterator)(struct tag *tag,

View File

@ -288,7 +288,7 @@ static int class_iterator(struct tag *tag, struct cu *cu, void *cookie)
static int cu_class_iterator(struct cu *cu, void *cookie)
{
struct tag *target = cu__find_struct_by_name(cu, cookie);
struct tag *target = cu__find_struct_by_name(cu, cookie, 0);
if (target == NULL)
return 0;