~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/ui/setup.c

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #include <pthread.h>
  2 #include <dlfcn.h>
  3 
  4 #include "../util/cache.h"
  5 #include "../util/debug.h"
  6 #include "../util/hist.h"
  7 #include "../util/util.h"
  8 
  9 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 10 void *perf_gtk_handle;
 11 int use_browser = -1;
 12 
 13 #define PERF_GTK_DSO "libperf-gtk.so"
 14 
 15 #ifdef HAVE_GTK2_SUPPORT
 16 
 17 static int setup_gtk_browser(void)
 18 {
 19         int (*perf_ui_init)(void);
 20 
 21         if (perf_gtk_handle)
 22                 return 0;
 23 
 24         perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
 25         if (perf_gtk_handle == NULL) {
 26                 char buf[PATH_MAX];
 27                 scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
 28                 perf_gtk_handle = dlopen(buf, RTLD_LAZY);
 29         }
 30         if (perf_gtk_handle == NULL)
 31                 return -1;
 32 
 33         perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
 34         if (perf_ui_init == NULL)
 35                 goto out_close;
 36 
 37         if (perf_ui_init() == 0)
 38                 return 0;
 39 
 40 out_close:
 41         dlclose(perf_gtk_handle);
 42         return -1;
 43 }
 44 
 45 static void exit_gtk_browser(bool wait_for_ok)
 46 {
 47         void (*perf_ui_exit)(bool);
 48 
 49         if (perf_gtk_handle == NULL)
 50                 return;
 51 
 52         perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
 53         if (perf_ui_exit == NULL)
 54                 goto out_close;
 55 
 56         perf_ui_exit(wait_for_ok);
 57 
 58 out_close:
 59         dlclose(perf_gtk_handle);
 60 
 61         perf_gtk_handle = NULL;
 62 }
 63 #else
 64 static inline int setup_gtk_browser(void) { return -1; }
 65 static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
 66 #endif
 67 
 68 int stdio__config_color(const struct option *opt __maybe_unused,
 69                         const char *mode, int unset __maybe_unused)
 70 {
 71         perf_use_color_default = perf_config_colorbool("color.ui", mode, -1);
 72         return 0;
 73 }
 74 
 75 void setup_browser(bool fallback_to_pager)
 76 {
 77         if (use_browser < 2 && (!isatty(1) || dump_trace))
 78                 use_browser = 0;
 79 
 80         /* default to TUI */
 81         if (use_browser < 0)
 82                 use_browser = 1;
 83 
 84         switch (use_browser) {
 85         case 2:
 86                 if (setup_gtk_browser() == 0)
 87                         break;
 88                 printf("GTK browser requested but could not find %s\n",
 89                        PERF_GTK_DSO);
 90                 sleep(1);
 91                 /* fall through */
 92         case 1:
 93                 use_browser = 1;
 94                 if (ui__init() == 0)
 95                         break;
 96                 /* fall through */
 97         default:
 98                 use_browser = 0;
 99                 if (fallback_to_pager)
100                         setup_pager();
101                 break;
102         }
103 }
104 
105 void exit_browser(bool wait_for_ok)
106 {
107         switch (use_browser) {
108         case 2:
109                 exit_gtk_browser(wait_for_ok);
110                 break;
111 
112         case 1:
113                 ui__exit(wait_for_ok);
114                 break;
115 
116         default:
117                 break;
118         }
119 }
120 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp