diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-08-18 04:14:43 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-08-18 04:14:43 -0400 |
commit | af924aa35129edf338ebc8da6a4eae08cf7cb297 (patch) | |
tree | 45417e729d0b4f0a346963f6b76e34687df2aa5a /tools/perf | |
parent | f373da34282560c60f0c197690eecb1b2dc49fc0 (diff) | |
parent | 759e612bf96627b64fcafe4174b3f6f2dedf2c0d (diff) |
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
User visible changes:
* Warn user to rebuild target with debuginfo in 'perf probe' (Masami Hiramatsu)
* Don't truncate Intel style addresses in 'annotate'. (Alex Converse)
Infrastructure changes:
* Annotate PMU related list_head members with type info. (Cody P Schafer)
* Add the triplet used for arm64 by Android (Elliott Hughes)
* Replace thread unsafe strerror() with strerror_r() accross the
whole tools/perf/ tree (Masami Hiramatsu)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf')
35 files changed, 234 insertions, 154 deletions
diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c index 42faf369211c..49776f190abf 100644 --- a/tools/perf/arch/common.c +++ b/tools/perf/arch/common.c | |||
@@ -12,6 +12,11 @@ const char *const arm_triplets[] = { | |||
12 | NULL | 12 | NULL |
13 | }; | 13 | }; |
14 | 14 | ||
15 | const char *const arm64_triplets[] = { | ||
16 | "aarch64-linux-android-", | ||
17 | NULL | ||
18 | }; | ||
19 | |||
15 | const char *const powerpc_triplets[] = { | 20 | const char *const powerpc_triplets[] = { |
16 | "powerpc-unknown-linux-gnu-", | 21 | "powerpc-unknown-linux-gnu-", |
17 | "powerpc64-unknown-linux-gnu-", | 22 | "powerpc64-unknown-linux-gnu-", |
@@ -105,6 +110,8 @@ static const char *normalize_arch(char *arch) | |||
105 | return "x86"; | 110 | return "x86"; |
106 | if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) | 111 | if (!strcmp(arch, "sun4u") || !strncmp(arch, "sparc", 5)) |
107 | return "sparc"; | 112 | return "sparc"; |
113 | if (!strcmp(arch, "aarch64") || !strcmp(arch, "arm64")) | ||
114 | return "arm64"; | ||
108 | if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) | 115 | if (!strncmp(arch, "arm", 3) || !strcmp(arch, "sa110")) |
109 | return "arm"; | 116 | return "arm"; |
110 | if (!strncmp(arch, "s390", 4)) | 117 | if (!strncmp(arch, "s390", 4)) |
@@ -159,6 +166,8 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env, | |||
159 | 166 | ||
160 | if (!strcmp(arch, "arm")) | 167 | if (!strcmp(arch, "arm")) |
161 | path_list = arm_triplets; | 168 | path_list = arm_triplets; |
169 | else if (!strcmp(arch, "arm64")) | ||
170 | path_list = arm64_triplets; | ||
162 | else if (!strcmp(arch, "powerpc")) | 171 | else if (!strcmp(arch, "powerpc")) |
163 | path_list = powerpc_triplets; | 172 | path_list = powerpc_triplets; |
164 | else if (!strcmp(arch, "sh")) | 173 | else if (!strcmp(arch, "sh")) |
diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index ac5838e0b1bd..70385756da63 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c | |||
@@ -291,6 +291,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
291 | *missing_filename = NULL, | 291 | *missing_filename = NULL, |
292 | *update_name_list_str = NULL, | 292 | *update_name_list_str = NULL, |
293 | *kcore_filename; | 293 | *kcore_filename; |
294 | char sbuf[STRERR_BUFSIZE]; | ||
294 | 295 | ||
295 | struct perf_data_file file = { | 296 | struct perf_data_file file = { |
296 | .mode = PERF_DATA_MODE_READ, | 297 | .mode = PERF_DATA_MODE_READ, |
@@ -347,7 +348,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
347 | continue; | 348 | continue; |
348 | } | 349 | } |
349 | pr_warning("Couldn't add %s: %s\n", | 350 | pr_warning("Couldn't add %s: %s\n", |
350 | pos->s, strerror(errno)); | 351 | pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); |
351 | } | 352 | } |
352 | 353 | ||
353 | strlist__delete(list); | 354 | strlist__delete(list); |
@@ -365,7 +366,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
365 | continue; | 366 | continue; |
366 | } | 367 | } |
367 | pr_warning("Couldn't remove %s: %s\n", | 368 | pr_warning("Couldn't remove %s: %s\n", |
368 | pos->s, strerror(errno)); | 369 | pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); |
369 | } | 370 | } |
370 | 371 | ||
371 | strlist__delete(list); | 372 | strlist__delete(list); |
@@ -386,7 +387,7 @@ int cmd_buildid_cache(int argc, const char **argv, | |||
386 | continue; | 387 | continue; |
387 | } | 388 | } |
388 | pr_warning("Couldn't update %s: %s\n", | 389 | pr_warning("Couldn't update %s: %s\n", |
389 | pos->s, strerror(errno)); | 390 | pos->s, strerror_r(errno, sbuf, sizeof(sbuf))); |
390 | } | 391 | } |
391 | 392 | ||
392 | strlist__delete(list); | 393 | strlist__delete(list); |
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 0384d930480b..25d20628212e 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c | |||
@@ -103,6 +103,8 @@ static int check_emacsclient_version(void) | |||
103 | 103 | ||
104 | static void exec_woman_emacs(const char *path, const char *page) | 104 | static void exec_woman_emacs(const char *path, const char *page) |
105 | { | 105 | { |
106 | char sbuf[STRERR_BUFSIZE]; | ||
107 | |||
106 | if (!check_emacsclient_version()) { | 108 | if (!check_emacsclient_version()) { |
107 | /* This works only with emacsclient version >= 22. */ | 109 | /* This works only with emacsclient version >= 22. */ |
108 | struct strbuf man_page = STRBUF_INIT; | 110 | struct strbuf man_page = STRBUF_INIT; |
@@ -111,16 +113,19 @@ static void exec_woman_emacs(const char *path, const char *page) | |||
111 | path = "emacsclient"; | 113 | path = "emacsclient"; |
112 | strbuf_addf(&man_page, "(woman \"%s\")", page); | 114 | strbuf_addf(&man_page, "(woman \"%s\")", page); |
113 | execlp(path, "emacsclient", "-e", man_page.buf, NULL); | 115 | execlp(path, "emacsclient", "-e", man_page.buf, NULL); |
114 | warning("failed to exec '%s': %s", path, strerror(errno)); | 116 | warning("failed to exec '%s': %s", path, |
117 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
115 | } | 118 | } |
116 | } | 119 | } |
117 | 120 | ||
118 | static void exec_man_konqueror(const char *path, const char *page) | 121 | static void exec_man_konqueror(const char *path, const char *page) |
119 | { | 122 | { |
120 | const char *display = getenv("DISPLAY"); | 123 | const char *display = getenv("DISPLAY"); |
124 | |||
121 | if (display && *display) { | 125 | if (display && *display) { |
122 | struct strbuf man_page = STRBUF_INIT; | 126 | struct strbuf man_page = STRBUF_INIT; |
123 | const char *filename = "kfmclient"; | 127 | const char *filename = "kfmclient"; |
128 | char sbuf[STRERR_BUFSIZE]; | ||
124 | 129 | ||
125 | /* It's simpler to launch konqueror using kfmclient. */ | 130 | /* It's simpler to launch konqueror using kfmclient. */ |
126 | if (path) { | 131 | if (path) { |
@@ -139,24 +144,31 @@ static void exec_man_konqueror(const char *path, const char *page) | |||
139 | path = "kfmclient"; | 144 | path = "kfmclient"; |
140 | strbuf_addf(&man_page, "man:%s(1)", page); | 145 | strbuf_addf(&man_page, "man:%s(1)", page); |
141 | execlp(path, filename, "newTab", man_page.buf, NULL); | 146 | execlp(path, filename, "newTab", man_page.buf, NULL); |
142 | warning("failed to exec '%s': %s", path, strerror(errno)); | 147 | warning("failed to exec '%s': %s", path, |
148 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
143 | } | 149 | } |
144 | } | 150 | } |
145 | 151 | ||
146 | static void exec_man_man(const char *path, const char *page) | 152 | static void exec_man_man(const char *path, const char *page) |
147 | { | 153 | { |
154 | char sbuf[STRERR_BUFSIZE]; | ||
155 | |||
148 | if (!path) | 156 | if (!path) |
149 | path = "man"; | 157 | path = "man"; |
150 | execlp(path, "man", page, NULL); | 158 | execlp(path, "man", page, NULL); |
151 | warning("failed to exec '%s': %s", path, strerror(errno)); | 159 | warning("failed to exec '%s': %s", path, |
160 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
152 | } | 161 | } |
153 | 162 | ||
154 | static void exec_man_cmd(const char *cmd, const char *page) | 163 | static void exec_man_cmd(const char *cmd, const char *page) |
155 | { | 164 | { |
156 | struct strbuf shell_cmd = STRBUF_INIT; | 165 | struct strbuf shell_cmd = STRBUF_INIT; |
166 | char sbuf[STRERR_BUFSIZE]; | ||
167 | |||
157 | strbuf_addf(&shell_cmd, "%s %s", cmd, page); | 168 | strbuf_addf(&shell_cmd, "%s %s", cmd, page); |
158 | execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL); | 169 | execl("/bin/sh", "sh", "-c", shell_cmd.buf, NULL); |
159 | warning("failed to exec '%s': %s", cmd, strerror(errno)); | 170 | warning("failed to exec '%s': %s", cmd, |
171 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
160 | } | 172 | } |
161 | 173 | ||
162 | static void add_man_viewer(const char *name) | 174 | static void add_man_viewer(const char *name) |
diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 14d03edc81c2..1a4ef9cd9d5f 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c | |||
@@ -990,6 +990,7 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) | |||
990 | int err, rc = -1; | 990 | int err, rc = -1; |
991 | struct perf_evsel *pos; | 991 | struct perf_evsel *pos; |
992 | struct perf_evlist *evlist = kvm->evlist; | 992 | struct perf_evlist *evlist = kvm->evlist; |
993 | char sbuf[STRERR_BUFSIZE]; | ||
993 | 994 | ||
994 | perf_evlist__config(evlist, &kvm->opts); | 995 | perf_evlist__config(evlist, &kvm->opts); |
995 | 996 | ||
@@ -1026,12 +1027,14 @@ static int kvm_live_open_events(struct perf_kvm_stat *kvm) | |||
1026 | 1027 | ||
1027 | err = perf_evlist__open(evlist); | 1028 | err = perf_evlist__open(evlist); |
1028 | if (err < 0) { | 1029 | if (err < 0) { |
1029 | printf("Couldn't create the events: %s\n", strerror(errno)); | 1030 | printf("Couldn't create the events: %s\n", |
1031 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
1030 | goto out; | 1032 | goto out; |
1031 | } | 1033 | } |
1032 | 1034 | ||
1033 | if (perf_evlist__mmap(evlist, kvm->opts.mmap_pages, false) < 0) { | 1035 | if (perf_evlist__mmap(evlist, kvm->opts.mmap_pages, false) < 0) { |
1034 | ui__error("Failed to mmap the events: %s\n", strerror(errno)); | 1036 | ui__error("Failed to mmap the events: %s\n", |
1037 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
1035 | perf_evlist__close(evlist); | 1038 | perf_evlist__close(evlist); |
1036 | goto out; | 1039 | goto out; |
1037 | } | 1040 | } |
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index c63fa2925075..347729e29a92 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -290,8 +290,11 @@ static void cleanup_params(void) | |||
290 | 290 | ||
291 | static void pr_err_with_code(const char *msg, int err) | 291 | static void pr_err_with_code(const char *msg, int err) |
292 | { | 292 | { |
293 | char sbuf[STRERR_BUFSIZE]; | ||
294 | |||
293 | pr_err("%s", msg); | 295 | pr_err("%s", msg); |
294 | pr_debug(" Reason: %s (Code: %d)", strerror(-err), err); | 296 | pr_debug(" Reason: %s (Code: %d)", |
297 | strerror_r(-err, sbuf, sizeof(sbuf)), err); | ||
295 | pr_err("\n"); | 298 | pr_err("\n"); |
296 | } | 299 | } |
297 | 300 | ||
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 4db670d4b8da..87e28a4e33ba 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -161,7 +161,7 @@ try_again: | |||
161 | 161 | ||
162 | if (perf_evlist__apply_filters(evlist)) { | 162 | if (perf_evlist__apply_filters(evlist)) { |
163 | error("failed to set filter with %d (%s)\n", errno, | 163 | error("failed to set filter with %d (%s)\n", errno, |
164 | strerror(errno)); | 164 | strerror_r(errno, msg, sizeof(msg))); |
165 | rc = -1; | 165 | rc = -1; |
166 | goto out; | 166 | goto out; |
167 | } | 167 | } |
@@ -175,7 +175,8 @@ try_again: | |||
175 | "(current value: %u)\n", opts->mmap_pages); | 175 | "(current value: %u)\n", opts->mmap_pages); |
176 | rc = -errno; | 176 | rc = -errno; |
177 | } else { | 177 | } else { |
178 | pr_err("failed to mmap with %d (%s)\n", errno, strerror(errno)); | 178 | pr_err("failed to mmap with %d (%s)\n", errno, |
179 | strerror_r(errno, msg, sizeof(msg))); | ||
179 | rc = -errno; | 180 | rc = -errno; |
180 | } | 181 | } |
181 | goto out; | 182 | goto out; |
@@ -480,7 +481,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
480 | } | 481 | } |
481 | 482 | ||
482 | if (forks && workload_exec_errno) { | 483 | if (forks && workload_exec_errno) { |
483 | char msg[512]; | 484 | char msg[STRERR_BUFSIZE]; |
484 | const char *emsg = strerror_r(workload_exec_errno, msg, sizeof(msg)); | 485 | const char *emsg = strerror_r(workload_exec_errno, msg, sizeof(msg)); |
485 | pr_err("Workload failed: %s\n", emsg); | 486 | pr_err("Workload failed: %s\n", emsg); |
486 | err = -1; | 487 | err = -1; |
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index f5874a27b346..9c9287fbf8e9 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -428,6 +428,7 @@ static u64 get_cpu_usage_nsec_parent(void) | |||
428 | static int self_open_counters(void) | 428 | static int self_open_counters(void) |
429 | { | 429 | { |
430 | struct perf_event_attr attr; | 430 | struct perf_event_attr attr; |
431 | char sbuf[STRERR_BUFSIZE]; | ||
431 | int fd; | 432 | int fd; |
432 | 433 | ||
433 | memset(&attr, 0, sizeof(attr)); | 434 | memset(&attr, 0, sizeof(attr)); |
@@ -440,7 +441,8 @@ static int self_open_counters(void) | |||
440 | 441 | ||
441 | if (fd < 0) | 442 | if (fd < 0) |
442 | pr_err("Error: sys_perf_event_open() syscall returned " | 443 | pr_err("Error: sys_perf_event_open() syscall returned " |
443 | "with %d (%s)\n", fd, strerror(errno)); | 444 | "with %d (%s)\n", fd, |
445 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
444 | return fd; | 446 | return fd; |
445 | } | 447 | } |
446 | 448 | ||
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3e80aa10cfd8..5fe0edb1de5d 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -593,7 +593,7 @@ static int __run_perf_stat(int argc, const char **argv) | |||
593 | 593 | ||
594 | if (perf_evlist__apply_filters(evsel_list)) { | 594 | if (perf_evlist__apply_filters(evsel_list)) { |
595 | error("failed to set filter with %d (%s)\n", errno, | 595 | error("failed to set filter with %d (%s)\n", errno, |
596 | strerror(errno)); | 596 | strerror_r(errno, msg, sizeof(msg))); |
597 | return -1; | 597 | return -1; |
598 | } | 598 | } |
599 | 599 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 87a6615a40fa..a77ff6ca5fbd 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -899,7 +899,7 @@ try_again: | |||
899 | 899 | ||
900 | if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) { | 900 | if (perf_evlist__mmap(evlist, opts->mmap_pages, false) < 0) { |
901 | ui__error("Failed to mmap with %d (%s)\n", | 901 | ui__error("Failed to mmap with %d (%s)\n", |
902 | errno, strerror(errno)); | 902 | errno, strerror_r(errno, msg, sizeof(msg))); |
903 | goto out_err; | 903 | goto out_err; |
904 | } | 904 | } |
905 | 905 | ||
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index d080b9cf0354..a9e96ff49c7f 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -1750,7 +1750,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel, | |||
1750 | signed_print: | 1750 | signed_print: |
1751 | fprintf(trace->output, ") = %d", ret); | 1751 | fprintf(trace->output, ") = %d", ret); |
1752 | } else if (ret < 0 && sc->fmt->errmsg) { | 1752 | } else if (ret < 0 && sc->fmt->errmsg) { |
1753 | char bf[256]; | 1753 | char bf[STRERR_BUFSIZE]; |
1754 | const char *emsg = strerror_r(-ret, bf, sizeof(bf)), | 1754 | const char *emsg = strerror_r(-ret, bf, sizeof(bf)), |
1755 | *e = audit_errno_to_name(-ret); | 1755 | *e = audit_errno_to_name(-ret); |
1756 | 1756 | ||
@@ -2044,6 +2044,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
2044 | int err = -1, i; | 2044 | int err = -1, i; |
2045 | unsigned long before; | 2045 | unsigned long before; |
2046 | const bool forks = argc > 0; | 2046 | const bool forks = argc > 0; |
2047 | char sbuf[STRERR_BUFSIZE]; | ||
2047 | 2048 | ||
2048 | trace->live = true; | 2049 | trace->live = true; |
2049 | 2050 | ||
@@ -2105,7 +2106,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv) | |||
2105 | 2106 | ||
2106 | err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false); | 2107 | err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false); |
2107 | if (err < 0) { | 2108 | if (err < 0) { |
2108 | fprintf(trace->output, "Couldn't mmap the events: %s\n", strerror(errno)); | 2109 | fprintf(trace->output, "Couldn't mmap the events: %s\n", |
2110 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
2109 | goto out_delete_evlist; | 2111 | goto out_delete_evlist; |
2110 | } | 2112 | } |
2111 | 2113 | ||
diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 2282d41879a2..452a8474d29d 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c | |||
@@ -313,6 +313,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
313 | int status; | 313 | int status; |
314 | struct stat st; | 314 | struct stat st; |
315 | const char *prefix; | 315 | const char *prefix; |
316 | char sbuf[STRERR_BUFSIZE]; | ||
316 | 317 | ||
317 | prefix = NULL; | 318 | prefix = NULL; |
318 | if (p->option & RUN_SETUP) | 319 | if (p->option & RUN_SETUP) |
@@ -343,7 +344,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
343 | status = 1; | 344 | status = 1; |
344 | /* Check for ENOSPC and EIO errors.. */ | 345 | /* Check for ENOSPC and EIO errors.. */ |
345 | if (fflush(stdout)) { | 346 | if (fflush(stdout)) { |
346 | fprintf(stderr, "write failure on standard output: %s", strerror(errno)); | 347 | fprintf(stderr, "write failure on standard output: %s", |
348 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
347 | goto out; | 349 | goto out; |
348 | } | 350 | } |
349 | if (ferror(stdout)) { | 351 | if (ferror(stdout)) { |
@@ -351,7 +353,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) | |||
351 | goto out; | 353 | goto out; |
352 | } | 354 | } |
353 | if (fclose(stdout)) { | 355 | if (fclose(stdout)) { |
354 | fprintf(stderr, "close failed on standard output: %s", strerror(errno)); | 356 | fprintf(stderr, "close failed on standard output: %s", |
357 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
355 | goto out; | 358 | goto out; |
356 | } | 359 | } |
357 | status = 0; | 360 | status = 0; |
@@ -466,6 +469,7 @@ void pthread__unblock_sigwinch(void) | |||
466 | int main(int argc, const char **argv) | 469 | int main(int argc, const char **argv) |
467 | { | 470 | { |
468 | const char *cmd; | 471 | const char *cmd; |
472 | char sbuf[STRERR_BUFSIZE]; | ||
469 | 473 | ||
470 | /* The page_size is placed in util object. */ | 474 | /* The page_size is placed in util object. */ |
471 | page_size = sysconf(_SC_PAGE_SIZE); | 475 | page_size = sysconf(_SC_PAGE_SIZE); |
@@ -561,7 +565,7 @@ int main(int argc, const char **argv) | |||
561 | } | 565 | } |
562 | 566 | ||
563 | fprintf(stderr, "Failed to run command '%s': %s\n", | 567 | fprintf(stderr, "Failed to run command '%s': %s\n", |
564 | cmd, strerror(errno)); | 568 | cmd, strerror_r(errno, sbuf, sizeof(sbuf))); |
565 | out: | 569 | out: |
566 | return 1; | 570 | return 1; |
567 | } | 571 | } |
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index c6796d22423a..99481361b19f 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -185,9 +185,11 @@ static bool perf_test__matches(int curr, int argc, const char *argv[]) | |||
185 | static int run_test(struct test *test) | 185 | static int run_test(struct test *test) |
186 | { | 186 | { |
187 | int status, err = -1, child = fork(); | 187 | int status, err = -1, child = fork(); |
188 | char sbuf[STRERR_BUFSIZE]; | ||
188 | 189 | ||
189 | if (child < 0) { | 190 | if (child < 0) { |
190 | pr_err("failed to fork test: %s\n", strerror(errno)); | 191 | pr_err("failed to fork test: %s\n", |
192 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
191 | return -1; | 193 | return -1; |
192 | } | 194 | } |
193 | 195 | ||
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c index 142263492f6f..9b9622a33932 100644 --- a/tools/perf/tests/mmap-basic.c +++ b/tools/perf/tests/mmap-basic.c | |||
@@ -31,6 +31,7 @@ int test__basic_mmap(void) | |||
31 | unsigned int nr_events[nsyscalls], | 31 | unsigned int nr_events[nsyscalls], |
32 | expected_nr_events[nsyscalls], i, j; | 32 | expected_nr_events[nsyscalls], i, j; |
33 | struct perf_evsel *evsels[nsyscalls], *evsel; | 33 | struct perf_evsel *evsels[nsyscalls], *evsel; |
34 | char sbuf[STRERR_BUFSIZE]; | ||
34 | 35 | ||
35 | threads = thread_map__new(-1, getpid(), UINT_MAX); | 36 | threads = thread_map__new(-1, getpid(), UINT_MAX); |
36 | if (threads == NULL) { | 37 | if (threads == NULL) { |
@@ -49,7 +50,7 @@ int test__basic_mmap(void) | |||
49 | sched_setaffinity(0, sizeof(cpu_set), &cpu_set); | 50 | sched_setaffinity(0, sizeof(cpu_set), &cpu_set); |
50 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { | 51 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { |
51 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", | 52 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", |
52 | cpus->map[0], strerror(errno)); | 53 | cpus->map[0], strerror_r(errno, sbuf, sizeof(sbuf))); |
53 | goto out_free_cpus; | 54 | goto out_free_cpus; |
54 | } | 55 | } |
55 | 56 | ||
@@ -79,7 +80,7 @@ int test__basic_mmap(void) | |||
79 | if (perf_evsel__open(evsels[i], cpus, threads) < 0) { | 80 | if (perf_evsel__open(evsels[i], cpus, threads) < 0) { |
80 | pr_debug("failed to open counter: %s, " | 81 | pr_debug("failed to open counter: %s, " |
81 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", | 82 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
82 | strerror(errno)); | 83 | strerror_r(errno, sbuf, sizeof(sbuf))); |
83 | goto out_delete_evlist; | 84 | goto out_delete_evlist; |
84 | } | 85 | } |
85 | 86 | ||
@@ -89,7 +90,7 @@ int test__basic_mmap(void) | |||
89 | 90 | ||
90 | if (perf_evlist__mmap(evlist, 128, true) < 0) { | 91 | if (perf_evlist__mmap(evlist, 128, true) < 0) { |
91 | pr_debug("failed to mmap events: %d (%s)\n", errno, | 92 | pr_debug("failed to mmap events: %d (%s)\n", errno, |
92 | strerror(errno)); | 93 | strerror_r(errno, sbuf, sizeof(sbuf))); |
93 | goto out_delete_evlist; | 94 | goto out_delete_evlist; |
94 | } | 95 | } |
95 | 96 | ||
diff --git a/tools/perf/tests/open-syscall-all-cpus.c b/tools/perf/tests/open-syscall-all-cpus.c index 5fecdbd2f5f7..8fa82d1700c7 100644 --- a/tools/perf/tests/open-syscall-all-cpus.c +++ b/tools/perf/tests/open-syscall-all-cpus.c | |||
@@ -12,6 +12,7 @@ int test__open_syscall_event_on_all_cpus(void) | |||
12 | unsigned int nr_open_calls = 111, i; | 12 | unsigned int nr_open_calls = 111, i; |
13 | cpu_set_t cpu_set; | 13 | cpu_set_t cpu_set; |
14 | struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); | 14 | struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); |
15 | char sbuf[STRERR_BUFSIZE]; | ||
15 | 16 | ||
16 | if (threads == NULL) { | 17 | if (threads == NULL) { |
17 | pr_debug("thread_map__new\n"); | 18 | pr_debug("thread_map__new\n"); |
@@ -35,7 +36,7 @@ int test__open_syscall_event_on_all_cpus(void) | |||
35 | if (perf_evsel__open(evsel, cpus, threads) < 0) { | 36 | if (perf_evsel__open(evsel, cpus, threads) < 0) { |
36 | pr_debug("failed to open counter: %s, " | 37 | pr_debug("failed to open counter: %s, " |
37 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", | 38 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
38 | strerror(errno)); | 39 | strerror_r(errno, sbuf, sizeof(sbuf))); |
39 | goto out_evsel_delete; | 40 | goto out_evsel_delete; |
40 | } | 41 | } |
41 | 42 | ||
@@ -56,7 +57,7 @@ int test__open_syscall_event_on_all_cpus(void) | |||
56 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { | 57 | if (sched_setaffinity(0, sizeof(cpu_set), &cpu_set) < 0) { |
57 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", | 58 | pr_debug("sched_setaffinity() failed on CPU %d: %s ", |
58 | cpus->map[cpu], | 59 | cpus->map[cpu], |
59 | strerror(errno)); | 60 | strerror_r(errno, sbuf, sizeof(sbuf))); |
60 | goto out_close_fd; | 61 | goto out_close_fd; |
61 | } | 62 | } |
62 | for (i = 0; i < ncalls; ++i) { | 63 | for (i = 0; i < ncalls; ++i) { |
diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index 0785b64ffd6c..922bdb627950 100644 --- a/tools/perf/tests/open-syscall-tp-fields.c +++ b/tools/perf/tests/open-syscall-tp-fields.c | |||
@@ -22,6 +22,7 @@ int test__syscall_open_tp_fields(void) | |||
22 | struct perf_evlist *evlist = perf_evlist__new(); | 22 | struct perf_evlist *evlist = perf_evlist__new(); |
23 | struct perf_evsel *evsel; | 23 | struct perf_evsel *evsel; |
24 | int err = -1, i, nr_events = 0, nr_polls = 0; | 24 | int err = -1, i, nr_events = 0, nr_polls = 0; |
25 | char sbuf[STRERR_BUFSIZE]; | ||
25 | 26 | ||
26 | if (evlist == NULL) { | 27 | if (evlist == NULL) { |
27 | pr_debug("%s: perf_evlist__new\n", __func__); | 28 | pr_debug("%s: perf_evlist__new\n", __func__); |
@@ -48,13 +49,15 @@ int test__syscall_open_tp_fields(void) | |||
48 | 49 | ||
49 | err = perf_evlist__open(evlist); | 50 | err = perf_evlist__open(evlist); |
50 | if (err < 0) { | 51 | if (err < 0) { |
51 | pr_debug("perf_evlist__open: %s\n", strerror(errno)); | 52 | pr_debug("perf_evlist__open: %s\n", |
53 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
52 | goto out_delete_evlist; | 54 | goto out_delete_evlist; |
53 | } | 55 | } |
54 | 56 | ||
55 | err = perf_evlist__mmap(evlist, UINT_MAX, false); | 57 | err = perf_evlist__mmap(evlist, UINT_MAX, false); |
56 | if (err < 0) { | 58 | if (err < 0) { |
57 | pr_debug("perf_evlist__mmap: %s\n", strerror(errno)); | 59 | pr_debug("perf_evlist__mmap: %s\n", |
60 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
58 | goto out_delete_evlist; | 61 | goto out_delete_evlist; |
59 | } | 62 | } |
60 | 63 | ||
diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c index c1dc7d25f38c..a33b2daae40f 100644 --- a/tools/perf/tests/open-syscall.c +++ b/tools/perf/tests/open-syscall.c | |||
@@ -9,6 +9,7 @@ int test__open_syscall_event(void) | |||
9 | struct perf_evsel *evsel; | 9 | struct perf_evsel *evsel; |
10 | unsigned int nr_open_calls = 111, i; | 10 | unsigned int nr_open_calls = 111, i; |
11 | struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); | 11 | struct thread_map *threads = thread_map__new(-1, getpid(), UINT_MAX); |
12 | char sbuf[STRERR_BUFSIZE]; | ||
12 | 13 | ||
13 | if (threads == NULL) { | 14 | if (threads == NULL) { |
14 | pr_debug("thread_map__new\n"); | 15 | pr_debug("thread_map__new\n"); |
@@ -24,7 +25,7 @@ int test__open_syscall_event(void) | |||
24 | if (perf_evsel__open_per_thread(evsel, threads) < 0) { | 25 | if (perf_evsel__open_per_thread(evsel, threads) < 0) { |
25 | pr_debug("failed to open counter: %s, " | 26 | pr_debug("failed to open counter: %s, " |
26 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", | 27 | "tweak /proc/sys/kernel/perf_event_paranoid?\n", |
27 | strerror(errno)); | 28 | strerror_r(errno, sbuf, sizeof(sbuf))); |
28 | goto out_evsel_delete; | 29 | goto out_evsel_delete; |
29 | } | 30 | } |
30 | 31 | ||
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c index aca1a83dd13a..2ce753c1db63 100644 --- a/tools/perf/tests/perf-record.c +++ b/tools/perf/tests/perf-record.c | |||
@@ -59,6 +59,7 @@ int test__PERF_RECORD(void) | |||
59 | int err = -1, errs = 0, i, wakeups = 0; | 59 | int err = -1, errs = 0, i, wakeups = 0; |
60 | u32 cpu; | 60 | u32 cpu; |
61 | int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, }; | 61 | int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, }; |
62 | char sbuf[STRERR_BUFSIZE]; | ||
62 | 63 | ||
63 | if (evlist == NULL || argv == NULL) { | 64 | if (evlist == NULL || argv == NULL) { |
64 | pr_debug("Not enough memory to create evlist\n"); | 65 | pr_debug("Not enough memory to create evlist\n"); |
@@ -100,7 +101,8 @@ int test__PERF_RECORD(void) | |||
100 | 101 | ||
101 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); | 102 | err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask); |
102 | if (err < 0) { | 103 | if (err < 0) { |
103 | pr_debug("sched__get_first_possible_cpu: %s\n", strerror(errno)); | 104 | pr_debug("sched__get_first_possible_cpu: %s\n", |
105 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
104 | goto out_delete_evlist; | 106 | goto out_delete_evlist; |
105 | } | 107 | } |
106 | 108 | ||
@@ -110,7 +112,8 @@ int test__PERF_RECORD(void) | |||
110 | * So that we can check perf_sample.cpu on all the samples. | 112 | * So that we can check perf_sample.cpu on all the samples. |
111 | */ | 113 | */ |
112 | if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) { | 114 | if (sched_setaffinity(evlist->workload.pid, cpu_mask_size, &cpu_mask) < 0) { |
113 | pr_debug("sched_setaffinity: %s\n", strerror(errno)); | 115 | pr_debug("sched_setaffinity: %s\n", |
116 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
114 | goto out_delete_evlist; | 117 | goto out_delete_evlist; |
115 | } | 118 | } |
116 | 119 | ||
@@ -120,7 +123,8 @@ int test__PERF_RECORD(void) | |||
120 | */ | 123 | */ |
121 | err = perf_evlist__open(evlist); | 124 | err = perf_evlist__open(evlist); |
122 | if (err < 0) { | 125 | if (err < 0) { |
123 | pr_debug("perf_evlist__open: %s\n", strerror(errno)); | 126 | pr_debug("perf_evlist__open: %s\n", |
127 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
124 | goto out_delete_evlist; | 128 | goto out_delete_evlist; |
125 | } | 129 | } |
126 | 130 | ||
@@ -131,7 +135,8 @@ int test__PERF_RECORD(void) | |||
131 | */ | 135 | */ |
132 | err = perf_evlist__mmap(evlist, opts.mmap_pages, false); | 136 | err = perf_evlist__mmap(evlist, opts.mmap_pages, false); |
133 | if (err < 0) { | 137 | if (err < 0) { |
134 | pr_debug("perf_evlist__mmap: %s\n", strerror(errno)); | 138 | pr_debug("perf_evlist__mmap: %s\n", |
139 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
135 | goto out_delete_evlist; | 140 | goto out_delete_evlist; |
136 | } | 141 | } |
137 | 142 | ||
diff --git a/tools/perf/tests/rdpmc.c b/tools/perf/tests/rdpmc.c index c04d1f268576..d31f2c4d9f64 100644 --- a/tools/perf/tests/rdpmc.c +++ b/tools/perf/tests/rdpmc.c | |||
@@ -100,6 +100,7 @@ static int __test__rdpmc(void) | |||
100 | }; | 100 | }; |
101 | u64 delta_sum = 0; | 101 | u64 delta_sum = 0; |
102 | struct sigaction sa; | 102 | struct sigaction sa; |
103 | char sbuf[STRERR_BUFSIZE]; | ||
103 | 104 | ||
104 | sigfillset(&sa.sa_mask); | 105 | sigfillset(&sa.sa_mask); |
105 | sa.sa_sigaction = segfault_handler; | 106 | sa.sa_sigaction = segfault_handler; |
@@ -109,14 +110,15 @@ static int __test__rdpmc(void) | |||
109 | perf_event_open_cloexec_flag()); | 110 | perf_event_open_cloexec_flag()); |
110 | if (fd < 0) { | 111 | if (fd < 0) { |
111 | pr_err("Error: sys_perf_event_open() syscall returned " | 112 | pr_err("Error: sys_perf_event_open() syscall returned " |
112 | "with %d (%s)\n", fd, strerror(errno)); | 113 | "with %d (%s)\n", fd, |
114 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
113 | return -1; | 115 | return -1; |
114 | } | 116 | } |
115 | 117 | ||
116 | addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0); | 118 | addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0); |
117 | if (addr == (void *)(-1)) { | 119 | if (addr == (void *)(-1)) { |
118 | pr_err("Error: mmap() syscall returned with (%s)\n", | 120 | pr_err("Error: mmap() syscall returned with (%s)\n", |
119 | strerror(errno)); | 121 | strerror_r(errno, sbuf, sizeof(sbuf))); |
120 | goto out_close; | 122 | goto out_close; |
121 | } | 123 | } |
122 | 124 | ||
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c index 983d6b8562a8..1aa21c90731b 100644 --- a/tools/perf/tests/sw-clock.c +++ b/tools/perf/tests/sw-clock.c | |||
@@ -22,6 +22,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
22 | volatile int tmp = 0; | 22 | volatile int tmp = 0; |
23 | u64 total_periods = 0; | 23 | u64 total_periods = 0; |
24 | int nr_samples = 0; | 24 | int nr_samples = 0; |
25 | char sbuf[STRERR_BUFSIZE]; | ||
25 | union perf_event *event; | 26 | union perf_event *event; |
26 | struct perf_evsel *evsel; | 27 | struct perf_evsel *evsel; |
27 | struct perf_evlist *evlist; | 28 | struct perf_evlist *evlist; |
@@ -62,14 +63,15 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) | |||
62 | 63 | ||
63 | err = -errno; | 64 | err = -errno; |
64 | pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", | 65 | pr_debug("Couldn't open evlist: %s\nHint: check %s, using %" PRIu64 " in this test.\n", |
65 | strerror(errno), knob, (u64)attr.sample_freq); | 66 | strerror_r(errno, sbuf, sizeof(sbuf)), |
67 | knob, (u64)attr.sample_freq); | ||
66 | goto out_delete_evlist; | 68 | goto out_delete_evlist; |
67 | } | 69 | } |
68 | 70 | ||
69 | err = perf_evlist__mmap(evlist, 128, true); | 71 | err = perf_evlist__mmap(evlist, 128, true); |
70 | if (err < 0) { | 72 | if (err < 0) { |
71 | pr_debug("failed to mmap event: %d (%s)\n", errno, | 73 | pr_debug("failed to mmap event: %d (%s)\n", errno, |
72 | strerror(errno)); | 74 | strerror_r(errno, sbuf, sizeof(sbuf))); |
73 | goto out_delete_evlist; | 75 | goto out_delete_evlist; |
74 | } | 76 | } |
75 | 77 | ||
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c index 5ff3db318f12..87522f01c7ad 100644 --- a/tools/perf/tests/task-exit.c +++ b/tools/perf/tests/task-exit.c | |||
@@ -42,6 +42,7 @@ int test__task_exit(void) | |||
42 | .uses_mmap = true, | 42 | .uses_mmap = true, |
43 | }; | 43 | }; |
44 | const char *argv[] = { "true", NULL }; | 44 | const char *argv[] = { "true", NULL }; |
45 | char sbuf[STRERR_BUFSIZE]; | ||
45 | 46 | ||
46 | signal(SIGCHLD, sig_handler); | 47 | signal(SIGCHLD, sig_handler); |
47 | 48 | ||
@@ -82,13 +83,14 @@ int test__task_exit(void) | |||
82 | 83 | ||
83 | err = perf_evlist__open(evlist); | 84 | err = perf_evlist__open(evlist); |
84 | if (err < 0) { | 85 | if (err < 0) { |
85 | pr_debug("Couldn't open the evlist: %s\n", strerror(-err)); | 86 | pr_debug("Couldn't open the evlist: %s\n", |
87 | strerror_r(-err, sbuf, sizeof(sbuf))); | ||
86 | goto out_delete_evlist; | 88 | goto out_delete_evlist; |
87 | } | 89 | } |
88 | 90 | ||
89 | if (perf_evlist__mmap(evlist, 128, true) < 0) { | 91 | if (perf_evlist__mmap(evlist, 128, true) < 0) { |
90 | pr_debug("failed to mmap events: %d (%s)\n", errno, | 92 | pr_debug("failed to mmap events: %d (%s)\n", errno, |
91 | strerror(errno)); | 93 | strerror_r(errno, sbuf, sizeof(sbuf))); |
92 | goto out_delete_evlist; | 94 | goto out_delete_evlist; |
93 | } | 95 | } |
94 | 96 | ||
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 7745fec01a6b..36437527dbb3 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -232,9 +232,16 @@ static int mov__parse(struct ins_operands *ops) | |||
232 | return -1; | 232 | return -1; |
233 | 233 | ||
234 | target = ++s; | 234 | target = ++s; |
235 | comment = strchr(s, '#'); | ||
235 | 236 | ||
236 | while (s[0] != '\0' && !isspace(s[0])) | 237 | if (comment != NULL) |
237 | ++s; | 238 | s = comment - 1; |
239 | else | ||
240 | s = strchr(s, '\0') - 1; | ||
241 | |||
242 | while (s > target && isspace(s[0])) | ||
243 | --s; | ||
244 | s++; | ||
238 | prev = *s; | 245 | prev = *s; |
239 | *s = '\0'; | 246 | *s = '\0'; |
240 | 247 | ||
@@ -244,7 +251,6 @@ static int mov__parse(struct ins_operands *ops) | |||
244 | if (ops->target.raw == NULL) | 251 | if (ops->target.raw == NULL) |
245 | goto out_free_source; | 252 | goto out_free_source; |
246 | 253 | ||
247 | comment = strchr(s, '#'); | ||
248 | if (comment == NULL) | 254 | if (comment == NULL) |
249 | return 0; | 255 | return 0; |
250 | 256 | ||
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 437ee09727e6..08f0fbf5527c 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -28,74 +28,55 @@ __thread struct callchain_cursor callchain_cursor; | |||
28 | int | 28 | int |
29 | parse_callchain_report_opt(const char *arg) | 29 | parse_callchain_report_opt(const char *arg) |
30 | { | 30 | { |
31 | char *tok, *tok2; | 31 | char *tok; |
32 | char *endptr; | 32 | char *endptr; |
33 | bool minpcnt_set = false; | ||
33 | 34 | ||
34 | symbol_conf.use_callchain = true; | 35 | symbol_conf.use_callchain = true; |
35 | 36 | ||
36 | if (!arg) | 37 | if (!arg) |
37 | return 0; | 38 | return 0; |
38 | 39 | ||
39 | tok = strtok((char *)arg, ","); | 40 | while ((tok = strtok((char *)arg, ",")) != NULL) { |
40 | if (!tok) | 41 | if (!strncmp(tok, "none", strlen(tok))) { |
41 | return -1; | 42 | callchain_param.mode = CHAIN_NONE; |
42 | 43 | symbol_conf.use_callchain = false; | |
43 | /* get the output mode */ | 44 | return 0; |
44 | if (!strncmp(tok, "graph", strlen(arg))) { | 45 | } |
45 | callchain_param.mode = CHAIN_GRAPH_ABS; | ||
46 | |||
47 | } else if (!strncmp(tok, "flat", strlen(arg))) { | ||
48 | callchain_param.mode = CHAIN_FLAT; | ||
49 | } else if (!strncmp(tok, "fractal", strlen(arg))) { | ||
50 | callchain_param.mode = CHAIN_GRAPH_REL; | ||
51 | } else if (!strncmp(tok, "none", strlen(arg))) { | ||
52 | callchain_param.mode = CHAIN_NONE; | ||
53 | symbol_conf.use_callchain = false; | ||
54 | return 0; | ||
55 | } else { | ||
56 | return -1; | ||
57 | } | ||
58 | |||
59 | /* get the min percentage */ | ||
60 | tok = strtok(NULL, ","); | ||
61 | if (!tok) | ||
62 | goto setup; | ||
63 | |||
64 | callchain_param.min_percent = strtod(tok, &endptr); | ||
65 | if (tok == endptr) | ||
66 | return -1; | ||
67 | 46 | ||
68 | /* get the print limit */ | 47 | /* try to get the output mode */ |
69 | tok2 = strtok(NULL, ","); | 48 | if (!strncmp(tok, "graph", strlen(tok))) |
70 | if (!tok2) | 49 | callchain_param.mode = CHAIN_GRAPH_ABS; |
71 | goto setup; | 50 | else if (!strncmp(tok, "flat", strlen(tok))) |
51 | callchain_param.mode = CHAIN_FLAT; | ||
52 | else if (!strncmp(tok, "fractal", strlen(tok))) | ||
53 | callchain_param.mode = CHAIN_GRAPH_REL; | ||
54 | /* try to get the call chain order */ | ||
55 | else if (!strncmp(tok, "caller", strlen(tok))) | ||
56 | callchain_param.order = ORDER_CALLER; | ||
57 | else if (!strncmp(tok, "callee", strlen(tok))) | ||
58 | callchain_param.order = ORDER_CALLEE; | ||
59 | /* try to get the sort key */ | ||
60 | else if (!strncmp(tok, "function", strlen(tok))) | ||
61 | callchain_param.key = CCKEY_FUNCTION; | ||
62 | else if (!strncmp(tok, "address", strlen(tok))) | ||
63 | callchain_param.key = CCKEY_ADDRESS; | ||
64 | /* try to get the min percent */ | ||
65 | else if (!minpcnt_set) { | ||
66 | callchain_param.min_percent = strtod(tok, &endptr); | ||
67 | if (tok == endptr) | ||
68 | return -1; | ||
69 | minpcnt_set = true; | ||
70 | } else { | ||
71 | /* try print limit at last */ | ||
72 | callchain_param.print_limit = strtoul(tok, &endptr, 0); | ||
73 | if (tok == endptr) | ||
74 | return -1; | ||
75 | } | ||
72 | 76 | ||
73 | if (tok2[0] != 'c') { | 77 | arg = NULL; |
74 | callchain_param.print_limit = strtoul(tok2, &endptr, 0); | ||
75 | tok2 = strtok(NULL, ","); | ||
76 | if (!tok2) | ||
77 | goto setup; | ||
78 | } | 78 | } |
79 | 79 | ||
80 | /* get the call chain order */ | ||
81 | if (!strncmp(tok2, "caller", strlen("caller"))) | ||
82 | callchain_param.order = ORDER_CALLER; | ||
83 | else if (!strncmp(tok2, "callee", strlen("callee"))) | ||
84 | callchain_param.order = ORDER_CALLEE; | ||
85 | else | ||
86 | return -1; | ||
87 | |||
88 | /* Get the sort key */ | ||
89 | tok2 = strtok(NULL, ","); | ||
90 | if (!tok2) | ||
91 | goto setup; | ||
92 | if (!strncmp(tok2, "function", strlen("function"))) | ||
93 | callchain_param.key = CCKEY_FUNCTION; | ||
94 | else if (!strncmp(tok2, "address", strlen("address"))) | ||
95 | callchain_param.key = CCKEY_ADDRESS; | ||
96 | else | ||
97 | return -1; | ||
98 | setup: | ||
99 | if (callchain_register_param(&callchain_param) < 0) { | 80 | if (callchain_register_param(&callchain_param) < 0) { |
100 | pr_err("Can't register callchain params\n"); | 81 | pr_err("Can't register callchain params\n"); |
101 | return -1; | 82 | return -1; |
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index 4945aa56a017..47b78b3f0325 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "../perf.h" | 3 | #include "../perf.h" |
4 | #include "cloexec.h" | 4 | #include "cloexec.h" |
5 | #include "asm/bug.h" | 5 | #include "asm/bug.h" |
6 | #include "debug.h" | ||
6 | 7 | ||
7 | static unsigned long flag = PERF_FLAG_FD_CLOEXEC; | 8 | static unsigned long flag = PERF_FLAG_FD_CLOEXEC; |
8 | 9 | ||
@@ -18,6 +19,7 @@ static int perf_flag_probe(void) | |||
18 | int err; | 19 | int err; |
19 | int cpu; | 20 | int cpu; |
20 | pid_t pid = -1; | 21 | pid_t pid = -1; |
22 | char sbuf[STRERR_BUFSIZE]; | ||
21 | 23 | ||
22 | cpu = sched_getcpu(); | 24 | cpu = sched_getcpu(); |
23 | if (cpu < 0) | 25 | if (cpu < 0) |
@@ -42,7 +44,7 @@ static int perf_flag_probe(void) | |||
42 | 44 | ||
43 | WARN_ONCE(err != EINVAL && err != EBUSY, | 45 | WARN_ONCE(err != EINVAL && err != EBUSY, |
44 | "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n", | 46 | "perf_event_open(..., PERF_FLAG_FD_CLOEXEC) failed with unexpected error %d (%s)\n", |
45 | err, strerror(err)); | 47 | err, strerror_r(err, sbuf, sizeof(sbuf))); |
46 | 48 | ||
47 | /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ | 49 | /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ |
48 | fd = sys_perf_event_open(&attr, pid, cpu, -1, 0); | 50 | fd = sys_perf_event_open(&attr, pid, cpu, -1, 0); |
@@ -50,7 +52,7 @@ static int perf_flag_probe(void) | |||
50 | 52 | ||
51 | if (WARN_ONCE(fd < 0 && err != EBUSY, | 53 | if (WARN_ONCE(fd < 0 && err != EBUSY, |
52 | "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n", | 54 | "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n", |
53 | err, strerror(err))) | 55 | err, strerror_r(err, sbuf, sizeof(sbuf)))) |
54 | return -1; | 56 | return -1; |
55 | 57 | ||
56 | close(fd); | 58 | close(fd); |
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 29d720cf5844..1921942fc2e0 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c | |||
@@ -50,12 +50,14 @@ static int open_file_read(struct perf_data_file *file) | |||
50 | { | 50 | { |
51 | struct stat st; | 51 | struct stat st; |
52 | int fd; | 52 | int fd; |
53 | char sbuf[STRERR_BUFSIZE]; | ||
53 | 54 | ||
54 | fd = open(file->path, O_RDONLY); | 55 | fd = open(file->path, O_RDONLY); |
55 | if (fd < 0) { | 56 | if (fd < 0) { |
56 | int err = errno; | 57 | int err = errno; |
57 | 58 | ||
58 | pr_err("failed to open %s: %s", file->path, strerror(err)); | 59 | pr_err("failed to open %s: %s", file->path, |
60 | strerror_r(err, sbuf, sizeof(sbuf))); | ||
59 | if (err == ENOENT && !strcmp(file->path, "perf.data")) | 61 | if (err == ENOENT && !strcmp(file->path, "perf.data")) |
60 | pr_err(" (try 'perf record' first)"); | 62 | pr_err(" (try 'perf record' first)"); |
61 | pr_err("\n"); | 63 | pr_err("\n"); |
@@ -88,6 +90,7 @@ static int open_file_read(struct perf_data_file *file) | |||
88 | static int open_file_write(struct perf_data_file *file) | 90 | static int open_file_write(struct perf_data_file *file) |
89 | { | 91 | { |
90 | int fd; | 92 | int fd; |
93 | char sbuf[STRERR_BUFSIZE]; | ||
91 | 94 | ||
92 | if (check_backup(file)) | 95 | if (check_backup(file)) |
93 | return -1; | 96 | return -1; |
@@ -95,7 +98,8 @@ static int open_file_write(struct perf_data_file *file) | |||
95 | fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); | 98 | fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR); |
96 | 99 | ||
97 | if (fd < 0) | 100 | if (fd < 0) |
98 | pr_err("failed to open %s : %s\n", file->path, strerror(errno)); | 101 | pr_err("failed to open %s : %s\n", file->path, |
102 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
99 | 103 | ||
100 | return fd; | 104 | return fd; |
101 | } | 105 | } |
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h index 6944ea3a119b..be264d6f3b30 100644 --- a/tools/perf/util/debug.h +++ b/tools/perf/util/debug.h | |||
@@ -3,6 +3,7 @@ | |||
3 | #define __PERF_DEBUG_H | 3 | #define __PERF_DEBUG_H |
4 | 4 | ||
5 | #include <stdbool.h> | 5 | #include <stdbool.h> |
6 | #include <string.h> | ||
6 | #include "event.h" | 7 | #include "event.h" |
7 | #include "../ui/helpline.h" | 8 | #include "../ui/helpline.h" |
8 | #include "../ui/progress.h" | 9 | #include "../ui/progress.h" |
@@ -36,6 +37,8 @@ extern int debug_ordered_events; | |||
36 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) | 37 | #define pr_oe_time(t, fmt, ...) pr_time_N(1, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
37 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) | 38 | #define pr_oe_time2(t, fmt, ...) pr_time_N(2, debug_ordered_events, t, pr_fmt(fmt), ##__VA_ARGS__) |
38 | 39 | ||
40 | #define STRERR_BUFSIZE 128 /* For the buffer size of strerror_r */ | ||
41 | |||
39 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); | 42 | int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); |
40 | void trace_event(union perf_event *event); | 43 | void trace_event(union perf_event *event); |
41 | 44 | ||
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index bdafd306fb52..55e39dc1bcda 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -162,13 +162,15 @@ static void close_first_dso(void); | |||
162 | static int do_open(char *name) | 162 | static int do_open(char *name) |
163 | { | 163 | { |
164 | int fd; | 164 | int fd; |
165 | char sbuf[STRERR_BUFSIZE]; | ||
165 | 166 | ||
166 | do { | 167 | do { |
167 | fd = open(name, O_RDONLY); | 168 | fd = open(name, O_RDONLY); |
168 | if (fd >= 0) | 169 | if (fd >= 0) |
169 | return fd; | 170 | return fd; |
170 | 171 | ||
171 | pr_debug("dso open failed, mmap: %s\n", strerror(errno)); | 172 | pr_debug("dso open failed, mmap: %s\n", |
173 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
172 | if (!dso__data_open_cnt || errno != EMFILE) | 174 | if (!dso__data_open_cnt || errno != EMFILE) |
173 | break; | 175 | break; |
174 | 176 | ||
@@ -530,10 +532,12 @@ static ssize_t cached_read(struct dso *dso, u64 offset, u8 *data, ssize_t size) | |||
530 | static int data_file_size(struct dso *dso) | 532 | static int data_file_size(struct dso *dso) |
531 | { | 533 | { |
532 | struct stat st; | 534 | struct stat st; |
535 | char sbuf[STRERR_BUFSIZE]; | ||
533 | 536 | ||
534 | if (!dso->data.file_size) { | 537 | if (!dso->data.file_size) { |
535 | if (fstat(dso->data.fd, &st)) { | 538 | if (fstat(dso->data.fd, &st)) { |
536 | pr_err("dso mmap failed, fstat: %s\n", strerror(errno)); | 539 | pr_err("dso mmap failed, fstat: %s\n", |
540 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
537 | return -1; | 541 | return -1; |
538 | } | 542 | } |
539 | dso->data.file_size = st.st_size; | 543 | dso->data.file_size = st.st_size; |
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 5dcd28c79c6e..a3e28b49128a 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c | |||
@@ -1295,7 +1295,7 @@ int perf_evlist__strerror_open(struct perf_evlist *evlist __maybe_unused, | |||
1295 | int err, char *buf, size_t size) | 1295 | int err, char *buf, size_t size) |
1296 | { | 1296 | { |
1297 | int printed, value; | 1297 | int printed, value; |
1298 | char sbuf[128], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); | 1298 | char sbuf[STRERR_BUFSIZE], *emsg = strerror_r(err, sbuf, sizeof(sbuf)); |
1299 | 1299 | ||
1300 | switch (err) { | 1300 | switch (err) { |
1301 | case EACCES: | 1301 | case EACCES: |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 01ce14c3575e..b38de5819323 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -2027,6 +2027,8 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err, | |||
2027 | int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, | 2027 | int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, |
2028 | int err, char *msg, size_t size) | 2028 | int err, char *msg, size_t size) |
2029 | { | 2029 | { |
2030 | char sbuf[STRERR_BUFSIZE]; | ||
2031 | |||
2030 | switch (err) { | 2032 | switch (err) { |
2031 | case EPERM: | 2033 | case EPERM: |
2032 | case EACCES: | 2034 | case EACCES: |
@@ -2072,8 +2074,9 @@ int perf_evsel__open_strerror(struct perf_evsel *evsel, struct target *target, | |||
2072 | } | 2074 | } |
2073 | 2075 | ||
2074 | return scnprintf(msg, size, | 2076 | return scnprintf(msg, size, |
2075 | "The sys_perf_event_open() syscall returned with %d (%s) for event (%s). \n" | 2077 | "The sys_perf_event_open() syscall returned with %d (%s) for event (%s).\n" |
2076 | "/bin/dmesg may provide additional information.\n" | 2078 | "/bin/dmesg may provide additional information.\n" |
2077 | "No CONFIG_PERF_EVENTS=y kernel support configured?\n", | 2079 | "No CONFIG_PERF_EVENTS=y kernel support configured?\n", |
2078 | err, strerror(err), perf_evsel__name(evsel)); | 2080 | err, strerror_r(err, sbuf, sizeof(sbuf)), |
2081 | perf_evsel__name(evsel)); | ||
2079 | } | 2082 | } |
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1e15df10a88c..e34c81a0bcf3 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "symbol.h" | 10 | #include "symbol.h" |
11 | #include "cache.h" | 11 | #include "cache.h" |
12 | #include "header.h" | 12 | #include "header.h" |
13 | #include "debug.h" | ||
13 | #include <api/fs/debugfs.h> | 14 | #include <api/fs/debugfs.h> |
14 | #include "parse-events-bison.h" | 15 | #include "parse-events-bison.h" |
15 | #define YY_EXTRA_TYPE int | 16 | #define YY_EXTRA_TYPE int |
@@ -1006,9 +1007,11 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob, | |||
1006 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; | 1007 | struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; |
1007 | char evt_path[MAXPATHLEN]; | 1008 | char evt_path[MAXPATHLEN]; |
1008 | char dir_path[MAXPATHLEN]; | 1009 | char dir_path[MAXPATHLEN]; |
1010 | char sbuf[STRERR_BUFSIZE]; | ||
1009 | 1011 | ||
1010 | if (debugfs_valid_mountpoint(tracing_events_path)) { | 1012 | if (debugfs_valid_mountpoint(tracing_events_path)) { |
1011 | printf(" [ Tracepoints not available: %s ]\n", strerror(errno)); | 1013 | printf(" [ Tracepoints not available: %s ]\n", |
1014 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
1012 | return; | 1015 | return; |
1013 | } | 1016 | } |
1014 | 1017 | ||
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 7a811eb61f75..9bf582750561 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c | |||
@@ -14,8 +14,8 @@ | |||
14 | 14 | ||
15 | struct perf_pmu_alias { | 15 | struct perf_pmu_alias { |
16 | char *name; | 16 | char *name; |
17 | struct list_head terms; | 17 | struct list_head terms; /* HEAD struct parse_events_term -> list */ |
18 | struct list_head list; | 18 | struct list_head list; /* ELEM */ |
19 | char unit[UNIT_MAX_LEN+1]; | 19 | char unit[UNIT_MAX_LEN+1]; |
20 | double scale; | 20 | double scale; |
21 | }; | 21 | }; |
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index c14a543ce1f3..1c1e2eecbe1f 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h | |||
@@ -17,9 +17,9 @@ struct perf_pmu { | |||
17 | char *name; | 17 | char *name; |
18 | __u32 type; | 18 | __u32 type; |
19 | struct cpu_map *cpus; | 19 | struct cpu_map *cpus; |
20 | struct list_head format; | 20 | struct list_head format; /* HEAD struct perf_pmu_format -> list */ |
21 | struct list_head aliases; | 21 | struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */ |
22 | struct list_head list; | 22 | struct list_head list; /* ELEM */ |
23 | }; | 23 | }; |
24 | 24 | ||
25 | struct perf_pmu *perf_pmu__find(const char *name); | 25 | struct perf_pmu *perf_pmu__find(const char *name); |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 784ea42ad8cb..f73595fc0627 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -258,21 +258,33 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) | |||
258 | #ifdef HAVE_DWARF_SUPPORT | 258 | #ifdef HAVE_DWARF_SUPPORT |
259 | 259 | ||
260 | /* Open new debuginfo of given module */ | 260 | /* Open new debuginfo of given module */ |
261 | static struct debuginfo *open_debuginfo(const char *module) | 261 | static struct debuginfo *open_debuginfo(const char *module, bool silent) |
262 | { | 262 | { |
263 | const char *path = module; | 263 | const char *path = module; |
264 | struct debuginfo *ret; | ||
264 | 265 | ||
265 | if (!module || !strchr(module, '/')) { | 266 | if (!module || !strchr(module, '/')) { |
266 | path = kernel_get_module_path(module); | 267 | path = kernel_get_module_path(module); |
267 | if (!path) { | 268 | if (!path) { |
268 | pr_err("Failed to find path of %s module.\n", | 269 | if (!silent) |
269 | module ?: "kernel"); | 270 | pr_err("Failed to find path of %s module.\n", |
271 | module ?: "kernel"); | ||
270 | return NULL; | 272 | return NULL; |
271 | } | 273 | } |
272 | } | 274 | } |
273 | return debuginfo__new(path); | 275 | ret = debuginfo__new(path); |
276 | if (!ret && !silent) { | ||
277 | pr_warning("The %s file has no debug information.\n", path); | ||
278 | if (!module || !strtailcmp(path, ".ko")) | ||
279 | pr_warning("Rebuild with CONFIG_DEBUG_INFO=y, "); | ||
280 | else | ||
281 | pr_warning("Rebuild with -g, "); | ||
282 | pr_warning("or install an appropriate debuginfo package.\n"); | ||
283 | } | ||
284 | return ret; | ||
274 | } | 285 | } |
275 | 286 | ||
287 | |||
276 | static int get_text_start_address(const char *exec, unsigned long *address) | 288 | static int get_text_start_address(const char *exec, unsigned long *address) |
277 | { | 289 | { |
278 | Elf *elf; | 290 | Elf *elf; |
@@ -333,15 +345,13 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp, | |||
333 | pr_debug("try to find information at %" PRIx64 " in %s\n", addr, | 345 | pr_debug("try to find information at %" PRIx64 " in %s\n", addr, |
334 | tp->module ? : "kernel"); | 346 | tp->module ? : "kernel"); |
335 | 347 | ||
336 | dinfo = open_debuginfo(tp->module); | 348 | dinfo = open_debuginfo(tp->module, verbose == 0); |
337 | if (dinfo) { | 349 | if (dinfo) { |
338 | ret = debuginfo__find_probe_point(dinfo, | 350 | ret = debuginfo__find_probe_point(dinfo, |
339 | (unsigned long)addr, pp); | 351 | (unsigned long)addr, pp); |
340 | debuginfo__delete(dinfo); | 352 | debuginfo__delete(dinfo); |
341 | } else { | 353 | } else |
342 | pr_debug("Failed to open debuginfo at 0x%" PRIx64 "\n", addr); | ||
343 | ret = -ENOENT; | 354 | ret = -ENOENT; |
344 | } | ||
345 | 355 | ||
346 | if (ret > 0) { | 356 | if (ret > 0) { |
347 | pp->retprobe = tp->retprobe; | 357 | pp->retprobe = tp->retprobe; |
@@ -457,13 +467,11 @@ static int try_to_find_probe_trace_events(struct perf_probe_event *pev, | |||
457 | struct debuginfo *dinfo; | 467 | struct debuginfo *dinfo; |
458 | int ntevs, ret = 0; | 468 | int ntevs, ret = 0; |
459 | 469 | ||
460 | dinfo = open_debuginfo(target); | 470 | dinfo = open_debuginfo(target, !need_dwarf); |
461 | 471 | ||
462 | if (!dinfo) { | 472 | if (!dinfo) { |
463 | if (need_dwarf) { | 473 | if (need_dwarf) |
464 | pr_warning("Failed to open debuginfo file.\n"); | ||
465 | return -ENOENT; | 474 | return -ENOENT; |
466 | } | ||
467 | pr_debug("Could not open debuginfo. Try to use symbols.\n"); | 475 | pr_debug("Could not open debuginfo. Try to use symbols.\n"); |
468 | return 0; | 476 | return 0; |
469 | } | 477 | } |
@@ -565,7 +573,7 @@ static int get_real_path(const char *raw_path, const char *comp_dir, | |||
565 | 573 | ||
566 | static int __show_one_line(FILE *fp, int l, bool skip, bool show_num) | 574 | static int __show_one_line(FILE *fp, int l, bool skip, bool show_num) |
567 | { | 575 | { |
568 | char buf[LINEBUF_SIZE]; | 576 | char buf[LINEBUF_SIZE], sbuf[STRERR_BUFSIZE]; |
569 | const char *color = show_num ? "" : PERF_COLOR_BLUE; | 577 | const char *color = show_num ? "" : PERF_COLOR_BLUE; |
570 | const char *prefix = NULL; | 578 | const char *prefix = NULL; |
571 | 579 | ||
@@ -585,7 +593,8 @@ static int __show_one_line(FILE *fp, int l, bool skip, bool show_num) | |||
585 | return 1; | 593 | return 1; |
586 | error: | 594 | error: |
587 | if (ferror(fp)) { | 595 | if (ferror(fp)) { |
588 | pr_warning("File read error: %s\n", strerror(errno)); | 596 | pr_warning("File read error: %s\n", |
597 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
589 | return -1; | 598 | return -1; |
590 | } | 599 | } |
591 | return 0; | 600 | return 0; |
@@ -618,13 +627,12 @@ static int __show_line_range(struct line_range *lr, const char *module) | |||
618 | FILE *fp; | 627 | FILE *fp; |
619 | int ret; | 628 | int ret; |
620 | char *tmp; | 629 | char *tmp; |
630 | char sbuf[STRERR_BUFSIZE]; | ||
621 | 631 | ||
622 | /* Search a line range */ | 632 | /* Search a line range */ |
623 | dinfo = open_debuginfo(module); | 633 | dinfo = open_debuginfo(module, false); |
624 | if (!dinfo) { | 634 | if (!dinfo) |
625 | pr_warning("Failed to open debuginfo file.\n"); | ||
626 | return -ENOENT; | 635 | return -ENOENT; |
627 | } | ||
628 | 636 | ||
629 | ret = debuginfo__find_line_range(dinfo, lr); | 637 | ret = debuginfo__find_line_range(dinfo, lr); |
630 | debuginfo__delete(dinfo); | 638 | debuginfo__delete(dinfo); |
@@ -656,7 +664,7 @@ static int __show_line_range(struct line_range *lr, const char *module) | |||
656 | fp = fopen(lr->path, "r"); | 664 | fp = fopen(lr->path, "r"); |
657 | if (fp == NULL) { | 665 | if (fp == NULL) { |
658 | pr_warning("Failed to open %s: %s\n", lr->path, | 666 | pr_warning("Failed to open %s: %s\n", lr->path, |
659 | strerror(errno)); | 667 | strerror_r(errno, sbuf, sizeof(sbuf))); |
660 | return -errno; | 668 | return -errno; |
661 | } | 669 | } |
662 | /* Skip to starting line number */ | 670 | /* Skip to starting line number */ |
@@ -772,9 +780,8 @@ int show_available_vars(struct perf_probe_event *pevs, int npevs, | |||
772 | if (ret < 0) | 780 | if (ret < 0) |
773 | return ret; | 781 | return ret; |
774 | 782 | ||
775 | dinfo = open_debuginfo(module); | 783 | dinfo = open_debuginfo(module, false); |
776 | if (!dinfo) { | 784 | if (!dinfo) { |
777 | pr_warning("Failed to open debuginfo file.\n"); | ||
778 | ret = -ENOENT; | 785 | ret = -ENOENT; |
779 | goto out; | 786 | goto out; |
780 | } | 787 | } |
@@ -1405,8 +1412,7 @@ int synthesize_perf_probe_arg(struct perf_probe_arg *pa, char *buf, size_t len) | |||
1405 | 1412 | ||
1406 | return tmp - buf; | 1413 | return tmp - buf; |
1407 | error: | 1414 | error: |
1408 | pr_debug("Failed to synthesize perf probe argument: %s\n", | 1415 | pr_debug("Failed to synthesize perf probe argument: %d\n", ret); |
1409 | strerror(-ret)); | ||
1410 | return ret; | 1416 | return ret; |
1411 | } | 1417 | } |
1412 | 1418 | ||
@@ -1455,8 +1461,7 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp) | |||
1455 | 1461 | ||
1456 | return buf; | 1462 | return buf; |
1457 | error: | 1463 | error: |
1458 | pr_debug("Failed to synthesize perf probe point: %s\n", | 1464 | pr_debug("Failed to synthesize perf probe point: %d\n", ret); |
1459 | strerror(-ret)); | ||
1460 | free(buf); | 1465 | free(buf); |
1461 | return NULL; | 1466 | return NULL; |
1462 | } | 1467 | } |
@@ -1782,7 +1787,7 @@ static void clear_probe_trace_event(struct probe_trace_event *tev) | |||
1782 | 1787 | ||
1783 | static void print_open_warning(int err, bool is_kprobe) | 1788 | static void print_open_warning(int err, bool is_kprobe) |
1784 | { | 1789 | { |
1785 | char sbuf[128]; | 1790 | char sbuf[STRERR_BUFSIZE]; |
1786 | 1791 | ||
1787 | if (err == -ENOENT) { | 1792 | if (err == -ENOENT) { |
1788 | const char *config; | 1793 | const char *config; |
@@ -1812,7 +1817,7 @@ static void print_both_open_warning(int kerr, int uerr) | |||
1812 | pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS " | 1817 | pr_warning("Please rebuild kernel with CONFIG_KPROBE_EVENTS " |
1813 | "or/and CONFIG_UPROBE_EVENTS.\n"); | 1818 | "or/and CONFIG_UPROBE_EVENTS.\n"); |
1814 | else { | 1819 | else { |
1815 | char sbuf[128]; | 1820 | char sbuf[STRERR_BUFSIZE]; |
1816 | pr_warning("Failed to open kprobe events: %s.\n", | 1821 | pr_warning("Failed to open kprobe events: %s.\n", |
1817 | strerror_r(-kerr, sbuf, sizeof(sbuf))); | 1822 | strerror_r(-kerr, sbuf, sizeof(sbuf))); |
1818 | pr_warning("Failed to open uprobe events: %s.\n", | 1823 | pr_warning("Failed to open uprobe events: %s.\n", |
@@ -1876,7 +1881,7 @@ static struct strlist *get_probe_trace_command_rawlist(int fd) | |||
1876 | p[idx] = '\0'; | 1881 | p[idx] = '\0'; |
1877 | ret = strlist__add(sl, buf); | 1882 | ret = strlist__add(sl, buf); |
1878 | if (ret < 0) { | 1883 | if (ret < 0) { |
1879 | pr_debug("strlist__add failed: %s\n", strerror(-ret)); | 1884 | pr_debug("strlist__add failed (%d)\n", ret); |
1880 | strlist__delete(sl); | 1885 | strlist__delete(sl); |
1881 | return NULL; | 1886 | return NULL; |
1882 | } | 1887 | } |
@@ -1935,7 +1940,7 @@ static int __show_perf_probe_events(int fd, bool is_kprobe) | |||
1935 | 1940 | ||
1936 | rawlist = get_probe_trace_command_rawlist(fd); | 1941 | rawlist = get_probe_trace_command_rawlist(fd); |
1937 | if (!rawlist) | 1942 | if (!rawlist) |
1938 | return -ENOENT; | 1943 | return -ENOMEM; |
1939 | 1944 | ||
1940 | strlist__for_each(ent, rawlist) { | 1945 | strlist__for_each(ent, rawlist) { |
1941 | ret = parse_probe_trace_command(ent->s, &tev); | 1946 | ret = parse_probe_trace_command(ent->s, &tev); |
@@ -2002,6 +2007,8 @@ static struct strlist *get_probe_trace_event_names(int fd, bool include_group) | |||
2002 | 2007 | ||
2003 | memset(&tev, 0, sizeof(tev)); | 2008 | memset(&tev, 0, sizeof(tev)); |
2004 | rawlist = get_probe_trace_command_rawlist(fd); | 2009 | rawlist = get_probe_trace_command_rawlist(fd); |
2010 | if (!rawlist) | ||
2011 | return NULL; | ||
2005 | sl = strlist__new(true, NULL); | 2012 | sl = strlist__new(true, NULL); |
2006 | strlist__for_each(ent, rawlist) { | 2013 | strlist__for_each(ent, rawlist) { |
2007 | ret = parse_probe_trace_command(ent->s, &tev); | 2014 | ret = parse_probe_trace_command(ent->s, &tev); |
@@ -2031,6 +2038,7 @@ static int write_probe_trace_event(int fd, struct probe_trace_event *tev) | |||
2031 | { | 2038 | { |
2032 | int ret = 0; | 2039 | int ret = 0; |
2033 | char *buf = synthesize_probe_trace_command(tev); | 2040 | char *buf = synthesize_probe_trace_command(tev); |
2041 | char sbuf[STRERR_BUFSIZE]; | ||
2034 | 2042 | ||
2035 | if (!buf) { | 2043 | if (!buf) { |
2036 | pr_debug("Failed to synthesize probe trace event.\n"); | 2044 | pr_debug("Failed to synthesize probe trace event.\n"); |
@@ -2042,7 +2050,7 @@ static int write_probe_trace_event(int fd, struct probe_trace_event *tev) | |||
2042 | ret = write(fd, buf, strlen(buf)); | 2050 | ret = write(fd, buf, strlen(buf)); |
2043 | if (ret <= 0) | 2051 | if (ret <= 0) |
2044 | pr_warning("Failed to write event: %s\n", | 2052 | pr_warning("Failed to write event: %s\n", |
2045 | strerror(errno)); | 2053 | strerror_r(errno, sbuf, sizeof(sbuf))); |
2046 | } | 2054 | } |
2047 | free(buf); | 2055 | free(buf); |
2048 | return ret; | 2056 | return ret; |
@@ -2056,7 +2064,7 @@ static int get_new_event_name(char *buf, size_t len, const char *base, | |||
2056 | /* Try no suffix */ | 2064 | /* Try no suffix */ |
2057 | ret = e_snprintf(buf, len, "%s", base); | 2065 | ret = e_snprintf(buf, len, "%s", base); |
2058 | if (ret < 0) { | 2066 | if (ret < 0) { |
2059 | pr_debug("snprintf() failed: %s\n", strerror(-ret)); | 2067 | pr_debug("snprintf() failed: %d\n", ret); |
2060 | return ret; | 2068 | return ret; |
2061 | } | 2069 | } |
2062 | if (!strlist__has_entry(namelist, buf)) | 2070 | if (!strlist__has_entry(namelist, buf)) |
@@ -2072,7 +2080,7 @@ static int get_new_event_name(char *buf, size_t len, const char *base, | |||
2072 | for (i = 1; i < MAX_EVENT_INDEX; i++) { | 2080 | for (i = 1; i < MAX_EVENT_INDEX; i++) { |
2073 | ret = e_snprintf(buf, len, "%s_%d", base, i); | 2081 | ret = e_snprintf(buf, len, "%s_%d", base, i); |
2074 | if (ret < 0) { | 2082 | if (ret < 0) { |
2075 | pr_debug("snprintf() failed: %s\n", strerror(-ret)); | 2083 | pr_debug("snprintf() failed: %d\n", ret); |
2076 | return ret; | 2084 | return ret; |
2077 | } | 2085 | } |
2078 | if (!strlist__has_entry(namelist, buf)) | 2086 | if (!strlist__has_entry(namelist, buf)) |
@@ -2437,7 +2445,8 @@ static int __del_trace_probe_event(int fd, struct str_node *ent) | |||
2437 | printf("Removed event: %s\n", ent->s); | 2445 | printf("Removed event: %s\n", ent->s); |
2438 | return 0; | 2446 | return 0; |
2439 | error: | 2447 | error: |
2440 | pr_warning("Failed to delete event: %s\n", strerror(-ret)); | 2448 | pr_warning("Failed to delete event: %s\n", |
2449 | strerror_r(-ret, buf, sizeof(buf))); | ||
2441 | return ret; | 2450 | return ret; |
2442 | } | 2451 | } |
2443 | 2452 | ||
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index dca9145d704c..9c593561aa71 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -281,6 +281,7 @@ static int convert_variable_type(Dwarf_Die *vr_die, | |||
281 | struct probe_trace_arg_ref **ref_ptr = &tvar->ref; | 281 | struct probe_trace_arg_ref **ref_ptr = &tvar->ref; |
282 | Dwarf_Die type; | 282 | Dwarf_Die type; |
283 | char buf[16]; | 283 | char buf[16]; |
284 | char sbuf[STRERR_BUFSIZE]; | ||
284 | int bsize, boffs, total; | 285 | int bsize, boffs, total; |
285 | int ret; | 286 | int ret; |
286 | 287 | ||
@@ -367,7 +368,7 @@ formatted: | |||
367 | if (ret >= 16) | 368 | if (ret >= 16) |
368 | ret = -E2BIG; | 369 | ret = -E2BIG; |
369 | pr_warning("Failed to convert variable type: %s\n", | 370 | pr_warning("Failed to convert variable type: %s\n", |
370 | strerror(-ret)); | 371 | strerror_r(-ret, sbuf, sizeof(sbuf))); |
371 | return ret; | 372 | return ret; |
372 | } | 373 | } |
373 | tvar->type = strdup(buf); | 374 | tvar->type = strdup(buf); |
@@ -779,10 +780,12 @@ static int find_lazy_match_lines(struct intlist *list, | |||
779 | size_t line_len; | 780 | size_t line_len; |
780 | ssize_t len; | 781 | ssize_t len; |
781 | int count = 0, linenum = 1; | 782 | int count = 0, linenum = 1; |
783 | char sbuf[STRERR_BUFSIZE]; | ||
782 | 784 | ||
783 | fp = fopen(fname, "r"); | 785 | fp = fopen(fname, "r"); |
784 | if (!fp) { | 786 | if (!fp) { |
785 | pr_warning("Failed to open %s: %s\n", fname, strerror(errno)); | 787 | pr_warning("Failed to open %s: %s\n", fname, |
788 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
786 | return -errno; | 789 | return -errno; |
787 | } | 790 | } |
788 | 791 | ||
diff --git a/tools/perf/util/run-command.c b/tools/perf/util/run-command.c index da8e9b285f51..34622b53e733 100644 --- a/tools/perf/util/run-command.c +++ b/tools/perf/util/run-command.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "cache.h" | 1 | #include "cache.h" |
2 | #include "run-command.h" | 2 | #include "run-command.h" |
3 | #include "exec_cmd.h" | 3 | #include "exec_cmd.h" |
4 | #include "debug.h" | ||
4 | 5 | ||
5 | static inline void close_pair(int fd[2]) | 6 | static inline void close_pair(int fd[2]) |
6 | { | 7 | { |
@@ -19,6 +20,7 @@ int start_command(struct child_process *cmd) | |||
19 | { | 20 | { |
20 | int need_in, need_out, need_err; | 21 | int need_in, need_out, need_err; |
21 | int fdin[2], fdout[2], fderr[2]; | 22 | int fdin[2], fdout[2], fderr[2]; |
23 | char sbuf[STRERR_BUFSIZE]; | ||
22 | 24 | ||
23 | /* | 25 | /* |
24 | * In case of errors we must keep the promise to close FDs | 26 | * In case of errors we must keep the promise to close FDs |
@@ -99,7 +101,7 @@ int start_command(struct child_process *cmd) | |||
99 | 101 | ||
100 | if (cmd->dir && chdir(cmd->dir)) | 102 | if (cmd->dir && chdir(cmd->dir)) |
101 | die("exec %s: cd to %s failed (%s)", cmd->argv[0], | 103 | die("exec %s: cd to %s failed (%s)", cmd->argv[0], |
102 | cmd->dir, strerror(errno)); | 104 | cmd->dir, strerror_r(errno, sbuf, sizeof(sbuf))); |
103 | if (cmd->env) { | 105 | if (cmd->env) { |
104 | for (; *cmd->env; cmd->env++) { | 106 | for (; *cmd->env; cmd->env++) { |
105 | if (strchr(*cmd->env, '=')) | 107 | if (strchr(*cmd->env, '=')) |
@@ -153,6 +155,8 @@ int start_command(struct child_process *cmd) | |||
153 | 155 | ||
154 | static int wait_or_whine(pid_t pid) | 156 | static int wait_or_whine(pid_t pid) |
155 | { | 157 | { |
158 | char sbuf[STRERR_BUFSIZE]; | ||
159 | |||
156 | for (;;) { | 160 | for (;;) { |
157 | int status, code; | 161 | int status, code; |
158 | pid_t waiting = waitpid(pid, &status, 0); | 162 | pid_t waiting = waitpid(pid, &status, 0); |
@@ -160,7 +164,8 @@ static int wait_or_whine(pid_t pid) | |||
160 | if (waiting < 0) { | 164 | if (waiting < 0) { |
161 | if (errno == EINTR) | 165 | if (errno == EINTR) |
162 | continue; | 166 | continue; |
163 | error("waitpid failed (%s)", strerror(errno)); | 167 | error("waitpid failed (%s)", |
168 | strerror_r(errno, sbuf, sizeof(sbuf))); | ||
164 | return -ERR_RUN_COMMAND_WAITPID; | 169 | return -ERR_RUN_COMMAND_WAITPID; |
165 | } | 170 | } |
166 | if (waiting != pid) | 171 | if (waiting != pid) |
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 25822bdf7bbf..24e8d871b74e 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c | |||
@@ -456,6 +456,7 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep) | |||
456 | size_t size = 0, alloc_size = 0; | 456 | size_t size = 0, alloc_size = 0; |
457 | void *bf = NULL, *nbf; | 457 | void *bf = NULL, *nbf; |
458 | int fd, n, err = 0; | 458 | int fd, n, err = 0; |
459 | char sbuf[STRERR_BUFSIZE]; | ||
459 | 460 | ||
460 | fd = open(filename, O_RDONLY); | 461 | fd = open(filename, O_RDONLY); |
461 | if (fd < 0) | 462 | if (fd < 0) |
@@ -476,8 +477,8 @@ int filename__read_str(const char *filename, char **buf, size_t *sizep) | |||
476 | n = read(fd, bf + size, alloc_size - size); | 477 | n = read(fd, bf + size, alloc_size - size); |
477 | if (n < 0) { | 478 | if (n < 0) { |
478 | if (size) { | 479 | if (size) { |
479 | pr_warning("read failed %d: %s\n", | 480 | pr_warning("read failed %d: %s\n", errno, |
480 | errno, strerror(errno)); | 481 | strerror_r(errno, sbuf, sizeof(sbuf))); |
481 | err = 0; | 482 | err = 0; |
482 | } else | 483 | } else |
483 | err = -errno; | 484 | err = -errno; |