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

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

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

~ [ 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