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

TOMOYO Linux Cross Reference
Linux/tools/perf/builtin-check.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/builtin-check.c (Version linux-6.12-rc7) and /tools/perf/builtin-check.c (Version linux-6.11.7)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 #include "builtin.h"                              
  3 #include "color.h"                                
  4 #include "util/debug.h"                           
  5 #include "util/header.h"                          
  6 #include <tools/config.h>                         
  7 #include <stdbool.h>                              
  8 #include <stdio.h>                                
  9 #include <string.h>                               
 10 #include <subcmd/parse-options.h>                 
 11                                                   
 12 static const char * const check_subcommands[]     
 13 static struct option check_options[] = {          
 14         OPT_BOOLEAN('q', "quiet", &quiet, "do     
 15         OPT_END()                                 
 16 };                                                
 17 static struct option check_feature_options[] =    
 18                                                   
 19 static const char *check_usage[] = { NULL, NUL    
 20 static const char *check_feature_usage[] = {      
 21         "perf check feature <feature_list>",      
 22         NULL                                      
 23 };                                                
 24                                                   
 25 struct feature_status supported_features[] = {    
 26         FEATURE_STATUS("aio", HAVE_AIO_SUPPORT    
 27         FEATURE_STATUS("bpf", HAVE_LIBBPF_SUPP    
 28         FEATURE_STATUS("bpf_skeletons", HAVE_B    
 29         FEATURE_STATUS("debuginfod", HAVE_DEBU    
 30         FEATURE_STATUS("dwarf", HAVE_DWARF_SUP    
 31         FEATURE_STATUS("dwarf_getlocations", H    
 32         FEATURE_STATUS("dwarf-unwind", HAVE_DW    
 33         FEATURE_STATUS("auxtrace", HAVE_AUXTRA    
 34         FEATURE_STATUS("libaudit", HAVE_LIBAUD    
 35         FEATURE_STATUS("libbfd", HAVE_LIBBFD_S    
 36         FEATURE_STATUS("libcapstone", HAVE_LIB    
 37         FEATURE_STATUS("libcrypto", HAVE_LIBCR    
 38         FEATURE_STATUS("libdw-dwarf-unwind", H    
 39         FEATURE_STATUS("libelf", HAVE_LIBELF_S    
 40         FEATURE_STATUS("libnuma", HAVE_LIBNUMA    
 41         FEATURE_STATUS("libopencsd", HAVE_CSTR    
 42         FEATURE_STATUS("libperl", HAVE_LIBPERL    
 43         FEATURE_STATUS("libpfm4", HAVE_LIBPFM)    
 44         FEATURE_STATUS("libpython", HAVE_LIBPY    
 45         FEATURE_STATUS("libslang", HAVE_SLANG_    
 46         FEATURE_STATUS("libtraceevent", HAVE_L    
 47         FEATURE_STATUS("libunwind", HAVE_LIBUN    
 48         FEATURE_STATUS("lzma", HAVE_LZMA_SUPPO    
 49         FEATURE_STATUS("numa_num_possible_cpus    
 50         FEATURE_STATUS("syscall_table", HAVE_S    
 51         FEATURE_STATUS("zlib", HAVE_ZLIB_SUPPO    
 52         FEATURE_STATUS("zstd", HAVE_ZSTD_SUPPO    
 53                                                   
 54         /* this should remain at end, to know     
 55         FEATURE_STATUS(NULL, _)                   
 56 };                                                
 57                                                   
 58 static void on_off_print(const char *status)      
 59 {                                                 
 60         printf("[ ");                             
 61                                                   
 62         if (!strcmp(status, "OFF"))               
 63                 color_fprintf(stdout, PERF_COL    
 64         else                                      
 65                 color_fprintf(stdout, PERF_COL    
 66                                                   
 67         printf(" ]");                             
 68 }                                                 
 69                                                   
 70 /* Helper function to print status of a featur    
 71 static void status_print(const char *name, con    
 72                          const char *status)      
 73 {                                                 
 74         printf("%22s: ", name);                   
 75         on_off_print(status);                     
 76         printf("  # %s\n", macro);                
 77 }                                                 
 78                                                   
 79 #define STATUS(feature)                           
 80 do {                                              
 81         if (feature.is_builtin)                   
 82                 status_print(feature.name, fea    
 83         else                                      
 84                 status_print(feature.name, fea    
 85 } while (0)                                       
 86                                                   
 87 /**                                               
 88  * check whether "feature" is built-in with pe    
 89  *                                                
 90  * returns:                                       
 91  *    0: NOT built-in or Feature not known        
 92  *    1: Built-in                                 
 93  */                                               
 94 static int has_support(const char *feature)       
 95 {                                                 
 96         for (int i = 0; supported_features[i].    
 97                 if ((strcasecmp(feature, suppo    
 98                     (strcasecmp(feature, suppo    
 99                         if (!quiet)               
100                                 STATUS(support    
101                         return supported_featu    
102                 }                                 
103         }                                         
104                                                   
105         if (!quiet)                               
106                 pr_err("Unknown feature '%s',     
107                                                   
108         return 0;                                 
109 }                                                 
110                                                   
111                                                   
112 /**                                               
113  * Usage: 'perf check feature <feature_list>'     
114  *                                                
115  * <feature_list> can be a single feature name    
116  * of feature names/macros                        
117  * eg. argument can be "libtraceevent" or "lib    
118  *                                                
119  * In case of a comma-separated list, feature_    
120  * all features passed in the string are suppo    
121  *                                                
122  * Note that argv will get modified               
123  */                                               
124 static int subcommand_feature(int argc, const     
125 {                                                 
126         char *feature_list;                       
127         char *feature_name;                       
128         int feature_enabled;                      
129                                                   
130         argc = parse_options(argc, argv, check    
131                         check_feature_usage, 0    
132                                                   
133         if (!argc)                                
134                 usage_with_options(check_featu    
135                                                   
136         if (argc > 1) {                           
137                 pr_err("Too many arguments pas    
138                 return -1;                        
139         }                                         
140                                                   
141         feature_enabled = 1;                      
142         /* feature_list is a non-const copy of    
143         feature_list = strdup(argv[0]);           
144         if (!feature_list) {                      
145                 pr_err("ERROR: failed to alloc    
146                 return -1;                        
147         }                                         
148                                                   
149         feature_name = strtok(feature_list, ",    
150                                                   
151         while (feature_name) {                    
152                 feature_enabled &= has_support    
153                 feature_name = strtok(NULL, ",    
154         }                                         
155                                                   
156         free(feature_list);                       
157                                                   
158         return !feature_enabled;                  
159 }                                                 
160                                                   
161 int cmd_check(int argc, const char **argv)        
162 {                                                 
163         argc = parse_options_subcommand(argc,     
164                         check_subcommands, che    
165                                                   
166         if (!argc)                                
167                 usage_with_options(check_usage    
168                                                   
169         if (strcmp(argv[0], "feature") == 0)      
170                 return subcommand_feature(argc    
171                                                   
172         /* If no subcommand matched above, pri    
173         pr_err("Unknown subcommand: %s\n", arg    
174         usage_with_options(check_usage, check_    
175                                                   
176         /* free usage string allocated by pars    
177         free((void *)check_usage[0]);             
178                                                   
179         return 0;                                 
180 }                                                 
181                                                   

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php