FreeBSD/lib/libkvm/kvm_powerpc64.c
/*
 * Determine the offset within the corefile corresponding the virtual
 * address. Return the number of contiguous bytes in the corefile or
 * 0 when the virtual address is invalid.
 */
Determine the offset within the corefile corresponding the virtual
address. Return the number of contiguous bytes in the corefile or
0 when the virtual address is invalid.
Determine the offset within the corefile corresponding the virtual address . Return the number of contiguous bytes in the corefile or 0 when the virtual address is invalid .
static size_t
powerpc64_va2off(kvm_t *kd, kvaddr_t va, off_t *ofs)
{
	struct vmstate *vm = kd->vmst;
	Elf64_Phdr *ph;
	int nph;
	ph = vm->ph;
	nph = be16toh(vm->eh->e_phnum);
	while (nph && (va < be64toh(ph->p_vaddr) ||
	    va >= be64toh(ph->p_vaddr) + be64toh(ph->p_memsz))) {
		nph--;
		ph = (void *)((uintptr_t)ph + be16toh(vm->eh->e_phentsize));
	}
	if (nph == 0)
		return (0);
	*ofs = vm->dmphdrsz + be64toh(ph->p_offset) +
	    (va - be64toh(ph->p_vaddr));
	return (be64toh(ph->p_memsz) - (va - be64toh(ph->p_vaddr)));
}
static size_t powerpc64_va2off ( kvm_t * kd , kvaddr_t va , off_t * ofs ) { struct vmstate * vm = kd -> vmst ; Elf64_Phdr * ph ; int nph ; ph = vm -> ph ; nph = be16toh ( vm -> eh -> e_phnum ) ; while ( nph && ( va < be64toh ( ph -> p_vaddr ) || va >= be64toh ( ph -> p_vaddr ) + be64toh ( ph -> p_memsz ) ) ) { nph -- ; ph = ( void * ) ( ( uintptr_t ) ph + be16toh ( vm -> eh -> e_phentsize ) ) ; } if ( nph == 0 ) return ( 0 ) ; * ofs = vm -> dmphdrsz + be64toh ( ph -> p_offset ) + ( va - be64toh ( ph -> p_vaddr ) ) ; return ( be64toh ( ph -> p_memsz ) - ( va - be64toh ( ph -> p_vaddr ) ) ) ; }
Determine the offset within the corefile corresponding the virtual
 address.
Determine the offset within the corefile corresponding the virtual address .
/* Segment found. Return file offset and range. */