Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

debugging - How to de-optimize the Linux kernel to and compile it with -O0?

I'm wanting to read and understand the Linux kernel's Memory Management (in particular defragcompactionmigration).

So, I turn off optimization for size in .config (using make menuconfig of course) and compile...This leaves me with still an optimized kernel.

NOTE: When I say optimized kernel, I mean that when I use gdb and tell it next that it'll jump around. I don't want that, I want to be able to follow the code line by line just as I would with a simple hello world.

Next, I edit the Makefile and swap -O2 with -O0 and that causes things to break.

I found this, but I don't know what files I'll want because I don't know how far down the rabbit hole goes.

Is there a more generic option that I can use? I understand the concepts of memory compaction; however, I want to see where everything happens and how it exactly happens.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't de-optimize the kernel. You might be able to de-optimize certain functions, like this:

void __attribute__((optimize("O0"))) foo(unsigned char data) {
    // unmodifiable compiler code
}

But the kernel as a whole requires -O2 because the code itself is written with assumptions that certain functions will be optimized in a certain way.

Sorry, but you really will need to know the size of the rabbit hole you want to go down.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...