Commit 3780f488 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Convert critical messages to ui__error()

There were places where use ui__warning (or even fprintf) to show
critical messages. This patch converts them to ui__error so that the
front-end code can implement appropriate behavior.
Signed-off-by: default avatarNamhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1338265382-6872-3-git-send-email-namhyung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 21f0d423
...@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann) ...@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
} }
if (total_nr_samples == 0) { if (total_nr_samples == 0) {
ui__warning("The %s file has no samples!\n", session->filename); ui__error("The %s file has no samples!\n", session->filename);
goto out_delete; goto out_delete;
} }
out_delete: out_delete:
......
...@@ -264,7 +264,7 @@ static void perf_record__open(struct perf_record *rec) ...@@ -264,7 +264,7 @@ static void perf_record__open(struct perf_record *rec)
} }
if (err == ENOENT) { if (err == ENOENT) {
ui__warning("The %s event is not supported.\n", ui__error("The %s event is not supported.\n",
event_name(pos)); event_name(pos));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) ...@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
usage_with_options(record_usage, record_options); usage_with_options(record_usage, record_options);
if (rec->force && rec->append_file) { if (rec->force && rec->append_file) {
fprintf(stderr, "Can't overwrite and append at the same time." ui__error("Can't overwrite and append at the same time."
" You need to choose between -f and -A"); " You need to choose between -f and -A");
usage_with_options(record_usage, record_options); usage_with_options(record_usage, record_options);
} else if (rec->append_file) { } else if (rec->append_file) {
rec->write_mode = WRITE_APPEND; rec->write_mode = WRITE_APPEND;
...@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) ...@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
} }
if (nr_cgroups && !rec->opts.target.system_wide) { if (nr_cgroups && !rec->opts.target.system_wide) {
fprintf(stderr, "cgroup monitoring only available in" ui__error("cgroup monitoring only available in"
" system-wide mode\n"); " system-wide mode\n");
usage_with_options(record_usage, record_options); usage_with_options(record_usage, record_options);
} }
...@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) ...@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno; int saved_errno = errno;
perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ); perf_target__strerror(&rec->opts.target, err, errbuf, BUFSIZ);
ui__warning("%s", errbuf); ui__error("%s", errbuf);
err = -saved_errno; err = -saved_errno;
goto out_free_fd; goto out_free_fd;
...@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) ...@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
else if (rec->opts.freq) { else if (rec->opts.freq) {
rec->opts.default_interval = rec->opts.freq; rec->opts.default_interval = rec->opts.freq;
} else { } else {
fprintf(stderr, "frequency and count are zero, aborting\n"); ui__error("frequency and count are zero, aborting\n");
err = -EINVAL; err = -EINVAL;
goto out_free_fd; goto out_free_fd;
} }
......
...@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep) ...@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) { if (!(self->sample_type & PERF_SAMPLE_CALLCHAIN)) {
if (sort__has_parent) { if (sort__has_parent) {
ui__warning("Selected --sort parent, but no " ui__error("Selected --sort parent, but no "
"callchain data. Did you call " "callchain data. Did you call "
"'perf record' without -g?\n"); "'perf record' without -g?\n");
return -EINVAL; return -EINVAL;
} }
if (symbol_conf.use_callchain) { if (symbol_conf.use_callchain) {
ui__warning("Selected -g but no callchain data. Did " ui__error("Selected -g but no callchain data. Did "
"you call 'perf record' without -g?\n"); "you call 'perf record' without -g?\n");
return -1; return -1;
} }
...@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep) ...@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep)
!symbol_conf.use_callchain) { !symbol_conf.use_callchain) {
symbol_conf.use_callchain = true; symbol_conf.use_callchain = true;
if (callchain_register_param(&callchain_param) < 0) { if (callchain_register_param(&callchain_param) < 0) {
ui__warning("Can't register callchain " ui__error("Can't register callchain params.\n");
"params.\n");
return -EINVAL; return -EINVAL;
} }
} }
if (sort__branch_mode == 1) { if (sort__branch_mode == 1) {
if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) { if (!(self->sample_type & PERF_SAMPLE_BRANCH_STACK)) {
fprintf(stderr, "selected -b but no branch data." ui__error("Selected -b but no branch data. "
" Did you call perf record without" "Did you call perf record without -b?\n");
" -b?\n");
return -1; return -1;
} }
} }
...@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep) ...@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep)
} }
if (nr_samples == 0) { if (nr_samples == 0) {
ui__warning("The %s file has no samples!\n", session->filename); ui__error("The %s file has no samples!\n", session->filename);
goto out_delete; goto out_delete;
} }
......
...@@ -959,16 +959,16 @@ static void perf_top__start_counters(struct perf_top *top) ...@@ -959,16 +959,16 @@ static void perf_top__start_counters(struct perf_top *top)
} }
if (err == ENOENT) { if (err == ENOENT) {
ui__warning("The %s event is not supported.\n", ui__error("The %s event is not supported.\n",
event_name(counter)); event_name(counter));
goto out_err; goto out_err;
} else if (err == EMFILE) { } else if (err == EMFILE) {
ui__warning("Too many events are opened.\n" ui__error("Too many events are opened.\n"
"Try again after reducing the number of events\n"); "Try again after reducing the number of events\n");
goto out_err; goto out_err;
} }
ui__warning("The sys_perf_event_open() syscall " ui__error("The sys_perf_event_open() syscall "
"returned with %d (%s). /bin/dmesg " "returned with %d (%s). /bin/dmesg "
"may provide additional information.\n" "may provide additional information.\n"
"No CONFIG_PERF_EVENTS=y kernel support " "No CONFIG_PERF_EVENTS=y kernel support "
...@@ -978,7 +978,7 @@ static void perf_top__start_counters(struct perf_top *top) ...@@ -978,7 +978,7 @@ static void perf_top__start_counters(struct perf_top *top)
} }
if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) { if (perf_evlist__mmap(evlist, top->mmap_pages, false) < 0) {
ui__warning("Failed to mmap with %d (%s)\n", ui__error("Failed to mmap with %d (%s)\n",
errno, strerror(errno)); errno, strerror(errno));
goto out_err; goto out_err;
} }
...@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top) ...@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top)
{ {
if (!top->sort_has_symbols) { if (!top->sort_has_symbols) {
if (symbol_conf.use_callchain) { if (symbol_conf.use_callchain) {
ui__warning("Selected -g but \"sym\" not present in --sort/-s."); ui__error("Selected -g but \"sym\" not present in --sort/-s.");
return -EINVAL; return -EINVAL;
} }
} else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) { } else if (!top->dont_use_callchains && callchain_param.mode != CHAIN_NONE) {
if (callchain_register_param(&callchain_param) < 0) { if (callchain_register_param(&callchain_param) < 0) {
ui__warning("Can't register callchain params.\n"); ui__error("Can't register callchain params.\n");
return -EINVAL; return -EINVAL;
} }
} }
...@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top) ...@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)
if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui : if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
display_thread), top)) { display_thread), top)) {
printf("Could not create display thread.\n"); ui__error("Could not create display thread.\n");
exit(-1); exit(-1);
} }
...@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top) ...@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top)
param.sched_priority = top->realtime_prio; param.sched_priority = top->realtime_prio;
if (sched_setscheduler(0, SCHED_FIFO, &param)) { if (sched_setscheduler(0, SCHED_FIFO, &param)) {
printf("Could not set realtime priority.\n"); ui__error("Could not set realtime priority.\n");
exit(-1); exit(-1);
} }
} }
...@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
int saved_errno = errno; int saved_errno = errno;
perf_target__strerror(&top.target, status, errbuf, BUFSIZ); perf_target__strerror(&top.target, status, errbuf, BUFSIZ);
ui__warning("%s", errbuf); ui__error("%s", errbuf);
status = -saved_errno; status = -saved_errno;
goto out_delete_evlist; goto out_delete_evlist;
...@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
if (!top.evlist->nr_entries && if (!top.evlist->nr_entries &&
perf_evlist__add_default(top.evlist) < 0) { perf_evlist__add_default(top.evlist) < 0) {
pr_err("Not enough memory for event selector list\n"); ui__error("Not enough memory for event selector list\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) ...@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
else if (top.freq) { else if (top.freq) {
top.default_interval = top.freq; top.default_interval = top.freq;
} else { } else {
fprintf(stderr, "frequency and count are zero, aborting\n"); ui__error("frequency and count are zero, aborting\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment