Lines Matching refs:image

109  * pmcstat_pcmap structures track per-image mappings.
126 * values, we map each pc value to a tuple (image, symbol), where
127 * 'image' denotes an executable object and 'symbol' is the closest
135 * All image descriptors are kept in a hash table.
170 /* image */
412 * Determine whether a given executable image is an A.OUT object, and
414 * Sets image->pi_type.
418 pmcstat_image_get_aout_params(struct pmcstat_image *image)
426 path = pmcstat_string_unintern(image->pi_execpath);
429 if (image->pi_iskernelmodule)
441 image->pi_type = PMCSTAT_IMAGE_INDETERMINABLE;
453 image->pi_type = PMCSTAT_IMAGE_AOUT;
480 * Map an address to a symbol in an image.
484 pmcstat_symbol_search(struct pmcstat_image *image, uintfptr_t addr)
488 if (image->pi_symbols == NULL)
495 return (bsearch((void *) &sym, image->pi_symbols,
496 image->pi_symcount, sizeof(struct pmcstat_symbol),
505 pmcstat_image_add_symbols(struct pmcstat_image *image, Elf *e,
537 firsttime = image->pi_symbols == NULL;
538 symptr = realloc(image->pi_symbols,
539 sizeof(*symptr) * (image->pi_symcount + nfuncsyms));
540 if (symptr == image->pi_symbols) /* realloc() failed. */
542 image->pi_symbols = symptr;
547 symptr += image->pi_symcount;
557 if (!firsttime && pmcstat_symbol_search(image, sym.st_value))
573 symptr->ps_start = sym.st_value - image->pi_vaddr;
580 image->pi_symcount += newsyms;
581 if (image->pi_symcount == 0)
590 image->pi_symbols = realloc(image->pi_symbols,
591 sizeof(*symptr) * image->pi_symcount);
596 qsort(image->pi_symbols, image->pi_symcount, sizeof(*symptr),
604 for (symptr = image->pi_symbols;
605 symptr < image->pi_symbols + (image->pi_symcount - 1);
613 * Sets image->pi_type if anything conclusive can be determined about
614 * this image.
618 pmcstat_image_get_elf_params(struct pmcstat_image *image)
633 assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN);
635 image->pi_start = minva = ~(uintfptr_t) 0;
636 image->pi_end = maxva = (uintfptr_t) 0;
637 image->pi_type = image_type = PMCSTAT_IMAGE_INDETERMINABLE;
638 image->pi_isdynamic = 0;
639 image->pi_dynlinkerpath = NULL;
640 image->pi_vaddr = 0;
642 path = pmcstat_string_unintern(image->pi_execpath);
649 if (image->pi_iskernelmodule)
674 !(image->pi_iskernelmodule && eh.e_type == ET_REL)) {
705 image->pi_isdynamic = 1;
714 image->pi_dynlinkerpath =
721 image->pi_vaddr = ph.p_vaddr & (-ph.p_align);
750 pmcstat_image_add_symbols(image, e, scn, &sh);
753 image->pi_start = minva;
754 image->pi_end = maxva;
755 image->pi_type = image_type;
756 image->pi_fullpath = pmcstat_string_intern(buffer);
764 image->pi_name = pmcstat_string_intern(endp);
774 * Given an image descriptor, determine whether it is an ELF, or AOUT.
775 * If no handler claims the image, set its type to 'INDETERMINABLE'.
779 pmcstat_image_determine_type(struct pmcstat_image *image)
781 assert(image->pi_type == PMCSTAT_IMAGE_UNKNOWN);
784 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN)
785 pmcstat_image_get_elf_params(image);
786 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN)
787 pmcstat_image_get_aout_params(image);
793 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN)
794 image->pi_type = PMCSTAT_IMAGE_INDETERMINABLE;
798 * Locate an image descriptor given an interned path, adding a fresh
800 * suitable name for this image's sample file.
802 * We defer filling in the file format specific parts of the image
804 * into this image.
855 * image 'image'.
859 pmcstat_image_link(struct pmcstat_process *pp, struct pmcstat_image *image,
865 assert(image->pi_type != PMCSTAT_IMAGE_UNKNOWN &&
866 image->pi_type != PMCSTAT_IMAGE_INDETERMINABLE);
876 offset = start - image->pi_vaddr;
877 pcmnew->ppm_lowpc = image->pi_start + offset;
878 pcmnew->ppm_highpc = image->pi_end + offset;
879 pcmnew->ppm_image = image;
964 pmcstat_image_addr2line(struct pmcstat_image *image, uintfptr_t addr,
974 if (image->pi_addr2line == NULL) {
979 pmcstat_string_unintern(image->pi_fullpath));
985 pmcstat_string_unintern(image->pi_fullpath));
991 image->pi_fullpath));
1003 image->pi_addr2line = popen(cmdline, "r+");
1004 if (image->pi_addr2line == NULL) {
1015 if (feof(image->pi_addr2line) || ferror(image->pi_addr2line)) {
1017 pclose(image->pi_addr2line);
1018 image->pi_addr2line = NULL;
1022 fprintf(image->pi_addr2line, "%p\n", (void *)addr);
1024 if (fgets(funcname, funcname_len, image->pi_addr2line) == NULL) {
1032 if (fgets(sourcefile, sourcefile_len, image->pi_addr2line) == NULL) {
1158 * Associate an AOUT image with a process.
1163 struct pmcstat_image *image, uintfptr_t entryaddr)
1166 (void) image;
1172 * Associate an ELF image with a process.
1177 struct pmcstat_image *image, uintfptr_t entryaddr)
1182 assert(image->pi_type == PMCSTAT_IMAGE_ELF32 ||
1183 image->pi_type == PMCSTAT_IMAGE_ELF64);
1186 pmcstat_image_link(pp, image, image->pi_vaddr);
1196 if (image->pi_isdynamic) {
1216 rtldimage = pmcstat_image_from_path(image->pi_dynlinkerpath, 0);
1218 warnx("WARNING: Cannot find image for \"%s\".",
1219 pmcstat_string_unintern(image->pi_dynlinkerpath));
1230 pmcstat_string_unintern(image->pi_dynlinkerpath));
1292 * Associate an image and a process.
1299 struct pmcstat_image *image;
1301 if ((image = pmcstat_image_from_path(path, 0)) == NULL) {
1306 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN)
1307 pmcstat_image_determine_type(image);
1309 assert(image->pi_type != PMCSTAT_IMAGE_UNKNOWN);
1311 switch (image->pi_type) {
1315 pmcstat_process_elf_exec(pp, image, entryaddr);
1320 pmcstat_process_aout_exec(pp, image, entryaddr);
1365 struct pmcstat_image *image;
1410 image = pmcstat_image_from_path(image_path, pid == -1);
1411 if (image->pi_type == PMCSTAT_IMAGE_UNKNOWN)
1412 pmcstat_image_determine_type(image);
1413 if (image->pi_type != PMCSTAT_IMAGE_INDETERMINABLE)
1414 pmcstat_image_link(pp, image,
1442 * We bring in the gmon file for the image
1534 * Change the executable image associated with
1547 * Associate this process image.