From owner-freebsd-hackers@FreeBSD.ORG Wed May 20 00:56:53 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2DF75EDA; Wed, 20 May 2015 00:56:53 +0000 (UTC) Received: from mail-qk0-x233.google.com (mail-qk0-x233.google.com [IPv6:2607:f8b0:400d:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DB4D31018; Wed, 20 May 2015 00:56:52 +0000 (UTC) Received: by qkgx75 with SMTP id x75so22210067qkg.1; Tue, 19 May 2015 17:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=K/Jp/NsAIgA4/1HirqQyEEOL11gH1mfSWN6A/85fAig=; b=wWOVktKKnJoJAuVD5OpX3iC+GRhvnUv2fseT43psmoFKHTS6OVUg6/hJ/G0r3akS4P 3gqlv92wrcTx0ottF5jm3SYHQ1PwsJBM3AATqmCtaHu+cm1WqMBNGPjfOQYHeVuux04g nevOgRoKaV1MdI3T4GCPfaaMAgr6YZ7dwT0cHz6l0NYQs14PuNtMYTkHK+kMyEn+Y84g R4SqOW6KUtaUqwCrDLWSKtb0q3yk1mKuAH8bG63QyFpra7wnzQLXN+VgfkpQol+yD8LM Ua4lxqjrl9FJsGIGSvmDFTqzOsjknMZ8+znJs3CcyX6U+Ya2ZX4S/noac9UQm9HEXS+J bmQw== MIME-Version: 1.0 X-Received: by 10.140.90.99 with SMTP id w90mr38953579qgd.57.1432083412162; Tue, 19 May 2015 17:56:52 -0700 (PDT) Received: by 10.140.98.73 with HTTP; Tue, 19 May 2015 17:56:52 -0700 (PDT) In-Reply-To: <2CEF3F4B-286C-47C5-B170-6CC017BE9D61@FreeBSD.org> References: <554E41EE.2010202@ignoranthack.me> <554E4BD1.1030802@ignoranthack.me> <406EAA27-D825-408B-985E-DC3FFE746473@frob.org> <554E5263.8010205@ignoranthack.me> <20150509190347.10e1e2c2@kan> <2CEF3F4B-286C-47C5-B170-6CC017BE9D61@FreeBSD.org> Date: Tue, 19 May 2015 17:56:52 -0700 Message-ID: Subject: Re: How to get anything useful out of kgdb? From: NGie Cooper To: Dimitry Andric Cc: Alexander Kabaev , "freebsd-hackers@freebsd.org" , Sean Bruno Content-Type: text/plain; charset=UTF-8 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: Wed, 20 May 2015 00:56:53 -0000 On Tue, May 19, 2015 at 3:25 PM, Dimitry Andric wrote: > On 19 May 2015, at 21:32, NGie Cooper wrote: >> >> On Mon, May 18, 2015 at 5:29 PM, NGie Cooper wrote: >> >>> As a sidenote, this has been broken for over a decade: >>> https://svnweb.freebsd.org/base?view=revision&revision=127204 :(... >> >> -O is synonymous with -O2 (both on clang and gcc) :(... > > No, for gcc -O has always meant -O1. For clang, it means -O2. If you > want -O1, please specify it. :) My bad. I typoed this earlier. > Though with clang I don't think you will see too much difference > regarding variables which have been put in registers, or eliminated > altogether, making it harder to follow for gdb (especially the ancient > version in base). > > If you want to have everything fully traceable, use -O0, and increase > your kernel stack size, otherwise it is likely to blow up. But *how* do you do that (especially when the build infrastructure gets in the way of you setting this)? Turns out there is a way if you dig deep enough through sys/conf/NOTES and are willing to abuse a feature... 62 # 63 # The `makeoptions' parameter allows variables to be passed to the 64 # generated Makefile in the build area. 65 # 66 # CONF_CFLAGS gives some extra compiler flags that are added to ${CFLAGS} 67 # after most other flags. Here we use it to inhibit use of non-optimal 68 # gcc built-in functions (e.g., memcmp). 69 # 70 # DEBUG happens to be magic. 71 # The following is equivalent to 'config -g KERNELNAME' and creates 72 # 'kernel.debug' compiled with -g debugging as well as a normal 73 # 'kernel'. Use 'make install.debug' to install the debug kernel 74 # but that isn't normally necessary as the debug symbols are not loaded 75 # by the kernel and are not useful there anyway. 76 # 77 # KERNEL can be overridden so that you can change the default name of your 78 # kernel. 79 # 80 # MODULES_OVERRIDE can be used to limit modules built to a specific list. 81 # 82 makeoptions CONF_CFLAGS=-fno-builtin #Don't allow use of memcmp, etc. 5 makeoptions CONF_CFLAGS=-O2 I wouldn't expect most folks to figure this out though, and it requires manual intervention in your kernel configuration to do this, even though DEBUG is set. This is not desirable for debug builds out of the box nor for folks who are trying to use makeoptions DEBUG=-g in their KERNCONFs. Cheers, -NGie