From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71288 invoked by alias); 21 Jul 2016 13:17:49 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 71123 invoked by uid 89); 21 Jul 2016 13:17:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=wherever, lep, ravi, Point X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 21 Jul 2016 13:17:46 +0000 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6LDE5R1084328 for ; Thu, 21 Jul 2016 09:17:44 -0400 Received: from e23smtp02.au.ibm.com (e23smtp02.au.ibm.com [202.81.31.144]) by mx0b-001b2d01.pphosted.com with ESMTP id 2496h8x5xn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Jul 2016 09:17:44 -0400 Received: from localhost by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jul 2016 23:17:40 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 21 Jul 2016 23:17:27 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: ravi.bangoria@linux.vnet.ibm.com X-IBM-RcptTo: systemtap@sourceware.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 6B3C82BB0054 for ; Thu, 21 Jul 2016 23:17:26 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6LDHQRv27984116 for ; Thu, 21 Jul 2016 23:17:26 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u6LDHPvO026883 for ; Thu, 21 Jul 2016 23:17:26 +1000 Received: from bangoria.in.ibm.com ([9.124.221.227]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u6LDHHNE026773; Thu, 21 Jul 2016 23:17:24 +1000 From: Ravi Bangoria To: systemtap@sourceware.org Cc: hemant@linux.vnet.ibm.com, mjw@redhat.com, atrajeev@linux.vnet.ibm.com, Ravi Bangoria Subject: [PATCH 2/3] ppc64le: Use LEP for probe location Date: Thu, 21 Jul 2016 13:17:00 -0000 In-Reply-To: <1469107036-4239-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> References: <1469107036-4239-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072113-0004-0000-0000-0000017CBDAA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072113-0005-0000-0000-0000084DA7AE Message-Id: <1469107036-4239-3-git-send-email-ravi.bangoria@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-07-21_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607210148 X-SW-Source: 2016-q3/txt/msg00079.txt.bz2 PPC64 ELF ABI v2 has a Global Entry Point and a Local Entry Point for the functions. Debuginfo of ELF contains GEP which is same as entrypc. While symbol table contains GEP and offset, from which we can calculate LEP. LEP is used to call function within single CU, when TOC pointer update is not required. So it's guaranteed that LEP will hit wherever function is called but GEP may not. Before Applying patch: $ vim uprobe_test.c #include void doit(int i) { printf("i : %d\n", i); } int main(int argc, char *argv[]) { doit(42); return 0; } $ gcc uprobe_test.c -g -o uprobe_test $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \ {printf("hit %d\n", $i)}' -c ./uprobe_test i : 42 hit 0 After Applying patch: $ sudo ./stap -e 'probe process("uprobe_test").function("doit") \ {printf("hit %d\n", $i)}' -c ./uprobe_test i : 42 hit 42 Fixes: Commit b4c6a4b1cd00 ("Prioritize symbol table lookup for ppc64le") Signed-off-by: Ravi Bangoria --- tapsets.cxx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tapsets.cxx b/tapsets.cxx index e7be711..1b3a1ea 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1391,6 +1391,55 @@ string path_remove_sysroot(const systemtap_session& sess, const string& path) return retval; } +/* + * Convert 'Global Entry Point' to 'Local Entry Point'. + * + * if @gep contains next address after prologue, don't change it. + * + * For ELF ABI v2 on PPC64 LE, we need to adjust sym.st_value corresponding + * to the bits of sym.st_other. These bits will tell us what's the offset + * of the local entry point from the global entry point. + * + * st_other field is currently only used with ABIv2 on ppc64 + */ +static Dwarf_Addr +get_lep(dwarf_query *q, Dwarf_Addr gep) +{ + Dwarf_Addr bias; + Dwfl_Module *mod = q->dw.module; + Elf* elf = (dwarf_getelf (dwfl_module_getdwarf (mod, &bias)) + ?: dwfl_module_getelf (mod, &bias)); + + GElf_Ehdr ehdr_mem; + GElf_Ehdr* em = gelf_getehdr (elf, &ehdr_mem); + if (em == NULL) + throw SEMANTIC_ERROR (_("Couldn't get elf header")); + + if (!(em->e_machine == EM_PPC64) || !((em->e_flags & EF_PPC64_ABI) == 2)) + return gep; + + int syments = dwfl_module_getsymtab(mod); + for (int i = 1; i < syments; ++i) + { + GElf_Sym sym; + GElf_Word section; + GElf_Addr addr; + +#if _ELFUTILS_PREREQ (0, 158) + dwfl_module_getsym_info (mod, i, &sym, &addr, §ion, NULL, NULL); +#else + dwfl_module_getsym (mod, i, &sym, §ion); + addr = sym.st_value; +#endif + + if (addr == gep && (GELF_ST_TYPE(sym.st_info) == STT_FUNC) + && sym.st_other) + return gep + PPC64_LOCAL_ENTRY_OFFSET(sym.st_other); + } + + return gep; +} + void dwarf_query::add_probe_point(interned_string dw_funcname, interned_string filename, @@ -1405,6 +1454,7 @@ dwarf_query::add_probe_point(interned_string dw_funcname, assert (! has_absolute); // already handled in dwarf_builder::build() + addr = get_lep(this, addr); reloc_addr = dw.relocate_address(addr, reloc_section); // If we originally used the linkage name, then let's call it that way -- 2.1.4