Lines Matching refs:fp

111 init_symtab(ctf_file_t *fp, const ctf_header_t *hp,  in init_symtab()  argument
115 uint_t *xp = fp->ctf_sxlate; in init_symtab()
116 uint_t *xend = xp + fp->ctf_nsyms; in init_symtab()
170 info = *(ushort_t *)((uintptr_t)fp->ctf_buf + funcoff); in init_symtab()
171 vlen = LCTF_INFO_VLEN(fp, info); in init_symtab()
178 if (LCTF_INFO_KIND(fp, info) == CTF_K_UNKNOWN && in init_symtab()
191 ctf_dprintf("loaded %lu symtab entries\n", fp->ctf_nsyms); in init_symtab()
200 init_types(ctf_file_t *fp, const ctf_header_t *cth) in init_types() argument
203 const ctf_type_t *tbuf = (ctf_type_t *)(fp->ctf_buf + cth->cth_typeoff); in init_types()
205 const ctf_type_t *tend = (ctf_type_t *)(fp->ctf_buf + cth->cth_stroff); in init_types()
227 for (tp = tbuf; tp < tend; fp->ctf_typemax++) { in init_types()
228 ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info); in init_types()
229 ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info); in init_types()
235 (void) ctf_get_ctt_size(fp, tp, &size, &increment); in init_types()
250 if (fp->ctf_version == CTF_VERSION_1 || in init_types()
307 ctf_dprintf("CTF container %p is a child\n", (void *)fp); in init_types()
308 fp->ctf_flags |= LCTF_CHILD; in init_types()
310 ctf_dprintf("CTF container %p is a parent\n", (void *)fp); in init_types()
316 if ((err = ctf_hash_create(&fp->ctf_structs, pop[CTF_K_STRUCT])) != 0) in init_types()
319 if ((err = ctf_hash_create(&fp->ctf_unions, pop[CTF_K_UNION])) != 0) in init_types()
322 if ((err = ctf_hash_create(&fp->ctf_enums, pop[CTF_K_ENUM])) != 0) in init_types()
325 if ((err = ctf_hash_create(&fp->ctf_names, in init_types()
331 fp->ctf_txlate = ctf_alloc(sizeof (uint_t) * (fp->ctf_typemax + 1)); in init_types()
332 fp->ctf_ptrtab = ctf_alloc(sizeof (ushort_t) * (fp->ctf_typemax + 1)); in init_types()
334 if (fp->ctf_txlate == NULL || fp->ctf_ptrtab == NULL) in init_types()
337 xp = fp->ctf_txlate; in init_types()
340 bzero(fp->ctf_txlate, sizeof (uint_t) * (fp->ctf_typemax + 1)); in init_types()
341 bzero(fp->ctf_ptrtab, sizeof (ushort_t) * (fp->ctf_typemax + 1)); in init_types()
348 ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info); in init_types()
349 ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info); in init_types()
357 (void) ctf_get_ctt_size(fp, tp, &size, &increment); in init_types()
358 name = ctf_strptr(fp, tp->ctt_name); in init_types()
368 if ((hep = ctf_hash_lookup(&fp->ctf_names, fp, in init_types()
370 err = ctf_hash_insert(&fp->ctf_names, fp, in init_types()
374 } else if (ctf_type_encoding(fp, hep->h_type, in init_types()
390 err = ctf_hash_insert(&fp->ctf_names, fp, in init_types()
398 err = ctf_hash_define(&fp->ctf_structs, fp, in init_types()
404 if (fp->ctf_version == CTF_VERSION_1 || in init_types()
414 err = ctf_hash_define(&fp->ctf_unions, fp, in init_types()
420 if (fp->ctf_version == CTF_VERSION_1 || in init_types()
430 err = ctf_hash_define(&fp->ctf_enums, fp, in init_types()
440 err = ctf_hash_insert(&fp->ctf_names, fp, in init_types()
454 hp = &fp->ctf_structs; in init_types()
457 hp = &fp->ctf_unions; in init_types()
460 hp = &fp->ctf_enums; in init_types()
463 hp = &fp->ctf_structs; in init_types()
466 if (ctf_hash_lookup(hp, fp, in init_types()
468 err = ctf_hash_insert(hp, fp, in init_types()
483 CTF_TYPE_TO_INDEX(tp->ctt_type) <= fp->ctf_typemax) in init_types()
484 fp->ctf_ptrtab[ in init_types()
491 err = ctf_hash_insert(&fp->ctf_names, fp, in init_types()
502 *xp = (uint_t)((uintptr_t)tp - (uintptr_t)fp->ctf_buf); in init_types()
506 ctf_dprintf("%lu total types processed\n", fp->ctf_typemax); in init_types()
507 ctf_dprintf("%u enum names hashed\n", ctf_hash_size(&fp->ctf_enums)); in init_types()
509 ctf_hash_size(&fp->ctf_structs), nlstructs); in init_types()
511 ctf_hash_size(&fp->ctf_unions), nlunions); in init_types()
513 ctf_hash_size(&fp->ctf_names)); in init_types()
521 for (id = 1; id <= fp->ctf_typemax; id++) { in init_types()
522 if ((dst = fp->ctf_ptrtab[id]) != 0) { in init_types()
523 tp = LCTF_INDEX_TO_TYPEPTR(fp, id); in init_types()
525 if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_TYPEDEF && in init_types()
526 strcmp(ctf_strptr(fp, tp->ctt_name), "") == 0 && in init_types()
528 CTF_TYPE_TO_INDEX(tp->ctt_type) <= fp->ctf_typemax) in init_types()
529 fp->ctf_ptrtab[ in init_types()
549 ctf_file_t *fp; in ctf_bufopen() local
679 if ((fp = ctf_alloc(sizeof (ctf_file_t))) == NULL) in ctf_bufopen()
682 bzero(fp, sizeof (ctf_file_t)); in ctf_bufopen()
683 fp->ctf_version = hp.cth_version; in ctf_bufopen()
684 fp->ctf_fileops = &ctf_fileops[hp.cth_version]; in ctf_bufopen()
685 fp->ctf_hflags = hflags; in ctf_bufopen()
686 bcopy(ctfsect, &fp->ctf_data, sizeof (ctf_sect_t)); in ctf_bufopen()
689 bcopy(symsect, &fp->ctf_symtab, sizeof (ctf_sect_t)); in ctf_bufopen()
690 bcopy(strsect, &fp->ctf_strtab, sizeof (ctf_sect_t)); in ctf_bufopen()
693 if (fp->ctf_data.cts_name != NULL) in ctf_bufopen()
694 fp->ctf_data.cts_name = ctf_strdup(fp->ctf_data.cts_name); in ctf_bufopen()
695 if (fp->ctf_symtab.cts_name != NULL) in ctf_bufopen()
696 fp->ctf_symtab.cts_name = ctf_strdup(fp->ctf_symtab.cts_name); in ctf_bufopen()
697 if (fp->ctf_strtab.cts_name != NULL) in ctf_bufopen()
698 fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name); in ctf_bufopen()
700 if (fp->ctf_data.cts_name == NULL) in ctf_bufopen()
701 fp->ctf_data.cts_name = _CTF_NULLSTR; in ctf_bufopen()
702 if (fp->ctf_symtab.cts_name == NULL) in ctf_bufopen()
703 fp->ctf_symtab.cts_name = _CTF_NULLSTR; in ctf_bufopen()
704 if (fp->ctf_strtab.cts_name == NULL) in ctf_bufopen()
705 fp->ctf_strtab.cts_name = _CTF_NULLSTR; in ctf_bufopen()
707 fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff; in ctf_bufopen()
708 fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen; in ctf_bufopen()
711 fp->ctf_str[CTF_STRTAB_1].cts_strs = strsect->cts_data; in ctf_bufopen()
712 fp->ctf_str[CTF_STRTAB_1].cts_len = strsect->cts_size; in ctf_bufopen()
715 fp->ctf_base = base; in ctf_bufopen()
716 fp->ctf_buf = buf; in ctf_bufopen()
717 fp->ctf_size = size + hdrsz; in ctf_bufopen()
724 fp->ctf_parlabel = ctf_strptr(fp, hp.cth_parlabel); in ctf_bufopen()
726 fp->ctf_parname = ctf_strptr(fp, hp.cth_parname); in ctf_bufopen()
729 fp->ctf_parname ? fp->ctf_parname : "<NULL>", in ctf_bufopen()
730 fp->ctf_parlabel ? fp->ctf_parlabel : "<NULL>"); in ctf_bufopen()
737 fp->ctf_nsyms = symsect->cts_size / symsect->cts_entsize; in ctf_bufopen()
738 fp->ctf_sxlate = ctf_alloc(fp->ctf_nsyms * sizeof (uint_t)); in ctf_bufopen()
740 if (fp->ctf_sxlate == NULL) { in ctf_bufopen()
745 if ((err = init_symtab(fp, &hp, symsect, strsect)) != 0) { in ctf_bufopen()
751 if ((err = init_types(fp, &hp)) != 0) { in ctf_bufopen()
761 fp->ctf_lookups[0].ctl_prefix = "struct"; in ctf_bufopen()
762 fp->ctf_lookups[0].ctl_len = strlen(fp->ctf_lookups[0].ctl_prefix); in ctf_bufopen()
763 fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs; in ctf_bufopen()
764 fp->ctf_lookups[1].ctl_prefix = "union"; in ctf_bufopen()
765 fp->ctf_lookups[1].ctl_len = strlen(fp->ctf_lookups[1].ctl_prefix); in ctf_bufopen()
766 fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions; in ctf_bufopen()
767 fp->ctf_lookups[2].ctl_prefix = "enum"; in ctf_bufopen()
768 fp->ctf_lookups[2].ctl_len = strlen(fp->ctf_lookups[2].ctl_prefix); in ctf_bufopen()
769 fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums; in ctf_bufopen()
770 fp->ctf_lookups[3].ctl_prefix = _CTF_NULLSTR; in ctf_bufopen()
771 fp->ctf_lookups[3].ctl_len = strlen(fp->ctf_lookups[3].ctl_prefix); in ctf_bufopen()
772 fp->ctf_lookups[3].ctl_hash = &fp->ctf_names; in ctf_bufopen()
773 fp->ctf_lookups[4].ctl_prefix = NULL; in ctf_bufopen()
774 fp->ctf_lookups[4].ctl_len = 0; in ctf_bufopen()
775 fp->ctf_lookups[4].ctl_hash = NULL; in ctf_bufopen()
779 (void) ctf_setmodel(fp, CTF_MODEL_LP64); in ctf_bufopen()
781 (void) ctf_setmodel(fp, CTF_MODEL_ILP32); in ctf_bufopen()
783 (void) ctf_setmodel(fp, CTF_MODEL_NATIVE); in ctf_bufopen()
785 fp->ctf_refcnt = 1; in ctf_bufopen()
786 return (fp); in ctf_bufopen()
789 ctf_close(fp); in ctf_bufopen()
803 ctf_file_t *fp; in ctf_dup() local
860 fp = ctf_bufopen(ctp, symp, strp, &err); in ctf_dup()
861 if (fp == NULL) { in ctf_dup()
866 fp->ctf_flags |= LCTF_MMAP; in ctf_dup()
868 return (fp); in ctf_dup()
886 ctf_close(ctf_file_t *fp) in ctf_close() argument
892 if (fp == NULL) in ctf_close()
895 ctf_dprintf("ctf_close(%p) refcnt=%u\n", (void *)fp, fp->ctf_refcnt); in ctf_close()
897 if (fp->ctf_refcnt > 1) { in ctf_close()
898 fp->ctf_refcnt--; in ctf_close()
902 if (fp->ctf_parent != NULL) in ctf_close()
903 ctf_close(fp->ctf_parent); in ctf_close()
909 for (dtd = ctf_list_prev(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) { in ctf_close()
911 ctf_dtd_delete(fp, dtd); in ctf_close()
914 for (dsd = ctf_list_prev(&fp->ctf_dsdefs); dsd != NULL; dsd = nsd) { in ctf_close()
916 ctf_dsd_delete(fp, dsd); in ctf_close()
919 for (dld = ctf_list_prev(&fp->ctf_dldefs); dld != NULL; dld = nld) { in ctf_close()
921 ctf_dld_delete(fp, dld); in ctf_close()
924 ctf_free(fp->ctf_dthash, fp->ctf_dthashlen * sizeof (ctf_dtdef_t *)); in ctf_close()
926 if (fp->ctf_flags & LCTF_MMAP) { in ctf_close()
931 if (fp->ctf_data.cts_data != NULL && in ctf_close()
932 !(fp->ctf_flags & LCTF_RDWR)) in ctf_close()
933 ctf_sect_munmap(&fp->ctf_data); in ctf_close()
934 if (fp->ctf_symtab.cts_data != NULL) in ctf_close()
935 ctf_sect_munmap(&fp->ctf_symtab); in ctf_close()
936 if (fp->ctf_strtab.cts_data != NULL) in ctf_close()
937 ctf_sect_munmap(&fp->ctf_strtab); in ctf_close()
940 if (fp->ctf_data.cts_name != _CTF_NULLSTR && in ctf_close()
941 fp->ctf_data.cts_name != NULL) { in ctf_close()
942 ctf_free((char *)fp->ctf_data.cts_name, in ctf_close()
943 strlen(fp->ctf_data.cts_name) + 1); in ctf_close()
946 if (fp->ctf_symtab.cts_name != _CTF_NULLSTR && in ctf_close()
947 fp->ctf_symtab.cts_name != NULL) { in ctf_close()
948 ctf_free((char *)fp->ctf_symtab.cts_name, in ctf_close()
949 strlen(fp->ctf_symtab.cts_name) + 1); in ctf_close()
952 if (fp->ctf_strtab.cts_name != _CTF_NULLSTR && in ctf_close()
953 fp->ctf_strtab.cts_name != NULL) { in ctf_close()
954 ctf_free((char *)fp->ctf_strtab.cts_name, in ctf_close()
955 strlen(fp->ctf_strtab.cts_name) + 1); in ctf_close()
958 if (fp->ctf_base != fp->ctf_data.cts_data && fp->ctf_base != NULL) in ctf_close()
959 ctf_data_free((void *)fp->ctf_base, fp->ctf_size); in ctf_close()
961 if (fp->ctf_sxlate != NULL) in ctf_close()
962 ctf_free(fp->ctf_sxlate, sizeof (uint_t) * fp->ctf_nsyms); in ctf_close()
964 if (fp->ctf_txlate != NULL) { in ctf_close()
965 ctf_free(fp->ctf_txlate, in ctf_close()
966 sizeof (uint_t) * (fp->ctf_typemax + 1)); in ctf_close()
969 if (fp->ctf_ptrtab != NULL) { in ctf_close()
970 ctf_free(fp->ctf_ptrtab, in ctf_close()
971 sizeof (ushort_t) * (fp->ctf_typemax + 1)); in ctf_close()
974 ctf_hash_destroy(&fp->ctf_structs); in ctf_close()
975 ctf_hash_destroy(&fp->ctf_unions); in ctf_close()
976 ctf_hash_destroy(&fp->ctf_enums); in ctf_close()
977 ctf_hash_destroy(&fp->ctf_names); in ctf_close()
979 ctf_free(fp, sizeof (ctf_file_t)); in ctf_close()
987 ctf_parent_file(ctf_file_t *fp) in ctf_parent_file() argument
989 return (fp->ctf_parent); in ctf_parent_file()
997 ctf_parent_name(ctf_file_t *fp) in ctf_parent_name() argument
999 return (fp->ctf_parname); in ctf_parent_name()
1007 ctf_parent_label(ctf_file_t *fp) in ctf_parent_label() argument
1009 return (fp->ctf_parlabel); in ctf_parent_label()
1018 ctf_import(ctf_file_t *fp, ctf_file_t *pfp) in ctf_import() argument
1020 if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0)) in ctf_import()
1021 return (ctf_set_errno(fp, EINVAL)); in ctf_import()
1023 if (pfp != NULL && pfp->ctf_dmodel != fp->ctf_dmodel) in ctf_import()
1024 return (ctf_set_errno(fp, ECTF_DMODEL)); in ctf_import()
1026 if (fp->ctf_parent != NULL) in ctf_import()
1027 ctf_close(fp->ctf_parent); in ctf_import()
1030 fp->ctf_flags |= LCTF_CHILD; in ctf_import()
1034 fp->ctf_parent = pfp; in ctf_import()
1042 ctf_setmodel(ctf_file_t *fp, int model) in ctf_setmodel() argument
1048 fp->ctf_dmodel = dp; in ctf_setmodel()
1053 return (ctf_set_errno(fp, EINVAL)); in ctf_setmodel()
1060 ctf_getmodel(ctf_file_t *fp) in ctf_getmodel() argument
1062 return (fp->ctf_dmodel->ctd_code); in ctf_getmodel()
1066 ctf_setspecific(ctf_file_t *fp, void *data) in ctf_setspecific() argument
1068 fp->ctf_specific = data; in ctf_setspecific()
1072 ctf_getspecific(ctf_file_t *fp) in ctf_getspecific() argument
1074 return (fp->ctf_specific); in ctf_getspecific()
1078 ctf_flags(ctf_file_t *fp) in ctf_flags() argument
1080 return (fp->ctf_hflags); in ctf_flags()