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;
677 if ((fp = ctf_alloc(sizeof (ctf_file_t))) == NULL)
680 bzero(fp, sizeof (ctf_file_t));
681 fp->ctf_version = hp.cth_version;
682 fp->ctf_fileops = &ctf_fileops[hp.cth_version];
683 bcopy(ctfsect, &fp->ctf_data, sizeof (ctf_sect_t));
686 bcopy(symsect, &fp->ctf_symtab, sizeof (ctf_sect_t));
687 bcopy(strsect, &fp->ctf_strtab, sizeof (ctf_sect_t));
690 if (fp->ctf_data.cts_name != NULL)
691 fp->ctf_data.cts_name = ctf_strdup(fp->ctf_data.cts_name);
692 if (fp->ctf_symtab.cts_name != NULL)
693 fp->ctf_symtab.cts_name = ctf_strdup(fp->ctf_symtab.cts_name);
694 if (fp->ctf_strtab.cts_name != NULL)
695 fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name);
697 if (fp->ctf_data.cts_name == NULL)
698 fp->ctf_data.cts_name = _CTF_NULLSTR;
699 if (fp->ctf_symtab.cts_name == NULL)
700 fp->ctf_symtab.cts_name = _CTF_NULLSTR;
701 if (fp->ctf_strtab.cts_name == NULL)
702 fp->ctf_strtab.cts_name = _CTF_NULLSTR;
704 fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff;
705 fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen;
708 fp->ctf_str[CTF_STRTAB_1].cts_strs = strsect->cts_data;
709 fp->ctf_str[CTF_STRTAB_1].cts_len = strsect->cts_size;
712 fp->ctf_base = base;
713 fp->ctf_buf = buf;
714 fp->ctf_size = size + hdrsz;
721 fp->ctf_parlabel = ctf_strptr(fp, hp.cth_parlabel);
723 fp->ctf_parname = ctf_strptr(fp, hp.cth_parname);
726 fp->ctf_parname ? fp->ctf_parname : "<NULL>",
727 fp->ctf_parlabel ? fp->ctf_parlabel : "<NULL>");
734 fp->ctf_nsyms = symsect->cts_size / symsect->cts_entsize;
735 fp->ctf_sxlate = ctf_alloc(fp->ctf_nsyms * sizeof (uint_t));
737 if (fp->ctf_sxlate == NULL) {
742 if ((err = init_symtab(fp, &hp, symsect, strsect)) != 0) {
748 if ((err = init_types(fp, &hp)) != 0) {
758 fp->ctf_lookups[0].ctl_prefix = "struct";
759 fp->ctf_lookups[0].ctl_len = strlen(fp->ctf_lookups[0].ctl_prefix);
760 fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs;
761 fp->ctf_lookups[1].ctl_prefix = "union";
762 fp->ctf_lookups[1].ctl_len = strlen(fp->ctf_lookups[1].ctl_prefix);
763 fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions;
764 fp->ctf_lookups[2].ctl_prefix = "enum";
765 fp->ctf_lookups[2].ctl_len = strlen(fp->ctf_lookups[2].ctl_prefix);
766 fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums;
767 fp->ctf_lookups[3].ctl_prefix = _CTF_NULLSTR;
768 fp->ctf_lookups[3].ctl_len = strlen(fp->ctf_lookups[3].ctl_prefix);
769 fp->ctf_lookups[3].ctl_hash = &fp->ctf_names;
770 fp->ctf_lookups[4].ctl_prefix = NULL;
771 fp->ctf_lookups[4].ctl_len = 0;
772 fp->ctf_lookups[4].ctl_hash = NULL;
776 (void) ctf_setmodel(fp, CTF_MODEL_LP64);
778 (void) ctf_setmodel(fp, CTF_MODEL_ILP32);
780 (void) ctf_setmodel(fp, CTF_MODEL_NATIVE);
782 fp->ctf_refcnt = 1;
783 return (fp);
786 ctf_close(fp);
800 ctf_file_t *fp;
857 fp = ctf_bufopen(ctp, symp, strp, &err);
858 if (fp == NULL) {
863 fp->ctf_flags |= LCTF_MMAP;
865 return (fp);
883 ctf_close(ctf_file_t *fp)
887 if (fp == NULL)
890 ctf_dprintf("ctf_close(%p) refcnt=%u\n", (void *)fp, fp->ctf_refcnt);
892 if (fp->ctf_refcnt > 1) {
893 fp->ctf_refcnt--;
897 if (fp->ctf_parent != NULL)
898 ctf_close(fp->ctf_parent);
904 for (dtd = ctf_list_prev(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) {
906 ctf_dtd_delete(fp, dtd);
909 ctf_free(fp->ctf_dthash, fp->ctf_dthashlen * sizeof (ctf_dtdef_t *));
911 if (fp->ctf_flags & LCTF_MMAP) {
912 if (fp->ctf_data.cts_data != NULL)
913 ctf_sect_munmap(&fp->ctf_data);
914 if (fp->ctf_symtab.cts_data != NULL)
915 ctf_sect_munmap(&fp->ctf_symtab);
916 if (fp->ctf_strtab.cts_data != NULL)
917 ctf_sect_munmap(&fp->ctf_strtab);
920 if (fp->ctf_data.cts_name != _CTF_NULLSTR &&
921 fp->ctf_data.cts_name != NULL) {
922 ctf_free((char *)fp->ctf_data.cts_name,
923 strlen(fp->ctf_data.cts_name) + 1);
926 if (fp->ctf_symtab.cts_name != _CTF_NULLSTR &&
927 fp->ctf_symtab.cts_name != NULL) {
928 ctf_free((char *)fp->ctf_symtab.cts_name,
929 strlen(fp->ctf_symtab.cts_name) + 1);
932 if (fp->ctf_strtab.cts_name != _CTF_NULLSTR &&
933 fp->ctf_strtab.cts_name != NULL) {
934 ctf_free((char *)fp->ctf_strtab.cts_name,
935 strlen(fp->ctf_strtab.cts_name) + 1);
938 if (fp->ctf_base != fp->ctf_data.cts_data && fp->ctf_base != NULL)
939 ctf_data_free((void *)fp->ctf_base, fp->ctf_size);
941 if (fp->ctf_sxlate != NULL)
942 ctf_free(fp->ctf_sxlate, sizeof (uint_t) * fp->ctf_nsyms);
944 if (fp->ctf_txlate != NULL) {
945 ctf_free(fp->ctf_txlate,
946 sizeof (uint_t) * (fp->ctf_typemax + 1));
949 if (fp->ctf_ptrtab != NULL) {
950 ctf_free(fp->ctf_ptrtab,
951 sizeof (ushort_t) * (fp->ctf_typemax + 1));
954 ctf_hash_destroy(&fp->ctf_structs);
955 ctf_hash_destroy(&fp->ctf_unions);
956 ctf_hash_destroy(&fp->ctf_enums);
957 ctf_hash_destroy(&fp->ctf_names);
959 ctf_free(fp, sizeof (ctf_file_t));
967 ctf_parent_file(ctf_file_t *fp)
969 return (fp->ctf_parent);
977 ctf_parent_name(ctf_file_t *fp)
979 return (fp->ctf_parname);
988 ctf_import(ctf_file_t *fp, ctf_file_t *pfp)
990 if (fp == NULL || fp == pfp || (pfp != NULL && pfp->ctf_refcnt == 0))
991 return (ctf_set_errno(fp, EINVAL));
993 if (pfp != NULL && pfp->ctf_dmodel != fp->ctf_dmodel)
994 return (ctf_set_errno(fp, ECTF_DMODEL));
996 if (fp->ctf_parent != NULL)
997 ctf_close(fp->ctf_parent);
1000 fp->ctf_flags |= LCTF_CHILD;
1004 fp->ctf_parent = pfp;
1012 ctf_setmodel(ctf_file_t *fp, int model)
1018 fp->ctf_dmodel = dp;
1023 return (ctf_set_errno(fp, EINVAL));
1030 ctf_getmodel(ctf_file_t *fp)
1032 return (fp->ctf_dmodel->ctd_code);
1036 ctf_setspecific(ctf_file_t *fp, void *data)
1038 fp->ctf_specific = data;
1042 ctf_getspecific(ctf_file_t *fp)
1044 return (fp->ctf_specific);