Lines Matching full:show

298  * Common data to all BTF show operations. Private show functions can add
300 * in the show callback. See btf_type_show() below.
307 * pass is signalled by show->state.depth_check being set, and if we
308 * encounter a non-zero value we set show->state.depth_to_show to
321 * The various data type show functions all start with a call to
342 void *target; /* target of show operation (seq file, buffer) */
343 void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
383 void (*show)(const struct btf *btf, const struct btf_type *t, member
385 struct btf_show *show);
762 * Populate show->state.name with type name information.
767 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
776 const struct btf_member *m = show->state.member; in btf_show_name()
777 const struct btf_type *t = show->state.type; in btf_show_name()
779 u32 id = show->state.type_id; in btf_show_name()
785 show->state.name[0] = '\0'; in btf_show_name()
788 * Don't show type name if we're showing an array member; in btf_show_name()
789 * in that case we show the array type so don't need to repeat in btf_show_name()
792 if (show->state.array_member) in btf_show_name()
797 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
807 * in our show->state points at the resolved type of the typedef. in btf_show_name()
809 t = btf_type_by_id(show->btf, id); in btf_show_name()
827 * or array string backwards so it will show the expected number of in btf_show_name()
840 name = btf_name_by_offset(show->btf, in btf_show_name()
867 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
874 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
903 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
904 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
907 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
922 return show->state.name; in btf_show_name()
925 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
930 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
931 return indent - show->state.depth; in __btf_show_indent()
935 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
937 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
940 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
942 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
945 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
947 if (show->state.depth == 0) in btf_show_delim()
950 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
951 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
957 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
961 if (!show->state.depth_check) { in btf_show()
963 show->showfn(show, fmt, args); in btf_show()
973 #define btf_show_type_value(show, fmt, value) \ argument
975 if ((value) != 0 || (show->flags & BTF_SHOW_ZERO) || \
976 show->state.depth == 0) { \
977 btf_show(show, "%s%s" fmt "%s%s", \
978 btf_show_indent(show), \
979 btf_show_name(show), \
980 value, btf_show_delim(show), \
981 btf_show_newline(show)); \
982 if (show->state.depth > show->state.depth_to_show) \
983 show->state.depth_to_show = show->state.depth; \
987 #define btf_show_type_values(show, fmt, ...) \ argument
989 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
990 btf_show_name(show), \
991 __VA_ARGS__, btf_show_delim(show), \
992 btf_show_newline(show)); \
993 if (show->state.depth > show->state.depth_to_show) \
994 show->state.depth_to_show = show->state.depth; \
998 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1000 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1004 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1006 return data >= show->obj.data && in btf_show_obj_is_safe()
1007 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1016 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1018 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1019 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1051 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1059 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1062 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1064 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1073 if (show->state.depth == 0) { in btf_show_obj_safe()
1074 show->obj.size = size; in btf_show_obj_safe()
1075 show->obj.head = data; in btf_show_obj_safe()
1098 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1109 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1112 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1114 if (!show->state.status) { in btf_show_obj_safe()
1115 show->obj.data = data; in btf_show_obj_safe()
1116 safe = show->obj.safe; in btf_show_obj_safe()
1124 * Set the type we are starting to show and return a safe data pointer
1127 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1131 show->state.type = t; in btf_show_start_type()
1132 show->state.type_id = type_id; in btf_show_start_type()
1133 show->state.name[0] = '\0'; in btf_show_start_type()
1135 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1138 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1140 show->state.type = NULL; in btf_show_end_type()
1141 show->state.type_id = 0; in btf_show_end_type()
1142 show->state.name[0] = '\0'; in btf_show_end_type()
1145 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1149 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1154 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1155 btf_show_name(show), in btf_show_start_aggr_type()
1156 btf_show_newline(show)); in btf_show_start_aggr_type()
1157 show->state.depth++; in btf_show_start_aggr_type()
1161 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1164 show->state.depth--; in btf_show_end_aggr_type()
1165 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1166 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1167 btf_show_end_type(show); in btf_show_end_aggr_type()
1170 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1173 show->state.member = m; in btf_show_start_member()
1176 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1178 show->state.array_member = 1; in btf_show_start_array_member()
1179 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1182 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1184 show->state.member = NULL; in btf_show_end_member()
1187 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1189 show->state.array_member = 0; in btf_show_end_array_member()
1190 btf_show_end_member(show); in btf_show_end_array_member()
1193 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1199 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1200 show->state.array_terminated = 0; in btf_show_start_array_type()
1201 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1204 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1206 show->state.array_encoding = 0; in btf_show_end_array_type()
1207 show->state.array_terminated = 0; in btf_show_end_array_type()
1208 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1211 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1216 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1219 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1221 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
1815 struct btf_show *show) in btf_df_show() argument
1817 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
1990 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2009 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2011 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2057 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2077 btf_int128_print(show, print_num); in btf_bitfield_show()
2084 struct btf_show *show) in btf_int_bits_show() argument
2097 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2102 struct btf_show *show) in btf_int_show() argument
2110 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2116 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2122 btf_int128_print(show, safe_data); in btf_int_show()
2126 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2128 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2132 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2134 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2138 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2140 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2143 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2145 if (show->state.array_terminated) in btf_int_show()
2148 show->state.array_terminated = 1; in btf_int_show()
2152 btf_show_type_value(show, "'%c'", in btf_int_show()
2158 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2160 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2163 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2167 btf_show_end_type(show); in btf_int_show()
2176 .show = btf_int_show,
2443 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2450 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2455 struct btf_show *show) in btf_var_show() argument
2459 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2464 struct btf_show *show) in btf_ptr_show() argument
2468 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2473 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2474 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2476 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2477 btf_show_end_type(show); in btf_ptr_show()
2492 .show = btf_modifier_show,
2501 .show = btf_ptr_show,
2542 .show = btf_df_show,
2703 struct btf_show *show) in __btf_array_show() argument
2730 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
2739 btf_show_start_array_member(show); in __btf_array_show()
2741 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2742 bits_offset, show); in __btf_array_show()
2745 btf_show_end_array_member(show); in __btf_array_show()
2747 if (show->state.array_terminated) in __btf_array_show()
2751 btf_show_end_array_type(show); in __btf_array_show()
2756 struct btf_show *show) in btf_array_show() argument
2758 const struct btf_member *m = show->state.member; in btf_array_show()
2765 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
2766 if (!show->state.depth_check) { in btf_array_show()
2767 show->state.depth_check = show->state.depth + 1; in btf_array_show()
2768 show->state.depth_to_show = 0; in btf_array_show()
2770 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2771 show->state.member = m; in btf_array_show()
2773 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
2775 show->state.depth_check = 0; in btf_array_show()
2777 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
2784 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2793 .show = btf_array_show,
3018 struct btf_show *show) in __btf_struct_show() argument
3024 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3036 btf_show_start_member(show, member); in __btf_struct_show()
3043 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
3049 bitfield_size, show); in __btf_struct_show()
3050 btf_show_end_type(show); in __btf_struct_show()
3053 ops->show(btf, member_type, member->type, in __btf_struct_show()
3054 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
3057 btf_show_end_member(show); in __btf_struct_show()
3060 btf_show_end_struct_type(show); in __btf_struct_show()
3065 struct btf_show *show) in btf_struct_show() argument
3067 const struct btf_member *m = show->state.member; in btf_struct_show()
3074 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
3075 if (!show->state.depth_check) { in btf_struct_show()
3076 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
3077 show->state.depth_to_show = 0; in btf_struct_show()
3079 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3081 show->state.member = m; in btf_struct_show()
3082 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
3084 show->state.depth_check = 0; in btf_struct_show()
3086 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
3094 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3103 .show = btf_struct_show,
3236 struct btf_show *show) in btf_enum_show() argument
3243 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
3253 btf_show_type_value(show, "%s", in btf_enum_show()
3257 btf_show_end_type(show); in btf_enum_show()
3261 btf_show_type_value(show, "%d", v); in btf_enum_show()
3262 btf_show_end_type(show); in btf_enum_show()
3271 .show = btf_enum_show,
3358 .show = btf_df_show,
3392 .show = btf_df_show,
3456 .show = btf_var_show,
3585 struct btf_show *show) in btf_datasec_show() argument
3591 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
3594 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
3599 btf_show(show, ","); in btf_datasec_show()
3600 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
3601 data + vsi->offset, bits_offset, show); in btf_datasec_show()
3603 btf_show_end_type(show); in btf_datasec_show()
3612 .show = btf_datasec_show,
5314 struct btf_show *show) in btf_type_show() argument
5318 show->btf = btf; in btf_type_show()
5319 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
5320 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
5322 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
5325 static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
5328 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
5354 struct btf_show show; member
5359 static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
5362 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
5365 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
5377 show->target += len; in btf_snprintf_show()
5386 ssnprintf.show.target = buf; in btf_type_snprintf_show()
5387 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
5388 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
5395 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
5396 return ssnprintf.show.state.status; in btf_type_snprintf_show()