Lines Matching refs:show

381 	void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
421 void (*show)(const struct btf *btf, const struct btf_type *t, member
423 struct btf_show *show);
911 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
920 const struct btf_member *m = show->state.member; in btf_show_name()
923 u32 id = show->state.type_id; in btf_show_name()
929 show->state.name[0] = '\0'; in btf_show_name()
936 if (show->state.array_member) in btf_show_name()
941 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
953 t = btf_type_by_id(show->btf, id); in btf_show_name()
984 name = btf_name_by_offset(show->btf, in btf_show_name()
1011 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
1018 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1048 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
1049 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
1052 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
1067 return show->state.name; in btf_show_name()
1070 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
1075 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
1076 return indent - show->state.depth; in __btf_show_indent()
1080 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
1082 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
1085 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
1087 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
1090 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
1092 if (show->state.depth == 0) in btf_show_delim()
1095 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
1096 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
1102 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
1106 if (!show->state.depth_check) { in btf_show()
1108 show->showfn(show, fmt, args); in btf_show()
1118 #define btf_show_type_value(show, fmt, value) \ argument
1121 (show->flags & BTF_SHOW_ZERO) || \
1122 show->state.depth == 0) { \
1123 btf_show(show, "%s%s" fmt "%s%s", \
1124 btf_show_indent(show), \
1125 btf_show_name(show), \
1126 value, btf_show_delim(show), \
1127 btf_show_newline(show)); \
1128 if (show->state.depth > show->state.depth_to_show) \
1129 show->state.depth_to_show = show->state.depth; \
1133 #define btf_show_type_values(show, fmt, ...) \ argument
1135 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
1136 btf_show_name(show), \
1137 __VA_ARGS__, btf_show_delim(show), \
1138 btf_show_newline(show)); \
1139 if (show->state.depth > show->state.depth_to_show) \
1140 show->state.depth_to_show = show->state.depth; \
1144 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1146 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1150 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1152 return data >= show->obj.data && in btf_show_obj_is_safe()
1153 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1162 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1164 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1165 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1197 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1205 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1208 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1210 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1219 if (show->state.depth == 0) { in btf_show_obj_safe()
1220 show->obj.size = size; in btf_show_obj_safe()
1221 show->obj.head = data; in btf_show_obj_safe()
1244 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1255 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1258 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1260 if (!show->state.status) { in btf_show_obj_safe()
1261 show->obj.data = data; in btf_show_obj_safe()
1262 safe = show->obj.safe; in btf_show_obj_safe()
1273 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1277 show->state.type = t; in btf_show_start_type()
1278 show->state.type_id = type_id; in btf_show_start_type()
1279 show->state.name[0] = '\0'; in btf_show_start_type()
1281 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1284 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1286 show->state.type = NULL; in btf_show_end_type()
1287 show->state.type_id = 0; in btf_show_end_type()
1288 show->state.name[0] = '\0'; in btf_show_end_type()
1291 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1295 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1300 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1301 btf_show_name(show), in btf_show_start_aggr_type()
1302 btf_show_newline(show)); in btf_show_start_aggr_type()
1303 show->state.depth++; in btf_show_start_aggr_type()
1307 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1310 show->state.depth--; in btf_show_end_aggr_type()
1311 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1312 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1313 btf_show_end_type(show); in btf_show_end_aggr_type()
1316 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1319 show->state.member = m; in btf_show_start_member()
1322 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1324 show->state.array_member = 1; in btf_show_start_array_member()
1325 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1328 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1330 show->state.member = NULL; in btf_show_end_member()
1333 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1335 show->state.array_member = 0; in btf_show_end_array_member()
1336 btf_show_end_member(show); in btf_show_end_array_member()
1339 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1345 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1346 show->state.array_terminated = 0; in btf_show_start_array_type()
1347 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1350 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1352 show->state.array_encoding = 0; in btf_show_end_array_type()
1353 show->state.array_terminated = 0; in btf_show_end_array_type()
1354 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1357 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1362 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1365 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1367 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
2022 struct btf_show *show) in btf_df_show() argument
2024 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2197 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2216 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2218 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2264 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2284 btf_int128_print(show, print_num); in btf_bitfield_show()
2291 struct btf_show *show) in btf_int_bits_show() argument
2304 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2309 struct btf_show *show) in btf_int_show() argument
2317 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2323 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2329 btf_int128_print(show, safe_data); in btf_int_show()
2333 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2335 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2339 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2341 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2345 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2347 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2350 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2352 if (show->state.array_terminated) in btf_int_show()
2355 show->state.array_terminated = 1; in btf_int_show()
2359 btf_show_type_value(show, "'%c'", in btf_int_show()
2365 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2367 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2370 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2374 btf_show_end_type(show); in btf_int_show()
2383 .show = btf_int_show,
2658 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2665 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2670 struct btf_show *show) in btf_var_show() argument
2674 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2679 struct btf_show *show) in btf_ptr_show() argument
2683 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2688 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2689 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2691 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2692 btf_show_end_type(show); in btf_ptr_show()
2707 .show = btf_modifier_show,
2716 .show = btf_ptr_show,
2757 .show = btf_df_show,
2918 struct btf_show *show) in __btf_array_show() argument
2945 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
2954 btf_show_start_array_member(show); in __btf_array_show()
2956 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2957 bits_offset, show); in __btf_array_show()
2960 btf_show_end_array_member(show); in __btf_array_show()
2962 if (show->state.array_terminated) in __btf_array_show()
2966 btf_show_end_array_type(show); in __btf_array_show()
2971 struct btf_show *show) in btf_array_show() argument
2973 const struct btf_member *m = show->state.member; in btf_array_show()
2980 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
2981 if (!show->state.depth_check) { in btf_array_show()
2982 show->state.depth_check = show->state.depth + 1; in btf_array_show()
2983 show->state.depth_to_show = 0; in btf_array_show()
2985 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2986 show->state.member = m; in btf_array_show()
2988 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
2990 show->state.depth_check = 0; in btf_array_show()
2992 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
2999 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3008 .show = btf_array_show,
3527 struct btf_show *show) in __btf_struct_show() argument
3533 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3545 btf_show_start_member(show, member); in __btf_struct_show()
3552 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
3558 bitfield_size, show); in __btf_struct_show()
3559 btf_show_end_type(show); in __btf_struct_show()
3562 ops->show(btf, member_type, member->type, in __btf_struct_show()
3563 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
3566 btf_show_end_member(show); in __btf_struct_show()
3569 btf_show_end_struct_type(show); in __btf_struct_show()
3574 struct btf_show *show) in btf_struct_show() argument
3576 const struct btf_member *m = show->state.member; in btf_struct_show()
3583 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
3584 if (!show->state.depth_check) { in btf_struct_show()
3585 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
3586 show->state.depth_to_show = 0; in btf_struct_show()
3588 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3590 show->state.member = m; in btf_struct_show()
3591 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
3593 show->state.depth_check = 0; in btf_struct_show()
3595 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
3603 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3612 .show = btf_struct_show,
3742 struct btf_show *show) in btf_enum_show() argument
3749 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
3759 btf_show_type_value(show, "%s", in btf_enum_show()
3763 btf_show_end_type(show); in btf_enum_show()
3768 btf_show_type_value(show, "%d", v); in btf_enum_show()
3770 btf_show_type_value(show, "%u", v); in btf_enum_show()
3771 btf_show_end_type(show); in btf_enum_show()
3780 .show = btf_enum_show,
3845 struct btf_show *show) in btf_enum64_show() argument
3852 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum64_show()
3862 btf_show_type_value(show, "%s", in btf_enum64_show()
3866 btf_show_end_type(show); in btf_enum64_show()
3871 btf_show_type_value(show, "%lld", v); in btf_enum64_show()
3873 btf_show_type_value(show, "%llu", v); in btf_enum64_show()
3874 btf_show_end_type(show); in btf_enum64_show()
3883 .show = btf_enum64_show,
3970 .show = btf_df_show,
4019 .show = btf_df_show,
4083 .show = btf_var_show,
4207 struct btf_show *show) in btf_datasec_show() argument
4213 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
4216 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
4221 btf_show(show, ","); in btf_datasec_show()
4222 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
4223 data + vsi->offset, bits_offset, show); in btf_datasec_show()
4225 btf_show_end_type(show); in btf_datasec_show()
4234 .show = btf_datasec_show,
4309 .show = btf_df_show,
4413 .show = btf_df_show,
6777 struct btf_show *show) in btf_type_show() argument
6781 show->btf = btf; in btf_type_show()
6782 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
6783 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
6785 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
6788 static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
6791 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
6817 struct btf_show show; member
6822 static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
6825 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
6828 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
6840 show->target += len; in btf_snprintf_show()
6849 ssnprintf.show.target = buf; in btf_type_snprintf_show()
6850 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
6851 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
6858 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
6859 return ssnprintf.show.state.status; in btf_type_snprintf_show()