perf evsel: Rename print_ip() to fprintf_sym()
As it receives a FILE, and its more than just the IP, which can even be requested not to be printed. For consistency with other similar methods in tools/perf/, name it as perf_evsel__fprintf_sym() and make it return the number of bytes printed, just like 'fprintf(3)' Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-84gawlqa3lhk63nf0t9vnqnn@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
566a08859f
commit
ff0c107806
|
@ -579,8 +579,8 @@ static void print_sample_bts(struct perf_sample *sample,
|
||||||
print_opts &= ~PRINT_IP_OPT_SRCLINE;
|
print_opts &= ~PRINT_IP_OPT_SRCLINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
perf_evsel__print_ip(evsel, sample, al, 0, print_opts,
|
perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts,
|
||||||
scripting_max_stack, stdout);
|
scripting_max_stack, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print branch_to information */
|
/* print branch_to information */
|
||||||
|
@ -788,9 +788,9 @@ static void process_event(struct perf_script *script,
|
||||||
else
|
else
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
perf_evsel__print_ip(evsel, sample, al, 0,
|
perf_evsel__fprintf_sym(evsel, sample, al, 0,
|
||||||
output[attr->type].print_ip_opts,
|
output[attr->type].print_ip_opts,
|
||||||
scripting_max_stack, stdout);
|
scripting_max_stack, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PRINT_FIELD(IREGS))
|
if (PRINT_FIELD(IREGS))
|
||||||
|
|
|
@ -2203,8 +2203,8 @@ signed_print:
|
||||||
event->header.type);
|
event->header.type);
|
||||||
goto out_put;
|
goto out_put;
|
||||||
}
|
}
|
||||||
perf_evsel__print_ip(evsel, sample, &al, 38, print_opts,
|
perf_evsel__fprintf_sym(evsel, sample, &al, 38, print_opts,
|
||||||
scripting_max_stack, trace->output);
|
scripting_max_stack, trace->output);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
ttrace->entry_pending = false;
|
ttrace->entry_pending = false;
|
||||||
|
|
|
@ -1953,11 +1953,12 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
|
int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
|
||||||
struct addr_location *al, int left_alignment,
|
struct addr_location *al, int left_alignment,
|
||||||
unsigned int print_opts, unsigned int stack_depth,
|
unsigned int print_opts, unsigned int stack_depth,
|
||||||
FILE *fp)
|
FILE *fp)
|
||||||
{
|
{
|
||||||
|
int printed = 0;
|
||||||
struct callchain_cursor_node *node;
|
struct callchain_cursor_node *node;
|
||||||
int print_ip = print_opts & PRINT_IP_OPT_IP;
|
int print_ip = print_opts & PRINT_IP_OPT_IP;
|
||||||
int print_sym = print_opts & PRINT_IP_OPT_SYM;
|
int print_sym = print_opts & PRINT_IP_OPT_SYM;
|
||||||
|
@ -1975,7 +1976,7 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
|
||||||
stack_depth) != 0) {
|
stack_depth) != 0) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
error("Failed to resolve callchain. Skipping\n");
|
error("Failed to resolve callchain. Skipping\n");
|
||||||
return;
|
return printed;
|
||||||
}
|
}
|
||||||
callchain_cursor_commit(&callchain_cursor);
|
callchain_cursor_commit(&callchain_cursor);
|
||||||
|
|
||||||
|
@ -1992,71 +1993,66 @@ void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
|
||||||
if (node->sym && node->sym->ignore)
|
if (node->sym && node->sym->ignore)
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
|
printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
|
||||||
|
|
||||||
if (print_ip)
|
if (print_ip)
|
||||||
fprintf(fp, "%c%16" PRIx64, s, node->ip);
|
printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
|
||||||
|
|
||||||
if (node->map)
|
if (node->map)
|
||||||
addr = node->map->map_ip(node->map, node->ip);
|
addr = node->map->map_ip(node->map, node->ip);
|
||||||
|
|
||||||
if (print_sym) {
|
if (print_sym) {
|
||||||
fprintf(fp, " ");
|
printed += fprintf(fp, " ");
|
||||||
if (print_symoffset) {
|
if (print_symoffset) {
|
||||||
node_al.addr = addr;
|
node_al.addr = addr;
|
||||||
node_al.map = node->map;
|
node_al.map = node->map;
|
||||||
symbol__fprintf_symname_offs(node->sym,
|
printed += symbol__fprintf_symname_offs(node->sym, &node_al, fp);
|
||||||
&node_al,
|
|
||||||
fp);
|
|
||||||
} else
|
} else
|
||||||
symbol__fprintf_symname(node->sym, fp);
|
printed += symbol__fprintf_symname(node->sym, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_dso) {
|
if (print_dso) {
|
||||||
fprintf(fp, " (");
|
printed += fprintf(fp, " (");
|
||||||
map__fprintf_dsoname(node->map, fp);
|
printed += map__fprintf_dsoname(node->map, fp);
|
||||||
fprintf(fp, ")");
|
printed += fprintf(fp, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_srcline)
|
if (print_srcline)
|
||||||
map__fprintf_srcline(node->map, addr, "\n ",
|
printed += map__fprintf_srcline(node->map, addr, "\n ", fp);
|
||||||
fp);
|
|
||||||
|
|
||||||
if (!print_oneline)
|
if (!print_oneline)
|
||||||
fprintf(fp, "\n");
|
printed += fprintf(fp, "\n");
|
||||||
|
|
||||||
stack_depth--;
|
stack_depth--;
|
||||||
next:
|
next:
|
||||||
callchain_cursor_advance(&callchain_cursor);
|
callchain_cursor_advance(&callchain_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if (!(al->sym && al->sym->ignore)) {
|
||||||
if (al->sym && al->sym->ignore)
|
printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
|
||||||
return;
|
|
||||||
|
|
||||||
fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
|
|
||||||
|
|
||||||
if (print_ip)
|
if (print_ip)
|
||||||
fprintf(fp, "%16" PRIx64, sample->ip);
|
printed += fprintf(fp, "%16" PRIx64, sample->ip);
|
||||||
|
|
||||||
if (print_sym) {
|
if (print_sym) {
|
||||||
fprintf(fp, " ");
|
printed += fprintf(fp, " ");
|
||||||
if (print_symoffset)
|
if (print_symoffset)
|
||||||
symbol__fprintf_symname_offs(al->sym, al,
|
printed += symbol__fprintf_symname_offs(al->sym, al, fp);
|
||||||
fp);
|
|
||||||
else
|
else
|
||||||
symbol__fprintf_symname(al->sym, fp);
|
printed += symbol__fprintf_symname(al->sym, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_dso) {
|
if (print_dso) {
|
||||||
fprintf(fp, " (");
|
printed += fprintf(fp, " (");
|
||||||
map__fprintf_dsoname(al->map, fp);
|
printed += map__fprintf_dsoname(al->map, fp);
|
||||||
fprintf(fp, ")");
|
printed += fprintf(fp, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_srcline)
|
if (print_srcline)
|
||||||
map__fprintf_srcline(al->map, al->addr, "\n ", fp);
|
printed += map__fprintf_srcline(al->map, al->addr, "\n ", fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return printed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int perf_session__cpu_bitmap(struct perf_session *session,
|
int perf_session__cpu_bitmap(struct perf_session *session,
|
||||||
|
|
|
@ -104,10 +104,10 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
|
||||||
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
||||||
unsigned int type);
|
unsigned int type);
|
||||||
|
|
||||||
void perf_evsel__print_ip(struct perf_evsel *evsel, struct perf_sample *sample,
|
int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample,
|
||||||
struct addr_location *al, int left_alignment,
|
struct addr_location *al, int left_alignment,
|
||||||
unsigned int print_opts, unsigned int stack_depth,
|
unsigned int print_opts, unsigned int stack_depth,
|
||||||
FILE *fp);
|
FILE *fp);
|
||||||
|
|
||||||
int perf_session__cpu_bitmap(struct perf_session *session,
|
int perf_session__cpu_bitmap(struct perf_session *session,
|
||||||
const char *cpu_list, unsigned long *cpu_bitmap);
|
const char *cpu_list, unsigned long *cpu_bitmap);
|
||||||
|
|
Loading…
Reference in New Issue