Lines Matching defs:km
693 kmt_mod_destroy(kmt_module_t *km)
695 if (km->km_name != NULL)
696 strfree(km->km_name);
697 if (km->km_symtab != NULL)
698 mdb_gelf_symtab_destroy(km->km_symtab);
699 if (km->km_ctfp != NULL)
700 mdb_ctf_close(km->km_ctfp);
706 kmt_module_t *km = mdb_zalloc(sizeof (kmt_module_t), UM_SLEEP);
709 km->km_name = mdb_alloc(strlen(name) + 1, UM_SLEEP);
710 (void) strcpy(km->km_name, name);
712 bcopy(ctlp, &km->km_modctl, sizeof (struct modctl));
714 if (mdb_tgt_vread(t, &km->km_module, sizeof (struct module),
715 (uintptr_t)km->km_modctl.mod_mp) != sizeof (struct module))
717 mod = &km->km_module;
721 mdb_gelf_ehdr_to_gehdr(&mod->hdr, &km->km_ehdr);
723 km->km_symtab = mdb_gelf_symtab_create_raw(&km->km_ehdr,
727 km->km_symtab_va = mod->symtbl;
728 km->km_strtab_va = mod->strings;
730 if (mdb_tgt_vread(t, &km->km_symtab_hdr, sizeof (Shdr),
732 mdb_tgt_vread(t, &km->km_strtab_hdr, sizeof (Shdr),
741 km->km_text_va = (uintptr_t)mod->text;
742 km->km_text_size = mod->text_size;
743 km->km_data_va = (uintptr_t)mod->data;
744 km->km_data_size = mod->data_size;
745 km->km_bss_va = (uintptr_t)mod->bss;
746 km->km_bss_size = mod->bss_size;
747 km->km_ctf_va = mod->ctfdata;
748 km->km_ctf_size = mod->ctfsize;
751 km->km_flags |= KM_F_PRIMARY;
753 return (km);
757 kmt_mod_destroy(km);
762 kmt_mod_remove(kmt_data_t *kmt, kmt_module_t *km)
764 mdb_var_t *v = mdb_nv_lookup(&kmt->kmt_modules, km->km_name);
768 mdb_dprintf(MDB_DBG_KMOD, "removing module %s\n", km->km_name);
770 mdb_list_delete(&kmt->kmt_modlist, km);
772 kmt_mod_destroy(km);
780 kmt_module_t *km;
799 km = MDB_NV_COOKIE(v);
801 if (kmdb_kdi_mod_haschanged(&km->km_modctl, &km->km_module,
809 kmt_mod_remove(kmt, km);
811 km->km_seen = 1;
818 if ((km = kmt_mod_create(t, modp, name)) != NULL) {
819 mdb_list_append(&kmt->kmt_modlist, km);
821 (uintptr_t)km, 0);
822 km->km_seen = 1;
832 kmt_module_t *km, *kmn;
839 km = mdb_list_next(&kmt->kmt_modlist);
840 while (km != NULL) {
841 kmn = mdb_list_next(km);
843 if (km->km_seen == 1) {
845 km->km_seen = 0;
851 kmt_mod_remove(kmt, km);
854 km = kmn;
869 kmt_module_t *km = mdb_list_next(&kmt->kmt_modlist);
885 prmod.km_list.ml_next = (mdb_list_t *)km;
886 km = &prmod;
893 for (; km != NULL; km = mdb_list_next(km)) {
894 if (km != &prmod && !kmt->kmt_symavail)
897 if (km->km_symtab == NULL)
900 if (mdb_gelf_symtab_lookup_by_addr(km->km_symtab, addr, flags,
906 sym_km = km;
916 sym_km = km;
977 kmt_module_t *km;
989 km = mdb_list_next(&kmt->kmt_modlist);
1010 km = mdb_nv_get_cookie(v);
1023 for (; n > 0; n--, km = mdb_list_next(km)) {
1024 if (mdb_gelf_symtab_lookup_by_name(km->km_symtab, name,
1075 kmt_module_t *km;
1088 km = mdb_nv_get_cookie(v);
1090 if (km->km_symtab != NULL) {
1091 kmt_symtab_iter(km->km_symtab, type,
1092 km->km_name, cb, data);
1109 km = mdb_nv_get_cookie(v);
1111 symtab = km->km_symtab;
1169 kmt_mod_to_map(kmt_module_t *km, mdb_map_t *map)
1171 (void) strncpy(map->map_name, km->km_name, MDB_TGT_MAPSZ);
1173 map->map_base = km->km_text_va;
1174 map->map_size = km->km_text_size;
1184 kmt_module_t *km;
1187 for (km = mdb_list_next(&kmt->kmt_modlist); km != NULL;
1188 km = mdb_list_next(km)) {
1189 if (func(private, kmt_mod_to_map(km, &m), km->km_name) == -1)
1200 kmt_module_t *km;
1202 for (km = mdb_list_next(&kmt->kmt_modlist); km != NULL;
1203 km = mdb_list_next(km)) {
1204 if (addr - km->km_text_va < km->km_text_size ||
1205 addr - km->km_data_va < km->km_data_size ||
1206 addr - km->km_bss_va < km->km_bss_size)
1207 return (kmt_mod_to_map(km, &kmt->kmt_map));
1217 kmt_module_t *km;
1219 for (km = mdb_list_next(&kmt->kmt_modlist); km != NULL;
1220 km = mdb_list_next(km)) {
1221 if (strcmp(name, km->km_name) == 0)
1222 return (km);
1232 kmt_module_t *km;
1247 if ((km = kmt_module_by_name(kmt, name)) != NULL)
1248 return (kmt_mod_to_map(km, &m));
1255 kmt_load_ctfdata(mdb_tgt_t *t, kmt_module_t *km)
1260 if (km->km_ctfp != NULL)
1261 return (km->km_ctfp);
1263 if (km->km_ctf_va == NULL || km->km_symtab == NULL) {
1268 if ((km->km_ctfp = mdb_ctf_bufopen(km->km_ctf_va, km->km_ctf_size,
1269 km->km_symtab_va, &km->km_symtab_hdr, km->km_strtab_va,
1270 &km->km_strtab_hdr, &err)) == NULL) {
1276 (ulong_t)km->km_ctf_size, km->km_name);
1278 if (ctf_parent_name(km->km_ctfp) != NULL) {
1282 ctf_parent_name(km->km_ctfp))) != NULL) {
1288 if (pm->km_ctfp != NULL && ctf_import(km->km_ctfp,
1291 "%s: %s\n", km->km_name,
1292 ctf_errmsg(ctf_errno(km->km_ctfp)));
1296 "loaded\n", km->km_name,
1297 ctf_parent_name(km->km_ctfp));
1301 return (km->km_ctfp);
1308 kmt_module_t *km;
1310 for (km = mdb_list_next(&kmt->kmt_modlist); km != NULL;
1311 km = mdb_list_next(km)) {
1312 if (addr - km->km_text_va < km->km_text_size ||
1313 addr - km->km_data_va < km->km_data_size ||
1314 addr - km->km_bss_va < km->km_bss_size)
1315 return (kmt_load_ctfdata(t, km));
1325 kmt_module_t *km;
1336 if ((km = kmt_module_by_name(kt, name)) != NULL)
1337 return (kmt_load_ctfdata(t, km));
2381 kmt_module_t *km, *pkm;
2384 for (km = mdb_list_prev(&kmt->kmt_modlist); km != NULL; km = pkm) {
2385 pkm = mdb_list_prev(km);
2386 mdb_free(km, sizeof (kmt_module_t));