Lines Matching refs:show

408 	__printf(2, 0) void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
448 void (*show)(const struct btf *btf, const struct btf_type *t, member
450 struct btf_show *show);
925 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
934 const struct btf_member *m = show->state.member; in btf_show_name()
937 u32 id = show->state.type_id; in btf_show_name()
943 show->state.name[0] = '\0'; in btf_show_name()
950 if (show->state.array_member) in btf_show_name()
955 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
967 t = btf_type_by_id(show->btf, id); in btf_show_name()
998 name = btf_name_by_offset(show->btf, in btf_show_name()
1025 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
1032 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1062 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
1063 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
1066 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
1081 return show->state.name; in btf_show_name()
1084 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
1089 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
1090 return indent - show->state.depth; in __btf_show_indent()
1094 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
1096 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
1099 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
1101 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
1104 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
1106 if (show->state.depth == 0) in btf_show_delim()
1109 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
1110 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
1116 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
1120 if (!show->state.depth_check) { in btf_show()
1122 show->showfn(show, fmt, args); in btf_show()
1132 #define btf_show_type_value(show, fmt, value) \ argument
1135 (show->flags & BTF_SHOW_ZERO) || \
1136 show->state.depth == 0) { \
1137 btf_show(show, "%s%s" fmt "%s%s", \
1138 btf_show_indent(show), \
1139 btf_show_name(show), \
1140 value, btf_show_delim(show), \
1141 btf_show_newline(show)); \
1142 if (show->state.depth > show->state.depth_to_show) \
1143 show->state.depth_to_show = show->state.depth; \
1147 #define btf_show_type_values(show, fmt, ...) \ argument
1149 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
1150 btf_show_name(show), \
1151 __VA_ARGS__, btf_show_delim(show), \
1152 btf_show_newline(show)); \
1153 if (show->state.depth > show->state.depth_to_show) \
1154 show->state.depth_to_show = show->state.depth; \
1158 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1160 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1164 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1166 return data >= show->obj.data && in btf_show_obj_is_safe()
1167 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1176 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1178 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1179 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1211 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1219 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1222 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1224 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1233 if (show->state.depth == 0) { in btf_show_obj_safe()
1234 show->obj.size = size; in btf_show_obj_safe()
1235 show->obj.head = data; in btf_show_obj_safe()
1258 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1269 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1272 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1274 if (!show->state.status) { in btf_show_obj_safe()
1275 show->obj.data = data; in btf_show_obj_safe()
1276 safe = show->obj.safe; in btf_show_obj_safe()
1287 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1291 show->state.type = t; in btf_show_start_type()
1292 show->state.type_id = type_id; in btf_show_start_type()
1293 show->state.name[0] = '\0'; in btf_show_start_type()
1295 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1298 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1300 show->state.type = NULL; in btf_show_end_type()
1301 show->state.type_id = 0; in btf_show_end_type()
1302 show->state.name[0] = '\0'; in btf_show_end_type()
1305 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1309 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1314 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1315 btf_show_name(show), in btf_show_start_aggr_type()
1316 btf_show_newline(show)); in btf_show_start_aggr_type()
1317 show->state.depth++; in btf_show_start_aggr_type()
1321 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1324 show->state.depth--; in btf_show_end_aggr_type()
1325 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1326 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1327 btf_show_end_type(show); in btf_show_end_aggr_type()
1330 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1333 show->state.member = m; in btf_show_start_member()
1336 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1338 show->state.array_member = 1; in btf_show_start_array_member()
1339 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1342 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1344 show->state.member = NULL; in btf_show_end_member()
1347 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1349 show->state.array_member = 0; in btf_show_end_array_member()
1350 btf_show_end_member(show); in btf_show_end_array_member()
1353 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1359 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1360 show->state.array_terminated = 0; in btf_show_start_array_type()
1361 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1364 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1366 show->state.array_encoding = 0; in btf_show_end_array_type()
1367 show->state.array_terminated = 0; in btf_show_end_array_type()
1368 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1371 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1376 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1379 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1381 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
2069 struct btf_show *show) in btf_df_show() argument
2071 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2244 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2263 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2265 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2311 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2331 btf_int128_print(show, print_num); in btf_bitfield_show()
2338 struct btf_show *show) in btf_int_bits_show() argument
2351 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2356 struct btf_show *show) in btf_int_show() argument
2364 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2370 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2376 btf_int128_print(show, safe_data); in btf_int_show()
2380 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2382 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2386 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2388 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2392 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2394 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2397 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2399 if (show->state.array_terminated) in btf_int_show()
2402 show->state.array_terminated = 1; in btf_int_show()
2406 btf_show_type_value(show, "'%c'", in btf_int_show()
2412 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2414 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2417 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2421 btf_show_end_type(show); in btf_int_show()
2430 .show = btf_int_show,
2705 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2712 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2717 struct btf_show *show) in btf_var_show() argument
2721 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2726 struct btf_show *show) in btf_ptr_show() argument
2730 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2735 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2736 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2738 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2739 btf_show_end_type(show); in btf_ptr_show()
2754 .show = btf_modifier_show,
2763 .show = btf_ptr_show,
2804 .show = btf_df_show,
2965 struct btf_show *show) in __btf_array_show() argument
2992 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
3001 btf_show_start_array_member(show); in __btf_array_show()
3003 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
3004 bits_offset, show); in __btf_array_show()
3007 btf_show_end_array_member(show); in __btf_array_show()
3009 if (show->state.array_terminated) in __btf_array_show()
3013 btf_show_end_array_type(show); in __btf_array_show()
3018 struct btf_show *show) in btf_array_show() argument
3020 const struct btf_member *m = show->state.member; in btf_array_show()
3027 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
3028 if (!show->state.depth_check) { in btf_array_show()
3029 show->state.depth_check = show->state.depth + 1; in btf_array_show()
3030 show->state.depth_to_show = 0; in btf_array_show()
3032 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3033 show->state.member = m; in btf_array_show()
3035 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
3037 show->state.depth_check = 0; in btf_array_show()
3039 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
3046 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3055 .show = btf_array_show,
3910 struct btf_show *show) in __btf_struct_show() argument
3916 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3928 btf_show_start_member(show, member); in __btf_struct_show()
3935 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
3941 bitfield_size, show); in __btf_struct_show()
3942 btf_show_end_type(show); in __btf_struct_show()
3945 ops->show(btf, member_type, member->type, in __btf_struct_show()
3946 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
3949 btf_show_end_member(show); in __btf_struct_show()
3952 btf_show_end_struct_type(show); in __btf_struct_show()
3957 struct btf_show *show) in btf_struct_show() argument
3959 const struct btf_member *m = show->state.member; in btf_struct_show()
3966 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
3967 if (!show->state.depth_check) { in btf_struct_show()
3968 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
3969 show->state.depth_to_show = 0; in btf_struct_show()
3971 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3973 show->state.member = m; in btf_struct_show()
3974 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
3976 show->state.depth_check = 0; in btf_struct_show()
3978 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
3986 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3995 .show = btf_struct_show,
4125 struct btf_show *show) in btf_enum_show() argument
4132 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
4142 btf_show_type_value(show, "%s", in btf_enum_show()
4146 btf_show_end_type(show); in btf_enum_show()
4151 btf_show_type_value(show, "%d", v); in btf_enum_show()
4153 btf_show_type_value(show, "%u", v); in btf_enum_show()
4154 btf_show_end_type(show); in btf_enum_show()
4163 .show = btf_enum_show,
4228 struct btf_show *show) in btf_enum64_show() argument
4235 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum64_show()
4245 btf_show_type_value(show, "%s", in btf_enum64_show()
4249 btf_show_end_type(show); in btf_enum64_show()
4254 btf_show_type_value(show, "%lld", v); in btf_enum64_show()
4256 btf_show_type_value(show, "%llu", v); in btf_enum64_show()
4257 btf_show_end_type(show); in btf_enum64_show()
4266 .show = btf_enum64_show,
4353 .show = btf_df_show,
4402 .show = btf_df_show,
4466 .show = btf_var_show,
4591 struct btf_show *show) in btf_datasec_show() argument
4597 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
4600 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
4605 btf_show(show, ","); in btf_datasec_show()
4606 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
4607 data + vsi->offset, bits_offset, show); in btf_datasec_show()
4609 btf_show_end_type(show); in btf_datasec_show()
4618 .show = btf_datasec_show,
4693 .show = btf_df_show,
4797 .show = btf_df_show,
7068 struct btf_show *show) in btf_type_show() argument
7072 show->btf = btf; in btf_type_show()
7073 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
7074 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
7076 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
7079 __printf(2, 0) static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
7082 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
7108 struct btf_show show; member
7113 __printf(2, 0) static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
7116 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
7119 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
7131 show->target += len; in btf_snprintf_show()
7140 ssnprintf.show.target = buf; in btf_type_snprintf_show()
7141 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
7142 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
7149 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
7150 return ssnprintf.show.state.status; in btf_type_snprintf_show()