Skip to content

Commit

Permalink
core: Print more info on tag__assert_search_result()
Browse files Browse the repository at this point in the history
Its about showing the tag for which we're not finding its type, so we
want to know if it is a class member, a function argument, etc:

Before:

⬢[acme@toolbox pahole]$ pahole --compile eelco/ovs-vswitchd_rhel8 > a
/var/home/acme/git/pahole/dwarves_emit.c::typedef__emit_definitions(158): tag not found, please report to [email protected]

After:

⬢[acme@toolbox pahole]$ pahole --compile eelco/ovs-vswitchd_rhel8 > a
/var/home/acme/git/pahole/dwarves_emit.c::typedef__emit_definitions(158, related to the type of tag DW_TAG_typedef "_IO_lock_t"): tag not found, please report to [email protected]

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Oct 10, 2022
1 parent d5012f7 commit cf27a2b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion codiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ static void show_changed_member(char change, const struct class_member *member,
const struct tag *type = cu__type(cu, member->tag.type);
char bf[128];

tag__assert_search_result(type);
tag__assert_search_result(type, member->tag.tag, class_member__name(member));
printf(" %c%-26s %-21s /* %5u %5zd */\n",
change, tag__name(type, cu, bf, sizeof(bf), NULL),
class_member__name(member),
Expand Down
8 changes: 4 additions & 4 deletions ctracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static struct class *class__clone_base_types(const struct tag *tag,
type__for_each_data_member_safe(&clone->type, pos, next) {
struct tag *member_type = cu__type(cu, pos->tag.type);

tag__assert_search_result(member_type);
tag__assert_search_result(member_type, pos->tag.tag, class_member__name(pos));
if (!tag__is_base_type(member_type, cu)) {
next = class__remove_member(clone, cu, pos);
class_member__delete(pos);
Expand Down Expand Up @@ -498,7 +498,7 @@ static struct tag *pointer_filter(struct tag *tag, struct cu *cu,
type__for_each_member(type, pos) {
struct tag *ctype = cu__type(cu, pos->tag.type);

tag__assert_search_result(ctype);
tag__assert_search_result(ctype, pos->tag.tag, class_member__name(pos));
if (tag__is_pointer_to(ctype, target_type_id))
return tag;
}
Expand Down Expand Up @@ -687,7 +687,7 @@ static int function__emit_probes(struct function *func, uint32_t function_id,
list_for_each_entry(pos, &func->proto.parms, tag.node) {
struct tag *type = cu__type(cu, pos->tag.type);

tag__assert_search_result(type);
tag__assert_search_result(type, pos->tag.tag, parameter__name(pos));
if (!tag__is_pointer_to(type, target_type_id))
continue;

Expand Down Expand Up @@ -762,7 +762,7 @@ static int cu_emit_pointer_probes_iterator(struct cu *cu, void *cookie)
type__for_each_member(tag__type(pointer), pos_member) {
struct tag *ctype = cu__type(cu, pos_member->tag.type);

tag__assert_search_result(ctype);
tag__assert_search_result(ctype, pos_member->tag.tag, class_member__name(pos_member));
if (tag__is_pointer_to(ctype, target_type_id))
break;
}
Expand Down
6 changes: 3 additions & 3 deletions dwarves.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ void tag__delete(struct tag *tag)
}
}

void tag__not_found_die(const char *file, int line, const char *func)
void tag__not_found_die(const char *file, int line, const char *func, int tag, const char *name)
{
fprintf(stderr, "%s::%s(%d): tag not found, please report to "
"[email protected]\n", file, func, line);
fprintf(stderr, "%s::%s(%d, related to the type of tag DW_TAG_%s \"%s\"): tag not found, please report to "
"[email protected]\n", file, func, line, dwarf_tag_name(tag), name);
exit(1);
}

Expand Down
8 changes: 4 additions & 4 deletions dwarves.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,11 @@ size_t tag__fprintf(struct tag *tag, const struct cu *cu,

const char *tag__name(const struct tag *tag, const struct cu *cu,
char *bf, size_t len, const struct conf_fprintf *conf);
void tag__not_found_die(const char *file, int line, const char *func);
void tag__not_found_die(const char *file, int line, const char *func, int tag, const char *name);

#define tag__assert_search_result(tag) \
do { if (!tag) tag__not_found_die(__FILE__,\
__LINE__, __func__); } while (0)
#define tag__assert_search_result(result, tag, name) \
do { if (!result) tag__not_found_die(__FILE__,\
__LINE__, __func__, tag, name); } while (0)

size_t tag__size(const struct tag *tag, const struct cu *cu);
size_t tag__nr_cachelines(const struct conf_fprintf *conf, const struct tag *tag, const struct cu *cu);
Expand Down
2 changes: 1 addition & 1 deletion dwarves_emit.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static int typedef__emit_definitions(struct tag *tdef, struct cu *cu,
}

type = cu__type(cu, tdef->type);
tag__assert_search_result(type);
tag__assert_search_result(type, tdef->tag, type__name(def));

switch (type->tag) {
case DW_TAG_array_type:
Expand Down
4 changes: 2 additions & 2 deletions dwarves_reorganize.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ static int class__demote_bitfields(struct class *class, const struct cu *cu,
cu__find_base_type_of_size(cu, bytes_needed,
&new_type_id);

tag__assert_search_result(old_type_tag);
tag__assert_search_result(new_type_tag);
tag__assert_search_result(old_type_tag, member->tag.tag, class_member__name(member));
tag__assert_search_result(new_type_tag, member->tag.tag, class_member__name(member));

if (verbose) {
char old_bf[64], new_bf[64];
Expand Down
10 changes: 5 additions & 5 deletions pahole.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,19 +871,19 @@ static void class__resize_LP(struct tag *tag, struct cu *cu)
continue;

type = cu__type(cu, tag_pos->type);
tag__assert_search_result(type);
tag__assert_search_result(type, tag_pos->tag, class_member__name(tag__class_member(tag_pos)));
if (type->tag == DW_TAG_array_type) {
int i;
for (i = 0; i < tag__array_type(type)->dimensions; ++i)
array_multiplier *= tag__array_type(type)->nr_entries[i];

type = cu__type(cu, type->type);
tag__assert_search_result(type);
tag__assert_search_result(type, tag_pos->tag, class_member__name(tag__class_member(tag_pos)));
}

if (tag__is_typedef(type)) {
type = tag__follow_typedef(type, cu);
tag__assert_search_result(type);
tag__assert_search_result(type, tag_pos->tag, class_member__name(tag__class_member(tag_pos)));
}

switch (type->tag) {
Expand Down Expand Up @@ -953,7 +953,7 @@ static void union__find_new_size(struct tag *tag, struct cu *cu)
continue;

type = cu__type(cu, tag_pos->type);
tag__assert_search_result(type);
tag__assert_search_result(type, tag_pos->tag, class_member__name(tag__class_member(tag_pos)));
if (tag__is_typedef(type))
type = tag__follow_typedef(type, cu);

Expand Down Expand Up @@ -1096,7 +1096,7 @@ static void print_structs_with_pointer_to(struct cu *cu, uint32_t type)
type__for_each_member(&pos->type, pos_member) {
struct tag *ctype = cu__type(cu, pos_member->tag.type);

tag__assert_search_result(ctype);
tag__assert_search_result(ctype, pos_member->tag.tag, class_member__name(pos_member));
if (!tag__is_pointer_to(ctype, type))
continue;

Expand Down
2 changes: 1 addition & 1 deletion syscse.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void emit_wrapper(struct function *f, struct cu *cu)
const type_id_t type_id = parm->tag.type;
struct tag *type = cu__type(cu, type_id);

tag__assert_search_result(type);
tag__assert_search_result(type, parm->tag.tag, parameter__name(parm));
if (type->tag == DW_TAG_base_type) {
struct base_type *bt = tag__base_type(type);
char bf[64];
Expand Down

0 comments on commit cf27a2b

Please sign in to comment.