From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754734AbcAMKAs (ORCPT ); Wed, 13 Jan 2016 05:00:48 -0500 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:58840 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752236AbcAMKAp (ORCPT ); Wed, 13 Jan 2016 05:00:45 -0500 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: hemant@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Message-ID: <56962014.5040702@linux.vnet.ibm.com> Date: Wed, 13 Jan 2016 15:29:48 +0530 From: Hemant Kumar User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: =?UTF-8?B?5bmz5p2+6ZuF5bezIC8gSElSQU1BVFXvvIxNQVNBTUk=?= , "linux-kernel@vger.kernel.org" CC: "mjw@redhat.com" , "sukadev@linux.vnet.ibm.com" , "linuxppc-dev@lists.ozlabs.org" , "srikar@linux.vnet.ibm.com" , "acme@kernel.org" Subject: Re: [PATCH v2] perf/probe: Search both .eh_frame and .debug_frame sections for probe location References: <1451900918-6710-1-git-send-email-hemant@linux.vnet.ibm.com> <50399556C9727B4D88A595C8584AAB37526926A9@GSjpTKYDCembx32.service.hitachi.net> In-Reply-To: <50399556C9727B4D88A595C8584AAB37526926A9@GSjpTKYDCembx32.service.hitachi.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16011310-0025-0000-0000-000002BDD4A5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/12/2016 04:34 PM, 平松雅巳 / HIRAMATU,MASAMI wrote: > Hi Hemant, > >> From: Hemant Kumar [mailto:hemant@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