Howard Shane
Howard Shane

Reputation: 956

make-kpkg build kernel with -O0 for kgdb

I am going to setup kgdb to debug Ubuntu debian kernel.

By default, the kernel compiled by make-kpkg has been optimized (-O2) so I am not able to debug the variables.

Is there a way to disable the kernel compilation optimization (for example, -O0)?

thanks!

Currently, gdb reports the variable has been optimized:

(gdb) p pb
$5 = <optimized out>

Upvotes: 0

Views: 182

Answers (1)

user5613277
user5613277

Reputation:

The Linux kernel depends on -O2. It will not compile with any lower optimization levels. It uses several GCC "tricks" that only work when certain optimizations are turned on, such as inline functions that are supposed to act like macros.

Upvotes: 1

Related Questions