perf callchain: Use 'struct map_symbol' in 'struct callchain_cursor_node'

To ease passing around map+symbol, just like done for other parts of the
tree recently.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c1529738
...@@ -412,8 +412,8 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample) ...@@ -412,8 +412,8 @@ static u64 find_callsite(struct evsel *evsel, struct perf_sample *sample)
sizeof(key), callcmp); sizeof(key), callcmp);
if (!caller) { if (!caller) {
/* found */ /* found */
if (node->map) if (node->ms.map)
addr = map__unmap_ip(node->map, node->ip); addr = map__unmap_ip(node->ms.map, node->ip);
else else
addr = node->ip; addr = node->ip;
......
...@@ -2172,7 +2172,7 @@ static void save_task_callchain(struct perf_sched *sched, ...@@ -2172,7 +2172,7 @@ static void save_task_callchain(struct perf_sched *sched,
if (node == NULL) if (node == NULL)
break; break;
sym = node->sym; sym = node->ms.sym;
if (sym) { if (sym) {
if (!strcmp(sym->name, "schedule") || if (!strcmp(sym->name, "schedule") ||
!strcmp(sym->name, "__schedule") || !strcmp(sym->name, "__schedule") ||
......
...@@ -582,8 +582,8 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor) ...@@ -582,8 +582,8 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
return -1; return -1;
} }
call->ip = cursor_node->ip; call->ip = cursor_node->ip;
call->ms.sym = cursor_node->sym; call->ms = cursor_node->ms;
call->ms.map = map__get(cursor_node->map); map__get(call->ms.map);
call->srcline = cursor_node->srcline; call->srcline = cursor_node->srcline;
if (cursor_node->branch) { if (cursor_node->branch) {
...@@ -720,21 +720,21 @@ static enum match_result match_chain(struct callchain_cursor_node *node, ...@@ -720,21 +720,21 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
/* otherwise fall-back to symbol-based comparison below */ /* otherwise fall-back to symbol-based comparison below */
__fallthrough; __fallthrough;
case CCKEY_FUNCTION: case CCKEY_FUNCTION:
if (node->sym && cnode->ms.sym) { if (node->ms.sym && cnode->ms.sym) {
/* /*
* Compare inlined frames based on their symbol name * Compare inlined frames based on their symbol name
* because different inlined frames will have the same * because different inlined frames will have the same
* symbol start. Otherwise do a faster comparison based * symbol start. Otherwise do a faster comparison based
* on the symbol start address. * on the symbol start address.
*/ */
if (cnode->ms.sym->inlined || node->sym->inlined) { if (cnode->ms.sym->inlined || node->ms.sym->inlined) {
match = match_chain_strings(cnode->ms.sym->name, match = match_chain_strings(cnode->ms.sym->name,
node->sym->name); node->ms.sym->name);
if (match != MATCH_ERROR) if (match != MATCH_ERROR)
break; break;
} else { } else {
match = match_chain_dso_addresses(cnode->ms.map, cnode->ms.sym->start, match = match_chain_dso_addresses(cnode->ms.map, cnode->ms.sym->start,
node->map, node->sym->start); node->ms.map, node->ms.sym->start);
break; break;
} }
} }
...@@ -742,7 +742,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node, ...@@ -742,7 +742,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
__fallthrough; __fallthrough;
case CCKEY_ADDRESS: case CCKEY_ADDRESS:
default: default:
match = match_chain_dso_addresses(cnode->ms.map, cnode->ip, node->map, node->ip); match = match_chain_dso_addresses(cnode->ms.map, cnode->ip, node->ms.map, node->ip);
break; break;
} }
...@@ -1004,8 +1004,7 @@ merge_chain_branch(struct callchain_cursor *cursor, ...@@ -1004,8 +1004,7 @@ merge_chain_branch(struct callchain_cursor *cursor,
int err = 0; int err = 0;
list_for_each_entry_safe(list, next_list, &src->val, list) { list_for_each_entry_safe(list, next_list, &src->val, list) {
callchain_cursor_append(cursor, list->ip, callchain_cursor_append(cursor, list->ip, &list->ms,
list->ms.map, list->ms.sym,
false, NULL, 0, 0, 0, list->srcline); false, NULL, 0, 0, 0, list->srcline);
list_del_init(&list->list); list_del_init(&list->list);
map__zput(list->ms.map); map__zput(list->ms.map);
...@@ -1044,7 +1043,7 @@ int callchain_merge(struct callchain_cursor *cursor, ...@@ -1044,7 +1043,7 @@ int callchain_merge(struct callchain_cursor *cursor,
} }
int callchain_cursor_append(struct callchain_cursor *cursor, int callchain_cursor_append(struct callchain_cursor *cursor,
u64 ip, struct map *map, struct symbol *sym, u64 ip, struct map_symbol *ms,
bool branch, struct branch_flags *flags, bool branch, struct branch_flags *flags,
int nr_loop_iter, u64 iter_cycles, u64 branch_from, int nr_loop_iter, u64 iter_cycles, u64 branch_from,
const char *srcline) const char *srcline)
...@@ -1060,9 +1059,9 @@ int callchain_cursor_append(struct callchain_cursor *cursor, ...@@ -1060,9 +1059,9 @@ int callchain_cursor_append(struct callchain_cursor *cursor,
} }
node->ip = ip; node->ip = ip;
map__zput(node->map); map__zput(node->ms.map);
node->map = map__get(map); node->ms = *ms;
node->sym = sym; map__get(node->ms.map);
node->branch = branch; node->branch = branch;
node->nr_loop_iter = nr_loop_iter; node->nr_loop_iter = nr_loop_iter;
node->iter_cycles = iter_cycles; node->iter_cycles = iter_cycles;
...@@ -1107,8 +1106,8 @@ int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *samp ...@@ -1107,8 +1106,8 @@ int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *samp
int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node,
bool hide_unresolved) bool hide_unresolved)
{ {
al->map = node->map; al->map = node->ms.map;
al->sym = node->sym; al->sym = node->ms.sym;
al->srcline = node->srcline; al->srcline = node->srcline;
al->addr = node->ip; al->addr = node->ip;
...@@ -1571,7 +1570,7 @@ int callchain_cursor__copy(struct callchain_cursor *dst, ...@@ -1571,7 +1570,7 @@ int callchain_cursor__copy(struct callchain_cursor *dst,
if (node == NULL) if (node == NULL)
break; break;
rc = callchain_cursor_append(dst, node->ip, node->map, node->sym, rc = callchain_cursor_append(dst, node->ip, &node->ms,
node->branch, &node->branch_flags, node->branch, &node->branch_flags,
node->nr_loop_iter, node->nr_loop_iter,
node->iter_cycles, node->iter_cycles,
...@@ -1597,5 +1596,5 @@ void callchain_cursor_reset(struct callchain_cursor *cursor) ...@@ -1597,5 +1596,5 @@ void callchain_cursor_reset(struct callchain_cursor *cursor)
cursor->last = &cursor->first; cursor->last = &cursor->first;
for (node = cursor->first; node != NULL; node = node->next) for (node = cursor->first; node != NULL; node = node->next)
map__zput(node->map); map__zput(node->ms.map);
} }
...@@ -141,8 +141,7 @@ struct callchain_list { ...@@ -141,8 +141,7 @@ struct callchain_list {
*/ */
struct callchain_cursor_node { struct callchain_cursor_node {
u64 ip; u64 ip;
struct map *map; struct map_symbol ms;
struct symbol *sym;
const char *srcline; const char *srcline;
bool branch; bool branch;
struct branch_flags branch_flags; struct branch_flags branch_flags;
...@@ -195,7 +194,7 @@ int callchain_merge(struct callchain_cursor *cursor, ...@@ -195,7 +194,7 @@ int callchain_merge(struct callchain_cursor *cursor,
void callchain_cursor_reset(struct callchain_cursor *cursor); void callchain_cursor_reset(struct callchain_cursor *cursor);
int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip,
struct map *map, struct symbol *sym, struct map_symbol *ms,
bool branch, struct branch_flags *flags, bool branch, struct branch_flags *flags,
int nr_loop_iter, u64 iter_cycles, u64 branch_from, int nr_loop_iter, u64 iter_cycles, u64 branch_from,
const char *srcline); const char *srcline);
......
...@@ -249,8 +249,8 @@ static struct call_path *call_path_from_sample(struct db_export *dbe, ...@@ -249,8 +249,8 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,
* constructing an addr_location struct and then passing it to * constructing an addr_location struct and then passing it to
* db_ids_from_al() to perform the export. * db_ids_from_al() to perform the export.
*/ */
al.sym = node->sym; al.sym = node->ms.sym;
al.map = node->map; al.map = node->ms.map;
al.mg = thread->mg; al.mg = thread->mg;
al.addr = node->ip; al.addr = node->ip;
......
...@@ -125,13 +125,18 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment, ...@@ -125,13 +125,18 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
callchain_cursor_commit(cursor); callchain_cursor_commit(cursor);
while (1) { while (1) {
struct symbol *sym;
struct map *map;
u64 addr = 0; u64 addr = 0;
node = callchain_cursor_current(cursor); node = callchain_cursor_current(cursor);
if (!node) if (!node)
break; break;
if (node->sym && node->sym->ignore && print_skip_ignored) sym = node->ms.sym;
map = node->ms.map;
if (sym && sym->ignore && print_skip_ignored)
goto next; goto next;
printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
...@@ -142,42 +147,42 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment, ...@@ -142,42 +147,42 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
if (print_ip) if (print_ip)
printed += fprintf(fp, "%c%16" PRIx64, s, node->ip); printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
if (node->map) if (map)
addr = node->map->map_ip(node->map, node->ip); addr = map->map_ip(map, node->ip);
if (print_sym) { if (print_sym) {
printed += fprintf(fp, " "); printed += fprintf(fp, " ");
node_al.addr = addr; node_al.addr = addr;
node_al.map = node->map; node_al.map = map;
if (print_symoffset) { if (print_symoffset) {
printed += __symbol__fprintf_symname_offs(node->sym, &node_al, printed += __symbol__fprintf_symname_offs(sym, &node_al,
print_unknown_as_addr, print_unknown_as_addr,
true, fp); true, fp);
} else { } else {
printed += __symbol__fprintf_symname(node->sym, &node_al, printed += __symbol__fprintf_symname(sym, &node_al,
print_unknown_as_addr, fp); print_unknown_as_addr, fp);
} }
} }
if (print_dso && (!node->sym || !node->sym->inlined)) { if (print_dso && (!sym || !sym->inlined)) {
printed += fprintf(fp, " ("); printed += fprintf(fp, " (");
printed += map__fprintf_dsoname(node->map, fp); printed += map__fprintf_dsoname(map, fp);
printed += fprintf(fp, ")"); printed += fprintf(fp, ")");
} }
if (print_srcline) if (print_srcline)
printed += map__fprintf_srcline(node->map, addr, "\n ", fp); printed += map__fprintf_srcline(map, addr, "\n ", fp);
if (node->sym && node->sym->inlined) if (sym && sym->inlined)
printed += fprintf(fp, " (inlined)"); printed += fprintf(fp, " (inlined)");
if (!print_oneline) if (!print_oneline)
printed += fprintf(fp, "\n"); printed += fprintf(fp, "\n");
/* Add srccode here too? */ /* Add srccode here too? */
if (bt_stop_list && node->sym && if (bt_stop_list && sym &&
strlist__has_entry(bt_stop_list, node->sym->name)) { strlist__has_entry(bt_stop_list, sym->name)) {
break; break;
} }
......
...@@ -2006,8 +2006,9 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample, ...@@ -2006,8 +2006,9 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
return mi; return mi;
} }
static char *callchain_srcline(struct map *map, struct symbol *sym, u64 ip) static char *callchain_srcline(struct map_symbol *ms, u64 ip)
{ {
struct map *map = ms->map;
char *srcline = NULL; char *srcline = NULL;
if (!map || callchain_param.key == CCKEY_FUNCTION) if (!map || callchain_param.key == CCKEY_FUNCTION)
...@@ -2019,7 +2020,7 @@ static char *callchain_srcline(struct map *map, struct symbol *sym, u64 ip) ...@@ -2019,7 +2020,7 @@ static char *callchain_srcline(struct map *map, struct symbol *sym, u64 ip)
bool show_addr = callchain_param.key == CCKEY_ADDRESS; bool show_addr = callchain_param.key == CCKEY_ADDRESS;
srcline = get_srcline(map->dso, map__rip_2objdump(map, ip), srcline = get_srcline(map->dso, map__rip_2objdump(map, ip),
sym, show_sym, show_addr, ip); ms->sym, show_sym, show_addr, ip);
srcline__tree_insert(&map->dso->srclines, ip, srcline); srcline__tree_insert(&map->dso->srclines, ip, srcline);
} }
...@@ -2042,6 +2043,7 @@ static int add_callchain_ip(struct thread *thread, ...@@ -2042,6 +2043,7 @@ static int add_callchain_ip(struct thread *thread,
struct iterations *iter, struct iterations *iter,
u64 branch_from) u64 branch_from)
{ {
struct map_symbol ms;
struct addr_location al; struct addr_location al;
int nr_loop_iter = 0; int nr_loop_iter = 0;
u64 iter_cycles = 0; u64 iter_cycles = 0;
...@@ -2099,8 +2101,10 @@ static int add_callchain_ip(struct thread *thread, ...@@ -2099,8 +2101,10 @@ static int add_callchain_ip(struct thread *thread,
iter_cycles = iter->cycles; iter_cycles = iter->cycles;
} }
srcline = callchain_srcline(al.map, al.sym, al.addr); ms.map = al.map;
return callchain_cursor_append(cursor, ip, al.map, al.sym, ms.sym = al.sym;
srcline = callchain_srcline(&ms, al.addr);
return callchain_cursor_append(cursor, ip, &ms,
branch, flags, nr_loop_iter, branch, flags, nr_loop_iter,
iter_cycles, branch_from, srcline); iter_cycles, branch_from, srcline);
} }
...@@ -2472,8 +2476,11 @@ static int append_inlines(struct callchain_cursor *cursor, struct map_symbol *ms ...@@ -2472,8 +2476,11 @@ static int append_inlines(struct callchain_cursor *cursor, struct map_symbol *ms
} }
list_for_each_entry(ilist, &inline_node->val, list) { list_for_each_entry(ilist, &inline_node->val, list) {
ret = callchain_cursor_append(cursor, ip, map, struct map_symbol ilist_ms = {
ilist->symbol, false, .map = map,
.sym = ilist->symbol,
};
ret = callchain_cursor_append(cursor, ip, &ilist_ms, false,
NULL, 0, 0, 0, ilist->srcline); NULL, 0, 0, 0, ilist->srcline);
if (ret != 0) if (ret != 0)
...@@ -2502,9 +2509,8 @@ static int unwind_entry(struct unwind_entry *entry, void *arg) ...@@ -2502,9 +2509,8 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
if (entry->ms.map) if (entry->ms.map)
addr = map__map_ip(entry->ms.map, entry->ip); addr = map__map_ip(entry->ms.map, entry->ip);
srcline = callchain_srcline(entry->ms.map, entry->ms.sym, addr); srcline = callchain_srcline(&entry->ms, addr);
return callchain_cursor_append(cursor, entry->ip, return callchain_cursor_append(cursor, entry->ip, &entry->ms,
entry->ms.map, entry->ms.sym,
false, NULL, 0, 0, 0, srcline); false, NULL, 0, 0, 0, srcline);
} }
......
...@@ -294,17 +294,17 @@ static SV *perl_process_callchain(struct perf_sample *sample, ...@@ -294,17 +294,17 @@ static SV *perl_process_callchain(struct perf_sample *sample,
goto exit; goto exit;
} }
if (node->sym) { if (node->ms.sym) {
HV *sym = newHV(); HV *sym = newHV();
if (!sym) { if (!sym) {
hv_undef(elem); hv_undef(elem);
goto exit; goto exit;
} }
if (!hv_stores(sym, "start", newSVuv(node->sym->start)) || if (!hv_stores(sym, "start", newSVuv(node->ms.sym->start)) ||
!hv_stores(sym, "end", newSVuv(node->sym->end)) || !hv_stores(sym, "end", newSVuv(node->ms.sym->end)) ||
!hv_stores(sym, "binding", newSVuv(node->sym->binding)) || !hv_stores(sym, "binding", newSVuv(node->ms.sym->binding)) ||
!hv_stores(sym, "name", newSVpvn(node->sym->name, !hv_stores(sym, "name", newSVpvn(node->ms.sym->name,
node->sym->namelen)) || node->ms.sym->namelen)) ||
!hv_stores(elem, "sym", newRV_noinc((SV*)sym))) { !hv_stores(elem, "sym", newRV_noinc((SV*)sym))) {
hv_undef(sym); hv_undef(sym);
hv_undef(elem); hv_undef(elem);
...@@ -312,8 +312,8 @@ static SV *perl_process_callchain(struct perf_sample *sample, ...@@ -312,8 +312,8 @@ static SV *perl_process_callchain(struct perf_sample *sample,
} }
} }
if (node->map) { if (node->ms.map) {
struct map *map = node->map; struct map *map = node->ms.map;
const char *dsoname = "[unknown]"; const char *dsoname = "[unknown]";
if (map && map->dso) { if (map && map->dso) {
if (symbol_conf.show_kernel_path && map->dso->long_name) if (symbol_conf.show_kernel_path && map->dso->long_name)
......
...@@ -428,24 +428,24 @@ static PyObject *python_process_callchain(struct perf_sample *sample, ...@@ -428,24 +428,24 @@ static PyObject *python_process_callchain(struct perf_sample *sample,
pydict_set_item_string_decref(pyelem, "ip", pydict_set_item_string_decref(pyelem, "ip",
PyLong_FromUnsignedLongLong(node->ip)); PyLong_FromUnsignedLongLong(node->ip));
if (node->sym) { if (node->ms.sym) {
PyObject *pysym = PyDict_New(); PyObject *pysym = PyDict_New();
if (!pysym) if (!pysym)
Py_FatalError("couldn't create Python dictionary"); Py_FatalError("couldn't create Python dictionary");
pydict_set_item_string_decref(pysym, "start", pydict_set_item_string_decref(pysym, "start",
PyLong_FromUnsignedLongLong(node->sym->start)); PyLong_FromUnsignedLongLong(node->ms.sym->start));
pydict_set_item_string_decref(pysym, "end", pydict_set_item_string_decref(pysym, "end",
PyLong_FromUnsignedLongLong(node->sym->end)); PyLong_FromUnsignedLongLong(node->ms.sym->end));
pydict_set_item_string_decref(pysym, "binding", pydict_set_item_string_decref(pysym, "binding",
_PyLong_FromLong(node->sym->binding)); _PyLong_FromLong(node->ms.sym->binding));
pydict_set_item_string_decref(pysym, "name", pydict_set_item_string_decref(pysym, "name",
_PyUnicode_FromStringAndSize(node->sym->name, _PyUnicode_FromStringAndSize(node->ms.sym->name,
node->sym->namelen)); node->ms.sym->namelen));
pydict_set_item_string_decref(pyelem, "sym", pysym); pydict_set_item_string_decref(pyelem, "sym", pysym);
} }
if (node->map) { if (node->ms.map) {
const char *dsoname = get_dsoname(node->map); const char *dsoname = get_dsoname(node->ms.map);
pydict_set_item_string_decref(pyelem, "dso", pydict_set_item_string_decref(pyelem, "dso",
_PyUnicode_FromString(dsoname)); _PyUnicode_FromString(dsoname));
......
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