Lines Matching full:show

307  * Common data to all BTF show operations. Private show functions can add
309 * in the show callback. See btf_type_show() below.
316 * pass is signalled by show->state.depth_check being set, and if we
317 * encounter a non-zero value we set show->state.depth_to_show to
330 * The various data type show functions all start with a call to
351 void *target; /* target of show operation (seq file, buffer) */
352 void (*showfn)(struct btf_show *show, const char *fmt, va_list args);
392 void (*show)(const struct btf *btf, const struct btf_type *t, member
394 struct btf_show *show);
803 * Populate show->state.name with type name information.
808 static const char *btf_show_name(struct btf_show *show) in btf_show_name() argument
817 const struct btf_member *m = show->state.member; in btf_show_name()
818 const struct btf_type *t = show->state.type; in btf_show_name()
820 u32 id = show->state.type_id; in btf_show_name()
826 show->state.name[0] = '\0'; in btf_show_name()
829 * Don't show type name if we're showing an array member; in btf_show_name()
830 * in that case we show the array type so don't need to repeat in btf_show_name()
833 if (show->state.array_member) in btf_show_name()
838 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
848 * in our show->state points at the resolved type of the typedef. in btf_show_name()
850 t = btf_type_by_id(show->btf, id); in btf_show_name()
868 * or array string backwards so it will show the expected number of in btf_show_name()
881 name = btf_name_by_offset(show->btf, in btf_show_name()
908 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
915 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
944 if (show->flags & BTF_SHOW_NONAME) in btf_show_name()
945 snprintf(show->state.name, sizeof(show->state.name), "%s", in btf_show_name()
948 snprintf(show->state.name, sizeof(show->state.name), in btf_show_name()
963 return show->state.name; in btf_show_name()
966 static const char *__btf_show_indent(struct btf_show *show) in __btf_show_indent() argument
971 if ((indent - show->state.depth) >= indents) in __btf_show_indent()
972 return indent - show->state.depth; in __btf_show_indent()
976 static const char *btf_show_indent(struct btf_show *show) in btf_show_indent() argument
978 return show->flags & BTF_SHOW_COMPACT ? "" : __btf_show_indent(show); in btf_show_indent()
981 static const char *btf_show_newline(struct btf_show *show) in btf_show_newline() argument
983 return show->flags & BTF_SHOW_COMPACT ? "" : "\n"; in btf_show_newline()
986 static const char *btf_show_delim(struct btf_show *show) in btf_show_delim() argument
988 if (show->state.depth == 0) in btf_show_delim()
991 if ((show->flags & BTF_SHOW_COMPACT) && show->state.type && in btf_show_delim()
992 BTF_INFO_KIND(show->state.type->info) == BTF_KIND_UNION) in btf_show_delim()
998 __printf(2, 3) static void btf_show(struct btf_show *show, const char *fmt, ...) in btf_show() argument
1002 if (!show->state.depth_check) { in btf_show()
1004 show->showfn(show, fmt, args); in btf_show()
1014 #define btf_show_type_value(show, fmt, value) \ argument
1016 if ((value) != 0 || (show->flags & BTF_SHOW_ZERO) || \
1017 show->state.depth == 0) { \
1018 btf_show(show, "%s%s" fmt "%s%s", \
1019 btf_show_indent(show), \
1020 btf_show_name(show), \
1021 value, btf_show_delim(show), \
1022 btf_show_newline(show)); \
1023 if (show->state.depth > show->state.depth_to_show) \
1024 show->state.depth_to_show = show->state.depth; \
1028 #define btf_show_type_values(show, fmt, ...) \ argument
1030 btf_show(show, "%s%s" fmt "%s%s", btf_show_indent(show), \
1031 btf_show_name(show), \
1032 __VA_ARGS__, btf_show_delim(show), \
1033 btf_show_newline(show)); \
1034 if (show->state.depth > show->state.depth_to_show) \
1035 show->state.depth_to_show = show->state.depth; \
1039 static int btf_show_obj_size_left(struct btf_show *show, void *data) in btf_show_obj_size_left() argument
1041 return show->obj.head + show->obj.size - data; in btf_show_obj_size_left()
1045 static bool btf_show_obj_is_safe(struct btf_show *show, void *data, int size) in btf_show_obj_is_safe() argument
1047 return data >= show->obj.data && in btf_show_obj_is_safe()
1048 (data + size) < (show->obj.data + BTF_SHOW_OBJ_SAFE_SIZE); in btf_show_obj_is_safe()
1057 static void *__btf_show_obj_safe(struct btf_show *show, void *data, int size) in __btf_show_obj_safe() argument
1059 if (btf_show_obj_is_safe(show, data, size)) in __btf_show_obj_safe()
1060 return show->obj.safe + (data - show->obj.data); in __btf_show_obj_safe()
1092 static void *btf_show_obj_safe(struct btf_show *show, in btf_show_obj_safe() argument
1100 if (show->flags & BTF_SHOW_UNSAFE) in btf_show_obj_safe()
1103 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1105 show->state.status = PTR_ERR(rt); in btf_show_obj_safe()
1114 if (show->state.depth == 0) { in btf_show_obj_safe()
1115 show->obj.size = size; in btf_show_obj_safe()
1116 show->obj.head = data; in btf_show_obj_safe()
1139 safe = __btf_show_obj_safe(show, data, in btf_show_obj_safe()
1150 size_left = btf_show_obj_size_left(show, data); in btf_show_obj_safe()
1153 show->state.status = copy_from_kernel_nofault(show->obj.safe, in btf_show_obj_safe()
1155 if (!show->state.status) { in btf_show_obj_safe()
1156 show->obj.data = data; in btf_show_obj_safe()
1157 safe = show->obj.safe; in btf_show_obj_safe()
1165 * Set the type we are starting to show and return a safe data pointer
1168 static void *btf_show_start_type(struct btf_show *show, in btf_show_start_type() argument
1172 show->state.type = t; in btf_show_start_type()
1173 show->state.type_id = type_id; in btf_show_start_type()
1174 show->state.name[0] = '\0'; in btf_show_start_type()
1176 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1179 static void btf_show_end_type(struct btf_show *show) in btf_show_end_type() argument
1181 show->state.type = NULL; in btf_show_end_type()
1182 show->state.type_id = 0; in btf_show_end_type()
1183 show->state.name[0] = '\0'; in btf_show_end_type()
1186 static void *btf_show_start_aggr_type(struct btf_show *show, in btf_show_start_aggr_type() argument
1190 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1195 btf_show(show, "%s%s%s", btf_show_indent(show), in btf_show_start_aggr_type()
1196 btf_show_name(show), in btf_show_start_aggr_type()
1197 btf_show_newline(show)); in btf_show_start_aggr_type()
1198 show->state.depth++; in btf_show_start_aggr_type()
1202 static void btf_show_end_aggr_type(struct btf_show *show, in btf_show_end_aggr_type() argument
1205 show->state.depth--; in btf_show_end_aggr_type()
1206 btf_show(show, "%s%s%s%s", btf_show_indent(show), suffix, in btf_show_end_aggr_type()
1207 btf_show_delim(show), btf_show_newline(show)); in btf_show_end_aggr_type()
1208 btf_show_end_type(show); in btf_show_end_aggr_type()
1211 static void btf_show_start_member(struct btf_show *show, in btf_show_start_member() argument
1214 show->state.member = m; in btf_show_start_member()
1217 static void btf_show_start_array_member(struct btf_show *show) in btf_show_start_array_member() argument
1219 show->state.array_member = 1; in btf_show_start_array_member()
1220 btf_show_start_member(show, NULL); in btf_show_start_array_member()
1223 static void btf_show_end_member(struct btf_show *show) in btf_show_end_member() argument
1225 show->state.member = NULL; in btf_show_end_member()
1228 static void btf_show_end_array_member(struct btf_show *show) in btf_show_end_array_member() argument
1230 show->state.array_member = 0; in btf_show_end_array_member()
1231 btf_show_end_member(show); in btf_show_end_array_member()
1234 static void *btf_show_start_array_type(struct btf_show *show, in btf_show_start_array_type() argument
1240 show->state.array_encoding = array_encoding; in btf_show_start_array_type()
1241 show->state.array_terminated = 0; in btf_show_start_array_type()
1242 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1245 static void btf_show_end_array_type(struct btf_show *show) in btf_show_end_array_type() argument
1247 show->state.array_encoding = 0; in btf_show_end_array_type()
1248 show->state.array_terminated = 0; in btf_show_end_array_type()
1249 btf_show_end_aggr_type(show, "]"); in btf_show_end_array_type()
1252 static void *btf_show_start_struct_type(struct btf_show *show, in btf_show_start_struct_type() argument
1257 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1260 static void btf_show_end_struct_type(struct btf_show *show) in btf_show_end_struct_type() argument
1262 btf_show_end_aggr_type(show, "}"); in btf_show_end_struct_type()
1885 struct btf_show *show) in btf_df_show() argument
1887 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2060 static void btf_int128_print(struct btf_show *show, void *data) in btf_int128_print() argument
2079 btf_show_type_value(show, "0x%llx", lower_num); in btf_int128_print()
2081 btf_show_type_values(show, "0x%llx%016llx", upper_num, in btf_int128_print()
2127 u8 nr_bits, struct btf_show *show) in btf_bitfield_show() argument
2147 btf_int128_print(show, print_num); in btf_bitfield_show()
2154 struct btf_show *show) in btf_int_bits_show() argument
2167 btf_bitfield_show(data, bits_offset, nr_bits, show); in btf_int_bits_show()
2172 struct btf_show *show) in btf_int_show() argument
2180 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2186 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2192 btf_int128_print(show, safe_data); in btf_int_show()
2196 btf_show_type_value(show, "%lld", *(s64 *)safe_data); in btf_int_show()
2198 btf_show_type_value(show, "%llu", *(u64 *)safe_data); in btf_int_show()
2202 btf_show_type_value(show, "%d", *(s32 *)safe_data); in btf_int_show()
2204 btf_show_type_value(show, "%u", *(u32 *)safe_data); in btf_int_show()
2208 btf_show_type_value(show, "%d", *(s16 *)safe_data); in btf_int_show()
2210 btf_show_type_value(show, "%u", *(u16 *)safe_data); in btf_int_show()
2213 if (show->state.array_encoding == BTF_INT_CHAR) { in btf_int_show()
2215 if (show->state.array_terminated) in btf_int_show()
2218 show->state.array_terminated = 1; in btf_int_show()
2222 btf_show_type_value(show, "'%c'", in btf_int_show()
2228 btf_show_type_value(show, "%d", *(s8 *)safe_data); in btf_int_show()
2230 btf_show_type_value(show, "%u", *(u8 *)safe_data); in btf_int_show()
2233 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2237 btf_show_end_type(show); in btf_int_show()
2246 .show = btf_int_show,
2513 u8 bits_offset, struct btf_show *show) in btf_modifier_show() argument
2520 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2525 struct btf_show *show) in btf_var_show() argument
2529 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2534 struct btf_show *show) in btf_ptr_show() argument
2538 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2543 if (show->flags & BTF_SHOW_PTR_RAW) in btf_ptr_show()
2544 btf_show_type_value(show, "0x%px", *(void **)safe_data); in btf_ptr_show()
2546 btf_show_type_value(show, "0x%p", *(void **)safe_data); in btf_ptr_show()
2547 btf_show_end_type(show); in btf_ptr_show()
2562 .show = btf_modifier_show,
2571 .show = btf_ptr_show,
2612 .show = btf_df_show,
2773 struct btf_show *show) in __btf_array_show() argument
2800 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
2809 btf_show_start_array_member(show); in __btf_array_show()
2811 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2812 bits_offset, show); in __btf_array_show()
2815 btf_show_end_array_member(show); in __btf_array_show()
2817 if (show->state.array_terminated) in __btf_array_show()
2821 btf_show_end_array_type(show); in __btf_array_show()
2826 struct btf_show *show) in btf_array_show() argument
2828 const struct btf_member *m = show->state.member; in btf_array_show()
2835 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_array_show()
2836 if (!show->state.depth_check) { in btf_array_show()
2837 show->state.depth_check = show->state.depth + 1; in btf_array_show()
2838 show->state.depth_to_show = 0; in btf_array_show()
2840 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2841 show->state.member = m; in btf_array_show()
2843 if (show->state.depth_check != show->state.depth + 1) in btf_array_show()
2845 show->state.depth_check = 0; in btf_array_show()
2847 if (show->state.depth_to_show <= show->state.depth) in btf_array_show()
2854 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2863 .show = btf_array_show,
3137 struct btf_show *show) in __btf_struct_show() argument
3143 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3155 btf_show_start_member(show, member); in __btf_struct_show()
3162 safe_data = btf_show_start_type(show, member_type, in __btf_struct_show()
3168 bitfield_size, show); in __btf_struct_show()
3169 btf_show_end_type(show); in __btf_struct_show()
3172 ops->show(btf, member_type, member->type, in __btf_struct_show()
3173 data + bytes_offset, bits8_offset, show); in __btf_struct_show()
3176 btf_show_end_member(show); in __btf_struct_show()
3179 btf_show_end_struct_type(show); in __btf_struct_show()
3184 struct btf_show *show) in btf_struct_show() argument
3186 const struct btf_member *m = show->state.member; in btf_struct_show()
3193 if (show->state.depth > 0 && !(show->flags & BTF_SHOW_ZERO)) { in btf_struct_show()
3194 if (!show->state.depth_check) { in btf_struct_show()
3195 show->state.depth_check = show->state.depth + 1; in btf_struct_show()
3196 show->state.depth_to_show = 0; in btf_struct_show()
3198 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3200 show->state.member = m; in btf_struct_show()
3201 if (show->state.depth_check != show->state.depth + 1) in btf_struct_show()
3203 show->state.depth_check = 0; in btf_struct_show()
3205 if (show->state.depth_to_show <= show->state.depth) in btf_struct_show()
3213 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3222 .show = btf_struct_show,
3355 struct btf_show *show) in btf_enum_show() argument
3362 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
3372 btf_show_type_value(show, "%s", in btf_enum_show()
3376 btf_show_end_type(show); in btf_enum_show()
3380 btf_show_type_value(show, "%d", v); in btf_enum_show()
3381 btf_show_end_type(show); in btf_enum_show()
3390 .show = btf_enum_show,
3477 .show = btf_df_show,
3511 .show = btf_df_show,
3575 .show = btf_var_show,
3699 struct btf_show *show) in btf_datasec_show() argument
3705 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
3708 btf_show_type_value(show, "section (\"%s\") = {", in btf_datasec_show()
3713 btf_show(show, ","); in btf_datasec_show()
3714 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
3715 data + vsi->offset, bits_offset, show); in btf_datasec_show()
3717 btf_show_end_type(show); in btf_datasec_show()
3726 .show = btf_datasec_show,
3801 .show = btf_df_show,
5734 struct btf_show *show) in btf_type_show() argument
5738 show->btf = btf; in btf_type_show()
5739 memset(&show->state, 0, sizeof(show->state)); in btf_type_show()
5740 memset(&show->obj, 0, sizeof(show->obj)); in btf_type_show()
5742 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
5745 static void btf_seq_show(struct btf_show *show, const char *fmt, in btf_seq_show() argument
5748 seq_vprintf((struct seq_file *)show->target, fmt, args); in btf_seq_show()
5774 struct btf_show show; member
5779 static void btf_snprintf_show(struct btf_show *show, const char *fmt, in btf_snprintf_show() argument
5782 struct btf_show_snprintf *ssnprintf = (struct btf_show_snprintf *)show; in btf_snprintf_show()
5785 len = vsnprintf(show->target, ssnprintf->len_left, fmt, args); in btf_snprintf_show()
5797 show->target += len; in btf_snprintf_show()
5806 ssnprintf.show.target = buf; in btf_type_snprintf_show()
5807 ssnprintf.show.flags = flags; in btf_type_snprintf_show()
5808 ssnprintf.show.showfn = btf_snprintf_show; in btf_type_snprintf_show()
5815 if (ssnprintf.show.state.status) in btf_type_snprintf_show()
5816 return ssnprintf.show.state.status; in btf_type_snprintf_show()