From owner-freebsd-dtrace@FreeBSD.ORG Sat Nov 8 22:06:40 2014 Return-Path: Delivered-To: freebsd-dtrace@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 87240DCA; Sat, 8 Nov 2014 22:06:40 +0000 (UTC) Received: from mail-ig0-x22b.google.com (mail-ig0-x22b.google.com [IPv6:2607:f8b0:4001:c05::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 519A6217; Sat, 8 Nov 2014 22:06:40 +0000 (UTC) Received: by mail-ig0-f171.google.com with SMTP id hl2so14588801igb.10 for ; Sat, 08 Nov 2014 14:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Twg4OyqotN7nyG+DUZlEMXL1WhK2/xSeyg3YdD74Cho=; b=xaI3FaIOU0bpbrs5uX4zWT4BXs83LNbd5L8Wt9wiUVNko8kZoyM4M5ixZRNS62bHot sIQFIqRXcKrCwBTxhvoo696zzAS39eKO7IPYsnoFQBebvfuCou5B3jfSC9R3VYCcsSTn g5Fkhcrkp6JQormp9lY41NcyXbDjasyfGM2asrwiPjztkIvSdGr1fQfJucFdV6+OWMej EP8UiCPACj4+VHvUzNIh3vPDhU4Qu/G6fpcrNSCn1EwWG0c9QEnUmQE0oqenXh/1DUMH 2nl+2Buk4UO5FTsO21vqmGRBiF+Bu/8Utz67NENnr4p0C8TN7uBGQxy+NGUmcGVHBtuU QqeQ== MIME-Version: 1.0 X-Received: by 10.42.216.77 with SMTP id hh13mr20843188icb.31.1415484399714; Sat, 08 Nov 2014 14:06:39 -0800 (PST) Received: by 10.107.19.234 with HTTP; Sat, 8 Nov 2014 14:06:39 -0800 (PST) Date: Sat, 8 Nov 2014 14:06:39 -0800 Message-ID: Subject: DTrace: stack() does not print kernel module functions for i386 From: Shrikanth Kamath To: freebsd-hackers@freebsd.org, freebsd-dtrace@freebsd.org, avg@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-dtrace@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "A discussion list for developers working on DTrace in FreeBSD." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2014 22:06:40 -0000 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. Can somebody help clarify this? Reference: commit revision 210425. -- Shrikanth R K