Not really a screenshot, but my kernel was acting very strangly and I wasted a lot of time on debugging it.
I had a very strange
heisenbug where local variables in my kernel were being overritten, but commenting out random code or adding extra debugging code either stopped it or made it modify other random variables!!
I was using the QEMU monitor and halting the world and inspecting the memory location of the variables that should not have modified, that they started looking suspiciously like addresses in my kernel address range. They lined up with addresses in my disassembled kernel (in kind of a reverse stack trace of functions that would have called each other.) I printed rsp in the QEMU monitor and it was pointing into my kernel's BSS section!
I discovered this in my interrupt handler:
Code:
mov rsp, interrupt_stack_top
Instead of:
Code:
mov rsp, [interrupt_stack_top]
I was setting the stack to the location of the variable 'interrupt_stack_top', rather than the address that the variable 'interrupt_stack_top' was pointing to.
The reason it went undetected was because the linker had been putting 'interrupt_stack_top' at the very start of my BSS section, and BSS is page aligned, so there was a little bit of empty padding and it was never an issue. But, some new code added global variables before 'interrupt_stack_top', and that's when I noticed my bug.