From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 31 19:27:22 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF92F10656CD; Tue, 31 Aug 2010 19:27:22 +0000 (UTC) (envelope-from pebu3op@googlemail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 211218FC17; Tue, 31 Aug 2010 19:27:21 +0000 (UTC) Received: by bwz20 with SMTP id 20so5667456bwz.13 for ; Tue, 31 Aug 2010 12:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:reply-to:mail-followup-to:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=xXU6XnTMhcHF4/5CfNrs1OOZOGlBGxVv7+35HQE6BKY=; b=YSLovpT9ilJsrQwAcEJUA/mWYjuwuzu3v+PcDpb90Q0EiHNT1X4WFW62pK4YYbMEoL poLdrSY6xwA+RR8K+MoSEqs/IogPj0NK3WLdr5x7uKleKq9cpuHUaqSmmwcUmMu3e44d QDxctULarUUWHPOY1CfSy8gua7brzBOHQ15SI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:reply-to:mail-followup-to :references:mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; b=LI9PQiryc0AJ9c5P4YUDsfAPcxWA0POdXcRagSFJBBrcigrbw1u/im7SbJt40ISEEN 73AG+kA9AB4cZfFtJobmpLtSDMTjBUudyLHnvayOYIA6YbyhHPtDxtsVDMi+naFXf4pG /F/So+DfODiPBf26cf1KSebBGt65Dt2ZiAEt8= Received: by 10.204.45.136 with SMTP id e8mr4907302bkf.94.1283282840627; Tue, 31 Aug 2010 12:27:20 -0700 (PDT) Received: from debmaster-laptop ([130.149.220.190]) by mx.google.com with ESMTPS id f18sm6542426bkf.3.2010.08.31.12.27.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 31 Aug 2010 12:27:19 -0700 (PDT) Date: Tue, 31 Aug 2010 21:27:16 +0200 From: Alexander Fiveg To: John Baldwin Message-ID: <20100831192716.GB5521@debmaster-laptop> Mail-Followup-To: John Baldwin , freebsd-hackers@freebsd.org, doc@freebsd.org References: <20100827201140.GA2812@debmaster-laptop> <201008301310.38148.jhb@freebsd.org> <20100830203404.GC3135@debmaster-laptop> <201008301734.01740.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201008301734.01740.jhb@freebsd.org> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-hackers@freebsd.org, doc@freebsd.org Subject: Re: Debugging Loadable Modules Using GDB X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Alexander Fiveg List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2010 19:27:23 -0000 On Mon, Aug 30, 2010 at 05:34:01PM -0400, John Baldwin wrote: > On Monday, August 30, 2010 4:34:04 pm Alexander Fiveg wrote: > > On Mon, Aug 30, 2010 at 01:10:37PM -0400, John Baldwin wrote: > > > On Monday, August 30, 2010 12:12:50 pm Alexander Fiveg wrote: > > > > On Mon, Aug 30, 2010 at 08:16:11AM -0400, John Baldwin wrote: > > > > > On Friday, August 27, 2010 4:11:41 pm Alexander Fiveg wrote: > > > > > > Hi, > > > > > > from "FreeBSD Developers' Handbook, 10.7 Debugging Loadable Modules Using > > > > > > GDB": > > > > > > "... > > > > > > (kgdb) add-symbol-file /sys/modules/linux/linux.ko 0xc0ae22d0 > > > > > > ... > > > > > > " > > > > > > Actually I couldn't debug my modules using .ko-file. Moreover, I've find out > > > > > that .ko files do not contain sections with debugging info. With .kld-file > > > > > debugging works out. Do I something incorrectly or the info in the Developers > > > > > Book is outdated? > > > > > > > > > > With newer versions of kgdb you shouldn't need to manually invoke 'add-symbol- > > > > > file'. Kernel modules are treated as shared libraries and should > > > > > automatically be loaded. Try using 'info sharedlibrary' to see the list of > > > > > kernel modules and if symbols for them are loaded already. > > > > Yes, the .ko files are loaded automatically. The problem is that they do > > > > not contain debugging info. I have always to load the .kld file in order to > > > > debug a module: > > > > > > > > (kgdb) f 9 > > > > #9 0xc4dc558b in rm_8254_delayed_interrupt_per_packet () from > > > > /boot/kernel/if_ringmap.ko > > > > (kgdb) info locals > > > > No symbol table info available. > > > > > > > > (kgdb) add-symbol-file /home/alexandre/p4/ringmap/current/sys/modules/ringmap/if_ringmap.kld 0xc4dafc70 > > > > add symbol table from file "/home/alexandre/p4/ringmap/current/sys/modules/ringmap/if_ringmap.kld" > > > > at > > > > .text_addr = 0xc4dafc70 > > > > (y or n) y > > > > Reading symbols from /home/alexandre/p4/ringmap/current/sys/modules/ringmap/if_ringmap.kld...done. > > > > > > > > (kgdb) f 9 > > > > #9 0xc4dc558b in rm_8254_delayed_interrupt_per_packet () > > > > at /home/alexandre/p4/ringmap/current/sys/modules/ringmap/../../dev/e1000/ringmap_8254.c:142 > > > > 142 co->ring->slot[slot_num].ts = co->ring->last_ts; > > > > > > > > (kgdb) info locals > > > > co = (struct capt_object *) 0xc4d68380 > > > > adapter = (struct adapter *) 0xc4e77000 > > > > __func__ = "E\000\000�\034@\000\000\211\203�E\000\000\017\206B\022\000\000\2039\000\213A\004\017\205�\f\000\000\001��1�" > > > > > > > > > > > > Is there any way to get the all symbols and needed debug info without > > > > loading the .kld file ? > > > > > > How are you compiling the kld? If you are building it by hand, use > > > 'make DEBUG_FLAGS=-g' when you build and install the kld. That should build > > > with debug symbols enabled and install the ko.symbols file which kgdb will > > > find and use. > > Thanks a lot!. That is what I want to know. But I think this option is not > > mentioned anywhere. I could not find it in "man make make.conf" and also > > no mention about it in FreeBSD Developers' Handbook. > > It's a bit of a "feature" of the bsd.*.mk files that if you define > 'DEBUG_FLAGS' it is added to CFLAGS (and CXXFLAGS) and that any resulting > binaries are not stripped, etc. The same trick can be used to build debug > versions of binaries and libraries. It probably is underdocumented. Not > sure make.conf(5) is the right place as the typical usage is on the command > line, not in /etc/make.conf or /etc/src.conf. However, I can't think of a > better place. Maybe src.conf(5)? Anyway, "FreeBSD Developers' Handbook" wouldn't be wrong place for it :) > > -- > John Baldwin -- Alexander Fiveg Key fingerprint = ECBB 747C 919D 78F5 E8EC 7DBC 8B46 376D 107B CCAA