I follow one of many tutorials found on Google results to build and debug the Linux kernel with gcc and kgdb/gdb. And I end up by discovering that is all waste of time. Since I can't compile the kernel without gcc optimization -O0 neither -Og. There's no config option for removing optimization. And last but not leat, Linus said years ago that is against debugging.
Saying that kgdb must exist for some reason. I was wondering if there is a way to get rid of variables/arguments "optimized out" and let the debugger step through the code sequentially and not jumping from everywhere to everywhere?