Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 288628
b: refs/heads/master
c: a978f2a
h: refs/heads/master
v: v3
  • Loading branch information
Akihiro Nagai authored and Arnaldo Carvalho de Melo committed Jan 30, 2012
1 parent 1101027 commit cb468bb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9558259697b827106b464648e850e568e0b0c931
refs/heads/master: a978f2ab4166a84c77d0f846f59690f2a892d058
2 changes: 1 addition & 1 deletion trunk/tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ OPTIONS
-f::
--fields::
Comma separated list of fields to print. Options are:
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr.
comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff.
Field list can be prepended with the type, trace, sw or hw,
to indicate to which event type the field list applies.
e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace
Expand Down
23 changes: 19 additions & 4 deletions trunk/tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ enum perf_output_field {
PERF_OUTPUT_SYM = 1U << 8,
PERF_OUTPUT_DSO = 1U << 9,
PERF_OUTPUT_ADDR = 1U << 10,
PERF_OUTPUT_SYMOFFSET = 1U << 11,
};

struct output_option {
Expand All @@ -57,6 +58,7 @@ struct output_option {
{.str = "sym", .field = PERF_OUTPUT_SYM},
{.str = "dso", .field = PERF_OUTPUT_DSO},
{.str = "addr", .field = PERF_OUTPUT_ADDR},
{.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
};

/* default set to maintain compatibility with current format */
Expand Down Expand Up @@ -193,6 +195,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
"to symbols.\n");
return -EINVAL;
}
if (PRINT_FIELD(SYMOFFSET) && !PRINT_FIELD(SYM)) {
pr_err("Display of offsets requested but symbol is not"
"selected.\n");
return -EINVAL;
}
if (PRINT_FIELD(DSO) && !PRINT_FIELD(IP) && !PRINT_FIELD(ADDR)) {
pr_err("Display of DSO requested but neither sample IP nor "
"sample address\nis selected. Hence, no addresses to convert "
Expand Down Expand Up @@ -353,7 +360,10 @@ static void print_sample_addr(union perf_event *event,

if (PRINT_FIELD(SYM)) {
printf(" ");
symbol__fprintf_symname(al.sym, stdout);
if (PRINT_FIELD(SYMOFFSET))
symbol__fprintf_symname_offs(al.sym, &al, stdout);
else
symbol__fprintf_symname(al.sym, stdout);
}

if (PRINT_FIELD(DSO)) {
Expand All @@ -378,7 +388,8 @@ static void print_sample_bts(union perf_event *event,
else
printf("\n");
perf_event__print_ip(event, sample, machine, evsel,
PRINT_FIELD(SYM), PRINT_FIELD(DSO));
PRINT_FIELD(SYM), PRINT_FIELD(DSO),
PRINT_FIELD(SYMOFFSET));
}

printf(" => ");
Expand Down Expand Up @@ -421,7 +432,8 @@ static void process_event(union perf_event *event __unused,
else
printf("\n");
perf_event__print_ip(event, sample, machine, evsel,
PRINT_FIELD(SYM), PRINT_FIELD(DSO));
PRINT_FIELD(SYM), PRINT_FIELD(DSO),
PRINT_FIELD(SYMOFFSET));
}

printf("\n");
Expand Down Expand Up @@ -1131,7 +1143,10 @@ static const struct option options[] = {
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
"Look for files with symbols relative to this directory"),
OPT_CALLBACK('f', "fields", NULL, "str",
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr",
"comma separated output fields prepend with 'type:'. "
"Valid types: hw,sw,trace,raw. "
"Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
"addr,symoff",
parse_output_fields),
OPT_BOOLEAN('a', "all-cpus", &system_wide,
"system-wide collection from all CPUs"),
Expand Down
8 changes: 6 additions & 2 deletions trunk/tools/perf/util/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,

void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
struct machine *machine, struct perf_evsel *evsel,
int print_sym, int print_dso)
int print_sym, int print_dso, int print_symoffset)
{
struct addr_location al;
struct callchain_cursor *cursor = &evsel->hists.callchain_cursor;
Expand Down Expand Up @@ -1340,7 +1340,11 @@ void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
printf("%16" PRIx64, sample->ip);
if (print_sym) {
printf(" ");
symbol__fprintf_symname(al.sym, stdout);
if (print_symoffset)
symbol__fprintf_symname_offs(al.sym, &al,
stdout);
else
symbol__fprintf_symname(al.sym, stdout);
}

if (print_dso) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/tools/perf/util/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,

void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
struct machine *machine, struct perf_evsel *evsel,
int print_sym, int print_dso);
int print_sym, int print_dso, int print_symoffset);

int perf_session__cpu_bitmap(struct perf_session *session,
const char *cpu_list, unsigned long *cpu_bitmap);
Expand Down
24 changes: 17 additions & 7 deletions trunk/tools/perf/util/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,26 @@ static size_t symbol__fprintf(struct symbol *sym, FILE *fp)
sym->name);
}

size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, FILE *fp)
{
const char *symname;
unsigned long offset;
size_t length;

if (sym && sym->name)
symname = sym->name;
else
symname = "[unknown]";
if (sym && sym->name) {
length = fprintf(fp, "%s", sym->name);
if (al) {
offset = al->addr - sym->start;
length += fprintf(fp, "+0x%lx", offset);
}
return length;
} else
return fprintf(fp, "[unknown]");
}

return fprintf(fp, "%s", symname);
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
{
return symbol__fprintf_symname_offs(sym, NULL, fp);
}

void dso__set_long_name(struct dso *dso, char *name)
Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ void machines__destroy_guest_kernel_maps(struct rb_root *machines);

int symbol__init(void);
void symbol__exit(void);
size_t symbol__fprintf_symname_offs(const struct symbol *sym,
const struct addr_location *al, FILE *fp);
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp);
bool symbol_type__is_a(char symbol_type, enum map_type map_type);

Expand Down

0 comments on commit cb468bb

Please sign in to comment.