Lines Matching +full:cache +full:-

1 // SPDX-License-Identifier: GPL-2.0
14 #define KABI_PREFIX_LEN (sizeof(KABI_PREFIX) - 1)
16 #define KABI_RESERVED_PREFIX_LEN (sizeof(KABI_RESERVED_PREFIX) - 1)
18 #define KABI_RENAMED_PREFIX_LEN (sizeof(KABI_RENAMED_PREFIX) - 1)
20 #define KABI_IGNORED_PREFIX_LEN (sizeof(KABI_IGNORED_PREFIX) - 1)
37 /* Line breaks and indentation for pretty-printing */
38 static void process_linebreak(struct die *cache, int n) in process_linebreak() argument
42 die_map_add_linebreak(cache, n); in process_linebreak()
98 state->sym = symbol_get(get_symbol_name(die)); in match_export_symbol()
101 if (!state->sym && source != die) in match_export_symbol()
102 state->sym = symbol_get(get_symbol_name(source)); in match_export_symbol()
104 state->die = *source; in match_export_symbol()
105 return !!state->sym; in match_export_symbol()
108 /* DW_AT_decl_file -> struct srcfile */
109 static struct cache srcfile_cache;
130 if (!dwarf_cu_die(die->cu, &cudie, NULL, NULL, NULL, NULL, NULL, NULL)) in is_definition_private()
131 error("dwarf_cu_die failed: '%s'", dwarf_errmsg(-1)); in is_definition_private()
134 error("dwarf_getsrcfiles failed: '%s'", dwarf_errmsg(-1)); in is_definition_private()
138 error("dwarf_filesrc failed: '%s'", dwarf_errmsg(-1)); in is_definition_private()
147 static bool is_kabi_definition(struct die *cache, Dwarf_Die *die) in is_kabi_definition() argument
154 if (kabi_is_declonly(cache->fqn)) in is_kabi_definition()
163 static void process(struct die *cache, const char *s) in process() argument
176 if (cache) in process()
177 die_debug_r("cache %p string '%s'", cache, s); in process()
178 die_map_add_string(cache, s); in process()
183 static void process_fmt(struct die *cache, const char *fmt, ...) in process_fmt() argument
193 process(cache, buf); in process_fmt()
197 static void update_fqn(struct die *cache, Dwarf_Die *die) in update_fqn() argument
201 if (!cache->fqn) { in update_fqn()
202 if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &fqn) && in update_fqn()
203 *fqn->fqn) in update_fqn()
204 cache->fqn = xstrdup(fqn->fqn); in update_fqn()
206 cache->fqn = ""; in update_fqn()
210 static void process_fqn(struct die *cache, Dwarf_Die *die) in process_fqn() argument
212 update_fqn(cache, die); in process_fqn()
213 if (*cache->fqn) in process_fqn()
214 process(cache, " "); in process_fqn()
215 process(cache, cache->fqn); in process_fqn()
219 static void process_##attribute##_attr(struct die *cache, \
224 process_fmt(cache, " " #attribute "(%" PRIu64 ")", \
236 static void process_byte_size_attr(struct die *cache, Dwarf_Die *die) in DEFINE_PROCESS_UDATA_ATTRIBUTE()
242 if (stable && kabi_get_byte_size(cache->fqn, &override)) in DEFINE_PROCESS_UDATA_ATTRIBUTE()
245 process_fmt(cache, " byte_size(%" PRIu64 ")", value); in DEFINE_PROCESS_UDATA_ATTRIBUTE()
249 /* Match functions -- die_match_callback_t */
266 int process_die_container(struct state *state, struct die *cache, in process_die_container() argument
275 state->first_list_item = true; in process_die_container()
281 res = checkp(func(state, cache, &current)); in process_die_container()
292 state->first_list_item = false; in process_die_container()
300 static void process_type_attr(struct state *state, struct die *cache, in process_type_attr() argument
306 check(process_type(state, cache, &type)); in process_type_attr()
310 /* Compilers can omit DW_AT_type -- print out 'void' to clarify */ in process_type_attr()
311 process(cache, "base_type void"); in process_type_attr()
314 static void process_list_comma(struct state *state, struct die *cache) in process_list_comma() argument
316 if (state->first_list_item) { in process_list_comma()
317 state->first_list_item = false; in process_list_comma()
319 process(cache, " ,"); in process_list_comma()
320 process_linebreak(cache, 0); in process_list_comma()
324 /* Comma-separated with DW_AT_type */
325 static void __process_list_type(struct state *state, struct die *cache, in __process_list_type() argument
333 state->kabi.orig_name = NULL; in __process_list_type()
336 process_list_comma(state, cache); in __process_list_type()
337 process(cache, type); in __process_list_type()
338 process_type_attr(state, cache, die); in __process_list_type()
340 if (stable && state->kabi.orig_name) in __process_list_type()
341 name = state->kabi.orig_name; in __process_list_type()
343 process(cache, " "); in __process_list_type()
344 process(cache, name); in __process_list_type()
347 process_accessibility_attr(cache, die); in __process_list_type()
348 process_bit_size_attr(cache, die); in __process_list_type()
349 process_data_bit_offset_attr(cache, die); in __process_list_type()
350 process_data_member_location_attr(cache, die); in __process_list_type()
355 struct die *cache, Dwarf_Die *die) \
357 __process_list_type(state, cache, die, #type " "); \
364 static void __process_type(struct state *state, struct die *cache, in DEFINE_PROCESS_LIST_TYPE()
367 process(cache, type); in DEFINE_PROCESS_LIST_TYPE()
368 process_fqn(cache, die); in DEFINE_PROCESS_LIST_TYPE()
369 process(cache, " {"); in DEFINE_PROCESS_LIST_TYPE()
370 process_linebreak(cache, 1); in DEFINE_PROCESS_LIST_TYPE()
371 process_type_attr(state, cache, die); in DEFINE_PROCESS_LIST_TYPE()
372 process_linebreak(cache, -1); in DEFINE_PROCESS_LIST_TYPE()
373 process(cache, "}"); in DEFINE_PROCESS_LIST_TYPE()
374 process_byte_size_attr(cache, die); in DEFINE_PROCESS_LIST_TYPE()
375 process_alignment_attr(cache, die); in DEFINE_PROCESS_LIST_TYPE()
380 struct die *cache, Dwarf_Die *die) \
382 __process_type(state, cache, die, #type "_type"); \
398 static void process_subrange_type(struct state *state, struct die *cache, in DEFINE_PROCESS_TYPE()
404 process_fmt(cache, "[%" PRIu64 "]", count); in DEFINE_PROCESS_TYPE()
406 process_fmt(cache, "[%" PRIu64 "]", count + 1); in DEFINE_PROCESS_TYPE()
408 process(cache, "[]"); in DEFINE_PROCESS_TYPE()
411 static void process_array_type(struct state *state, struct die *cache, in process_array_type() argument
414 process(cache, "array_type"); in process_array_type()
416 check(process_die_container(state, cache, die, process_type, in process_array_type()
418 process(cache, " {"); in process_array_type()
419 process_linebreak(cache, 1); in process_array_type()
420 process_type_attr(state, cache, die); in process_array_type()
421 process_linebreak(cache, -1); in process_array_type()
422 process(cache, "}"); in process_array_type()
425 static void __process_subroutine_type(struct state *state, struct die *cache, in __process_subroutine_type() argument
428 process(cache, type); in __process_subroutine_type()
429 process(cache, " ("); in __process_subroutine_type()
430 process_linebreak(cache, 1); in __process_subroutine_type()
432 check(process_die_container(state, cache, die, process_type, in __process_subroutine_type()
434 process_linebreak(cache, -1); in __process_subroutine_type()
435 process(cache, ")"); in __process_subroutine_type()
436 process_linebreak(cache, 0); in __process_subroutine_type()
438 process(cache, "-> "); in __process_subroutine_type()
439 process_type_attr(state, cache, die); in __process_subroutine_type()
442 static void process_subroutine_type(struct state *state, struct die *cache, in process_subroutine_type() argument
445 __process_subroutine_type(state, cache, die, "subroutine_type"); in process_subroutine_type()
448 static void process_variant_type(struct state *state, struct die *cache, in process_variant_type() argument
451 process_list_comma(state, cache); in process_variant_type()
452 process(cache, "variant {"); in process_variant_type()
453 process_linebreak(cache, 1); in process_variant_type()
454 check(process_die_container(state, cache, die, process_type, in process_variant_type()
456 process_linebreak(cache, -1); in process_variant_type()
457 process(cache, "}"); in process_variant_type()
458 process_discr_value_attr(cache, die); in process_variant_type()
461 static void process_variant_part_type(struct state *state, struct die *cache, in process_variant_part_type() argument
464 process_list_comma(state, cache); in process_variant_part_type()
465 process(cache, "variant_part {"); in process_variant_part_type()
466 process_linebreak(cache, 1); in process_variant_part_type()
467 check(process_die_container(state, cache, die, process_type, in process_variant_part_type()
469 process_linebreak(cache, -1); in process_variant_part_type()
470 process(cache, "}"); in process_variant_part_type()
521 res = get_kabi_status(die, &state->kabi.orig_name); in check_struct_member_kabi_status()
524 !get_ref_die_attr(die, DW_AT_type, &state->kabi.placeholder)) in check_struct_member_kabi_status()
547 * type memberN; // <- type, N = {0,1} in check_union_member_kabi_status()
556 res = get_kabi_status(die, &state->kabi.orig_name); in check_union_member_kabi_status()
559 state->kabi.placeholder = type; in check_union_member_kabi_status()
568 if (res <= KABI_NORMAL && ++state->kabi.members < 2) in check_union_member_kabi_status()
590 * // an 8-byte placeholder for future use in get_union_kabi_status()
667 static int ___process_structure_type(struct state *state, struct die *cache, in ___process_structure_type() argument
674 return check(process_type(state, cache, die)); in ___process_structure_type()
676 return check(process_type(state, cache, die)); in ___process_structure_type()
683 /* Skip non-member types, including member functions */ in ___process_structure_type()
690 static void __process_structure_type(struct state *state, struct die *cache, in __process_structure_type() argument
697 process(cache, type); in __process_structure_type()
698 process_fqn(cache, die); in __process_structure_type()
699 process(cache, " {"); in __process_structure_type()
700 process_linebreak(cache, 1); in __process_structure_type()
702 expand = state->expand.expand && is_kabi_definition(cache, die); in __process_structure_type()
705 state->expand.current_fqn = cache->fqn; in __process_structure_type()
706 check(process_die_container(state, cache, die, process_func, in __process_structure_type()
710 process_linebreak(cache, -1); in __process_structure_type()
711 process(cache, "}"); in __process_structure_type()
714 process_byte_size_attr(cache, die); in __process_structure_type()
715 process_alignment_attr(cache, die); in __process_structure_type()
721 struct state *state, struct die *cache, Dwarf_Die *die) \
723 __process_structure_type(state, cache, die, \
732 static void process_union_type(struct state *state, struct die *cache, in DEFINE_PROCESS_STRUCTURE_TYPE()
738 &state->kabi.orig_name)); in DEFINE_PROCESS_STRUCTURE_TYPE()
741 check(process_type(state, cache, &placeholder)); in DEFINE_PROCESS_STRUCTURE_TYPE()
745 __process_structure_type(state, cache, die, "union_type", in DEFINE_PROCESS_STRUCTURE_TYPE()
749 static void process_enumerator_type(struct state *state, struct die *cache, in process_enumerator_type() argument
757 update_fqn(cache, die); in process_enumerator_type()
759 if (kabi_is_enumerator_ignored(state->expand.current_fqn, in process_enumerator_type()
760 cache->fqn)) in process_enumerator_type()
764 state->expand.current_fqn, cache->fqn, &value); in process_enumerator_type()
767 process_list_comma(state, cache); in process_enumerator_type()
768 process(cache, "enumerator"); in process_enumerator_type()
769 process_fqn(cache, die); in process_enumerator_type()
772 process(cache, " = "); in process_enumerator_type()
773 process_fmt(cache, "%" PRIu64, value); in process_enumerator_type()
777 static void process_enumeration_type(struct state *state, struct die *cache, in process_enumeration_type() argument
780 __process_structure_type(state, cache, die, "enumeration_type", in process_enumeration_type()
784 static void process_base_type(struct state *state, struct die *cache, in process_base_type() argument
787 process(cache, "base_type"); in process_base_type()
788 process_fqn(cache, die); in process_base_type()
789 process_byte_size_attr(cache, die); in process_base_type()
790 process_encoding_attr(cache, die); in process_base_type()
791 process_alignment_attr(cache, die); in process_base_type()
794 static void process_unspecified_type(struct state *state, struct die *cache, in process_unspecified_type() argument
798 * These can be emitted for stand-alone assembly code, which means we in process_unspecified_type()
801 process(cache, "unspecified_type"); in process_unspecified_type()
804 static void process_cached(struct state *state, struct die *cache, in process_cached() argument
810 list_for_each_entry(df, &cache->fragments, list) { in process_cached()
811 switch (df->type) { in process_cached()
813 die_debug_b("cache %p STRING '%s'", cache, in process_cached()
814 df->data.str); in process_cached()
815 process(NULL, df->data.str); in process_cached()
818 process_linebreak(NULL, df->data.linebreak); in process_cached()
821 if (!dwarf_die_addr_die(dwarf_cu_getdwarf(die->cu), in process_cached()
822 (void *)df->data.addr, &child)) in process_cached()
824 die_debug_b("cache %p DIE addr %" PRIxPTR " tag %x", in process_cached()
825 cache, df->data.addr, dwarf_tag(&child)); in process_cached()
836 state->expand.expand = true; in state_init()
837 state->expand.current_fqn = NULL; in state_init()
838 cache_init(&state->expansion_cache); in state_init()
844 state->expand = saved->expand; in expansion_state_restore()
845 state->current_fqn = saved->current_fqn; in expansion_state_restore()
862 process_##type##_type(state, cache, die); \
868 struct die *cache; in process_type() local
872 expansion_state_save(&state->expand, &saved); in process_type()
880 if (cache_was_expanded(&state->expansion_cache, die->addr)) in process_type()
881 state->expand.expand = false; in process_type()
883 if (state->expand.expand) in process_type()
884 cache_mark_expanded(&state->expansion_cache, die->addr); in process_type()
893 cache = die_map_get(die, want_state); in process_type()
895 if (cache->state == want_state) { in process_type()
896 die_debug_g("cached addr %p tag %x -- %s", die->addr, tag, in process_type()
897 die_state_name(cache->state)); in process_type()
899 process_cached(state, cache, die); in process_type()
900 die_map_add_die(parent, cache); in process_type()
902 expansion_state_restore(&state->expand, &saved); in process_type()
906 die_debug_g("addr %p tag %x -- %s -> %s", die->addr, tag, in process_type()
907 die_state_name(cache->state), die_state_name(want_state)); in process_type()
944 die_debug_r("parent %p cache %p die addr %p tag %x", parent, cache, in process_type()
945 die->addr, tag); in process_type()
947 /* Update cache state and append to the parent (if any) */ in process_type()
948 cache->tag = tag; in process_type()
949 cache->state = want_state; in process_type()
950 die_map_add_die(parent, cache); in process_type()
952 expansion_state_restore(&state->expand, &saved); in process_type()
961 struct die *cache; in get_symbol_cache() local
963 cache = die_map_get(die, DIE_SYMBOL); in get_symbol_cache()
965 if (cache->state != DIE_INCOMPLETE) in get_symbol_cache()
968 cache->tag = dwarf_tag(die); in get_symbol_cache()
969 return cache; in get_symbol_cache()
975 struct die *cache; in process_symbol() local
977 symbol_set_die(state->sym, die); in process_symbol()
979 cache = get_symbol_cache(state, die); in process_symbol()
980 if (!cache) in process_symbol()
983 debug("%s", state->sym->name); in process_symbol()
984 check(process_func(state, cache, die)); in process_symbol()
985 cache->state = DIE_SYMBOL; in process_symbol()
990 static int __process_subprogram(struct state *state, struct die *cache, in __process_subprogram() argument
993 __process_subroutine_type(state, cache, die, "subprogram"); in __process_subprogram()
1002 static int __process_variable(struct state *state, struct die *cache, in __process_variable() argument
1005 process(cache, "variable "); in __process_variable()
1006 process_type_attr(state, cache, die); in __process_variable()
1020 if (!get_ref_die_attr(&state->die, DW_AT_type, &ptr_type) || in save_symbol_ptr()
1023 get_symbol_name(&state->die)); in save_symbol_ptr()
1027 get_symbol_name(&state->die)); in save_symbol_ptr()
1035 symbol_set_ptr(state->sym, &type); in save_symbol_ptr()
1037 symbol_set_ptr(state->sym, &ptr_type); in save_symbol_ptr()
1040 static int process_exported_symbols(struct state *unused, struct die *cache, in process_exported_symbols() argument
1051 NULL, cache, die, process_exported_symbols, match_all)); in process_exported_symbols()
1083 if (sym->state != SYMBOL_UNPROCESSED || !sym->ptr_die_addr) in process_symbol_ptr()
1086 debug("%s", sym->name); in process_symbol_ptr()
1090 if (!dwarf_die_addr_die(dwarf, (void *)sym->ptr_die_addr, &state.die)) in process_symbol_ptr()
1092 sym->name); in process_symbol_ptr()
1106 struct die *cache; in resolve_fqns() local
1113 if (!__die_map_get((uintptr_t)die->addr, DIE_FQN, &cache)) in resolve_fqns()
1128 if (parent && parent->expand.current_fqn && (use_prefix || name)) { in resolve_fqns()
1133 if (asprintf(&prefix, "%s::%s", parent->expand.current_fqn, in resolve_fqns()
1157 /* If the DIE has a non-empty name, cache it. */ in resolve_fqns()
1159 cache = die_map_get(die, DIE_FQN); in resolve_fqns()
1161 cache->fqn = fqn; in resolve_fqns()
1162 cache->state = DIE_FQN; in resolve_fqns()
1180 symbol_for_each(process_symbol_ptr, dwarf_cu_getdwarf(cudie->cu)); in process_cu()