4 SPDX-License-Identifier: GPL-2.0-only
6 Copyright (C) 2006 Mandriva Conectiva S.A.
7 Copyright (C) 2006..2019 Arnaldo Carvalho de Melo <acme@redhat.com>
16 #include <elfutils/libdwfl.h>
17 #include <sys/types.h>
23 /* Force a compilation error if condition is true, but also produce a
24 result (of value 0 and type size_t), so the expression can be used
25 e.g. in a structure initializer (or where-ever else comma expressions
27 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
29 /* Are two types/vars the same type (ignoring qualifiers)? */
31 # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
34 /* &a[0] degrades to a pointer: a different type from an array */
35 #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
37 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
41 enum load_steal_kind
{
48 * BTF combines all the types into one big CU using btf_dedup(), so for something
49 * like a allyesconfig vmlinux kernel we can get over 65535 types.
51 typedef uint32_t type_id_t
;
56 /** struct conf_load - load configuration
57 * @extra_dbg_info - keep original debugging format extra info
58 * (e.g. DWARF's decl_{line,file}, id, etc)
59 * @fixup_silly_bitfields - Fixup silly things such as "int foo:32;"
60 * @get_addr_info - wheter to load DW_AT_location and other addr info
61 * @nr_jobs - -j argument, number of threads to use
62 * @ptr_table_stats - print developer oriented ptr_table statistics.
63 * @skip_missing - skip missing types rather than bailing out.
66 enum load_steal_kind (*steal
)(struct cu
*cu
, struct conf_load
*conf
);
67 struct cu
* (*early_cu_filter
)(struct cu
*cu
);
73 bool fixup_silly_bitfields
;
75 bool ignore_alignment_attr
;
76 bool ignore_inline_expansions
;
79 bool skip_encoding_btf_decl_tag
;
81 bool skip_encoding_btf_type_tag
;
82 bool skip_encoding_btf_enum64
;
83 bool btf_gen_optimized
;
84 bool skip_encoding_btf_inconsistent_proto
;
85 bool skip_encoding_btf_vars
;
86 bool encode_btf_global_vars
;
88 bool btf_encode_force
;
89 bool reproducible_build
;
90 bool btf_decl_tag_kfuncs
;
91 bool btf_gen_distilled_base
;
92 uint8_t hashtable_bits
;
93 uint8_t max_hashtable_bits
;
94 uint16_t kabi_prefix_len
;
95 const char *kabi_prefix
;
97 struct conf_fprintf
*conf_fprintf
;
100 /** struct conf_fprintf - hints to the __fprintf routines
102 * @count - Just like 'dd', stop pretty printing input after 'count' records
103 * @skip - Just like 'dd', skip 'count' records when pretty printing input
104 * @seek_bytes - Number of bytes to seek, if stdin only from start, when we have --pretty FILE, then from the end as well with negative numbers,
105 * may be of the form $header.MEMBER_NAME when using with --header.
106 * @size_bytes - Number of bytes to read, similar to seek_bytes, and when both are in place, first seek seek_bytes then read size_bytes
107 * @range - data structure field in --header to determine --seek_bytes and --size_bytes, must have 'offset' and 'size' fields
108 * @flat_arrays - a->foo[10][2] becomes a->foo[20]
109 * @classes_as_structs - class f becomes struct f, CTF doesn't have a "class"
110 * @cachelinep - pointer to current cacheline, so that when expanding types we keep track of it,
111 * needs to be "global", i.e. not set at each recursion.
112 * @suppress_force_paddings: This makes sense only if the debugging format has struct alignment information,
113 * So allow for it to be disabled and disable it automatically for things like BTF,
114 * that don't have such info.
115 * @skip_emitting_atomic_typedefs: Allow not emitting "typedef _Atomic int atomic_int;" and friends
117 struct conf_fprintf
{
120 int32_t type_spacing
;
121 int32_t name_spacing
;
122 uint32_t base_offset
;
124 uint32_t *cachelinep
;
125 const char *seek_bytes
;
126 const char *size_bytes
;
127 const char *header_type
;
130 uint16_t cacheline_size
;
132 uint8_t expand_types
:1;
133 uint8_t expand_pointers
:1;
134 uint8_t rel_offset
:1;
135 uint8_t emit_stats
:1;
136 uint8_t suppress_comments
:1;
137 uint8_t has_alignment_info
:1;
138 uint8_t suppress_aligned_attribute
:1;
139 uint8_t suppress_offset_comment
:1;
140 uint8_t suppress_force_paddings
:1;
141 uint8_t suppress_packed
:1;
142 uint8_t show_decl_info
:1;
143 uint8_t show_only_data_members
:1;
144 uint8_t no_semicolon
:1;
145 uint8_t show_first_biggest_size_base_type_member
:1;
146 uint8_t flat_arrays
:1;
147 uint8_t first_member
:1;
148 uint8_t last_member
:1;
149 uint8_t union_member
:1;
150 uint8_t no_parm_names
:1;
151 uint8_t classes_as_structs
:1;
153 uint8_t strip_inline
:1;
154 uint8_t skip_emitting_atomic_typedefs
:1;
155 uint8_t skip_emitting_errors
:1;
156 uint8_t skip_emitting_modifier
:1;
161 struct cus
*cus__new(void);
162 void cus__delete(struct cus
*cus
);
164 int cus__load_file(struct cus
*cus
, struct conf_load
*conf
,
165 const char *filename
);
166 int cus__load_files(struct cus
*cus
, struct conf_load
*conf
,
168 int cus__fprintf_load_files_err(struct cus
*cus
, const char *tool
,
169 char *argv
[], int err
, FILE *output
);
170 int cus__load_dir(struct cus
*cus
, struct conf_load
*conf
,
171 const char *dirname
, const char *filename_mask
,
172 const int recursive
);
173 void __cus__add(struct cus
*cus
, struct cu
*cu
);
174 void cus__add(struct cus
*cus
, struct cu
*cu
);
176 void __cus__remove(struct cus
*cus
, struct cu
*cu
);
177 void cus__remove(struct cus
*cus
, struct cu
*cu
);
179 void cus__print_error_msg(const char *progname
, const struct cus
*cus
,
180 const char *filename
, const int err
);
181 struct cu
*cus__find_pair(struct cus
*cus
, const char *name
);
182 struct cu
*cus__find_cu_by_name(struct cus
*cus
, const char *name
);
183 struct tag
*cus__find_struct_by_name(struct cus
*cus
, struct cu
**cu
,
184 const char *name
, const int include_decls
,
186 struct tag
*cus__find_struct_or_union_by_name(struct cus
*cus
, struct cu
**cu
,
187 const char *name
, const int include_decls
, type_id_t
*id
);
188 void *cu__tag_alloc(struct cu
*cu
, size_t size
);
189 void cu__tag_free(struct cu
*cu
, struct tag
*tag
);
190 struct tag
*cu__find_type_by_name(const struct cu
*cu
, const char *name
, const int include_decls
, type_id_t
*idp
);
191 struct tag
*cus__find_type_by_name(struct cus
*cus
, struct cu
**cu
, const char *name
,
192 const int include_decls
, type_id_t
*id
);
193 struct function
*cus__find_function_at_addr(struct cus
*cus
, uint64_t addr
, struct cu
**cu
);
194 void cus__for_each_cu(struct cus
*cus
, int (*iterator
)(struct cu
*cu
, void *cookie
),
196 struct cu
*(*filter
)(struct cu
*cu
));
197 bool cus__empty(const struct cus
*cus
);
198 uint32_t cus__nr_entries(const struct cus
*cus
);
200 void cus__lock(struct cus
*cus
);
201 void cus__unlock(struct cus
*cus
);
203 void *cus__priv(struct cus
*cus
);
204 void cus__set_priv(struct cus
*cus
, void *priv
);
206 void cus__set_loader_exit(struct cus
*cus
, void (*loader_exit
)(struct cus
*cus
));
211 uint32_t allocated_entries
;
219 /* Same as DW_LANG, so that we don't have to include dwarf.h in CTF */
220 enum dwarf_languages
{
221 LANG_C89
= 0x01, /* ISO C:1989 */
222 LANG_C
= 0x02, /* C */
223 LANG_Ada83
= 0x03, /* ISO Ada:1983 */
224 LANG_C_plus_plus
= 0x04, /* ISO C++:1998 */
225 LANG_Cobol74
= 0x05, /* ISO Cobol:1974 */
226 LANG_Cobol85
= 0x06, /* ISO Cobol:1985 */
227 LANG_Fortran77
= 0x07, /* ISO FORTRAN 77 */
228 LANG_Fortran90
= 0x08, /* ISO Fortran 90 */
229 LANG_Pascal83
= 0x09, /* ISO Pascal:1983 */
230 LANG_Modula2
= 0x0a, /* ISO Modula-2:1996 */
231 LANG_Java
= 0x0b, /* Java */
232 LANG_C99
= 0x0c, /* ISO C:1999 */
233 LANG_Ada95
= 0x0d, /* ISO Ada:1995 */
234 LANG_Fortran95
= 0x0e, /* ISO Fortran 95 */
235 LANG_PL1
= 0x0f, /* ISO PL/1:1976 */
236 LANG_Objc
= 0x10, /* Objective-C */
237 LANG_ObjC_plus_plus
= 0x11, /* Objective-C++ */
238 LANG_UPC
= 0x12, /* Unified Parallel C */
239 LANG_D
= 0x13, /* D */
242 /** struct debug_fmt_ops - specific to the underlying debug file format
244 * cu__delete - called at cu__delete(), to give a chance to formats such as
245 * CTF to keep the .strstab ELF section available till the cu is
248 struct debug_fmt_ops
{
252 int (*load_file
)(struct cus
*cus
,
253 struct conf_load
*conf
,
254 const char *filename
);
255 const char *(*tag__decl_file
)(const struct tag
*tag
,
256 const struct cu
*cu
);
257 uint32_t (*tag__decl_line
)(const struct tag
*tag
,
258 const struct cu
*cu
);
259 unsigned long long (*tag__orig_id
)(const struct tag
*tag
,
260 const struct cu
*cu
);
261 void *(*tag__alloc
)(struct cu
*cu
, size_t size
);
262 void (*tag__free
)(struct tag
*tag
, struct cu
*cu
);
263 void (*cu__delete
)(struct cu
*cu
);
264 bool has_alignment_info
;
267 #define ARCH_MAX_REGISTER_PARAMS 8
270 struct list_head node
;
271 struct list_head tags
;
272 struct list_head tool_list
; /* To be used by tools such as ctracer */
273 struct ptr_table types_table
;
274 struct ptr_table functions_table
;
275 struct ptr_table tags_table
;
276 struct rb_root functions
;
281 struct debug_fmt_ops
*dfops
;
284 struct obstack obstack
;
285 uint32_t cached_symtab_nr_entries
;
288 uint8_t extra_dbg_info
:1;
289 uint8_t has_addr_info
:1;
290 uint8_t uses_global_strings
:1;
291 uint8_t little_endian
:1;
292 uint8_t nr_register_params
;
293 int register_params
[ARCH_MAX_REGISTER_PARAMS
];
296 unsigned long nr_inline_expansions
;
297 size_t size_inline_expansions
;
298 uint32_t nr_functions_changed
;
299 uint32_t nr_structures_changed
;
300 size_t max_len_changed_item
;
301 size_t function_bytes_added
;
302 size_t function_bytes_removed
;
304 unsigned char build_id
[0];
307 struct cu
*cu__new(const char *name
, uint8_t addr_size
,
308 const unsigned char *build_id
, int build_id_len
,
309 const char *filename
, bool use_obstack
);
310 void cu__delete(struct cu
*cu
);
312 void *cu__malloc(struct cu
*cu
, size_t size
);
313 void *cu__zalloc(struct cu
*cu
, size_t size
);
314 void cu__free(struct cu
*cu
, void *ptr
);
316 int cu__fprintf_ptr_table_stats_csv(struct cu
*cu
, FILE *fp
);
318 int cus__fprintf_ptr_table_stats_csv_header(FILE *fp
);
320 static inline int cu__cache_symtab(struct cu
*cu
)
322 int err
= dwfl_module_getsymtab(cu
->dwfl
);
324 cu
->cached_symtab_nr_entries
= dwfl_module_getsymtab(cu
->dwfl
);
328 static inline __pure
bool cu__is_c_plus_plus(const struct cu
*cu
)
330 return cu
->language
== LANG_C_plus_plus
;
333 static inline __pure
bool cu__is_c(const struct cu
*cu
)
335 return cu
->language
== LANG_C
;
338 int lang__str2int(const char *lang
);
339 const char *lang__int2str(int lang
);
348 int languages__init(struct languages
*languages
, const char *tool
);
349 int languages__parse(struct languages
*languages
, const char *tool
);
350 bool languages__in(struct languages
*languages
, int lang
);
351 bool languages__cu_filtered(struct languages
*languages
, struct cu
*cu
, bool verbose
);
354 * cu__for_each_cached_symtab_entry - iterate thru the cached symtab entries
355 * @cu: struct cu instance
356 * @id: uint32_t tag id
357 * @pos: struct GElf_Sym iterator
358 * @name: char pointer where the symbol_name will be stored
360 #define cu__for_each_cached_symtab_entry(cu, id, pos, name) \
362 name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL); \
363 id < cu->cached_symtab_nr_entries; \
364 ++id, name = dwfl_module_getsym(cu->dwfl, id, &sym, NULL))
367 * cu__for_each_type - iterate thru all the type tags
368 * @cu: struct cu instance to iterate
370 * @pos: struct tag iterator
372 * See cu__table_nullify_type_entry and users for the reason for
373 * the NULL test (hint: CTF Unknown types)
375 #define cu__for_each_type(cu, id, pos) \
376 for (id = 1; id < cu->types_table.nr_entries; ++id) \
377 if (!(pos = cu->types_table.entries[id])) \
382 * cu__for_each_struct - iterate thru all the struct tags
383 * @cu: struct cu instance to iterate
384 * @pos: struct class iterator
387 #define cu__for_each_struct(cu, id, pos) \
388 for (id = 1; id < cu->types_table.nr_entries; ++id) \
389 if (!(pos = tag__class(cu->types_table.entries[id])) || \
390 !tag__is_struct(class__tag(pos))) \
395 * cu__for_each_struct_or_union - iterate thru all the struct and union tags
396 * @cu: struct cu instance to iterate
397 * @pos: struct class iterator
398 * @id: type_id_t tag id
400 #define cu__for_each_struct_or_union(cu, id, pos) \
401 for (id = 1; id < cu->types_table.nr_entries; ++id) \
402 if (!(pos = tag__class(cu->types_table.entries[id])) || \
403 !(tag__is_struct(class__tag(pos)) || \
404 tag__is_union(class__tag(pos)))) \
409 * cu__for_each_enumeration - iterate thru all the enumeration tags
410 * @cu: enumeration cu instance to iterate
411 * @pos: enumeration iterator
414 #define cu__for_each_enumeration(cu, id, pos) \
415 for (id = 1; id < cu->types_table.nr_entries; ++id) \
416 if (!(pos = tag__type(cu->types_table.entries[id])) || \
417 !tag__is_enumeration(type__tag(pos))) \
422 * cu__for_each_function - iterate thru all the function tags
423 * @cu: struct cu instance to iterate
424 * @pos: struct function iterator
425 * @id: uint32_t tag id
427 #define cu__for_each_function(cu, id, pos) \
428 for (id = 0; id < cu->functions_table.nr_entries; ++id) \
429 if (!(pos = tag__function(cu->functions_table.entries[id]))) \
434 * cu__for_each_variable - iterate thru all the global variable tags
435 * @cu: struct cu instance to iterate
436 * @pos: struct tag iterator
437 * @id: uint32_t tag id
439 #define cu__for_each_variable(cu, id, pos) \
440 for (id = 0; id < cu->tags_table.nr_entries; ++id) \
441 if (!(pos = cu->tags_table.entries[id]) || \
442 !tag__is_variable(pos)) \
447 * cu__for_each_constant - iterate thru all the global constant tags
448 * @cu: struct cu instance to iterate
449 * @pos: struct tag iterator
450 * @id: uint32_t tag id
452 #define cu__for_each_constant(cu, id, pos) \
453 for (id = 0; id < cu->tags_table.nr_entries; ++id) \
454 if (!(pos = cu->tags_table.entries[id]) || \
455 !tag__is_constant(pos)) \
460 * cu__for_each_namespace - iterate thru all the global namespace tags
461 * @cu: struct cu instance to iterate
462 * @pos: struct tag iterator
463 * @id: uint32_t tag id
465 #define cu__for_each_namespace(cu, id, pos) \
466 for (id = 0; id < cu->tags_table.nr_entries; ++id) \
467 if (!(pos = cu->tags_table.entries[id]) || \
468 !tag__is_namespace(pos)) \
472 int cu__add_tag(struct cu
*cu
, struct tag
*tag
, uint32_t *id
);
473 int cu__add_tag_with_id(struct cu
*cu
, struct tag
*tag
, uint32_t id
);
474 int cu__table_add_tag(struct cu
*cu
, struct tag
*tag
, uint32_t *id
);
475 int cu__table_add_tag_with_id(struct cu
*cu
, struct tag
*tag
, uint32_t id
);
476 int cu__table_nullify_type_entry(struct cu
*cu
, uint32_t id
);
477 struct tag
*cu__find_base_type_by_name(const struct cu
*cu
, const char *name
,
479 struct tag
*cu__find_base_type_by_name_and_size(const struct cu
*cu
, const char* name
,
480 uint16_t bit_size
, type_id_t
*idp
);
481 struct tag
*cu__find_enumeration_by_name(const struct cu
*cu
, const char *name
, type_id_t
*idp
);
482 struct tag
*cu__find_enumeration_by_name_and_size(const struct cu
*cu
, const char* name
,
483 uint16_t bit_size
, type_id_t
*idp
);
484 struct tag
*cu__find_first_typedef_of_type(const struct cu
*cu
,
485 const type_id_t type
);
486 struct tag
*cu__find_function_by_name(const struct cu
*cu
, const char *name
);
487 struct function
*cu__find_function_at_addr(const struct cu
*cu
,
489 struct tag
*cu__function(const struct cu
*cu
, const uint32_t id
);
490 struct tag
*cu__tag(const struct cu
*cu
, const uint32_t id
);
491 struct tag
*cu__type(const struct cu
*cu
, const type_id_t id
);
492 struct tag
*cu__find_struct_by_name(const struct cu
*cu
, const char *name
,
493 const int include_decls
, type_id_t
*id
);
494 struct tag
*cu__find_struct_or_union_by_name(const struct cu
*cu
, const char *name
,
495 const int include_decls
, type_id_t
*id
);
496 bool cu__same_build_id(const struct cu
*cu
, const struct cu
*other
);
497 void cu__account_inline_expansions(struct cu
*cu
);
498 int cu__for_all_tags(struct cu
*cu
,
499 int (*iterator
)(struct tag
*tag
,
500 struct cu
*cu
, void *cookie
),
505 const char *values
[];
508 /** struct tag - basic representation of a debug info element
509 * @priv - extra data, for instance, DWARF offset, id, decl_{file,line}
511 * @shared_tags: used by struct namespace
512 * @attributes - attributes specified by BTF_DECL_TAGs targeting this tag
515 struct list_head node
;
520 bool has_btf_type_tag
:1;
522 uint8_t recursivity_level
;
523 struct attributes
*attributes
;
526 // To use with things like type->type_enum == perf_event_type+perf_user_event_type
532 void tag__delete(struct tag
*tag
, struct cu
*cu
);
534 static inline int tag__is_enumeration(const struct tag
*tag
)
536 return tag
->tag
== DW_TAG_enumeration_type
;
539 static inline int tag__is_namespace(const struct tag
*tag
)
541 return tag
->tag
== DW_TAG_namespace
;
544 static inline int tag__is_struct(const struct tag
*tag
)
546 return tag
->tag
== DW_TAG_structure_type
||
547 tag
->tag
== DW_TAG_interface_type
||
548 tag
->tag
== DW_TAG_class_type
;
551 static inline int tag__is_typedef(const struct tag
*tag
)
553 return tag
->tag
== DW_TAG_typedef
;
556 static inline int tag__is_rvalue_reference_type(const struct tag
*tag
)
558 return tag
->tag
== DW_TAG_rvalue_reference_type
;
561 static inline int tag__is_union(const struct tag
*tag
)
563 return tag
->tag
== DW_TAG_union_type
;
566 static inline int tag__is_const(const struct tag
*tag
)
568 return tag
->tag
== DW_TAG_const_type
;
571 static inline int tag__is_pointer(const struct tag
*tag
)
573 return tag
->tag
== DW_TAG_pointer_type
;
576 static inline int tag__is_pointer_to(const struct tag
*tag
, type_id_t type
)
578 return tag__is_pointer(tag
) && tag
->type
== type
;
581 static inline bool tag__is_variable(const struct tag
*tag
)
583 return tag
->tag
== DW_TAG_variable
;
586 static inline bool tag__is_constant(const struct tag
*tag
)
588 return tag
->tag
== DW_TAG_constant
;
591 static inline bool tag__is_volatile(const struct tag
*tag
)
593 return tag
->tag
== DW_TAG_volatile_type
;
596 static inline bool tag__is_atomic(const struct tag
*tag
)
598 return tag
->tag
== DW_TAG_atomic_type
;
601 static inline bool tag__is_restrict(const struct tag
*tag
)
603 return tag
->tag
== DW_TAG_restrict_type
;
606 static inline int tag__is_modifier(const struct tag
*tag
)
608 return tag__is_const(tag
) ||
609 tag__is_volatile(tag
) ||
610 tag__is_restrict(tag
) ||
614 static inline bool tag__has_namespace(const struct tag
*tag
)
616 return tag__is_struct(tag
) ||
617 tag__is_union(tag
) ||
618 tag__is_namespace(tag
) ||
619 tag__is_enumeration(tag
);
623 * tag__is_tag_type - is this tag derived from the 'type' class?
626 static inline int tag__is_type(const struct tag
*tag
)
628 return tag__is_union(tag
) ||
629 tag__is_struct(tag
) ||
630 tag__is_typedef(tag
) ||
631 tag__is_rvalue_reference_type(tag
) ||
632 tag__is_enumeration(tag
);
636 * tag__is_tag_type - is this one of the possible types for a tag?
639 static inline int tag__is_tag_type(const struct tag
*tag
)
641 return tag__is_type(tag
) ||
642 tag
->tag
== DW_TAG_array_type
||
643 tag
->tag
== DW_TAG_string_type
||
644 tag
->tag
== DW_TAG_base_type
||
645 tag
->tag
== DW_TAG_const_type
||
646 tag
->tag
== DW_TAG_pointer_type
||
647 tag
->tag
== DW_TAG_rvalue_reference_type
||
648 tag
->tag
== DW_TAG_ptr_to_member_type
||
649 tag
->tag
== DW_TAG_reference_type
||
650 tag
->tag
== DW_TAG_restrict_type
||
651 tag
->tag
== DW_TAG_subroutine_type
||
652 tag
->tag
== DW_TAG_unspecified_type
||
653 tag
->tag
== DW_TAG_volatile_type
||
654 tag
->tag
== DW_TAG_atomic_type
||
655 tag
->tag
== DW_TAG_unspecified_type
||
656 tag
->tag
== DW_TAG_LLVM_annotation
;
659 static inline const char *tag__decl_file(const struct tag
*tag
,
662 if (cu
->dfops
&& cu
->dfops
->tag__decl_file
)
663 return cu
->dfops
->tag__decl_file(tag
, cu
);
667 static inline uint32_t tag__decl_line(const struct tag
*tag
,
670 if (cu
->dfops
&& cu
->dfops
->tag__decl_line
)
671 return cu
->dfops
->tag__decl_line(tag
, cu
);
675 static inline unsigned long long tag__orig_id(const struct tag
*tag
,
678 if (cu
->dfops
&& cu
->dfops
->tag__orig_id
)
679 return cu
->dfops
->tag__orig_id(tag
, cu
);
683 size_t tag__fprintf_decl_info(const struct tag
*tag
,
684 const struct cu
*cu
, FILE *fp
);
685 size_t tag__fprintf(struct tag
*tag
, const struct cu
*cu
,
686 const struct conf_fprintf
*conf
, FILE *fp
);
688 const char *tag__name(const struct tag
*tag
, const struct cu
*cu
,
689 char *bf
, size_t len
, const struct conf_fprintf
*conf
);
690 void tag__not_found_die(const char *file
, int line
, const char *func
, int tag
, const char *name
);
692 #define tag__assert_search_result(result, tag, name) \
693 do { if (!result) tag__not_found_die(__FILE__,\
694 __LINE__, __func__, tag, name); } while (0)
696 size_t tag__size(const struct tag
*tag
, const struct cu
*cu
);
697 size_t tag__nr_cachelines(const struct conf_fprintf
*conf
, const struct tag
*tag
, const struct cu
*cu
);
698 struct tag
*tag__follow_typedef(const struct tag
*tag
, const struct cu
*cu
);
699 struct tag
*tag__strip_typedefs_and_modifiers(const struct tag
*tag
, const struct cu
*cu
);
701 size_t __tag__id_not_found_fprintf(FILE *fp
, type_id_t id
,
702 const char *fn
, int line
);
703 #define tag__id_not_found_fprintf(fp, id) \
704 __tag__id_not_found_fprintf(fp, id, __func__, __LINE__)
706 int __tag__has_type_loop(const struct tag
*tag
, const struct tag
*type
,
707 char *bf
, size_t len
, FILE *fp
,
708 const char *fn
, int line
);
709 #define tag__has_type_loop(tag, type, bf, len, fp) \
710 __tag__has_type_loop(tag, type, bf, len, fp, __func__, __LINE__)
712 struct ptr_to_member_type
{
714 type_id_t containing_type
;
717 static inline struct ptr_to_member_type
*
718 tag__ptr_to_member_type(const struct tag
*tag
)
720 return (struct ptr_to_member_type
*)tag
;
723 struct llvm_annotation
{
725 int16_t component_idx
;
726 struct list_head node
;
729 /** struct btf_type_tag_type - representing a btf_type_tag annotation
731 * @tag - DW_TAG_LLVM_annotation tag
732 * @value - btf_type_tag value string
733 * @node - list_head node
735 struct btf_type_tag_type
{
738 struct list_head node
;
741 /** The struct btf_type_tag_ptr_type - type containing both pointer type and
742 * its btf_type_tag annotations
744 * @tag - pointer type tag
745 * @tags - btf_type_tag annotations for the pointer type
747 struct btf_type_tag_ptr_type
{
749 struct list_head tags
;
752 static inline struct btf_type_tag_ptr_type
*tag__btf_type_tag_ptr(struct tag
*tag
)
754 return (struct btf_type_tag_ptr_type
*)tag
;
757 static inline struct btf_type_tag_type
*tag__btf_type_tag(struct tag
*tag
)
759 return (struct btf_type_tag_type
*)tag
;
762 /** struct namespace - base class for enums, structs, unions, typedefs, etc
764 * @tags - class_member, enumerators, etc
765 * @shared_tags: if this bit is set, don't free the entries in @tags
770 struct list_head tags
;
771 struct list_head annots
;
774 static inline struct namespace *tag__namespace(const struct tag
*tag
)
776 return (struct namespace *)tag
;
779 void namespace__delete(struct namespace *nspace
, struct cu
*cu
);
781 static inline __pure
bool namespace__shared_tags(struct namespace *nspace
)
783 return nspace
->tag
.shared_tags
;
787 * namespace__for_each_tag - iterate thru all the tags
788 * @nspace: struct namespace instance to iterate
789 * @pos: struct tag iterator
791 #define namespace__for_each_tag(nspace, pos) \
792 list_for_each_entry(pos, &(nspace)->tags, node)
795 * namespace__for_each_tag_safe_reverse - safely iterate thru all the tags, in reverse order
796 * @nspace: struct namespace instance to iterate
797 * @pos: struct tag iterator
798 * @n: struct class_member temp iterator
800 #define namespace__for_each_tag_safe_reverse(nspace, pos, n) \
801 list_for_each_entry_safe_reverse(pos, n, &(nspace)->tags, node)
803 void namespace__add_tag(struct namespace *nspace
, struct tag
*tag
);
810 struct inline_expansion
{
816 static inline struct inline_expansion
*
817 tag__inline_expansion(const struct tag
*tag
)
819 return (struct inline_expansion
*)tag
;
827 static inline struct label
*tag__label(const struct tag
*tag
)
829 return (struct label
*)tag
;
832 static inline const char *label__name(const struct label
*label
)
843 } __attribute__((packed
));
854 uint8_t declaration
:1;
855 uint8_t has_specification
:1;
856 uint8_t artificial
:1;
859 struct location location
;
860 struct hlist_node tool_hnode
;
861 struct list_head annots
;
862 struct variable
*spec
;
865 static inline struct variable
*tag__variable(const struct tag
*tag
)
867 return (struct variable
*)tag
;
870 enum vscope
variable__scope(const struct variable
*var
);
871 const char *variable__scope_str(const struct variable
*var
);
873 const char *variable__name(const struct variable
*var
);
875 const char *variable__type_name(const struct variable
*var
,
876 const struct cu
*cu
, char *bf
, size_t len
);
884 static inline struct constant
*tag__constant(const struct tag
*tag
)
886 return (struct constant
*)tag
;
889 static inline const char *constant__name(const struct constant
*constant
)
891 return constant
->name
;
894 static inline uint64_t constant__value(const struct constant
*constant
)
896 return constant
->value
;
901 struct list_head tags
;
903 uint16_t nr_inline_expansions
;
905 uint16_t nr_variables
;
906 uint16_t nr_lexblocks
;
907 uint32_t size_inline_expansions
;
910 static inline struct lexblock
*tag__lexblock(const struct tag
*tag
)
912 return (struct lexblock
*)tag
;
915 void lexblock__delete(struct lexblock
*lexblock
, struct cu
*cu
);
919 void lexblock__add_inline_expansion(struct lexblock
*lexblock
,
920 struct inline_expansion
*exp
);
921 void lexblock__add_label(struct lexblock
*lexblock
, struct label
*label
);
922 void lexblock__add_lexblock(struct lexblock
*lexblock
, struct lexblock
*child
);
923 void lexblock__add_tag(struct lexblock
*lexblock
, struct tag
*tag
);
924 void lexblock__add_variable(struct lexblock
*lexblock
, struct variable
*var
);
925 size_t lexblock__fprintf(const struct lexblock
*lexblock
, const struct cu
*cu
,
926 struct function
*function
, uint16_t indent
,
927 const struct conf_fprintf
*conf
, FILE *fp
);
933 uint8_t unexpected_reg
:1;
937 static inline struct parameter
*tag__parameter(const struct tag
*tag
)
939 return (struct parameter
*)tag
;
942 static inline const char *parameter__name(const struct parameter
*parm
)
947 /* struct template_type_param - parameters to a template, stored in 'struct type'
949 struct template_type_param
{
954 void template_type_param__delete(struct template_type_param
*ttparam
, struct cu
*cu
);
956 struct template_value_param
{
959 uint64_t const_value
;
960 uint64_t default_value
;
963 void template_value_param__delete(struct template_value_param
*ttparam
, struct cu
*cu
);
965 /* struct template_parameter_pack - list of DW_TAG_template_type_param
968 struct template_parameter_pack
{
971 struct list_head params
;
974 void template_parameter_pack__delete(struct template_parameter_pack
*pack
, struct cu
*cu
);
976 static inline struct template_parameter_pack
*tag__template_parameter_pack(const struct tag
*tag
)
978 return (struct template_parameter_pack
*)tag
;
981 void template_parameter_pack__add(struct template_parameter_pack
*pack
, struct template_type_param
*param
);
983 /* struct formal_parameter_pack - list of DW_TAG_formal_parameter
986 struct formal_parameter_pack
{
988 struct list_head params
;
991 void formal_parameter_pack__delete(struct formal_parameter_pack
*pack
, struct cu
*cu
);
993 static inline struct formal_parameter_pack
*tag__formal_parameter_pack(const struct tag
*tag
)
995 return (struct formal_parameter_pack
*)tag
;
998 void formal_parameter_pack__add(struct formal_parameter_pack
*pack
, struct parameter
*param
);
1001 * tag.tag can be DW_TAG_subprogram_type or DW_TAG_subroutine_type.
1005 struct list_head parms
;
1006 size_t byte_size
; // First seen in DW_TAG_subroutine_type in a Go CU
1008 uint8_t unspec_parms
:1; /* just one bit is needed */
1009 uint8_t optimized_parms
:1;
1010 uint8_t unexpected_reg
:1;
1011 uint8_t processed
:1;
1012 uint8_t inconsistent_proto
:1;
1013 struct list_head template_type_params
;
1014 struct list_head template_value_params
;
1015 struct template_parameter_pack
*template_parameter_pack
;
1016 struct formal_parameter_pack
*formal_parameter_pack
;
1019 static inline struct ftype
*tag__ftype(const struct tag
*tag
)
1021 return (struct ftype
*)tag
;
1024 void ftype__delete(struct ftype
*ftype
, struct cu
*cu
);
1027 * ftype__for_each_parameter - iterate thru all the parameters
1028 * @ftype: struct ftype instance to iterate
1029 * @pos: struct parameter iterator
1031 #define ftype__for_each_parameter(ftype, pos) \
1032 list_for_each_entry(pos, &(ftype)->parms, tag.node)
1035 * ftype__for_each_parameter_safe - safely iterate thru all the parameters
1036 * @ftype: struct ftype instance to iterate
1037 * @pos: struct parameter iterator
1038 * @n: struct parameter temp iterator
1040 #define ftype__for_each_parameter_safe(ftype, pos, n) \
1041 list_for_each_entry_safe(pos, n, &(ftype)->parms, tag.node)
1044 * ftype__for_each_parameter_safe_reverse - safely iterate thru all the parameters, in reverse order
1045 * @ftype: struct ftype instance to iterate
1046 * @pos: struct parameter iterator
1047 * @n: struct parameter temp iterator
1049 #define ftype__for_each_parameter_safe_reverse(ftype, pos, n) \
1050 list_for_each_entry_safe_reverse(pos, n, &(ftype)->parms, tag.node)
1052 void ftype__add_parameter(struct ftype
*ftype
, struct parameter
*parm
);
1053 void ftype__add_template_type_param(struct ftype
*ftype
, struct template_type_param
*param
);
1054 void ftype__add_template_value_param(struct ftype
*ftype
, struct template_value_param
*param
);
1056 size_t ftype__fprintf(const struct ftype
*ftype
, const struct cu
*cu
,
1057 const char *name
, const int inlined
,
1058 const int is_pointer
, const int type_spacing
, bool is_prototype
,
1059 const struct conf_fprintf
*conf
, FILE *fp
);
1060 size_t ftype__fprintf_parms(const struct ftype
*ftype
,
1061 const struct cu
*cu
, int indent
,
1062 const struct conf_fprintf
*conf
, FILE *fp
);
1063 int ftype__has_parm_of_type(const struct ftype
*ftype
, const type_id_t target
,
1064 const struct cu
*cu
);
1068 struct lexblock lexblock
;
1069 struct rb_node rb_node
;
1071 const char *linkage_name
;
1072 const char *alias
; /* name.isra.0 */
1073 uint32_t cu_total_size_inline_expansions
;
1074 uint16_t cu_total_nr_inline_expansions
;
1076 uint8_t abstract_origin
:1;
1078 uint8_t accessibility
:2; /* DW_ACCESS_{public,protected,private} */
1079 uint8_t virtuality
:2; /* DW_VIRTUALITY_{none,virtual,pure_virtual} */
1080 uint8_t declaration
:1;
1082 int32_t vtable_entry
;
1083 struct list_head vtable_node
;
1084 struct list_head annots
;
1085 /* fields used by tools */
1087 struct list_head tool_node
;
1088 struct hlist_node tool_hnode
;
1093 static inline struct function
*tag__function(const struct tag
*tag
)
1095 return (struct function
*)tag
;
1098 static inline struct tag
*function__tag(const struct function
*func
)
1100 return (struct tag
*)func
;
1103 void function__delete(struct function
*func
, struct cu
*cu
);
1105 static __pure
inline int tag__is_function(const struct tag
*tag
)
1107 return tag
->tag
== DW_TAG_subprogram
;
1111 * function__for_each_parameter - iterate thru all the parameters
1112 * @func: struct function instance to iterate
1113 * @pos: struct parameter iterator
1115 #define function__for_each_parameter(func, cu, pos) \
1116 ftype__for_each_parameter(func->btf ? tag__ftype(cu__type(cu, func->proto.tag.type)) : &func->proto, pos)
1118 const char *function__name(struct function
*func
);
1120 static inline const char *function__linkage_name(const struct function
*func
)
1122 return func
->linkage_name
;
1125 size_t function__fprintf_stats(const struct tag
*tag_func
,
1126 const struct cu
*cu
,
1127 const struct conf_fprintf
*conf
,
1129 const char *function__prototype(const struct function
*func
,
1130 const struct cu
*cu
, char *bf
, size_t len
);
1131 const char *function__prototype_conf(const struct function
*func
,
1132 const struct cu
*cu
,
1133 const struct conf_fprintf
*conf
,
1134 char *bf
, size_t len
);
1136 static __pure
inline uint64_t function__addr(const struct function
*func
)
1138 return func
->lexblock
.ip
.addr
;
1141 static __pure
inline uint32_t function__size(const struct function
*func
)
1143 return func
->lexblock
.size
;
1146 static inline int function__declared_inline(const struct function
*func
)
1148 return (func
->inlined
== DW_INL_declared_inlined
||
1149 func
->inlined
== DW_INL_declared_not_inlined
);
1152 static inline int function__inlined(const struct function
*func
)
1154 return (func
->inlined
== DW_INL_inlined
||
1155 func
->inlined
== DW_INL_declared_inlined
);
1158 /* struct class_member - struct, union, class member
1160 * @bit_offset - offset in bits from the start of the struct
1161 * @bit_size - cached bit size, can be smaller than the integral type if in a bitfield
1162 * @byte_offset - offset in bytes from the start of the struct
1163 * @byte_size - cached byte size, integral type byte size for bitfields
1164 * @bitfield_offset - offset in the current bitfield
1165 * @bitfield_size - size in the current bitfield
1166 * @bit_hole - If there is a bit hole before the next one (or the end of the struct)
1167 * @bitfield_end - Is this the last entry in a bitfield?
1168 * @alignment - DW_AT_alignement, zero if not present, gcc emits since circa 7.3.1
1169 * @accessibility - DW_ACCESS_{public,protected,private}
1170 * @virtuality - DW_VIRTUALITY_{none,virtual,pure_virtual}
1171 * @hole - If there is a hole before the next one (or the end of the struct).
1172 * A negative hole may happen when there is padding on an DW_TAG_inheritance,
1173 * i.e. in a ancestor type and the compiler puts the class member of the
1174 * derived class to use that padding.
1175 * @has_bit_offset: Don't recalcule this, it came from the debug info (DWARF5's DW_AT_data_bit_offset)
1177 struct class_member
{
1180 uint32_t bit_offset
;
1182 uint32_t byte_offset
;
1185 int8_t bitfield_offset
;
1186 uint8_t bitfield_size
;
1188 uint8_t bitfield_end
:1;
1190 uint8_t is_static
:1;
1191 uint8_t has_bit_offset
:1;
1192 uint8_t accessibility
:2;
1193 uint8_t virtuality
:2;
1195 uint64_t const_value
;
1198 void class_member__delete(struct class_member
*member
, struct cu
*cu
);
1200 static inline struct class_member
*tag__class_member(const struct tag
*tag
)
1202 return (struct class_member
*)tag
;
1205 static inline const char *class_member__name(const struct class_member
*member
)
1207 return member
->name
;
1210 static __pure
inline int tag__is_class_member(const struct tag
*tag
)
1212 return tag
->tag
== DW_TAG_member
;
1215 int tag__is_base_type(const struct tag
*tag
, const struct cu
*cu
);
1216 bool tag__is_array(const struct tag
*tag
, const struct cu
*cu
);
1218 struct class_member_filter
;
1220 struct tag_cu_node
{
1221 struct list_head node
;
1226 * struct type - base type for enumerations, structs and unions
1228 * @node: Used in emissions->fwd_decls, i.e. only on the 'dwarves_emit.c' file
1229 * @nr_members: number of non static DW_TAG_member entries
1230 * @nr_static_members: number of static DW_TAG_member entries
1231 * @nr_tags: number of tags
1232 * @alignment: DW_AT_alignement, zero if not present, gcc emits since circa 7.3.1
1233 * @natural_alignment: For inferring __packed__, normally the widest scalar in it, recursively
1234 * @suffix_disambiguation: if we have both 'union foo' and 'struct foo' then we must disambiguate,
1235 * useful to generate a vmlinux.h with all Linux types out of BTF data, for instance.
1236 * @sizeof_member: Use this to find the size of the record
1237 * @type_member: Use this to select a member from where to get an id on an enum to find a type
1238 * to cast for, needs to be used with the upcoming type_enum.
1239 * @type_enum: enumeration(s) to use together with type_member to find a type to cast
1240 * @member_prefix: the common prefix for all members, say in an enum, this should be calculated on demand
1241 * @member_prefix_len: the lenght of the common prefix for all members
1244 struct namespace namespace;
1245 struct list_head node
;
1248 uint16_t nr_static_members
;
1249 uint16_t nr_members
;
1251 struct class_member
*sizeof_member
;
1252 struct class_member
*type_member
;
1253 struct class_member_filter
*filter
;
1254 struct list_head type_enum
;
1255 char *member_prefix
;
1256 uint16_t member_prefix_len
;
1257 uint16_t max_tag_name_len
;
1258 uint16_t natural_alignment
;
1259 uint8_t suffix_disambiguation
:1;
1260 uint8_t packed_attributes_inferred
:1;
1261 uint8_t declaration
:1;
1262 uint8_t definition_emitted
:1;
1263 uint8_t fwd_decl_emitted
:1;
1265 uint8_t is_signed_enum
:1;
1266 struct list_head template_type_params
;
1267 struct list_head template_value_params
;
1268 struct template_parameter_pack
*template_parameter_pack
;
1271 void __type__init(struct type
*type
);
1273 size_t tag__natural_alignment(struct tag
*tag
, const struct cu
*cu
);
1275 static inline struct class *type__class(const struct type
*type
)
1277 return (struct class *)type
;
1280 static inline struct tag
*type__tag(const struct type
*type
)
1282 return (struct tag
*)type
;
1285 void type__delete(struct type
*type
, struct cu
*cu
);
1287 static inline struct class_member
*type__first_member(struct type
*type
)
1289 return list_first_entry(&type
->namespace.tags
, struct class_member
, tag
.node
);
1292 static inline struct class_member
*class_member__next(struct class_member
*member
)
1294 return list_entry(member
->tag
.node
.next
, struct class_member
, tag
.node
);
1298 * type__for_each_tag - iterate thru all the tags
1299 * @type: struct type instance to iterate
1300 * @pos: struct tag iterator
1302 #define type__for_each_tag(type, pos) \
1303 list_for_each_entry(pos, &(type)->namespace.tags, node)
1306 * type__for_each_enumerator - iterate thru the enumerator entries
1307 * @type: struct type instance to iterate
1308 * @pos: struct enumerator iterator
1310 #define type__for_each_enumerator(type, pos) \
1311 struct list_head *__type__for_each_enumerator_head = \
1312 namespace__shared_tags(&(type)->namespace) ? \
1313 (type)->namespace.tags.next : \
1314 &(type)->namespace.tags; \
1315 list_for_each_entry(pos, __type__for_each_enumerator_head, tag.node)
1318 * type__for_each_enumerator_safe_reverse - safely iterate thru the enumerator entries, in reverse order
1319 * @type: struct type instance to iterate
1320 * @pos: struct enumerator iterator
1321 * @n: struct enumerator temp iterator
1323 #define type__for_each_enumerator_safe_reverse(type, pos, n) \
1324 if (namespace__shared_tags(&(type)->namespace)) /* Do nothing */ ; else \
1325 list_for_each_entry_safe_reverse(pos, n, &(type)->namespace.tags, tag.node)
1328 * type__for_each_member - iterate thru the entries that use space
1329 * (data members and inheritance entries)
1330 * @type: struct type instance to iterate
1331 * @pos: struct class_member iterator
1333 #define type__for_each_member(type, pos) \
1334 list_for_each_entry(pos, &(type)->namespace.tags, tag.node) \
1335 if (!(pos->tag.tag == DW_TAG_member || \
1336 pos->tag.tag == DW_TAG_inheritance)) \
1341 * type__for_each_data_member - iterate thru the data member entries
1342 * @type: struct type instance to iterate
1343 * @pos: struct class_member iterator
1345 #define type__for_each_data_member(type, pos) \
1346 list_for_each_entry(pos, &(type)->namespace.tags, tag.node) \
1347 if (pos->tag.tag != DW_TAG_member) \
1352 * type__for_each_member_safe - safely iterate thru the entries that use space
1353 * (data members and inheritance entries)
1354 * @type: struct type instance to iterate
1355 * @pos: struct class_member iterator
1356 * @n: struct class_member temp iterator
1358 #define type__for_each_member_safe(type, pos, n) \
1359 list_for_each_entry_safe(pos, n, &(type)->namespace.tags, tag.node) \
1360 if (pos->tag.tag != DW_TAG_member) \
1365 * type__for_each_data_member_safe - safely iterate thru the data member entries
1366 * @type: struct type instance to iterate
1367 * @pos: struct class_member iterator
1368 * @n: struct class_member temp iterator
1370 #define type__for_each_data_member_safe(type, pos, n) \
1371 list_for_each_entry_safe(pos, n, &(type)->namespace.tags, tag.node) \
1372 if (pos->tag.tag != DW_TAG_member) \
1377 * type__for_each_tag_safe_reverse - safely iterate thru all tags in a type, in reverse order
1378 * @type: struct type instance to iterate
1379 * @pos: struct class_member iterator
1380 * @n: struct class_member temp iterator
1382 #define type__for_each_tag_safe_reverse(type, pos, n) \
1383 list_for_each_entry_safe_reverse(pos, n, &(type)->namespace.tags, tag.node)
1385 void type__add_member(struct type
*type
, struct class_member
*member
);
1386 void type__add_template_type_param(struct type
*type
, struct template_type_param
*ttparm
);
1387 void type__add_template_value_param(struct type
*type
, struct template_value_param
*tvparam
);
1389 struct class_member
*
1390 type__find_first_biggest_size_base_type_member(struct type
*type
,
1391 const struct cu
*cu
);
1393 struct class_member
*type__find_member_by_name(const struct type
*type
, const char *name
);
1394 uint32_t type__nr_members_of_type(const struct type
*type
, const type_id_t oftype
);
1395 struct class_member
*type__last_member(struct type
*type
);
1397 void enumerations__calc_prefix(struct list_head
*enumerations
);
1399 size_t typedef__fprintf(const struct tag
*tag_type
, const struct cu
*cu
,
1400 const struct conf_fprintf
*conf
, FILE *fp
);
1402 static inline struct type
*tag__type(const struct tag
*tag
)
1404 return (struct type
*)tag
;
1409 struct list_head vtable
;
1410 uint16_t nr_vtable_entries
;
1412 uint8_t nr_bit_holes
;
1415 uint8_t pre_bit_hole
;
1416 uint8_t bit_padding
;
1417 bool holes_searched
;
1418 bool flexible_array_verified
;
1419 bool embedded_flexible_array_searched
;
1420 bool has_flexible_array
;
1421 bool has_embedded_flexible_array
;
1426 static inline struct class *tag__class(const struct tag
*tag
)
1428 return (struct class *)tag
;
1431 static inline struct tag
*class__tag(const struct class *cls
)
1433 return (struct tag
*)cls
;
1436 struct class *class__clone(const struct class *from
, const char *new_class_name
, struct cu
*cu
);
1437 void class__delete(struct class *cls
, struct cu
*cu
);
1439 static inline struct list_head
*class__tags(struct class *cls
)
1441 return &cls
->type
.namespace.tags
;
1444 static __pure
inline const char *namespace__name(const struct namespace *nspace
)
1446 return nspace
->name
;
1449 static __pure
inline const char *type__name(const struct type
*type
)
1451 return namespace__name(&type
->namespace);
1454 static __pure
inline const char *class__name(struct class *cls
)
1456 return type__name(&cls
->type
);
1459 static inline int class__is_struct(const struct class *cls
)
1461 return tag__is_struct(&cls
->type
.namespace.tag
);
1464 bool class__has_embedded_flexible_array(struct class *cls
, const struct cu
*cu
);
1465 bool class__has_flexible_array(struct class *class, const struct cu
*cu
);
1466 void class__find_holes(struct class *cls
);
1467 int class__has_hole_ge(const struct class *cls
, const uint16_t size
);
1469 bool class__infer_packed_attributes(struct class *cls
, const struct cu
*cu
);
1471 void union__infer_packed_attributes(struct type
*type
, const struct cu
*cu
);
1473 void type__check_structs_at_unnatural_alignments(struct type
*type
, const struct cu
*cu
);
1475 size_t class__fprintf(struct class *cls
, const struct cu
*cu
, FILE *fp
);
1477 void class__add_vtable_entry(struct class *cls
, struct function
*vtable_entry
);
1478 static inline struct class_member
*
1479 class__find_member_by_name(const struct class *cls
, const char *name
)
1481 return type__find_member_by_name(&cls
->type
, name
);
1484 static inline uint16_t class__nr_members(const struct class *cls
)
1486 return cls
->type
.nr_members
;
1489 static inline uint32_t class__size(const struct class *cls
)
1491 return cls
->type
.size
;
1494 static inline int class__is_declaration(const struct class *cls
)
1496 return cls
->type
.declaration
;
1499 const struct class_member
*class__find_bit_hole(const struct class *cls
,
1500 const struct class_member
*trailer
,
1501 const uint16_t bit_hole_size
);
1503 #define class__for_each_member_from(cls, from, pos) \
1504 pos = list_prepare_entry(from, class__tags(cls), tag.node); \
1505 list_for_each_entry_from(pos, class__tags(cls), tag.node) \
1506 if (!tag__is_class_member(&pos->tag)) \
1510 #define class__for_each_member_safe_from(cls, from, pos, tmp) \
1511 pos = list_prepare_entry(from, class__tags(cls), tag.node); \
1512 list_for_each_entry_safe_from(pos, tmp, class__tags(cls), tag.node) \
1513 if (!tag__is_class_member(&pos->tag)) \
1517 #define class__for_each_member_continue(cls, from, pos) \
1518 pos = list_prepare_entry(from, class__tags(cls), tag.node); \
1519 list_for_each_entry_continue(pos, class__tags(cls), tag.node) \
1520 if (!tag__is_class_member(&pos->tag)) \
1524 #define class__for_each_member_reverse(cls, member) \
1525 list_for_each_entry_reverse(member, class__tags(cls), tag.node) \
1526 if (member->tag.tag != DW_TAG_member) \
1530 enum base_type_float_type
{
1548 struct list_head node
;
1550 uint8_t name_has_encoding
:1;
1551 uint8_t is_signed
:1;
1553 uint8_t is_varargs
:1;
1554 uint8_t float_type
:4;
1555 uint8_t definition_emitted
:1;
1558 static inline struct base_type
*tag__base_type(const struct tag
*tag
)
1560 return (struct base_type
*)tag
;
1563 static inline uint16_t base_type__size(const struct tag
*tag
)
1565 return tag__base_type(tag
)->bit_size
/ 8;
1568 const char *__base_type__name(const struct base_type
*bt
);
1570 const char *base_type__name(const struct base_type
*btype
, char *bf
, size_t len
);
1572 size_t base_type__name_to_size(struct base_type
*btype
, struct cu
*cu
);
1574 bool base_type__language_defined(struct base_type
*bt
);
1578 uint32_t *nr_entries
;
1583 static inline struct array_type
*tag__array_type(const struct tag
*tag
)
1585 return (struct array_type
*)tag
;
1588 struct string_type
{
1590 uint32_t nr_entries
;
1593 static inline struct string_type
*tag__string_type(const struct tag
*tag
)
1595 return (struct string_type
*)tag
;
1602 struct tag_cu type_enum
; // To cache the type_enum searches
1605 static inline const char *enumerator__name(const struct enumerator
*enumerator
)
1607 return enumerator
->name
;
1610 void enumeration__delete(struct type
*type
, struct cu
*cu
);
1611 void enumeration__add(struct type
*type
, struct enumerator
*enumerator
);
1612 size_t enumeration__fprintf(const struct tag
*tag_enum
,
1613 const struct conf_fprintf
*conf
, FILE *fp
);
1615 int dwarves__init(void);
1616 void dwarves__exit(void);
1617 void dwarves__resolve_cacheline_size(const struct conf_load
*conf
, uint16_t user_cacheline_size
);
1619 const char *dwarf_tag_name(const uint32_t tag
);
1621 const char *vmlinux_path__btf_filename(void);
1623 const char *vmlinux_path__find_running_kernel(void);
1627 void dwarves_print_version(FILE *fp
, struct argp_state
*state
);
1628 void dwarves_print_numeric_version(FILE *fp
);
1630 extern bool print_numeric_version
;
1632 extern bool no_bitfield_type_recode
;
1634 extern const char tabs
[];
1636 #ifndef DW_TAG_atomic_type
1637 #define DW_TAG_atomic_type 0x47
1640 #ifndef DW_TAG_skeleton_unit
1641 #define DW_TAG_skeleton_unit 0x4a
1644 #endif /* _DWARVES_H_ */