Lines Matching +full:jd +full:- +full:invert

1 /*-
7 * BG 91-66 and contributed to Berkeley.
72 * Report an error using printf style arguments. "program" is kd->program
88 (void)vsnprintf(kd->errbuf, in _kvm_err()
89 sizeof(kd->errbuf), fmt, ap); in _kvm_err()
106 char *cp = kd->errbuf; in _kvm_syserr()
108 (void)vsnprintf(cp, sizeof(kd->errbuf), fmt, ap); in _kvm_syserr()
110 (void)snprintf(&cp[n], sizeof(kd->errbuf) - n, ": %s", in _kvm_syserr()
122 _kvm_err(kd, kd->program, "can't allocate %zu bytes: %s", in _kvm_malloc()
131 return (kd->nlehdr.e_ident[EI_CLASS] == class && in _kvm_probe_elf_kernel()
133 kd->nlehdr.e_type == ET_DYN : kd->nlehdr.e_type == ET_EXEC) && in _kvm_probe_elf_kernel()
134 kd->nlehdr.e_machine == machine); in _kvm_probe_elf_kernel()
142 if (kd->rawdump) in _kvm_is_minidump()
144 if (pread(kd->pmfd, &minihdr, 8, 0) == 8 && in _kvm_is_minidump()
166 elf = elf_begin(kd->pmfd, ELF_C_READ, NULL); in _kvm_read_core_phdrs()
168 _kvm_err(kd, kd->program, "%s", elf_errmsg(0)); in _kvm_read_core_phdrs()
169 return (-1); in _kvm_read_core_phdrs()
172 _kvm_err(kd, kd->program, "invalid core"); in _kvm_read_core_phdrs()
175 if (gelf_getclass(elf) != kd->nlehdr.e_ident[EI_CLASS]) { in _kvm_read_core_phdrs()
176 _kvm_err(kd, kd->program, "invalid core"); in _kvm_read_core_phdrs()
180 _kvm_err(kd, kd->program, "%s", elf_errmsg(0)); in _kvm_read_core_phdrs()
184 _kvm_err(kd, kd->program, "invalid core"); in _kvm_read_core_phdrs()
187 if (ehdr.e_machine != kd->nlehdr.e_machine) { in _kvm_read_core_phdrs()
188 _kvm_err(kd, kd->program, "invalid core"); in _kvm_read_core_phdrs()
192 if (elf_getphdrnum(elf, &phnum) == -1) { in _kvm_read_core_phdrs()
193 _kvm_err(kd, kd->program, "%s", elf_errmsg(0)); in _kvm_read_core_phdrs()
199 _kvm_err(kd, kd->program, "failed to allocate phdrs"); in _kvm_read_core_phdrs()
206 _kvm_err(kd, kd->program, "%s", elf_errmsg(0)); in _kvm_read_core_phdrs()
217 return (-1); in _kvm_read_core_phdrs()
230 return (v & (((1ULL << (bitN - bit0)) - 1ULL) << bit0)); in bitmask_range()
235 * given base, from bit0 to bitN. bit0 may be non-zero in the case of
241 uint32_t res = bitN - bit0; in popcount_bytes()
245 /* Align to 64-bit boundary on the left side if needed. */ in popcount_bytes()
249 res -= (bound - bit0); in popcount_bytes()
256 res -= bound; in popcount_bytes()
268 if ((off_t)off >= kd->pt_sparse_off) in _kvm_pmap_get()
270 return (void *)((uintptr_t)kd->page_map + off); in _kvm_pmap_get()
280 if (off == -1) in _kvm_map_get()
283 addr = (uintptr_t)kd->page_map + off; in _kvm_map_get()
284 if (off >= kd->pt_sparse_off) in _kvm_map_get()
285 addr = (uintptr_t)kd->sparse_map + (off - kd->pt_sparse_off); in _kvm_map_get()
299 kd->dump_avail_size = dump_avail_size; in _kvm_pt_init()
301 kd->dump_avail = mmap(NULL, kd->dump_avail_size, PROT_READ, in _kvm_pt_init()
302 MAP_PRIVATE, kd->pmfd, dump_avail_off); in _kvm_pt_init()
310 kd->dump_avail = calloc(4, sizeof(uint64_t)); in _kvm_pt_init()
311 kd->dump_avail[1] = _kvm64toh(kd, map_len * 8 * page_size); in _kvm_pt_init()
317 kd->pt_map = _kvm_malloc(kd, map_len); in _kvm_pt_init()
318 if (kd->pt_map == NULL) { in _kvm_pt_init()
319 _kvm_err(kd, kd->program, "cannot allocate %zu bytes for bitmap", in _kvm_pt_init()
321 return (-1); in _kvm_pt_init()
323 rd = pread(kd->pmfd, kd->pt_map, map_len, map_off); in _kvm_pt_init()
325 _kvm_err(kd, kd->program, "cannot read %zu bytes for bitmap", in _kvm_pt_init()
327 return (-1); in _kvm_pt_init()
329 kd->pt_map_size = map_len; in _kvm_pt_init()
342 addr = kd->pt_map; in _kvm_pt_init()
345 kd->pt_popcounts = calloc(pc_bins, sizeof(uint32_t)); in _kvm_pt_init()
346 if (kd->pt_popcounts == NULL) { in _kvm_pt_init()
347 _kvm_err(kd, kd->program, "cannot allocate popcount bins"); in _kvm_pt_init()
348 return (-1); in _kvm_pt_init()
351 for (popcount_bin = &kd->pt_popcounts[1]; res > 0; in _kvm_pt_init()
352 addr++, res -= sizeof(*addr)) { in _kvm_pt_init()
357 *popcount_bin = *(popcount_bin - 1); in _kvm_pt_init()
363 ((uintptr_t)popcount_bin - (uintptr_t)kd->pt_popcounts)); in _kvm_pt_init()
365 kd->pt_sparse_off = sparse_off; in _kvm_pt_init()
366 kd->pt_sparse_size = (uint64_t)*popcount_bin * page_size; in _kvm_pt_init()
367 kd->pt_page_size = page_size; in _kvm_pt_init()
375 kd->sparse_map = mmap(NULL, kd->pt_sparse_size, PROT_READ, in _kvm_pt_init()
376 MAP_PRIVATE, kd->pmfd, kd->pt_sparse_off); in _kvm_pt_init()
377 if (kd->sparse_map == MAP_FAILED) { in _kvm_pt_init()
378 _kvm_err(kd, kd->program, "cannot map %" PRIu64 in _kvm_pt_init()
379 " bytes from fd %d offset %jd for sparse map: %s", in _kvm_pt_init()
380 kd->pt_sparse_size, kd->pmfd, in _kvm_pt_init()
381 (intmax_t)kd->pt_sparse_off, strerror(errno)); in _kvm_pt_init()
382 return (-1); in _kvm_pt_init()
392 kd->page_map_size = pmap_size; in _kvm_pmap_init()
393 kd->page_map_off = pmap_off; in _kvm_pmap_init()
394 kd->page_map = _kvm_malloc(kd, pmap_size); in _kvm_pmap_init()
395 if (kd->page_map == NULL) { in _kvm_pmap_init()
396 _kvm_err(kd, kd->program, "cannot allocate %u bytes " in _kvm_pmap_init()
398 return (-1); in _kvm_pmap_init()
400 if (pread(kd->pmfd, kd->page_map, pmap_size, pmap_off) != exp_len) { in _kvm_pmap_init()
401 _kvm_err(kd, kd->program, "cannot read %d bytes from " in _kvm_pmap_init()
402 "offset %jd for page map", pmap_size, (intmax_t)pmap_off); in _kvm_pmap_init()
403 return (-1); in _kvm_pmap_init()
411 return (_kvm64toh(kd, kd->dump_avail[i])); in dump_avail_n()
423 adj += howmany(dump_avail_n(kd, i + 1), page_size) - in _kvm_pa_bit_id()
426 return (pa / page_size - in _kvm_pa_bit_id()
440 sz = howmany(dump_avail_n(kd, i + 1), page_size) - in _kvm_bit_id_pa()
446 bit_id -= sz; in _kvm_bit_id_pa()
452 * Find the offset for the given physical page address; returns -1 otherwise.
468 uint64_t *bitmap = kd->pt_map; in _kvm_pt_find()
478 pte_bit_id >= (kd->pt_map_size * NBBY) || in _kvm_pt_find()
480 return (-1); in _kvm_pt_find()
489 count = kd->pt_popcounts[popcount_id] + popcount_bytes( in _kvm_pt_find()
491 0, pte_bit_id - popcount_id * POPCOUNT_BITS); in _kvm_pt_find()
495 * reading from bytes that are not in range, and invert. in _kvm_pt_find()
501 kd->pt_map_size * BITS_IN(uint8_t)); in _kvm_pt_find()
502 count = kd->pt_popcounts[popcount_id] - popcount_bytes( in _kvm_pt_find()
504 pte_bit_id - pte_u64_bit_off, bitN - pte_u64_bit_off); in _kvm_pt_find()
511 if (count >= (kd->pt_sparse_size / page_size)) in _kvm_pt_find()
512 return (-1); in _kvm_pt_find()
514 return (kd->pt_sparse_off + (uint64_t)count * page_size); in _kvm_pt_find()
523 if (kd->resolve_symbol == NULL) { in kvm_fdnlist()
533 nfail = __fdnlist(kd->nlfd, nl); in kvm_fdnlist()
543 while (list->n_name != NULL && list->n_name[0] != '\0') { in kvm_fdnlist()
544 error = kd->resolve_symbol(list->n_name, &addr); in kvm_fdnlist()
547 list->n_value = 0; in kvm_fdnlist()
548 list->n_type = 0; in kvm_fdnlist()
550 list->n_value = addr; in kvm_fdnlist()
551 list->n_type = N_DATA | N_EXT; in kvm_fdnlist()
579 for (p = nl; p->n_name && p->n_name[0]; ++p) { in kvm_fdnlist_prefix()
580 if (p->n_type != N_UNDF) in kvm_fdnlist_prefix()
583 2 * (strlen(p->n_name) + 1); in kvm_fdnlist_prefix()
603 for (p = nl; p->n_name && p->n_name[0]; ++p) { in kvm_fdnlist_prefix()
604 if (p->n_type != N_UNDF) in kvm_fdnlist_prefix()
608 slen = snprintf(cp, ce - cp, "%s%s%c%s", prefix, in kvm_fdnlist_prefix()
609 (prefix[0] != '\0' && p->n_name[0] == '_') ? in kvm_fdnlist_prefix()
610 (p->n_name + 1) : p->n_name, '\0', p->n_name); in kvm_fdnlist_prefix()
611 if (slen < 0 || slen >= ce - cp) in kvm_fdnlist_prefix()
613 np->n_name = cp; in kvm_fdnlist_prefix()
626 for (; np->n_name && np->n_name[0]; np++) in kvm_fdnlist_prefix()
627 if (np->n_type != N_UNDF) in kvm_fdnlist_prefix()
633 for (p = nl; np->n_name && np->n_name[0] && in kvm_fdnlist_prefix()
634 p->n_name && p->n_name[0]; ++p) { in kvm_fdnlist_prefix()
635 if (p->n_type != N_UNDF) in kvm_fdnlist_prefix()
638 ccp = np->n_name + strlen(np->n_name) + 1; in kvm_fdnlist_prefix()
639 if (strcmp(ccp, p->n_name) != 0) in kvm_fdnlist_prefix()
642 p->n_type = np->n_type; in kvm_fdnlist_prefix()
644 p->n_value = (*validate_fn)(kd, np->n_value); in kvm_fdnlist_prefix()
646 p->n_value = np->n_value; in kvm_fdnlist_prefix()
647 missing--; in kvm_fdnlist_prefix()
649 for (np++; np->n_name && np->n_name[0]; np++) in kvm_fdnlist_prefix()
650 if (np->n_type != N_UNDF) in kvm_fdnlist_prefix()
668 char symname[1024]; /* XXX-BZ symbol name length limit? */ in _kvm_nlist()
699 for (p = nl; p->n_name && p->n_name[0]; ++p) { in _kvm_nlist()
700 if (p->n_type != N_UNDF) in _kvm_nlist()
708 (prefix[0] != '\0' && p->n_name[0] == '_') ? in _kvm_nlist()
709 (p->n_name + 1) : p->n_name); in _kvm_nlist()
716 if (kldsym(0, KLDSYM_LOOKUP, &lookup) != -1) { in _kvm_nlist()
717 p->n_type = N_TEXT; in _kvm_nlist()
720 p->n_value = in _kvm_nlist()
724 p->n_value = in _kvm_nlist()
727 p->n_value = lookup.symvalue; in _kvm_nlist()
737 error = ((p - nl) - nvalid); in _kvm_nlist()
753 error = ((p - nl) - nvalid); in _kvm_nlist()
755 _kvm_syserr(kd, kd->program, "kvm_nlist"); in _kvm_nlist()
764 bm->map = calloc(bitmapsize, sizeof *bm->map); in _kvm_bitmap_init()
765 if (bm->map == NULL) in _kvm_bitmap_init()
767 bm->size = bitmapsize; in _kvm_bitmap_init()
774 uint8_t *byte = &bm->map[bm_index / 8]; in _kvm_bitmap_set()
776 if (bm_index / 8 < bm->size) in _kvm_bitmap_set()
783 u_long first_invalid = bm->size * CHAR_BIT; in _kvm_bitmap_next()
793 if ((bm->map[*idx / CHAR_BIT] & mask) != 0) in _kvm_bitmap_next()
804 free(bm->map); in _kvm_bitmap_deinit()