I'm getting acquainted with QEMU's internals because I'll need to know them very well for the next few months. I've reached a point where I want to debug QEMU with gdb in order to better understand the code flux related to some things that are still not clear after just looking at the code.
The thing is, debugging QEMU with GDB seems to be quite troublesome. GDB keeps reporting the wrong source-code location when stepping through the code and I'm unable to insert breakpoints at some of the most important functions. I've tried to disable GCC optimizations, but the compilation fails without -O2.
Is this my fault? How can I fix it?
Or, is this the expected behavior? In that case, which techniques do you use to debug QEMU?