From owner-freebsd-hackers@freebsd.org Fri Aug 12 20:32:04 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B224BB791A for ; Fri, 12 Aug 2016 20:32:04 +0000 (UTC) (envelope-from jhb@freebsd.org) 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 7ABED1DB9; Fri, 12 Aug 2016 20:32:04 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 61CC7B91E; Fri, 12 Aug 2016 16:32:03 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Cc: "K. Macy" , Andriy Gapon , Samy Bahra , Ryan Stone Subject: Re: How to get better debugging for the kernel. Date: Fri, 12 Aug 2016 12:22:18 -0700 Message-ID: <1551519.RkbAThDAeZ@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.3-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: <5cc825d5-9ed7-efac-b711-60a8d4b18cc4@FreeBSD.org> 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, 12 Aug 2016 16:32:03 -0400 (EDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2016 20:32:04 -0000 On Thursday, August 04, 2016 01:07:39 AM K. Macy wrote: > On Wed, Aug 3, 2016 at 12:53 PM, Andriy Gapon wrote: > > On 03/08/2016 20:14, Ryan Stone wrote: > >> Are you using the kgdb from the base system or from ports(it's a part of > >> devel/gdb)? The kgdb in ports is significantly better. If you haven't > >> tried the version from ports already, definitely do that first. > > > > kgdb 7.x from ports is certainly more powerful than the old base kgdb, > > but clang with O2 optimizations seems to be too much even for it. > > Samy did a good presentation about this issue. I'm hoping I can get > him to put his slides on line. Evidently clang is much more simplistic > about how it treats callee saved registers. In essence clang will > always err on the side of saying "optimized out" even when it has > sufficient state to know otherwise. Gcc, on the other hand will > sometimes incorrectly infer that a value is valid when it is in fact > not. > > I have been building some kernels with clang with dwarf4 enabled (and > thus needed to use kgdb 7.x from ports). Contrary to what I have heard > from some others I have found it to have virtually no added benefit. My understanding is that dwarf4 will not help with C programs like the kernel, that the new idioms in dwarf4 are for declaring more complex constructs in C++11, C++14, etc. I have heard that clang does not update debug information during optimization passes causing it to loose track of variables that are moved during optimization. I have not (yet) tried using gcc as avg@ describes though I will likely start doing so soon. -- John Baldwin