From mboxrd@z Thu Jan 1 00:00:00 1970 From: ablacktshirt@gmail.com (Yubin Ruan) Date: Fri, 20 Apr 2018 23:39:10 +0800 Subject: How can I disable compile optimization in kernel for friendly debugging, Thanks In-Reply-To: <25804.1524158893@turing-police.cc.vt.edu> References: <623d8297.8a0f.162dd208d7b.Coremail.sizel@163.com> <25804.1524158893@turing-police.cc.vt.edu> Message-ID: <20180420153909.r3cjaytzmxnttswz@HP> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On 2018-04-19 13:28, valdis.kletnieks at vt.edu wrote: > On Thu, 19 Apr 2018 16:58:40 +0800, sizel said: > > How can I disable compile optimization in kernel for friendly debugging, Thanks > > First off, there are parts of the kernel that *WILL* explode if you try to build > with -O0 - in particular, any code that expects static inlines to be treated as > part of the unit they are inlined into for the purposes of __builtin_return_address() > and similar. Can you elaborate more on that? > Second, modern gdb is perfectly able to deal with -O2 optimization, > especially if you build with -g. (In the kernel build, CONFIG_DEBUG_INFO=y > will do the right thing for this). I don't think so. According to my experience, GDB is not good enough to deal with -O2 optimization. Maybe my gdb is not modern enough? I am using gdb7.11 (Ubuntu 7.11.1-0ubuntu1~16.5) Yubin