From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24235 invoked by alias); 29 Nov 2010 09:59:51 -0000 Received: (qmail 24217 invoked by uid 22791); 29 Nov 2010 09:59:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_KG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (213.235.205.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Nov 2010 09:59:44 +0000 Received: from basil.firstfloor.org (p5B3C9554.dip0.t-ipconnect.de [91.60.149.84]) by one.firstfloor.org (Postfix) with ESMTP id 2EC241ED8020; Mon, 29 Nov 2010 10:59:41 +0100 (CET) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 802FBB2955; Mon, 29 Nov 2010 10:59:40 +0100 (CET) From: Andi Kleen To: Hui Zhu Cc: linux-kernel@vger.kernel.org, gdb@sourceware.org, hellogcc@freelists.org Subject: Re: [PATCH] Built kernel without -O2 option References: Date: Mon, 29 Nov 2010 09:59:00 -0000 In-Reply-To: (Hui Zhu's message of "Mon, 29 Nov 2010 11:56:15 +0800") Message-ID: <87r5e4lab7.fsf@basil.nowhere.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-11/txt/msg00114.txt.bz2 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 = > 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. > > This is becuase the Kernel is bult with gcc -O2. Gcc 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". It 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 ? -Andi -- ak@linux.intel.com -- Speaking for myself only.