[PATCH v2] perf/probe: Search both .eh_frame and .debug_frame sections for probe location

Hemant Kumar hemant at linux.vnet.ibm.com
Wed Jan 13 20:59:48 AEDT 2016



On 01/12/2016 04:34 PM, 平松雅巳 / HIRAMATU,MASAMI wrote:
> Hi Hemant,
>
>> From: Hemant Kumar [mailto:hemant at linux.vnet.ibm.com]
>>
>> perf probe through debuginfo__find_probes() in util/probe-finder.c
>> checks for the functions' frame descriptions in either .eh_frame section
>> of an ELF or the .debug_frame. The check is based on whether either one
>> of these sections is present. Depending on distro, toolchain defaults,
>> architetcutre, build flags, etc., CFI might be found in either .eh_frame
>> and/or .debug_frame. Sometimes, it may happen that, .eh_frame, even if
>> present, may not be complete and may miss some descriptions. Therefore,
>> to be sure, to find the CFI covering an address we will always have to
>> investigate both if available.
> OK, so we'd better check both cfi's.
>   [...]
>> +/* Find probe points from debuginfo */
>> +static int debuginfo__find_probes(struct debuginfo *dbg,
>> +				  struct probe_finder *pf)
>> +{
>> +	int ret = 0;
>> +
>> +#if _ELFUTILS_PREREQ(0, 142)
>> +	Elf *elf;
>> +	GElf_Ehdr ehdr;
>> +	GElf_Shdr shdr;
>> +
>> +	if (pf->cfi_eh || pf->cfi_dbg)
>> +		return debuginfo__find_probe_location(dbg, pf);
>> +
>> +	/* Get the call frame information from this dwarf */
>> +	elf = dwarf_getelf(dbg->dbg);
>> +	if (elf == NULL)
>> +		return -EINVAL;
>> +
>> +	if (gelf_getehdr(elf, &ehdr) == NULL)
>> +		return -EINVAL;
>> +
>> +	if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
>> +	    shdr.sh_type == SHT_PROGBITS) {
>> +		pf->cfi_eh = dwarf_getcfi_elf(elf);
>> +	} else {
>> +		pf->cfi_dbg = dwarf_getcfi(dbg->dbg);
>> +	}
> Hmm, if you want to check both of those cfi's, don't we have to do below?
>
> 	if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
> 	    shdr.sh_type == SHT_PROGBITS)
> 		pf->cfi_eh = dwarf_getcfi_elf(elf);
>
> 	pf->cfi_dbg = dwarf_getcfi(dbg->dbg);
>
> Then, both of pf->cfi_* will be filled (if the elf has ".eh_frame").
>
> Thanks!

Ah, right. Fixed in v3.

>
>

-- 
Thanks,
Hemant Kumar



More information about the Linuxppc-dev mailing list