Commit 023aceec authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf annotate-data: Update type stat at the end of find_data_type_die()

After trying all possibilities with DWARF and instruction tracking.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240816235840.2754937-10-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ba883370
...@@ -432,10 +432,8 @@ static enum type_match_result check_variable(struct data_loc_info *dloc, ...@@ -432,10 +432,8 @@ static enum type_match_result check_variable(struct data_loc_info *dloc,
needs_pointer = false; needs_pointer = false;
/* Get the type of the variable */ /* Get the type of the variable */
if (__die_get_real_type(var_die, type_die) == NULL) { if (__die_get_real_type(var_die, type_die) == NULL)
ann_data_stat.no_typeinfo++;
return PERF_TMR_NO_TYPE; return PERF_TMR_NO_TYPE;
}
/* /*
* Usually it expects a pointer type for a memory access. * Usually it expects a pointer type for a memory access.
...@@ -444,11 +442,9 @@ static enum type_match_result check_variable(struct data_loc_info *dloc, ...@@ -444,11 +442,9 @@ static enum type_match_result check_variable(struct data_loc_info *dloc,
*/ */
if (needs_pointer) { if (needs_pointer) {
if (!is_pointer_type(type_die) || if (!is_pointer_type(type_die) ||
__die_get_real_type(type_die, type_die) == NULL) { __die_get_real_type(type_die, type_die) == NULL)
ann_data_stat.no_typeinfo++;
return PERF_TMR_NO_POINTER; return PERF_TMR_NO_POINTER;
} }
}
if (dwarf_tag(type_die) == DW_TAG_typedef) if (dwarf_tag(type_die) == DW_TAG_typedef)
die_get_real_type(type_die, &sized_type); die_get_real_type(type_die, &sized_type);
...@@ -456,16 +452,12 @@ static enum type_match_result check_variable(struct data_loc_info *dloc, ...@@ -456,16 +452,12 @@ static enum type_match_result check_variable(struct data_loc_info *dloc,
sized_type = *type_die; sized_type = *type_die;
/* Get the size of the actual type */ /* Get the size of the actual type */
if (dwarf_aggregate_size(&sized_type, &size) < 0) { if (dwarf_aggregate_size(&sized_type, &size) < 0)
ann_data_stat.invalid_size++;
return PERF_TMR_NO_SIZE; return PERF_TMR_NO_SIZE;
}
/* Minimal sanity check */ /* Minimal sanity check */
if ((unsigned)offset >= size) { if ((unsigned)offset >= size)
ann_data_stat.bad_offset++;
return PERF_TMR_BAD_OFFSET; return PERF_TMR_BAD_OFFSET;
}
return PERF_TMR_OK; return PERF_TMR_OK;
} }
...@@ -1275,7 +1267,7 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) ...@@ -1275,7 +1267,7 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die)
bool found = false; bool found = false;
u64 pc; u64 pc;
char buf[64]; char buf[64];
enum type_match_result result; enum type_match_result result = PERF_TMR_UNKNOWN;
if (dloc->op->multi_regs) if (dloc->op->multi_regs)
snprintf(buf, sizeof(buf), "reg%d, reg%d", dloc->op->reg1, dloc->op->reg2); snprintf(buf, sizeof(buf), "reg%d, reg%d", dloc->op->reg1, dloc->op->reg2);
...@@ -1317,7 +1309,7 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) ...@@ -1317,7 +1309,7 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die)
pr_debug_dtp("found by addr=%#"PRIx64" type_offset=%#x\n", pr_debug_dtp("found by addr=%#"PRIx64" type_offset=%#x\n",
dloc->var_addr, offset); dloc->var_addr, offset);
pr_debug_type_name(type_die, TSR_KIND_TYPE); pr_debug_type_name(type_die, TSR_KIND_TYPE);
ret = 0; found = true;
goto out; goto out;
} }
} }
...@@ -1416,16 +1408,37 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die) ...@@ -1416,16 +1408,37 @@ static int find_data_type_die(struct data_loc_info *dloc, Dwarf_Die *type_die)
} }
} }
out:
if (found) { if (found) {
pr_debug_dtp("final type:"); pr_debug_dtp("final type:");
pr_debug_type_name(type_die, TSR_KIND_TYPE); pr_debug_type_name(type_die, TSR_KIND_TYPE);
ret = 0; ret = 0;
} else { } else {
switch (result) {
case PERF_TMR_NO_TYPE:
case PERF_TMR_NO_POINTER:
pr_debug_dtp("%s\n", match_result_str(result));
ann_data_stat.no_typeinfo++;
break;
case PERF_TMR_NO_SIZE:
pr_debug_dtp("%s\n", match_result_str(result));
ann_data_stat.invalid_size++;
break;
case PERF_TMR_BAD_OFFSET:
pr_debug_dtp("%s\n", match_result_str(result));
ann_data_stat.bad_offset++;
break;
case PERF_TMR_UNKNOWN:
case PERF_TMR_BAIL_OUT:
case PERF_TMR_OK: /* should not reach here */
default:
pr_debug_dtp("no variable found\n"); pr_debug_dtp("no variable found\n");
ann_data_stat.no_var++; ann_data_stat.no_var++;
break;
}
ret = -1;
} }
out:
free(scopes); free(scopes);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment