Commit 947b4ad1d198b7303ecc961f4939a331be0c48f0
1 parent
301120396b
Exists in
master
and in
20 other branches
perf list: Fix max event string size
Recent stalled-cycles event names were larger than the 40 chars printout used by perf list. Extend that, make it robust for future extensions and also adjust alignments in face of wider event names. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Link: http://lkml.kernel.org/n/tip-7y40wib8n009io7hjpn1dsrm@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 13 additions and 12 deletions Side-by-side Diff
tools/perf/util/parse-events.c
... | ... | @@ -929,7 +929,7 @@ |
929 | 929 | |
930 | 930 | snprintf(evt_path, MAXPATHLEN, "%s:%s", |
931 | 931 | sys_dirent.d_name, evt_dirent.d_name); |
932 | - printf(" %-42s [%s]\n", evt_path, | |
932 | + printf(" %-50s [%s]\n", evt_path, | |
933 | 933 | event_type_descriptors[PERF_TYPE_TRACEPOINT]); |
934 | 934 | } |
935 | 935 | closedir(evt_dir); |
... | ... | @@ -994,7 +994,7 @@ |
994 | 994 | else |
995 | 995 | snprintf(name, sizeof(name), "%s", syms->symbol); |
996 | 996 | |
997 | - printf(" %-42s [%s]\n", name, | |
997 | + printf(" %-50s [%s]\n", name, | |
998 | 998 | event_type_descriptors[type]); |
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | |
... | ... | @@ -1012,11 +1012,10 @@ |
1012 | 1012 | for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { |
1013 | 1013 | char *name = event_cache_name(type, op, i); |
1014 | 1014 | |
1015 | - if (event_glob != NULL && | |
1016 | - !strglobmatch(name, event_glob)) | |
1015 | + if (event_glob != NULL && !strglobmatch(name, event_glob)) | |
1017 | 1016 | continue; |
1018 | 1017 | |
1019 | - printf(" %-42s [%s]\n", name, | |
1018 | + printf(" %-50s [%s]\n", name, | |
1020 | 1019 | event_type_descriptors[PERF_TYPE_HW_CACHE]); |
1021 | 1020 | ++printed; |
1022 | 1021 | } |
1023 | 1022 | |
1024 | 1023 | |
... | ... | @@ -1026,14 +1025,16 @@ |
1026 | 1025 | return printed; |
1027 | 1026 | } |
1028 | 1027 | |
1028 | +#define MAX_NAME_LEN 100 | |
1029 | + | |
1029 | 1030 | /* |
1030 | 1031 | * Print the help text for the event symbols: |
1031 | 1032 | */ |
1032 | 1033 | void print_events(const char *event_glob) |
1033 | 1034 | { |
1034 | - struct event_symbol *syms = event_symbols; | |
1035 | 1035 | unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0; |
1036 | - char name[40]; | |
1036 | + struct event_symbol *syms = event_symbols; | |
1037 | + char name[MAX_NAME_LEN]; | |
1037 | 1038 | |
1038 | 1039 | printf("\n"); |
1039 | 1040 | printf("List of pre-defined events (to be used in -e):\n"); |
1040 | 1041 | |
... | ... | @@ -1053,10 +1054,10 @@ |
1053 | 1054 | continue; |
1054 | 1055 | |
1055 | 1056 | if (strlen(syms->alias)) |
1056 | - sprintf(name, "%s OR %s", syms->symbol, syms->alias); | |
1057 | + snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias); | |
1057 | 1058 | else |
1058 | - strcpy(name, syms->symbol); | |
1059 | - printf(" %-42s [%s]\n", name, | |
1059 | + strncpy(name, syms->symbol, MAX_NAME_LEN); | |
1060 | + printf(" %-50s [%s]\n", name, | |
1060 | 1061 | event_type_descriptors[type]); |
1061 | 1062 | |
1062 | 1063 | prev_type = type; |
1063 | 1064 | |
... | ... | @@ -1073,12 +1074,12 @@ |
1073 | 1074 | return; |
1074 | 1075 | |
1075 | 1076 | printf("\n"); |
1076 | - printf(" %-42s [%s]\n", | |
1077 | + printf(" %-50s [%s]\n", | |
1077 | 1078 | "rNNN (see 'perf list --help' on how to encode it)", |
1078 | 1079 | event_type_descriptors[PERF_TYPE_RAW]); |
1079 | 1080 | printf("\n"); |
1080 | 1081 | |
1081 | - printf(" %-42s [%s]\n", | |
1082 | + printf(" %-50s [%s]\n", | |
1082 | 1083 | "mem:<addr>[:access]", |
1083 | 1084 | event_type_descriptors[PERF_TYPE_BREAKPOINT]); |
1084 | 1085 | printf("\n"); |