Lines Matching refs:show
418 __printf(2, 0) void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
458 void (*show)(const struct btf *btf, const struct btf_type *t, member
460 struct btf_show *show);
947 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
956 const struct btf_member *m = show->state.member; in btf_show_name()
959 u32 id = show->state.type_id; in btf_show_name()
965 show->state.name[0] = '\0'; in btf_show_name()
972 if (show->state.array_member) in btf_show_name()
977 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
989 t = btf_type_by_id(show->btf, id); in btf_show_name()
1020 name = btf_name_by_offset(show->btf, in btf_show_name()
1047 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
1054 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1084 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
1085 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
1088 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
1103 return show->state.name; in btf_show_name()
1106 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
1111 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
1112 return indent - show->state.depth; in __btf_show_indent()
1116 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
1118 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
1121 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
1123 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
1126 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
1128 if (show->state.depth == 0) in btf_show_delim()
1131 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
1132 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
1138 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
1142 if (!show->state.depth_check) { in btf_show()
1144 show->showfn(show, fmt, args); in btf_show()
1154 #define btf_show_type_value(show, fmt, value) \ argument
1157 (show->flags & BTF_SHOW_ZERO) || \
1158 show->state.depth == 0) { \
1159 btf_show(show, "%s%s" fmt "%s%s", \
1160 btf_show_indent(show), \
1161 btf_show_name(show), \
1162 value, btf_show_delim(show), \
1163 btf_show_newline(show)); \
1164 if (show->state.depth > show->state.depth_to_show) \
1165 show->state.depth_to_show = show->state.depth; \
1169 #define btf_show_type_values(show, fmt, ...) \ argument
1171 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
1172 btf_show_name(show), \
1173 __VA_ARGS__, btf_show_delim(show), \
1174 btf_show_newline(show)); \
1175 if (show->state.depth > show->state.depth_to_show) \
1176 show->state.depth_to_show = show->state.depth; \
1180 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1182 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1186 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1188 return data >= show->obj.data && in btf_show_obj_is_safe()
1189 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1198 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1200 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1201 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1233 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1241 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1244 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1246 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1255 if (show->state.depth == 0) { in btf_show_obj_safe()
1256 show->obj.size = size; in btf_show_obj_safe()
1257 show->obj.head = data; in btf_show_obj_safe()
1280 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1291 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1294 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1296 if (!show->state.status) { in btf_show_obj_safe()
1297 show->obj.data = data; in btf_show_obj_safe()
1298 safe = show->obj.safe; in btf_show_obj_safe()
1309 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1313 show->state.type = t; in btf_show_start_type()
1314 show->state.type_id = type_id; in btf_show_start_type()
1315 show->state.name[0] = '\0'; in btf_show_start_type()
1317 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1320 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1322 show->state.type = NULL; in btf_show_end_type()
1323 show->state.type_id = 0; in btf_show_end_type()
1324 show->state.name[0] = '\0'; in btf_show_end_type()
1327 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1331 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1336 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1337 btf_show_name(show), in btf_show_start_aggr_type()
1338 btf_show_newline(show)); in btf_show_start_aggr_type()
1339 show->state.depth++; in btf_show_start_aggr_type()
1343 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1346 show->state.depth--; in btf_show_end_aggr_type()
1347 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1348 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1349 btf_show_end_type(show); in btf_show_end_aggr_type()
1352 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1355 show->state.member = m; in btf_show_start_member()
1358 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1360 show->state.array_member = 1; in btf_show_start_array_member()
1361 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1364 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1366 show->state.member = NULL; in btf_show_end_member()
1369 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1371 show->state.array_member = 0; in btf_show_end_array_member()
1372 btf_show_end_member(show); in btf_show_end_array_member()
1375 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1381 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1382 show->state.array_terminated = 0; in btf_show_start_array_type()
1383 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1386 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1388 show->state.array_encoding = 0; in btf_show_end_array_type()
1389 show->state.array_terminated = 0; in btf_show_end_array_type()
1390 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1393 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1398 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1401 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1403 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
2128 struct btf_show *show) in btf_df_show() argument
2130 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2303 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2322 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2324 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2370 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2390 btf_int128_print(show, print_num); in btf_bitfield_show()
2397 struct btf_show *show) in btf_int_bits_show() argument
2410 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2415 struct btf_show *show) in btf_int_show() argument
2423 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2429 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2435 btf_int128_print(show, safe_data); in btf_int_show()
2439 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2441 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2445 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2447 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2451 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2453 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2456 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2458 if (show->state.array_terminated) in btf_int_show()
2461 show->state.array_terminated = 1; in btf_int_show()
2465 btf_show_type_value(show, "'%c'", in btf_int_show()
2471 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2473 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2476 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2480 btf_show_end_type(show); in btf_int_show()
2489 .show = btf_int_show,
2764 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2771 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2776 struct btf_show *show) in btf_var_show() argument
2780 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2785 struct btf_show *show) in btf_ptr_show() argument
2789 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2794 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2795 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2797 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2798 btf_show_end_type(show); in btf_ptr_show()
2813 .show = btf_modifier_show,
2822 .show = btf_ptr_show,
2863 .show = btf_df_show,
3024 struct btf_show *show) in __btf_array_show() argument
3051 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
3060 btf_show_start_array_member(show); in __btf_array_show()
3062 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
3063 bits_offset, show); in __btf_array_show()
3066 btf_show_end_array_member(show); in __btf_array_show()
3068 if (show->state.array_terminated) in __btf_array_show()
3072 btf_show_end_array_type(show); in __btf_array_show()
3077 struct btf_show *show) in btf_array_show() argument
3079 const struct btf_member *m = show->state.member; in btf_array_show()
3086 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
3087 if (!show->state.depth_check) { in btf_array_show()
3088 show->state.depth_check = show->state.depth + 1; in btf_array_show()
3089 show->state.depth_to_show = 0; in btf_array_show()
3091 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3092 show->state.member = m; in btf_array_show()
3094 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
3096 show->state.depth_check = 0; in btf_array_show()
3098 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
3105 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3114 .show = btf_array_show,
4160 struct btf_show *show) in __btf_struct_show() argument
4166 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
4178 btf_show_start_member(show, member); in __btf_struct_show()
4185 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
4191 bitfield_size, show); in __btf_struct_show()
4192 btf_show_end_type(show); in __btf_struct_show()
4195 ops->show(btf, member_type, member->type, in __btf_struct_show()
4196 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
4199 btf_show_end_member(show); in __btf_struct_show()
4202 btf_show_end_struct_type(show); in __btf_struct_show()
4207 struct btf_show *show) in btf_struct_show() argument
4209 const struct btf_member *m = show->state.member; in btf_struct_show()
4216 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
4217 if (!show->state.depth_check) { in btf_struct_show()
4218 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
4219 show->state.depth_to_show = 0; in btf_struct_show()
4221 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
4223 show->state.member = m; in btf_struct_show()
4224 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
4226 show->state.depth_check = 0; in btf_struct_show()
4228 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
4236 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
4245 .show = btf_struct_show,
4375 struct btf_show *show) in btf_enum_show() argument
4382 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
4392 btf_show_type_value(show, "%s", in btf_enum_show()
4396 btf_show_end_type(show); in btf_enum_show()
4401 btf_show_type_value(show, "%d", v); in btf_enum_show()
4403 btf_show_type_value(show, "%u", v); in btf_enum_show()
4404 btf_show_end_type(show); in btf_enum_show()
4413 .show = btf_enum_show,
4478 struct btf_show *show) in btf_enum64_show() argument
4485 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum64_show()
4495 btf_show_type_value(show, "%s", in btf_enum64_show()
4499 btf_show_end_type(show); in btf_enum64_show()
4504 btf_show_type_value(show, "%lld", v); in btf_enum64_show()
4506 btf_show_type_value(show, "%llu", v); in btf_enum64_show()
4507 btf_show_end_type(show); in btf_enum64_show()
4516 .show = btf_enum64_show,
4603 .show = btf_df_show,
4652 .show = btf_df_show,
4716 .show = btf_var_show,
4841 struct btf_show *show) in btf_datasec_show() argument
4847 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
4850 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
4855 btf_show(show, ","); in btf_datasec_show()
4856 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
4857 data + vsi->offset, bits_offset, show); in btf_datasec_show()
4859 btf_show_end_type(show); in btf_datasec_show()
4868 .show = btf_datasec_show,
4943 .show = btf_df_show,
5042 .show = btf_df_show,
7860 struct btf_show *show) in btf_type_show() argument
7864 show->btf = btf; in btf_type_show()
7865 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
7866 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
7868 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
7871 __printf(2, 0) static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
7874 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
7900 struct btf_show show; member
7905 __printf(2, 0) static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
7908 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
7911 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
7923 show->target += len; in btf_snprintf_show()
7932 ssnprintf.show.target = buf; in btf_type_snprintf_show()
7933 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
7934 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
7941 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
7942 return ssnprintf.show.state.status; in btf_type_snprintf_show()