Lines Matching defs:fp

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