Lines Matching refs:show
353 void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
393 void (*show)(const struct btf *btf, const struct btf_type *t, member
395 struct btf_show *show);
827 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
836 const struct btf_member *m = show->state.member; in btf_show_name()
837 const struct btf_type *t = show->state.type; in btf_show_name()
839 u32 id = show->state.type_id; in btf_show_name()
845 show->state.name[0] = '\0'; in btf_show_name()
852 if (show->state.array_member) in btf_show_name()
857 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
869 t = btf_type_by_id(show->btf, id); in btf_show_name()
900 name = btf_name_by_offset(show->btf, in btf_show_name()
927 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
934 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
963 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
964 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
967 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
982 return show->state.name; in btf_show_name()
985 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
990 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
991 return indent - show->state.depth; in __btf_show_indent()
995 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
997 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
1000 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
1002 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
1005 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
1007 if (show->state.depth == 0) in btf_show_delim()
1010 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
1011 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
1017 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
1021 if (!show->state.depth_check) { in btf_show()
1023 show->showfn(show, fmt, args); in btf_show()
1033 #define btf_show_type_value(show, fmt, value) \ argument
1035 if ((value) != 0 || (show->flags & BTF_SHOW_ZERO) || \
1036 show->state.depth == 0) { \
1037 btf_show(show, "%s%s" fmt "%s%s", \
1038 btf_show_indent(show), \
1039 btf_show_name(show), \
1040 value, btf_show_delim(show), \
1041 btf_show_newline(show)); \
1042 if (show->state.depth > show->state.depth_to_show) \
1043 show->state.depth_to_show = show->state.depth; \
1047 #define btf_show_type_values(show, fmt, ...) \ argument
1049 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
1050 btf_show_name(show), \
1051 __VA_ARGS__, btf_show_delim(show), \
1052 btf_show_newline(show)); \
1053 if (show->state.depth > show->state.depth_to_show) \
1054 show->state.depth_to_show = show->state.depth; \
1058 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1060 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1064 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1066 return data >= show->obj.data && in btf_show_obj_is_safe()
1067 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1076 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1078 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1079 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1111 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1119 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1122 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1124 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1133 if (show->state.depth == 0) { in btf_show_obj_safe()
1134 show->obj.size = size; in btf_show_obj_safe()
1135 show->obj.head = data; in btf_show_obj_safe()
1158 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1169 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1172 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1174 if (!show->state.status) { in btf_show_obj_safe()
1175 show->obj.data = data; in btf_show_obj_safe()
1176 safe = show->obj.safe; in btf_show_obj_safe()
1187 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1191 show->state.type = t; in btf_show_start_type()
1192 show->state.type_id = type_id; in btf_show_start_type()
1193 show->state.name[0] = '\0'; in btf_show_start_type()
1195 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1198 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1200 show->state.type = NULL; in btf_show_end_type()
1201 show->state.type_id = 0; in btf_show_end_type()
1202 show->state.name[0] = '\0'; in btf_show_end_type()
1205 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1209 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1214 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1215 btf_show_name(show), in btf_show_start_aggr_type()
1216 btf_show_newline(show)); in btf_show_start_aggr_type()
1217 show->state.depth++; in btf_show_start_aggr_type()
1221 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1224 show->state.depth--; in btf_show_end_aggr_type()
1225 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1226 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1227 btf_show_end_type(show); in btf_show_end_aggr_type()
1230 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1233 show->state.member = m; in btf_show_start_member()
1236 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1238 show->state.array_member = 1; in btf_show_start_array_member()
1239 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1242 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1244 show->state.member = NULL; in btf_show_end_member()
1247 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1249 show->state.array_member = 0; in btf_show_end_array_member()
1250 btf_show_end_member(show); in btf_show_end_array_member()
1253 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1259 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1260 show->state.array_terminated = 0; in btf_show_start_array_type()
1261 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1264 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1266 show->state.array_encoding = 0; in btf_show_end_array_type()
1267 show->state.array_terminated = 0; in btf_show_end_array_type()
1268 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1271 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1276 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1279 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1281 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
1904 struct btf_show *show) in btf_df_show() argument
1906 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2079 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2098 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2100 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2146 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2166 btf_int128_print(show, print_num); in btf_bitfield_show()
2173 struct btf_show *show) in btf_int_bits_show() argument
2186 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2191 struct btf_show *show) in btf_int_show() argument
2199 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2205 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2211 btf_int128_print(show, safe_data); in btf_int_show()
2215 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2217 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2221 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2223 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2227 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2229 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2232 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2234 if (show->state.array_terminated) in btf_int_show()
2237 show->state.array_terminated = 1; in btf_int_show()
2241 btf_show_type_value(show, "'%c'", in btf_int_show()
2247 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2249 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2252 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2256 btf_show_end_type(show); in btf_int_show()
2265 .show = btf_int_show,
2532 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2539 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2544 struct btf_show *show) in btf_var_show() argument
2548 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2553 struct btf_show *show) in btf_ptr_show() argument
2557 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2562 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2563 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2565 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2566 btf_show_end_type(show); in btf_ptr_show()
2581 .show = btf_modifier_show,
2590 .show = btf_ptr_show,
2631 .show = btf_df_show,
2792 struct btf_show *show) in __btf_array_show() argument
2819 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
2828 btf_show_start_array_member(show); in __btf_array_show()
2830 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2831 bits_offset, show); in __btf_array_show()
2834 btf_show_end_array_member(show); in __btf_array_show()
2836 if (show->state.array_terminated) in __btf_array_show()
2840 btf_show_end_array_type(show); in __btf_array_show()
2845 struct btf_show *show) in btf_array_show() argument
2847 const struct btf_member *m = show->state.member; in btf_array_show()
2854 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
2855 if (!show->state.depth_check) { in btf_array_show()
2856 show->state.depth_check = show->state.depth + 1; in btf_array_show()
2857 show->state.depth_to_show = 0; in btf_array_show()
2859 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2860 show->state.member = m; in btf_array_show()
2862 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
2864 show->state.depth_check = 0; in btf_array_show()
2866 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
2873 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2882 .show = btf_array_show,
3156 struct btf_show *show) in __btf_struct_show() argument
3162 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3174 btf_show_start_member(show, member); in __btf_struct_show()
3181 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
3187 bitfield_size, show); in __btf_struct_show()
3188 btf_show_end_type(show); in __btf_struct_show()
3191 ops->show(btf, member_type, member->type, in __btf_struct_show()
3192 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
3195 btf_show_end_member(show); in __btf_struct_show()
3198 btf_show_end_struct_type(show); in __btf_struct_show()
3203 struct btf_show *show) in btf_struct_show() argument
3205 const struct btf_member *m = show->state.member; in btf_struct_show()
3212 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
3213 if (!show->state.depth_check) { in btf_struct_show()
3214 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
3215 show->state.depth_to_show = 0; in btf_struct_show()
3217 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3219 show->state.member = m; in btf_struct_show()
3220 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
3222 show->state.depth_check = 0; in btf_struct_show()
3224 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
3232 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3241 .show = btf_struct_show,
3374 struct btf_show *show) in btf_enum_show() argument
3381 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
3391 btf_show_type_value(show, "%s", in btf_enum_show()
3395 btf_show_end_type(show); in btf_enum_show()
3399 btf_show_type_value(show, "%d", v); in btf_enum_show()
3400 btf_show_end_type(show); in btf_enum_show()
3409 .show = btf_enum_show,
3496 .show = btf_df_show,
3530 .show = btf_df_show,
3594 .show = btf_var_show,
3718 struct btf_show *show) in btf_datasec_show() argument
3724 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
3727 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
3732 btf_show(show, ","); in btf_datasec_show()
3733 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
3734 data + vsi->offset, bits_offset, show); in btf_datasec_show()
3736 btf_show_end_type(show); in btf_datasec_show()
3745 .show = btf_datasec_show,
3820 .show = btf_df_show,
3924 .show = btf_df_show,
5862 struct btf_show *show) in btf_type_show() argument
5866 show->btf = btf; in btf_type_show()
5867 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
5868 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
5870 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
5873 static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
5876 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
5902 struct btf_show show; member
5907 static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
5910 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
5913 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
5925 show->target += len; in btf_snprintf_show()
5934 ssnprintf.show.target = buf; in btf_type_snprintf_show()
5935 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
5936 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
5943 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
5944 return ssnprintf.show.state.status; in btf_type_snprintf_show()