GDB x86_64 stub

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
robbiedobbie
Member
Member
Posts: 36
Joined: Fri May 16, 2014 2:40 pm
Libera.chat IRC: robbiedobbie

GDB x86_64 stub

Post by robbiedobbie »

I'm working on a kernel for some time now, and I'm making slow but (generally) steady progress. In emulators and virtual machines (bochs, qemu, virtualbox) everything works fine, and when something does not, it is easy to debug. However, when running on native systems, I run into all sorts of problems, which are extremely hard to debug. Therefore I wanted to integrate a gdb stub into my kernel, so that I can debug my physical computers as well.

After searching quite a bit on the internet, I can only find a i368 stub. Unfortunately, all my code (except for a small bootstrap asm) is running in long mode. Searching for a x86_64 version did not result to anything helpfull (The only thing I could find was the qemu-gdb stub, which has quite a messy unclear source code). Of course I can dig into the documentation, the protocol and the existing stubs, in order to write my own. This however, is quite a lot of work, and at the moment I just want to use it for some really hard to debug issue I have on my system.

I was wondering if anyone has found such stub, and could point me to it. Any other tips on this are also very welcome!

Thanks
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: GDB x86_64 stub

Post by jnc100 »

I have never managed to find one. They are not too hard to write, however. If you don't mind translating from C#, there is a sample implementation here.

Regards,
John.
robbiedobbie
Member
Member
Posts: 36
Joined: Fri May 16, 2014 2:40 pm
Libera.chat IRC: robbiedobbie

Re: GDB x86_64 stub

Post by robbiedobbie »

I guess I'll have to roll my own solution then. Your C# version does help a bit, since it shows how gdb expects 64bit registers to be sent. Thank you!
Post Reply