Skip to content

Commit

Permalink
perf ui/tui: Show fatal error message only if exists
Browse files Browse the repository at this point in the history
When perf exits with some error it shows the error message with
ui__error() or ui__warning() and then calls ui__exit() during
exit_browser().

On TUI, it then shows a window titled "Fatal Error" to inform user a
last message which might be related with this condition.  However it
sometimes contains no message and just annoyes users.

The usual case for this is running perf top as normal user.  (And
/proc/sys/kernel/perf_event_paranoid being 1).

Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
namhyung authored and acmel committed Jan 22, 2015
1 parent 605a306 commit 4397bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tools/perf/ui/tui/helpline.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../libslang.h"

char ui_helpline__last_msg[1024];
bool tui_helpline__set;

static void tui_helpline__pop(void)
{
Expand All @@ -35,6 +36,8 @@ static int tui_helpline__show(const char *format, va_list ap)
sizeof(ui_helpline__last_msg) - backlog, format, ap);
backlog += ret;

tui_helpline__set = true;

if (ui_helpline__last_msg[backlog - 1] == '\n') {
ui_helpline__puts(ui_helpline__last_msg);
SLsmg_refresh();
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/ui/tui/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
static volatile int ui__need_resize;

extern struct perf_error_ops perf_tui_eops;
extern bool tui_helpline__set;

extern void hist_browser__init_hpp(void);

Expand Down Expand Up @@ -159,7 +160,7 @@ int ui__init(void)

void ui__exit(bool wait_for_ok)
{
if (wait_for_ok)
if (wait_for_ok && tui_helpline__set)
ui__question_window("Fatal Error",
ui_helpline__last_msg,
"Press any key...", 0);
Expand Down

0 comments on commit 4397bd2

Please sign in to comment.