Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pmcstat/pmcstat_log.c
Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Lines | #endif | ||||
*/ | */ | ||||
for (symptr = image->pi_symbols; | for (symptr = image->pi_symbols; | ||||
symptr < image->pi_symbols + (image->pi_symcount - 1); | symptr < image->pi_symbols + (image->pi_symcount - 1); | ||||
symptr++) | symptr++) | ||||
if (symptr->ps_start == symptr->ps_end) | if (symptr->ps_start == symptr->ps_end) | ||||
symptr->ps_end = (symptr+1)->ps_start; | symptr->ps_end = (symptr+1)->ps_start; | ||||
} | } | ||||
static int | |||||
pmcstat_find_module(const char *path, char *buffer, size_t len) | |||||
{ | |||||
struct pmcstat_path *pp; | |||||
/* Try the module list */ | |||||
STAILQ_FOREACH(pp, &args.pa_modules, pp_next) { | |||||
snprintf(buffer, len, "%s%s/%s", args.pa_fsroot, pp->pp_path, | |||||
path); | |||||
if (access(buffer, R_OK) != -1) | |||||
return (1); | |||||
} | |||||
/* Try the kernel path */ | |||||
snprintf(buffer, len, "%s%s/%s", args.pa_fsroot, args.pa_kernel, path); | |||||
if (access(buffer, R_OK) != -1) | |||||
return (1); | |||||
return (0); | |||||
} | |||||
/* | /* | ||||
* Examine an ELF file to determine the size of its text segment. | * Examine an ELF file to determine the size of its text segment. | ||||
* Sets image->pi_type if anything conclusive can be determined about | * Sets image->pi_type if anything conclusive can be determined about | ||||
* this image. | * this image. | ||||
*/ | */ | ||||
static void | static void | ||||
pmcstat_image_get_elf_params(struct pmcstat_image *image) | pmcstat_image_get_elf_params(struct pmcstat_image *image) | ||||
Show All 22 Lines | pmcstat_image_get_elf_params(struct pmcstat_image *image) | ||||
path = pmcstat_string_unintern(image->pi_execpath); | path = pmcstat_string_unintern(image->pi_execpath); | ||||
assert(path != NULL); | assert(path != NULL); | ||||
/* | /* | ||||
* Look for kernel modules under FSROOT/KERNELPATH/NAME, | * Look for kernel modules under FSROOT/KERNELPATH/NAME, | ||||
* and user mode executable objects under FSROOT/PATHNAME. | * and user mode executable objects under FSROOT/PATHNAME. | ||||
*/ | */ | ||||
if (image->pi_iskernelmodule) | if (image->pi_iskernelmodule) { | ||||
(void) snprintf(buffer, sizeof(buffer), "%s%s/%s", | if (pmcstat_find_module(path, buffer, sizeof(buffer)) == 0) | ||||
args.pa_fsroot, args.pa_kernel, path); | warnx("WARNING: Cannot find kernel module \"%s\".", | ||||
else | path); | ||||
} else | |||||
(void) snprintf(buffer, sizeof(buffer), "%s%s", | (void) snprintf(buffer, sizeof(buffer), "%s%s", | ||||
args.pa_fsroot, path); | args.pa_fsroot, path); | ||||
e = NULL; | e = NULL; | ||||
if ((fd = open(buffer, O_RDONLY, 0)) < 0 || | if ((fd = open(buffer, O_RDONLY, 0)) < 0 || | ||||
(e = elf_begin(fd, ELF_C_READ, NULL)) == NULL || | (e = elf_begin(fd, ELF_C_READ, NULL)) == NULL || | ||||
(elf_kind(e) != ELF_K_ELF)) { | (elf_kind(e) != ELF_K_ELF)) { | ||||
if (args.pa_verbosity >= 2) | if (args.pa_verbosity >= 2) | ||||
▲ Show 20 Lines • Show All 1,578 Lines • Show Last 20 Lines |