@@ -66,6 +66,7 @@ static uint8_t global_verbose;
66
66
static uint8_t recursive ;
67
67
static size_t cacheline_size ;
68
68
static uint8_t find_containers ;
69
+ static bool find_enumeration_with_enumerator ;
69
70
static uint8_t find_pointers_in_structs ;
70
71
static int reorganize ;
71
72
static bool show_private_classes ;
@@ -75,6 +76,7 @@ static bool just_structs;
75
76
static bool just_packed_structs ;
76
77
static int show_reorg_steps ;
77
78
static const char * class_name ;
79
+ static const char * enumerator_name ;
78
80
static LIST_HEAD (class_names );
79
81
static char separator = '\t' ;
80
82
@@ -1232,6 +1234,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
1232
1234
#define ARGP_btf_features 341
1233
1235
#define ARGP_supported_btf_features 342
1234
1236
#define ARGP_btf_features_strict 343
1237
+ #define ARGP_contains_enumerator 344
1235
1238
1236
1239
/* --btf_features=feature1[,feature2,..] allows us to specify
1237
1240
* a list of requested BTF features or "all" to enable all features.
@@ -1445,6 +1448,12 @@ static const struct argp_option pahole__options[] = {
1445
1448
.arg = "CLASS_NAME" ,
1446
1449
.doc = "Show classes that contains CLASS_NAME"
1447
1450
},
1451
+ {
1452
+ .name = "contains_enumerator" ,
1453
+ .key = ARGP_contains_enumerator ,
1454
+ .arg = "ENUMERATOR" ,
1455
+ .doc = "Show enumerations that contains ENUMERATOR"
1456
+ },
1448
1457
{
1449
1458
.name = "show_decl_info" ,
1450
1459
.key = 'I' ,
@@ -1841,6 +1850,9 @@ static error_t pahole__options_parser(int key, char *arg,
1841
1850
conf_load .extra_dbg_info = 1 ; break ;
1842
1851
case 'i' : find_containers = 1 ;
1843
1852
class_name = arg ; break ;
1853
+ case ARGP_contains_enumerator :
1854
+ find_enumeration_with_enumerator = true;
1855
+ enumerator_name = arg ; break ;
1844
1856
case 'j' :
1845
1857
#if _ELFUTILS_PREREQ (0 , 178 )
1846
1858
conf_load .nr_jobs = arg ? atoi (arg ) :
@@ -3124,6 +3136,22 @@ static int type__find_type_enum(struct type *type, struct cu *cu, const char *ty
3124
3136
3125
3137
static struct type_instance * header ;
3126
3138
3139
+ static bool print_enumeration_with_enumerator (struct cu * cu , const char * name )
3140
+ {
3141
+ struct type * enumeration ;
3142
+ uint32_t id ;
3143
+
3144
+ cu__for_each_enumeration (cu , id , enumeration ) {
3145
+ if (enumeration__find_enumerator (enumeration , name ) != NULL ) {
3146
+ enumeration__fprintf (type__tag (enumeration ), & conf , stdout );
3147
+ fputc ('\n' , stdout );
3148
+ return true;
3149
+ }
3150
+ }
3151
+
3152
+ return false;
3153
+ }
3154
+
3127
3155
struct thread_data {
3128
3156
struct btf * btf ;
3129
3157
struct btf_encoder * encoder ;
@@ -3209,6 +3237,10 @@ static enum load_steal_kind pahole_stealer(struct cu *cu,
3209
3237
cu__fprintf_ptr_table_stats_csv (cu , stderr );
3210
3238
}
3211
3239
3240
+ if (find_enumeration_with_enumerator &&
3241
+ print_enumeration_with_enumerator (cu , enumerator_name ))
3242
+ return LSK__DELETE ; // Maybe we can find this in several CUs, so don't stop it
3243
+
3212
3244
if (btf_encode ) {
3213
3245
static pthread_mutex_t btf_lock = PTHREAD_MUTEX_INITIALIZER ;
3214
3246
struct btf_encoder * encoder ;
0 commit comments