diff --git a/ctracer.c b/ctracer.c index c75f6c7..19bae66 100644 --- a/ctracer.c +++ b/ctracer.c @@ -520,8 +520,7 @@ static struct tag *pointer_filter(struct tag *tag, struct cu *cu, struct tag *ctype = cu__type(cu, pos->tag.type); tag__assert_search_result(ctype); - if (ctype->tag == DW_TAG_pointer_type && - ctype->type == target_type_id) + if (tag__is_pointer(ctype) && ctype->type == target_type_id) return tag; } @@ -712,8 +711,7 @@ static int function__emit_probes(struct function *func, uint32_t function_id, struct tag *type = cu__type(cu, pos->tag.type); tag__assert_search_result(type); - if (type->tag != DW_TAG_pointer_type || - type->type != target_type_id) + if (!tag__is_pointer(type) || type->type != target_type_id) continue; if (member != NULL) @@ -789,7 +787,7 @@ static int cu_emit_pointer_probes_iterator(struct cu *cu, void *cookie) struct tag *ctype = cu__type(cu, pos_member->tag.type); tag__assert_search_result(ctype); - if (ctype->tag == DW_TAG_pointer_type && ctype->type == target_type_id) + if (tag__is_pointer(ctype) && ctype->type == target_type_id) break; } diff --git a/dwarves.c b/dwarves.c index 1c2df05..35af996 100644 --- a/dwarves.c +++ b/dwarves.c @@ -1121,7 +1121,7 @@ int ftype__has_parm_of_type(const struct ftype *ftype, const type_id_t target, ftype__for_each_parameter(ftype, pos) { struct tag *type = cu__type(cu, pos->tag.type); - if (type != NULL && type->tag == DW_TAG_pointer_type) { + if (type != NULL && tag__is_pointer(type)) { if (type->type == target) return 1; } diff --git a/dwarves.h b/dwarves.h index d00e89e..4dabae3 100644 --- a/dwarves.h +++ b/dwarves.h @@ -403,6 +403,11 @@ static inline int tag__is_const(const struct tag *tag) return tag->tag == DW_TAG_const_type; } +static inline int tag__is_pointer(const struct tag *tag) +{ + return tag->tag == DW_TAG_pointer_type; +} + static inline bool tag__is_variable(const struct tag *tag) { return tag->tag == DW_TAG_variable; diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index d2c8e28..e96a5f2 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -575,7 +575,7 @@ static size_t type__fprintf(struct tag *type, const struct cu *cu, if (conf->expand_pointers) { int nr_indirections = 0; - while (type->tag == DW_TAG_pointer_type && type->type != 0) { + while (tag__is_pointer(type) && type->type != 0) { struct tag *ttype = cu__type(cu, type->type); if (ttype == NULL) goto out_type_not_found; @@ -956,7 +956,7 @@ size_t ftype__fprintf_parms(const struct ftype *ftype, stype = sbf; goto print_it; } - if (type->tag == DW_TAG_pointer_type) { + if (tag__is_pointer(type)) { if (type->type != 0) { int n; struct tag *ptype = cu__type(cu, type->type); diff --git a/pahole.c b/pahole.c index c0204b1..63951ed 100644 --- a/pahole.c +++ b/pahole.c @@ -625,7 +625,7 @@ static void cu__account_nr_methods(struct cu *cu) list_for_each_entry(pos, &pos_function->proto.parms, tag.node) { struct tag *type = cu__type(cu, pos->tag.type); - if (type == NULL || type->tag != DW_TAG_pointer_type) + if (type == NULL || !tag__is_pointer(type)) continue; type = cu__type(cu, type->type); @@ -676,7 +676,7 @@ static void print_structs_with_pointer_to(const struct cu *cu, uint32_t type) struct tag *ctype = cu__type(cu, pos_member->tag.type); tag__assert_search_result(ctype); - if (ctype->tag != DW_TAG_pointer_type || ctype->type != type) + if (!tag__is_pointer(ctype) || ctype->type != type) continue; if (!looked) { diff --git a/pdwtags.c b/pdwtags.c index 3b8f559..d3c823a 100644 --- a/pdwtags.c +++ b/pdwtags.c @@ -32,7 +32,7 @@ static void emit_tag(struct tag *tag, uint32_t tag_id, struct cu *cu) printf("anonymous base_type\n"); else puts(name); - } else if (tag->tag == DW_TAG_pointer_type) + } else if (tag__is_pointer(tag)) printf(" /* pointer to %lld */\n", (unsigned long long)tag->type); else tag__fprintf(tag, cu, &conf, stdout); diff --git a/pfunct.c b/pfunct.c index 303fdde..81003e1 100644 --- a/pfunct.c +++ b/pfunct.c @@ -335,7 +335,7 @@ static int function__emit_type_definitions(struct function *func, if (type == NULL) continue; - if (type->tag == DW_TAG_pointer_type || tag__is_modifier(type)) { + if (tag__is_pointer(type) || tag__is_modifier(type)) { type = cu__type(cu, type->type); goto try_again; }