perf script: split sym format option into ip, sym, dso
cover perf script: split sym format option into ip, sym, dso
The option to dump events with a custom field selection assumes "sym" means instruction pointer/callchain and the conversions to symbol and dso. This series adds "ip" to mean dump the instruction pointer/callchain and shifts the meaning of "sym" to symbol conversion of addresses. The "dso" option further splits the old "sym" format into symbols and the dso it comes from.
David Ahern (2):
perf script: "sym" field really means show IP data perf script: make printing of dso a separate field option
tools/perf/Documentation/perf-script.txt | 10 +++--- tools/perf/builtin-script.c | 38 ++++++++++++++----- tools/perf/util/session.c | 57 +++++++++++++++++++----------- tools/perf/util/session.h | 5 ++- 4 files changed, 72 insertions(+), 38 deletions(-)
Signature · 1 line
1.7.5.1
PATCH 1/2 perf script: "sym" field really means show IP data
Currently the "sym" output field is used to dump instruction pointers and callchain stack. Sample addresses can also be converted to symbols, so the meaning of "sym" needs to be fixed. This patch adds an "ip" option and if it is selected the user can also opt to dump symbols for them. If the user opts to dump IP without syms only the address is shown.
--- tools/perf/Documentation/perf-script.txt | 10 +++--- tools/perf/builtin-script.c | 31 ++++++++++++------ tools/perf/util/session.c | 50 +++++++++++++++++------------ tools/perf/util/session.h | 5 ++- 4 files changed, 58 insertions(+), 38 deletions(-)
tools/perf/Documentation/perf-script.txt +5 -5
@@ -115,10 +115,10 @@ OPTIONS -f:: --fields:: Comma separated list of fields to print. Options are: - comm, tid, pid, time, cpu, event, trace, sym. Field + comm, tid, pid, time, cpu, event, trace, ip, sym. 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,sym and -f trace:time,cpu,trace + e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace perf script -f <fields>
@@ -132,17 +132,17 @@ OPTIONS The arguments are processed in the order received. A later usage can reset a prior request. e.g.: - -f trace: -f comm,tid,time,sym + -f trace: -f comm,tid,time,ip,sym The first -f suppresses trace events (field list is ""), but then the - second invocation sets the fields to comm,tid,time,sym. In this case a + second invocation sets the fields to comm,tid,time,ip,sym. In this case a warning is given to the user: "Overriding previous field request for all events." Alternativey, consider the order: - -f comm,tid,time,sym -f trace: + -f comm,tid,time,ip,sym -f trace: The first -f sets the fields for all events and the second -f suppresses trace events. The user is given a warning message about
tools/perf/builtin-script.c +21 -10
@@ -31,7 +31,8 @@ enum perf_output_field {PERF_OUTPUT_CPU =1U <<4 ,PERF_OUTPUT_EVNAME =1U <<5 ,PERF_OUTPUT_TRACE =1U <<6 , - PERF_OUTPUT_SYM = 1U << 7, +PERF_OUTPUT_IP =1U <<7 , + PERF_OUTPUT_SYM = 1U << 8, }; struct output_option {
@@ -45,6 +46,7 @@ struct output_option { {.str = "cpu", .field = PERF_OUTPUT_CPU}, {.str = "event", .field = PERF_OUTPUT_EVNAME}, {.str = "trace", .field = PERF_OUTPUT_TRACE}, + {.str = "ip", .field = PERF_OUTPUT_IP}, {.str = "sym", .field = PERF_OUTPUT_SYM}, };
@@ -61,7 +63,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -71,7 +74,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -89,7 +93,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -158,15 +163,20 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, !perf_session__has_traces(session, "record -R"))return -EINVAL ; -if (PRINT_FIELD (SYM )) { +if (PRINT_FIELD (IP )) {if (perf_event_attr__check_stype (attr,PERF_SAMPLE_IP ,"IP" , -PERF_OUTPUT_SYM )) +PERF_OUTPUT_IP ))return -EINVAL ;if (!no_callchain && !(attr->sample_type &PERF_SAMPLE_CALLCHAIN )) symbol_conf.use_callchain = false; } +if (PRINT_FIELD (SYM ) && !PRINT_FIELD (IP )) { +pr_err ("Display of symbols requested but IP is not selected.\n" +"No addresses to convert to symbols.\n" ); +return -EINVAL ; + }if ((PRINT_FIELD (PID ) ||PRINT_FIELD (TID )) && perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
@@ -231,7 +241,7 @@ static void print_sample_start(struct perf_sample *sample,if (PRINT_FIELD (COMM )) {if (latency_format)printf ("%8.8s " , thread->comm); -else if (PRINT_FIELD (SYM ) && symbol_conf.use_callchain) +else if (PRINT_FIELD (IP ) && symbol_conf.use_callchain)printf ("%s " , thread->comm);else printf ("%16s " , thread->comm);
@@ -289,12 +299,13 @@ static void process_event(union perf_event *event __unused,print_trace_event (sample->cpu, sample->raw_data, sample->raw_size); -if (PRINT_FIELD (SYM )) { +if (PRINT_FIELD (IP )) {if (!symbol_conf.use_callchain)printf (" " );else printf ("\n" ); -perf_session__print_symbols (event, sample, session); +perf_session__print_ip (event, sample, session, +PRINT_FIELD (SYM )); }printf ("\n" );
@@ -986,7 +997,7 @@ 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,sym" , +"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym" , parse_output_fields),OPT_END ()
tools/perf/util/session.c +29 -21
70 lines not on this page · raw message
tools/perf/util/session.h +3 -2
@@ -165,8 +165,9 @@ static inline int perf_session__parse_sample(struct perf_session *session,struct perf_evsel *perf_session__find_first_evtype (struct perf_session *session,unsigned int type); -void perf_session__print_symbols (union perf_event *event, +void perf_session__print_ip (union perf_event *event,struct perf_sample *sample, -struct perf_session *session); +struct perf_session *session, +int print_sym);#endif /* __PERF_SESSION_H */
Signature · 1 line
1.7.5.1
[tip:perf/core] perf script: "sym" field really means show IP data
Commit-ID: 787bef174f055343c69a9639e6e05a564980ed4c Gitweb: http://git.kernel.org/tip/787bef174f055343c69a9639e6e05a564980ed4c Author: David Ahern <[email protected]> AuthorDate: Fri, 27 May 2011 14:28:43 -0600 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 2 Jun 2011 13:28:34 -0300
perf script: "sym" field really means show IP data
Currently the "sym" output field is used to dump instruction pointers and callchain stack. Sample addresses can also be converted to symbols, so the meaning of "sym" needs to be fixed. This patch adds an "ip" option and if it is selected the user can also opt to dump symbols for them. If the user opts to dump IP without syms only the address is shown.
--- tools/perf/Documentation/perf-script.txt | 10 +++--- tools/perf/builtin-script.c | 31 ++++++++++++------ tools/perf/util/session.c | 50 +++++++++++++++++------------ tools/perf/util/session.h | 5 ++- 4 files changed, 58 insertions(+), 38 deletions(-)
tools/perf/Documentation/perf-script.txt +5 -5
@@ -115,10 +115,10 @@ OPTIONS -f:: --fields:: Comma separated list of fields to print. Options are: - comm, tid, pid, time, cpu, event, trace, sym. Field + comm, tid, pid, time, cpu, event, trace, ip, sym. 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,sym and -f trace:time,cpu,trace + e.g., -f sw:comm,tid,time,ip,sym and -f trace:time,cpu,trace perf script -f <fields>
@@ -132,17 +132,17 @@ OPTIONS The arguments are processed in the order received. A later usage can reset a prior request. e.g.: - -f trace: -f comm,tid,time,sym + -f trace: -f comm,tid,time,ip,sym The first -f suppresses trace events (field list is ""), but then the - second invocation sets the fields to comm,tid,time,sym. In this case a + second invocation sets the fields to comm,tid,time,ip,sym. In this case a warning is given to the user: "Overriding previous field request for all events." Alternativey, consider the order: - -f comm,tid,time,sym -f trace: + -f comm,tid,time,ip,sym -f trace: The first -f sets the fields for all events and the second -f suppresses trace events. The user is given a warning message about
tools/perf/builtin-script.c +21 -10
@@ -30,7 +30,8 @@ enum perf_output_field {PERF_OUTPUT_CPU =1U <<4 ,PERF_OUTPUT_EVNAME =1U <<5 ,PERF_OUTPUT_TRACE =1U <<6 , - PERF_OUTPUT_SYM = 1U << 7, +PERF_OUTPUT_IP =1U <<7 , + PERF_OUTPUT_SYM = 1U << 8, }; struct output_option {
@@ -44,6 +45,7 @@ struct output_option { {.str = "cpu", .field = PERF_OUTPUT_CPU}, {.str = "event", .field = PERF_OUTPUT_EVNAME}, {.str = "trace", .field = PERF_OUTPUT_TRACE}, + {.str = "ip", .field = PERF_OUTPUT_IP}, {.str = "sym", .field = PERF_OUTPUT_SYM}, };
@@ -60,7 +62,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -70,7 +73,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -88,7 +92,8 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME | - PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM, +PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | + PERF_OUTPUT_SYM, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -157,15 +162,20 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, !perf_session__has_traces(session, "record -R"))return -EINVAL ; -if (PRINT_FIELD (SYM )) { +if (PRINT_FIELD (IP )) {if (perf_event_attr__check_stype (attr,PERF_SAMPLE_IP ,"IP" , -PERF_OUTPUT_SYM )) +PERF_OUTPUT_IP ))return -EINVAL ;if (!no_callchain && !(attr->sample_type &PERF_SAMPLE_CALLCHAIN )) symbol_conf.use_callchain = false; } +if (PRINT_FIELD (SYM ) && !PRINT_FIELD (IP )) { +pr_err ("Display of symbols requested but IP is not selected.\n" +"No addresses to convert to symbols.\n" ); +return -EINVAL ; + }if ((PRINT_FIELD (PID ) ||PRINT_FIELD (TID )) && perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
@@ -230,7 +240,7 @@ static void print_sample_start(struct perf_sample *sample,if (PRINT_FIELD (COMM )) {if (latency_format)printf ("%8.8s " , thread->comm); -else if (PRINT_FIELD (SYM ) && symbol_conf.use_callchain) +else if (PRINT_FIELD (IP ) && symbol_conf.use_callchain)printf ("%s " , thread->comm);else printf ("%16s " , thread->comm);
@@ -288,12 +298,13 @@ static void process_event(union perf_event *event __unused,print_trace_event (sample->cpu, sample->raw_data, sample->raw_size); -if (PRINT_FIELD (SYM )) { +if (PRINT_FIELD (IP )) {if (!symbol_conf.use_callchain)printf (" " );else printf ("\n" ); -perf_session__print_symbols (event, sample, session); +perf_session__print_ip (event, sample, session, +PRINT_FIELD (SYM )); }printf ("\n" );
@@ -985,7 +996,7 @@ 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,sym" , +"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym" , parse_output_fields),OPT_END ()
tools/perf/util/session.c +29 -21
70 lines not on this page · raw message
tools/perf/util/session.h +3 -2
@@ -167,8 +167,9 @@ static inline int perf_session__parse_sample(struct perf_session *session,struct perf_evsel *perf_session__find_first_evtype (struct perf_session *session,unsigned int type); -void perf_session__print_symbols (union perf_event *event, +void perf_session__print_ip (union perf_event *event,struct perf_sample *sample, -struct perf_session *session); +struct perf_session *session, +int print_sym);#endif /* __PERF_SESSION_H */
PATCH 2/2 perf script: make printing of dso a separate field option
In reply to David AhernThe 'sym' option displays both the function name and the DSO it comes from. Split the display of the dso into a separate option. This allows display of the ip address and symbol without the dso, thus shortening line lengths - and decluttering the output a bit.
--- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/builtin-script.c | 17 ++++++++++++----- tools/perf/util/session.c | 13 ++++++++++--- tools/perf/util/session.h | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-)
tools/perf/Documentation/perf-script.txt +1 -1
@@ -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. Field + comm, tid, pid, time, cpu, event, trace, ip, sym, dso. 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
tools/perf/builtin-script.c +12 -5
@@ -33,6 +33,7 @@ enum perf_output_field {PERF_OUTPUT_TRACE =1U <<6 ,PERF_OUTPUT_IP =1U <<7 ,PERF_OUTPUT_SYM =1U <<8 , + PERF_OUTPUT_DSO = 1U << 9, }; struct output_option {
@@ -48,6 +49,7 @@ struct output_option { {.str = "trace", .field = PERF_OUTPUT_TRACE}, {.str = "ip", .field = PERF_OUTPUT_IP}, {.str = "sym", .field = PERF_OUTPUT_SYM}, + {.str = "dso", .field = PERF_OUTPUT_DSO}, };/* default set to maintain compatibility with current format */
@@ -64,7 +66,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -75,7 +77,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -94,7 +96,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -177,6 +179,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, "No addresses to convert to symbols.\n");return -EINVAL ; } +if (PRINT_FIELD (DSO ) && !PRINT_FIELD (IP )) { +pr_err ("Display of DSO requested but IP is not selected.\n" +"No addresses to convert to dso.\n" ); +return -EINVAL ; + }if ((PRINT_FIELD (PID ) ||PRINT_FIELD (TID )) && perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
@@ -305,7 +312,7 @@ static void process_event(union perf_event *event __unused,else printf ("\n" );perf_session__print_ip (event, sample, session, -PRINT_FIELD (SYM )); +PRINT_FIELD (SYM ),PRINT_FIELD (DSO )); }printf ("\n" );
@@ -997,7 +1004,7 @@ 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" , +"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso" , parse_output_fields),OPT_END ()
tools/perf/util/session.c +10 -3
@@ -1171,7 +1171,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,void perf_session__print_ip (union perf_event *event,struct perf_sample *sample,struct perf_session *session, -int print_sym) +int print_sym,int print_dso) {struct addr_location al;const char *symname, *dsoname;
@@ -1207,12 +1207,15 @@ void perf_session__print_ip(union perf_event *event,else symname ="" ; +printf (" %s" , symname); + } +if (print_dso) {if (node->map && node->map->dso && node->map->dso->name) dsoname = node->map->dso->name;else dsoname ="" ; -printf (" %s (%s)" , symname, dsoname); +printf (" (%s)" , dsoname); }printf ("\n" );
@@ -1227,12 +1230,16 @@ void perf_session__print_ip(union perf_event *event,else symname ="" ; +printf (" %s" , symname); + } + +if (print_dso) {if (al.map && al.map->dso && al.map->dso->name) dsoname = al.map->dso->name;else dsoname ="" ; -printf (" %s (%s)" , symname, dsoname); +printf (" (%s)" , dsoname); } } }
tools/perf/util/session.h +1 -1
@@ -168,6 +168,6 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,void perf_session__print_ip (union perf_event *event,struct perf_sample *sample,struct perf_session *session, -int print_sym); +int print_sym,int print_dso);#endif /* __PERF_SESSION_H */
Signature · 1 line
1.7.5.1
[tip:perf/core] perf script: Make printing of dso a separate field option
Commit-ID: 610723f24eeb842025178a6722fa9108c4e157b6 Gitweb: http://git.kernel.org/tip/610723f24eeb842025178a6722fa9108c4e157b6 Author: David Ahern <[email protected]> AuthorDate: Fri, 27 May 2011 14:28:44 -0600 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 2 Jun 2011 13:29:14 -0300
perf script: Make printing of dso a separate field option
The 'sym' option displays both the function name and the DSO it comes from. Split the display of the dso into a separate option. This allows display of the ip address and symbol without the dso, thus shortening line lengths - and decluttering the output a bit.
--- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/builtin-script.c | 17 ++++++++++++----- tools/perf/util/session.c | 13 ++++++++++--- tools/perf/util/session.h | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-)
tools/perf/Documentation/perf-script.txt +1 -1
@@ -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. Field + comm, tid, pid, time, cpu, event, trace, ip, sym, dso. 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
tools/perf/builtin-script.c +12 -5
@@ -32,6 +32,7 @@ enum perf_output_field {PERF_OUTPUT_TRACE =1U <<6 ,PERF_OUTPUT_IP =1U <<7 ,PERF_OUTPUT_SYM =1U <<8 , + PERF_OUTPUT_DSO = 1U << 9, }; struct output_option {
@@ -47,6 +48,7 @@ struct output_option { {.str = "trace", .field = PERF_OUTPUT_TRACE}, {.str = "ip", .field = PERF_OUTPUT_IP}, {.str = "sym", .field = PERF_OUTPUT_SYM}, + {.str = "dso", .field = PERF_OUTPUT_DSO}, };/* default set to maintain compatibility with current format */
@@ -63,7 +65,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -74,7 +76,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -93,7 +95,7 @@ static struct { .fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |PERF_OUTPUT_CPU |PERF_OUTPUT_TIME |PERF_OUTPUT_EVNAME |PERF_OUTPUT_IP | - PERF_OUTPUT_SYM, + PERF_OUTPUT_SYM | PERF_OUTPUT_DSO, .invalid_fields = PERF_OUTPUT_TRACE, },
@@ -176,6 +178,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel, "No addresses to convert to symbols.\n");return -EINVAL ; } +if (PRINT_FIELD (DSO ) && !PRINT_FIELD (IP )) { +pr_err ("Display of DSO requested but IP is not selected.\n" +"No addresses to convert to dso.\n" ); +return -EINVAL ; + }if ((PRINT_FIELD (PID ) ||PRINT_FIELD (TID )) && perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
@@ -304,7 +311,7 @@ static void process_event(union perf_event *event __unused,else printf ("\n" );perf_session__print_ip (event, sample, session, -PRINT_FIELD (SYM )); +PRINT_FIELD (SYM ),PRINT_FIELD (DSO )); }printf ("\n" );
@@ -996,7 +1003,7 @@ 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" , +"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso" , parse_output_fields),OPT_END ()
tools/perf/util/session.c +10 -3
@@ -1205,7 +1205,7 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,void perf_session__print_ip (union perf_event *event,struct perf_sample *sample,struct perf_session *session, -int print_sym) +int print_sym,int print_dso) {struct addr_location al;const char *symname, *dsoname;
@@ -1241,12 +1241,15 @@ void perf_session__print_ip(union perf_event *event,else symname ="" ; +printf (" %s" , symname); + } +if (print_dso) {if (node->map && node->map->dso && node->map->dso->name) dsoname = node->map->dso->name;else dsoname ="" ; -printf (" %s (%s)" , symname, dsoname); +printf (" (%s)" , dsoname); }printf ("\n" );
@@ -1261,12 +1264,16 @@ void perf_session__print_ip(union perf_event *event,else symname ="" ; +printf (" %s" , symname); + } + +if (print_dso) {if (al.map && al.map->dso && al.map->dso->name) dsoname = al.map->dso->name;else dsoname ="" ; -printf (" %s (%s)" , symname, dsoname); +printf (" (%s)" , dsoname); } } }
tools/perf/util/session.h +1 -1
@@ -170,6 +170,6 @@ struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,void perf_session__print_ip (union perf_event *event,struct perf_sample *sample,struct perf_session *session, -int print_sym); +int print_sym,int print_dso);#endif /* __PERF_SESSION_H */