From owner-freebsd-hackers@FreeBSD.ORG Fri May 15 15:50:55 2015 Return-Path: Delivered-To: freebsd-hackers@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 E0B10492; Fri, 15 May 2015 15:50:55 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BD4741D87; Fri, 15 May 2015 15:50:55 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id CC7BAB939; Fri, 15 May 2015 11:50:54 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org, sbruno@freebsd.org Subject: Re: How to get anything useful out of kgdb? Date: Fri, 15 May 2015 11:50:38 -0400 Message-ID: <2063489.pgabuk9nPJ@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.1-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: <554E41EE.2010202@ignoranthack.me> References: <554E41EE.2010202@ignoranthack.me> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 15 May 2015 11:50:54 -0400 (EDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2015 15:50:56 -0000 On Saturday, May 09, 2015 10:20:46 AM Sean Bruno wrote: > tl;dr What are the kernel config options to get good output of kgdb? > > > I'm trying to get the ability to debug and display internal variables, > as one does, with kgdb. I'm *must* be doing this wrong as I cannot get > any useful output from accessing variables that were JUST accessed in > order to invoke a panic() that I have inserted. This is a GENERIC > kernel without INVARIANTS and without WITNESS: > > https://people.freebsd.org/~sbruno/wtf_kgdb.txt > > I seem to have debug enabled and am able to browse source, but I > obviously haven't compiled correctly as things are optimized out. 1) gdb7 does a better job. I hope to get the kgdb patches into the port soon. If you are feeling brave: # add texinfo for HEAD % pkg install gmake bison % git clone https://github.com/bsdjhb/gdb.git % cd gdb % git checkout freebsd-7.9.0-kgdb % fetch http://people.freebsd.org/~jhb/gdb/build % sh ./build % cd obj # or obj.i386 for i386 % gmake Then use /path/to/git/gdb/obj/gdb/kgdb 2) Even with gdb7 it can't figure out variables that it should figure out sometimes. Other options are either to find the variable in a higher frame (e.g. if it is something like 'td' or a driver softc) or to start poking around in the dissassembly to work out which register it is in (or which register points to a structure that contains it) and go from there. -- John Baldwin