Lines Matching refs:type_id

451 static int btf_validate_str(const struct btf *btf, __u32 str_off, const char *what, __u32 type_id)
457 pr_warn("btf: type [%u]: invalid %s (string offset %u)\n", type_id, what, str_off);
621 struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id)
623 if (type_id == 0)
625 if (type_id < btf->start_id)
626 return btf_type_by_id(btf->base_btf, type_id);
627 return btf->types_data + btf->type_offs[type_id - btf->start_id];
630 const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
632 if (type_id >= btf->start_id + btf->nr_types)
634 return btf_type_by_id((struct btf *)btf, type_id);
763 __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
771 t = btf__type_by_id(btf, type_id);
793 type_id = t->type;
800 type_id = array->type;
806 t = btf__type_by_id(btf, type_id);
873 int btf__resolve_type(const struct btf *btf, __u32 type_id)
878 t = btf__type_by_id(btf, type_id);
882 type_id = t->type;
883 t = btf__type_by_id(btf, type_id);
890 return type_id;
1801 static int btf_rewrite_type_ids(__u32 *type_id, void *ctx)
1805 if (!*type_id) /* nothing to do for VOID references */
1812 *type_id += btf->start_id + btf->nr_types - 1;
2173 * - *type_id* - type ID for the type describing field type;
2180 int btf__add_field(struct btf *btf, const char *name, int type_id,
2195 if (validate_type_id(type_id))
2222 m->type = type_id;
2591 * - *type_id* - type ID describing the type of the parameter.
2596 int btf__add_func_param(struct btf *btf, const char *name, int type_id)
2602 if (validate_type_id(type_id))
2628 p->type = type_id;
2644 * - *type_id* - type ID of the type describing the type of the variable.
2649 int btf__add_var(struct btf *btf, const char *name, int linkage, int type_id)
2661 if (validate_type_id(type_id))
2679 t->type = type_id;
3326 static int btf_dedup_table_add(struct btf_dedup *d, long hash, __u32 type_id)
3328 return hashmap__append(d->dedup_table, hash, type_id);
3854 int type_id;
3860 for (type_id = 1; type_id < d->btf->start_id; type_id++) {
3861 t = btf_type_by_id(d->btf, type_id);
3864 d->map[type_id] = type_id;
3901 pr_debug("unknown kind %d for type [%d]\n", btf_kind(t), type_id);
3904 if (btf_dedup_table_add(d, h, type_id))
3917 static int btf_dedup_prim_type(struct btf_dedup *d, __u32 type_id)
3919 struct btf_type *t = btf_type_by_id(d->btf, type_id);
3923 __u32 new_id = type_id;
3973 d->map[cand_id] = type_id;
3995 d->map[type_id] = new_id;
3996 if (type_id == new_id && btf_dedup_table_add(d, h, type_id))
4017 static inline bool is_type_mapped(struct btf_dedup *d, uint32_t type_id)
4019 return d->map[type_id] <= BTF_MAX_NR_TYPES;
4027 static inline __u32 resolve_type_id(struct btf_dedup *d, __u32 type_id)
4029 while (is_type_mapped(d, type_id) && d->map[type_id] != type_id)
4030 type_id = d->map[type_id];
4031 return type_id;
4038 static uint32_t resolve_fwd_id(struct btf_dedup *d, uint32_t type_id)
4040 __u32 orig_type_id = type_id;
4042 if (!btf_is_fwd(btf__type_by_id(d->btf, type_id)))
4043 return type_id;
4045 while (is_type_mapped(d, type_id) && d->map[type_id] != type_id)
4046 type_id = d->map[type_id];
4048 if (!btf_is_fwd(btf__type_by_id(d->btf, type_id)))
4049 return type_id;
4464 static int btf_dedup_struct_type(struct btf_dedup *d, __u32 type_id)
4469 __u32 new_id = type_id;
4474 if (d->map[type_id] <= BTF_MAX_NR_TYPES)
4477 t = btf_type_by_id(d->btf, type_id);
4503 eq = btf_dedup_is_equiv(d, type_id, cand_id);
4515 d->map[type_id] = new_id;
4516 if (type_id == new_id && btf_dedup_table_add(d, h, type_id))
4558 static int btf_dedup_ref_type(struct btf_dedup *d, __u32 type_id)
4561 __u32 new_id = type_id, cand_id;
4567 if (d->map[type_id] == BTF_IN_PROGRESS_ID)
4569 if (d->map[type_id] <= BTF_MAX_NR_TYPES)
4570 return resolve_type_id(d, type_id);
4572 t = btf_type_by_id(d->btf, type_id);
4573 d->map[type_id] = BTF_IN_PROGRESS_ID;
4677 d->map[type_id] = new_id;
4678 if (type_id == new_id && btf_dedup_table_add(d, h, type_id))
4708 __u32 type_id;
4716 for (type_id = 1; type_id < nr_types; ++type_id) {
4717 t = btf_type_by_id(d->btf, type_id);
4724 if (type_id != d->map[type_id])
4727 err = hashmap__add(names_map, t->name_off, type_id);
4738 static int btf_dedup_resolve_fwd(struct btf_dedup *d, struct hashmap *names_map, __u32 type_id)
4740 struct btf_type *t = btf_type_by_id(d->btf, type_id);
4750 if (type_id != d->map[type_id])
4766 d->map[type_id] = cand_id;
4795 * [3] PTR '(anon)' type_id=1
4797 * [5] PTR '(anon)' type_id=4
4888 * `type_id` by first resolving it into corresponding canonical type ID and
4892 static int btf_dedup_remap_type_id(__u32 *type_id, void *ctx)
4897 resolved_type_id = resolve_type_id(d, *type_id);
4902 *type_id = new_type_id;
5147 err = visit(&rec->type_id, ctx);
5158 err = visit(&rec->type_id, ctx);