Namhyung Kim | 0985a94 | 2012-08-16 17:14:54 +0900 | [diff] [blame] | 1 | #include <pthread.h> |
2 | |||||
Namhyung Kim | ea251d5 | 2012-09-03 11:53:06 +0900 | [diff] [blame] | 3 | #include "../util/cache.h" |
4 | #include "../util/debug.h" | ||||
5 | #include "../util/hist.h" | ||||
Arnaldo Carvalho de Melo | 3f7247e | 2011-10-18 13:45:16 -0200 | [diff] [blame] | 6 | |
Namhyung Kim | 0985a94 | 2012-08-16 17:14:54 +0900 | [diff] [blame] | 7 | pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; |
8 | |||||
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 9 | void setup_browser(bool fallback_to_pager) |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 10 | { |
Namhyung Kim | 2b676bf | 2013-02-07 18:02:08 +0900 | [diff] [blame] | 11 | if (use_browser < 2 && (!isatty(1) || dump_trace)) |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 12 | use_browser = 0; |
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 13 | |
14 | /* default to TUI */ | ||||
15 | if (use_browser < 0) | ||||
16 | use_browser = 1; | ||||
17 | |||||
18 | switch (use_browser) { | ||||
19 | case 2: | ||||
Namhyung Kim | dc41b9b | 2012-04-30 13:55:09 +0900 | [diff] [blame] | 20 | if (perf_gtk__init() == 0) |
21 | break; | ||||
22 | /* fall through */ | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 23 | case 1: |
Namhyung Kim | dc41b9b | 2012-04-30 13:55:09 +0900 | [diff] [blame] | 24 | use_browser = 1; |
25 | if (ui__init() == 0) | ||||
26 | break; | ||||
27 | /* fall through */ | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 28 | default: |
Namhyung Kim | 21f0d42 | 2012-05-28 23:53:22 +0900 | [diff] [blame] | 29 | use_browser = 0; |
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 30 | if (fallback_to_pager) |
31 | setup_pager(); | ||||
Namhyung Kim | ea251d5 | 2012-09-03 11:53:06 +0900 | [diff] [blame] | 32 | |
Jiri Olsa | 1240005 | 2012-10-13 00:06:16 +0200 | [diff] [blame] | 33 | perf_hpp__column_enable(PERF_HPP__OVERHEAD); |
Jiri Olsa | 1d77822 | 2012-10-04 21:49:39 +0900 | [diff] [blame] | 34 | perf_hpp__init(); |
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 35 | break; |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 36 | } |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 37 | } |
38 | |||||
39 | void exit_browser(bool wait_for_ok) | ||||
40 | { | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 41 | 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 Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 52 | } |
53 | } |