Not sure exactly what part of the title is relevant, but essentially the situation is this: I have a x86-64 kernel, which I was initially loading at virtual address 0xC0000000 using a custom bootloader. At that point I had full debug support via a combination of Bochs and GDB, as in, I could set and hit breakpoints anywhere in the entire address space. I decided to start loading the kernel at -2GB instead, as I was reading about the benefits of higher half kernels, so I made the relevant changes to do so in the bootloader, rebuilt libgcc and my kernel with `-mcmodel=kernel` and adjusted the link script to load at -2GB. To my surprise, everything seemed to work, with one exception: I find myself unable to set breakpoints in the kernel in either the Bochs internal debugger or in GDB. The symbol addresses seem to be correct -- `print &kmain` and `print &_init` within GDB seem to report the correct addresses -- and I can hit breakpoints in the bootloader perfectly fine. I just can't hit any breakpoints in the kernel binary itself. What's even stranger is that GDB does break upon hitting an interrupt handler, but even after that point isn't capable of inserting breakpoints.
I did some googling, and found someone who ran into a similar issue a while back but they had a different configuration and still never seemed to resolve the underlying issue.
Anyone else run into this problem and know a solution? Perhaps a bug in Bochs? The fact that it doesn't work even in the Bochs internal debugger leads me to suspect it, rather than GDB, is the culprit, but I haven't been able to get QEMU working with my bootloader to confirm.
Bochs GDB with Higher Half Kernel (x86-64)
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Bochs GDB with Higher Half Kernel (x86-64)
For that thread, the issue was that either QEMU's GDB stub or GDB itself didn't support debugging 32-bit code with a nonzero segment base. You can't have 64-bit code with a nonzero segment base, so it's probably not the same issue.tyg13 wrote:I did some googling, and found someone who ran into a similar issue a while back but they had a different configuration and still never seemed to resolve the underlying issue.
You didn't follow one of those awful "how to write a bootloader" tutorials, did you? (If you post a link to your code I'll give it a look.)tyg13 wrote:The fact that it doesn't work even in the Bochs internal debugger leads me to suspect it, rather than GDB, is the culprit, but I haven't been able to get QEMU working with my bootloader to confirm.
And since you seem to be new here, why not check out this post? It might be helpful if you haven't seen it yet.