@@ -3094,66 +3094,46 @@ int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel,
30943094 return err ;
30953095}
30963096
3097- #define ANNOTATION__CFG (n ) \
3098- { .name = #n, .value = &annotation__default_options.n, }
3099-
3100- /*
3101- * Keep the entries sorted, they are bsearch'ed
3102- */
3103- static struct annotation_config {
3104- const char * name ;
3105- void * value ;
3106- } annotation__configs [] = {
3107- ANNOTATION__CFG (hide_src_code ),
3108- ANNOTATION__CFG (jump_arrows ),
3109- ANNOTATION__CFG (offset_level ),
3110- ANNOTATION__CFG (show_linenr ),
3111- ANNOTATION__CFG (show_nr_jumps ),
3112- ANNOTATION__CFG (show_nr_samples ),
3113- ANNOTATION__CFG (show_total_period ),
3114- ANNOTATION__CFG (use_offset ),
3115- };
3116-
3117- #undef ANNOTATION__CFG
3118-
3119- static int annotation_config__cmp (const void * name , const void * cfgp )
3097+ static int annotation__config (const char * var , const char * value , void * data )
31203098{
3121- const struct annotation_config * cfg = cfgp ;
3122-
3123- return strcmp (name , cfg -> name );
3124- }
3125-
3126- static int annotation__config (const char * var , const char * value ,
3127- void * data __maybe_unused )
3128- {
3129- struct annotation_config * cfg ;
3130- const char * name ;
3099+ struct annotation_options * opt = data ;
31313100
31323101 if (!strstarts (var , "annotate." ))
31333102 return 0 ;
31343103
3135- name = var + 9 ;
3136- cfg = bsearch (name , annotation__configs , ARRAY_SIZE (annotation__configs ),
3137- sizeof (struct annotation_config ), annotation_config__cmp );
3138-
3139- if (cfg == NULL )
3140- pr_debug ("%s variable unknown, ignoring..." , var );
3141- else if (strcmp (var , "annotate.offset_level" ) == 0 ) {
3142- perf_config_int (cfg -> value , name , value );
3143-
3144- if (* (int * )cfg -> value > ANNOTATION__MAX_OFFSET_LEVEL )
3145- * (int * )cfg -> value = ANNOTATION__MAX_OFFSET_LEVEL ;
3146- else if (* (int * )cfg -> value < ANNOTATION__MIN_OFFSET_LEVEL )
3147- * (int * )cfg -> value = ANNOTATION__MIN_OFFSET_LEVEL ;
3104+ if (!strcmp (var , "annotate.offset_level" )) {
3105+ perf_config_u8 (& opt -> offset_level , "offset_level" , value );
3106+
3107+ if (opt -> offset_level > ANNOTATION__MAX_OFFSET_LEVEL )
3108+ opt -> offset_level = ANNOTATION__MAX_OFFSET_LEVEL ;
3109+ else if (opt -> offset_level < ANNOTATION__MIN_OFFSET_LEVEL )
3110+ opt -> offset_level = ANNOTATION__MIN_OFFSET_LEVEL ;
3111+ } else if (!strcmp (var , "annotate.hide_src_code" )) {
3112+ opt -> hide_src_code = perf_config_bool ("hide_src_code" , value );
3113+ } else if (!strcmp (var , "annotate.jump_arrows" )) {
3114+ opt -> jump_arrows = perf_config_bool ("jump_arrows" , value );
3115+ } else if (!strcmp (var , "annotate.show_linenr" )) {
3116+ opt -> show_linenr = perf_config_bool ("show_linenr" , value );
3117+ } else if (!strcmp (var , "annotate.show_nr_jumps" )) {
3118+ opt -> show_nr_jumps = perf_config_bool ("show_nr_jumps" , value );
3119+ } else if (!strcmp (var , "annotate.show_nr_samples" )) {
3120+ symbol_conf .show_nr_samples = perf_config_bool ("show_nr_samples" ,
3121+ value );
3122+ } else if (!strcmp (var , "annotate.show_total_period" )) {
3123+ symbol_conf .show_total_period = perf_config_bool ("show_total_period" ,
3124+ value );
3125+ } else if (!strcmp (var , "annotate.use_offset" )) {
3126+ opt -> use_offset = perf_config_bool ("use_offset" , value );
31483127 } else {
3149- * ( bool * ) cfg -> value = perf_config_bool ( name , value );
3128+ pr_debug ( "%s variable unknown, ignoring..." , var );
31503129 }
3130+
31513131 return 0 ;
31523132}
31533133
3154- void annotation_config__init (void )
3134+ void annotation_config__init (struct annotation_options * opt )
31553135{
3156- perf_config (annotation__config , NULL );
3136+ perf_config (annotation__config , opt );
31573137}
31583138
31593139static unsigned int parse_percent_type (char * str1 , char * str2 )
0 commit comments