From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9738 invoked by alias); 1 Dec 2010 12:52:52 -0000 Received: (qmail 9720 invoked by uid 22791); 1 Dec 2010 12:52:52 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_KG X-Spam-Check-By: sourceware.org Received: from mail-ww0-f43.google.com (HELO mail-ww0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Dec 2010 12:52:47 +0000 Received: by wwi17 with SMTP id 17so1463284wwi.12 for ; Wed, 01 Dec 2010 04:52:45 -0800 (PST) Received: by 10.216.188.71 with SMTP id z49mr7558905wem.82.1291207964884; Wed, 01 Dec 2010 04:52:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.186.148 with HTTP; Wed, 1 Dec 2010 04:52:16 -0800 (PST) In-Reply-To: <87r5e4lab7.fsf@basil.nowhere.org> References: <87r5e4lab7.fsf@basil.nowhere.org> From: Hui Zhu Date: Wed, 01 Dec 2010 12:52:00 -0000 Message-ID: Subject: Re: [PATCH] Built kernel without -O2 option To: Andi Kleen Cc: linux-kernel@vger.kernel.org, gdb@sourceware.org, hellogcc@freelists.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-12/txt/msg00005.txt.bz2 On Mon, Nov 29, 2010 at 17:59, Andi Kleen wrote: > Hui Zhu writes: > >> Now, there are a lot of ways to debug the Linux kernel with GDB, like >> qemu, kgtp or kgdb and so on. >> But the developer more like add a printk. It have a lot of reason, a big= one is: >> (gdb) p ret >> $3 =3D >> And the code execution order is not right. > > Really the right place to fix a lot of this would be gcc (and perhaps > gdb). I suspect with some careful work the debugging experience > for -O2 could be improved a lot. > I also believe the latest gccs already have improvements in this area. > If you think they are OK, go get a new gcc and try. :) >> >> This is becuase the Kernel is bult with gcc -O2. =A0Gcc will not >> generate enough debug message with file with -O2. >> So GDB cannot work very well with Linux kernel. >> >> So I make a patch that add a option in "Kernel hacking" called "Close >> GCC optimization". =A0It will make kernel be built without -O2. > > > You need to at least keep aggressive inlining for header files, > otherwise there will be too much code bloat and bad code. > > Like -O1 -finline-functions ? > If I can build OK, why I need add some options? Thanks, Hui