From 9fadbfffba3af323543c2593af0aa7366f6e1508 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 6 Mar 2009 11:14:26 -0300 Subject: [PATCH] dwarves: use tag__is_function in the tools Signed-off-by: Arnaldo Carvalho de Melo --- codiff.c | 10 +++------- ctracer.c | 4 ++-- dwarf_loader.c | 2 +- dwarves.c | 7 +++---- pahole.c | 2 +- pdwtags.c | 4 ++-- pfunct.c | 8 ++++---- pglobal.c | 2 +- prefcnt.c | 2 +- syscse.c | 2 +- 10 files changed, 19 insertions(+), 24 deletions(-) diff --git a/codiff.c b/codiff.c index b86e3d4..23102d0 100644 --- a/codiff.c +++ b/codiff.c @@ -72,8 +72,6 @@ static void diff_function(const struct cu *new_cu, struct function *function, struct tag *new_tag; const char *name; - assert(function->proto.tag.tag == DW_TAG_subprogram); - if (function->inlined || function->abstract_origin != 0) return; @@ -285,7 +283,7 @@ static int diff_tag_iterator(struct tag *tag, struct cu *cu, void *new_cu) { if (tag__is_struct(tag)) diff_struct(new_cu, tag__class(tag), cu); - else if (tag->tag == DW_TAG_subprogram) + else if (tag__is_function(tag)) diff_function(new_cu, tag__function(tag), cu); return 0; @@ -298,8 +296,6 @@ static int find_new_functions_iterator(struct tag *tfunction, struct cu *cu, struct tag *old_function; const char *name; - assert(function->proto.tag.tag == DW_TAG_subprogram); - if (function->inlined) return 0; @@ -350,7 +346,7 @@ static int find_new_classes_iterator(struct tag *tag, struct cu *cu, void *old_c static int find_new_tags_iterator(struct tag *tag, struct cu *cu, void *old_cu) { - if (tag->tag == DW_TAG_subprogram) { + if (tag__is_function(tag)) { /* * We're not interested in aliases, just real function definitions, * where we'll know if the kind of inlining @@ -609,7 +605,7 @@ static int show_function_diffs_iterator(struct tag *tag, struct cu *cu, { struct function *function = tag__function(tag); - if (tag->tag == DW_TAG_subprogram && function->priv != NULL) + if (tag__is_function(tag) && function->priv != NULL) show_diffs_function(function, cu, cookie); return 0; } diff --git a/ctracer.c b/ctracer.c index e2f4227..807712a 100644 --- a/ctracer.c +++ b/ctracer.c @@ -172,7 +172,7 @@ static void method__add(struct cu *cu, struct function *function, uint32_t id) } /* - * We want just the DW_TAG_subprogram tags that have as one of its parameters + * We want just the function tags that have as one of its parameters * a pointer to the specified "class" (a struct, unions can be added later). */ static struct function *function__filter(struct function *function, @@ -189,7 +189,7 @@ static struct function *function__filter(struct function *function, /* * Iterate thru all the tags in the compilation unit, looking just for the - * DW_TAG_subprogram tags that have as one of its parameters a pointer to + * function tags that have as one of its parameters a pointer to * the specified "class" (struct). */ static int cu_find_methods_iterator(struct cu *cu, void *cookie) diff --git a/dwarf_loader.c b/dwarf_loader.c index fb0d9ae..4b85131 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -960,7 +960,7 @@ static void die__process_class(Dwarf_Die *die, struct type *class, namespace__add_tag(&class->namespace, tag); cu__hash(cu, tag); - if (tag->tag == DW_TAG_subprogram) { + if (tag__is_function(tag)) { struct function *fself = tag__function(tag); if (fself->vtable_entry != -1) diff --git a/dwarves.c b/dwarves.c index 65ea711..8fd3858 100644 --- a/dwarves.c +++ b/dwarves.c @@ -792,7 +792,7 @@ struct tag *cu__find_function_by_name(const struct cu *self, const char *name) return NULL; list_for_each_entry(pos, &self->tags, node) { - if (pos->tag != DW_TAG_subprogram) + if (!tag__is_function(pos)) continue; fpos = tag__function(pos); if (fpos->name && strcmp(s(fpos->name), name) == 0) @@ -1668,7 +1668,7 @@ void cu__account_inline_expansions(struct cu *self) struct function *fpos; list_for_each_entry(pos, &self->tags, node) { - if (pos->tag != DW_TAG_subprogram) + if (!tag__is_function(pos)) continue; fpos = tag__function(pos); lexblock__account_inline_expansions(&fpos->lexblock, self); @@ -2421,8 +2421,7 @@ size_t tag__fprintf(struct tag *self, const struct cu *cu, ++printed; } - if (self->tag == DW_TAG_subprogram && - !pconf->suppress_comments) { + if (tag__is_function(self) && !pconf->suppress_comments) { const struct function *fself = tag__function(self); if (fself->linkage_name) diff --git a/pahole.c b/pahole.c index c15a133..d080343 100644 --- a/pahole.c +++ b/pahole.c @@ -676,7 +676,7 @@ static int cu_fixup_word_size_iterator(struct cu *cu, void *cookie) static struct tag *nr_methods__filter(struct tag *tag, struct cu *cu __unused, void *cookie __unused) { - if (tag->tag != DW_TAG_subprogram) + if (!tag__is_function(tag)) return NULL; if (function__declared_inline(tag__function(tag))) diff --git a/pdwtags.c b/pdwtags.c index f443b51..6b0febe 100644 --- a/pdwtags.c +++ b/pdwtags.c @@ -23,7 +23,7 @@ static void emit_tag(struct tag *self, uint32_t tag_id, struct cu *cu) if (tag__is_struct(self)) class__find_holes(tag__class(self), cu); - conf.no_semicolon = self->tag == DW_TAG_subprogram; + conf.no_semicolon = tag__is_function(self); printf("%d ", tag_id); @@ -39,7 +39,7 @@ static void emit_tag(struct tag *self, uint32_t tag_id, struct cu *cu) else tag__fprintf(self, cu, &conf, stdout); - if (self->tag == DW_TAG_subprogram) { + if (tag__is_function(self)) { struct function *fn = tag__function(self); putchar('\n'); lexblock__fprintf(&fn->lexblock, cu, fn, 0, stdout); diff --git a/pfunct.c b/pfunct.c index 9564d06..4c45f1b 100644 --- a/pfunct.c +++ b/pfunct.c @@ -215,7 +215,7 @@ static struct tag *function__filter(struct tag *tag, struct cu *cu, struct fn_stats *fstats; const char *name; - if (tag->tag != DW_TAG_subprogram) + if (!tag__is_function(tag)) return NULL; if (!tag->top_level) @@ -261,7 +261,7 @@ static struct tag *function__filter(struct tag *tag, struct cu *cu, static int unique_iterator(struct tag *tag, struct cu *cu, void *cookie __unused) { - if (tag->tag == DW_TAG_subprogram) + if (tag__is_function(tag)) fn_stats__add(tag, cu); return 0; } @@ -277,7 +277,7 @@ static int class_iterator(struct tag *tag, struct cu *cu, void *cookie) uint16_t *target_id = cookie; struct function *function; - if (tag->tag != DW_TAG_subprogram) + if (!tag__is_function(tag)) return 0; function = tag__function(tag); @@ -335,7 +335,7 @@ static int function_iterator(struct tag *tag, struct cu *cu, void *cookie) { struct function *function; - if (tag->tag != DW_TAG_subprogram) + if (!tag__is_function(tag)) return 0; function = tag__function(tag); diff --git a/pglobal.c b/pglobal.c index 8549a68..8066455 100644 --- a/pglobal.c +++ b/pglobal.c @@ -139,7 +139,7 @@ static struct tag *extfun__filter(struct tag *tag, struct cu *cu __unused, { struct function *fun; - if (tag->tag != DW_TAG_subprogram) + if (!tag__is_function(tag)) return NULL; fun = tag__function(tag); diff --git a/prefcnt.c b/prefcnt.c index a99d246..af1c14e 100644 --- a/prefcnt.c +++ b/prefcnt.c @@ -120,7 +120,7 @@ static int refcnt_tag_iterator(struct tag *tag, struct cu *cu, void *cookie) { if (tag__is_struct(tag)) class__find_holes(tag__class(tag), cu); - else if (tag->tag == DW_TAG_subprogram) + else if (tag__is_function(tag)) refcnt_function_iterator(tag__function(tag), cu, cookie); return 0; diff --git a/syscse.c b/syscse.c index 874eb05..7dd475b 100644 --- a/syscse.c +++ b/syscse.c @@ -23,7 +23,7 @@ static size_t prefix_len = 4; static struct tag *filter(struct tag *self, struct cu *cu, void *cookie __unused) { - if (self->tag == DW_TAG_subprogram) { + if (tag__is_function(self)) { struct function *f = tag__function(self); if (f->proto.nr_parms != 0) {