aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/perf/util/evsel_fprintf.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/perf/util/evsel_fprintf.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c
index fb498a723a00..8719b3cb5646 100644
--- a/tools/perf/util/evsel_fprintf.c
+++ b/tools/perf/util/evsel_fprintf.c
@@ -2,7 +2,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <stdbool.h>
-#include <traceevent/event-parse.h>
+#include "util/evlist.h"
#include "evsel.h"
#include "util/evsel_fprintf.h"
#include "util/event.h"
@@ -11,6 +11,11 @@
#include "strlist.h"
#include "symbol.h"
#include "srcline.h"
+#include "dso.h"
+
+#ifdef HAVE_LIBTRACEEVENT
+#include <traceevent/event-parse.h>
+#endif
static int comma_fprintf(FILE *fp, bool *first, const char *fmt, ...)
{
@@ -73,6 +78,7 @@ int evsel__fprintf(struct evsel *evsel, struct perf_attr_details *details, FILE
term, (u64)evsel->core.attr.sample_freq);
}
+#ifdef HAVE_LIBTRACEEVENT
if (details->trace_fields) {
struct tep_format_field *field;
@@ -95,11 +101,13 @@ int evsel__fprintf(struct evsel *evsel, struct perf_attr_details *details, FILE
field = field->next;
}
}
+#endif
out:
fputc('\n', fp);
return ++printed;
}
+#ifndef PYTHON_PERF
int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
unsigned int print_opts, struct callchain_cursor *cursor,
struct strlist *bt_stop_list, FILE *fp)
@@ -109,6 +117,7 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
int print_ip = print_opts & EVSEL__PRINT_IP;
int print_sym = print_opts & EVSEL__PRINT_SYM;
int print_dso = print_opts & EVSEL__PRINT_DSO;
+ int print_dsoff = print_opts & EVSEL__PRINT_DSOFF;
int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
int print_oneline = print_opts & EVSEL__PRINT_ONELINE;
int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
@@ -118,9 +127,10 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
char s = print_oneline ? ' ' : '\t';
bool first = true;
- if (sample->callchain) {
- struct addr_location node_al;
+ if (cursor == NULL)
+ return fprintf(fp, "<not enough memory for the callchain cursor>%s", print_oneline ? "" : "\n");
+ if (sample->callchain) {
callchain_cursor_commit(cursor);
while (1) {
@@ -143,16 +153,19 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
if (print_arrow && !first)
printed += fprintf(fp, " <-");
+ if (map)
+ addr = map__map_ip(map, node->ip);
+
if (print_ip)
printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
- if (map)
- addr = map->map_ip(map, node->ip);
-
if (print_sym) {
+ struct addr_location node_al;
+
+ addr_location__init(&node_al);
printed += fprintf(fp, " ");
node_al.addr = addr;
- node_al.map = map;
+ node_al.map = map__get(map);
if (print_symoffset) {
printed += __symbol__fprintf_symname_offs(sym, &node_al,
@@ -162,13 +175,11 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
printed += __symbol__fprintf_symname(sym, &node_al,
print_unknown_as_addr, fp);
}
+ addr_location__exit(&node_al);
}
- if (print_dso && (!sym || !sym->inlined)) {
- printed += fprintf(fp, " (");
- printed += map__fprintf_dsoname(map, fp);
- printed += fprintf(fp, ")");
- }
+ if (print_dso && (!sym || !sym->inlined))
+ printed += map__fprintf_dsoname_dsoff(map, print_dsoff, addr, fp);
if (print_srcline)
printed += map__fprintf_srcline(map, addr, "\n ", fp);
@@ -202,6 +213,7 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
int print_ip = print_opts & EVSEL__PRINT_IP;
int print_sym = print_opts & EVSEL__PRINT_SYM;
int print_dso = print_opts & EVSEL__PRINT_DSO;
+ int print_dsoff = print_opts & EVSEL__PRINT_DSOFF;
int print_symoffset = print_opts & EVSEL__PRINT_SYMOFFSET;
int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
@@ -227,11 +239,8 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
}
}
- if (print_dso) {
- printed += fprintf(fp, " (");
- printed += map__fprintf_dsoname(al->map, fp);
- printed += fprintf(fp, ")");
- }
+ if (print_dso)
+ printed += map__fprintf_dsoname_dsoff(al->map, print_dsoff, al->addr, fp);
if (print_srcline)
printed += map__fprintf_srcline(al->map, al->addr, "\n ", fp);
@@ -239,3 +248,4 @@ int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
return printed;
}
+#endif /* PYTHON_PERF */