blob: ae6a789cb0f62780a9fa088f7fe99939c798ef2d [file] [log] [blame]
Namhyung Kim0985a942012-08-16 17:14:54 +09001#include <pthread.h>
2
Namhyung Kimea251d52012-09-03 11:53:06 +09003#include "../util/cache.h"
4#include "../util/debug.h"
5#include "../util/hist.h"
Arnaldo Carvalho de Melo3f7247e2011-10-18 13:45:16 -02006
Namhyung Kim0985a942012-08-16 17:14:54 +09007pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
8
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -02009void setup_browser(bool fallback_to_pager)
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030010{
Namhyung Kim2b676bf2013-02-07 18:02:08 +090011 if (use_browser < 2 && (!isatty(1) || dump_trace))
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030012 use_browser = 0;
Namhyung Kim281ef542012-04-30 13:55:08 +090013
14 /* default to TUI */
15 if (use_browser < 0)
16 use_browser = 1;
17
18 switch (use_browser) {
19 case 2:
Namhyung Kimdc41b9b2012-04-30 13:55:09 +090020 if (perf_gtk__init() == 0)
21 break;
22 /* fall through */
Namhyung Kim281ef542012-04-30 13:55:08 +090023 case 1:
Namhyung Kimdc41b9b2012-04-30 13:55:09 +090024 use_browser = 1;
25 if (ui__init() == 0)
26 break;
27 /* fall through */
Namhyung Kim281ef542012-04-30 13:55:08 +090028 default:
Namhyung Kim21f0d422012-05-28 23:53:22 +090029 use_browser = 0;
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -020030 if (fallback_to_pager)
31 setup_pager();
Namhyung Kimea251d52012-09-03 11:53:06 +090032
Jiri Olsa12400052012-10-13 00:06:16 +020033 perf_hpp__column_enable(PERF_HPP__OVERHEAD);
Jiri Olsa1d778222012-10-04 21:49:39 +090034 perf_hpp__init();
Namhyung Kim281ef542012-04-30 13:55:08 +090035 break;
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030036 }
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030037}
38
39void exit_browser(bool wait_for_ok)
40{
Namhyung Kim281ef542012-04-30 13:55:08 +090041 switch (use_browser) {
42 case 2:
43 perf_gtk__exit(wait_for_ok);
44 break;
45
46 case 1:
47 ui__exit(wait_for_ok);
48 break;
49
50 default:
51 break;
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030052 }
53}