From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 10 19:19:53 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23B62E7F for ; Mon, 10 Nov 2014 19:19:53 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0BE31DEC for ; Mon, 10 Nov 2014 19:19:53 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id sAAJJqrg043779 for ; Mon, 10 Nov 2014 19:19:52 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 194933] New: DTrace: Stack() command does not print function name if it is from a kernel module for i386. Date: Mon, 10 Nov 2014 19:19:53 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 10.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: shrikanth07@gmail.com X-Bugzilla-Status: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2014 19:19:53 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194933 Bug ID: 194933 Summary: DTrace: Stack() command does not print function name if it is from a kernel module for i386. Product: Base System Version: 10.0-STABLE Hardware: i386 OS: Any Status: Needs Triage Severity: Affects Many People Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: shrikanth07@gmail.com I verified this on a FreeBSD 10.0 STABLE, the stack() feature does not appear to print functions from kernel modules. I believe there is a glitch in libdtrace in the function "dt_module_update" (cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c). The section header address computation which is currently being done in the function dt_module_update for elf type ET_REL, a similar computation needs to be done for the ET_DYN maybe. I lack background on the elf types but for experiment sakes I changed the line @@ -948,7 +948,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_fil #if defined(__FreeBSD__) mapbase = (uintptr_t)k_stat->address; gelf_getehdr(dmp->dm_elf, &ehdr); - is_elf_obj = (ehdr.e_type == ET_REL); + is_elf_obj = (ehdr.e_type == ET_REL) || (ehdr.e_type == ET_DYN); if (is_elf_obj) { dmp->dm_sec_offsets = malloc(ehdr.e_shnum * sizeof(*dmp->dm_sec_offsets)); So from a previous run where I was running a dtrace one liner %dtrace -n 'fbt:hwpmc:: { stack(); }' The output without the above change shows a sample as 0 50825 pmc_find_process_descriptor:entry 0xc3c35bf5 <-- Address not matched to symbol kernel`syscall+0x48b kernel`0xc0fd2121 whereas with the above nit change to include ET_DYN for section offset adjustment I get the complete stack trace as 0 50825 pmc_find_process_descriptor:entry hwpmc.ko`pmc_hook_handler+0x6a5 <-- Address matched to symbol kernel`syscall+0x48b kernel`0xc0fd2121 I believe without the correct section offset adjustment the following check in the function "dtrace_lookup_by_addr" fails to match the address to the correct symbol if (addr - dmp->dm_text_va < dmp->dm_text_size || addr - dmp->dm_data_va < dmp->dm_data_size || addr - dmp->dm_bss_va < dmp->dm_bss_size) because dml->dm_text_va was not setup correctly in dt_module_update. Filing a bug report after discussion on freebsd-hackers, please refer the following thread https://lists.freebsd.org/pipermail/freebsd-hackers/2014-November/046435.html Reference: commit revision 210425. And also the related thread https://lists.freebsd.org/pipermail/freebsd-amd64/2010-June/013034.html Note that this is not an issue on amd64. -- You are receiving this mail because: You are the assignee for the bug.