From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3033 invoked by alias); 1 Dec 2010 12:18:55 -0000 Received: (qmail 3019 invoked by uid 22791); 1 Dec 2010 12:18:53 -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-wy0-f169.google.com (HELO mail-wy0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Dec 2010 12:18:48 +0000 Received: by wyb42 with SMTP id 42so15016063wyb.0 for ; Wed, 01 Dec 2010 04:18:46 -0800 (PST) Received: by 10.216.7.210 with SMTP id 60mr6618873wep.97.1291205925738; Wed, 01 Dec 2010 04:18:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.186.148 with HTTP; Wed, 1 Dec 2010 04:18:24 -0800 (PST) In-Reply-To: <4CF37603.5080301@de.ibm.com> References: <20101129081619.GD5218@cr0.nay.redhat.com> <4CF37603.5080301@de.ibm.com> From: Hui Zhu Date: Wed, 01 Dec 2010 12:18:00 -0000 Message-ID: Subject: Re: [PATCH] Built kernel without -O2 option To: Christian Borntraeger Cc: =?ISO-8859-1?Q?Am=E9rico_Wang?= , linux-kernel@vger.kernel.org, gdb@sourceware.org, hellogcc@freelists.org, linux-kbuild@vger.kernel.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/msg00003.txt.bz2 On Mon, Nov 29, 2010 at 17:44, Christian Borntraeger wrote: > Am 29.11.2010 09:16, schrieb Am=E9rico Wang: >> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote: >>> Hi, >>> >>> 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 bi= g one is: >>> (gdb) p ret >>> $3 =3D >>> And the code execution order is not right. >>> >>> 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. >>> >>> I built and use it in i386 and x86_64. =A0I will try to make it OK in o= ther arch. >>> >> >> The problem is that some functions _have to_ be inlined and gcc without = -O2 >> doesn't inline them. Have check all the cases? I doubt. > > In essence -O2 just tells gcc to activate a list of optimizations > gcc =A0-Q -O2 --help=3Doptimizers > tells you what. > > So what about making this patch much smaller by explicitely using the opt= imizations > that are absolutely necessary? > e.g: > -finline-small-functions -finline-functions-called-once > (what else do we need?) > > We might even =A0be able to collapse this with the optimize for size opti= on, > by providing a Kconfig entry that allows to choose between > > -O0 -finline-small-functions -finline-functions-called-once > -O1 -finline-small-functions -finline-functions-called-once > -Os > -O2 > -O3 > > Christian > Hi Christian. If we can build without any optimization options just set some file to O2. I think keep it it will better than add some optimization options to all files, right? But make for this file that I add O2 to them, I can change them to to some others options like "-O0 -finline-small-functions -finline-functions-called-once". Thanks, Hui