GDB and QEMU on Win64
GDB and QEMU on Win64
Hi! I am using gdb to debug my O.S. on QEMU but it fail when I set a breakpoint telling me "Remote 'g' packet reply is too long:".I am in Win 2003 x86-64 machine. In Linux works fine if you do "SET ARCHITECTURE I386:X86-64:INTEL" but in Win doesn't .
I fixed the problem using my own patch and recompiling gdb-7.0 and it works fine , Do Anyone know other patch ? .
Thanks in advance.
I fixed the problem using my own patch and recompiling gdb-7.0 and it works fine , Do Anyone know other patch ? .
Thanks in advance.
Re: GDB and QEMU on Win64
I got a similar problem. My host is snow leopard, my kernel runs in 64-bit mode. I tried cross gdb and qemu to debug, but failed with same error. Would you mind share you patch?
Thanks
torshie
Thanks
torshie
- xenos
- Member
- Posts: 1118
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: GDB and QEMU on Win64
I had a very similar problem with GDB and debugging 64bit kernel code. Searching the web for quite some time I found some post to the GDB mailing list about this problem. The outcome of that discussion was that GDB does not handle the protected mode / long mode transition very well, as the target architecture "changes" at runtime, and that solving this problem would require large changes in the GDB source.
All that was a few months ago and I haven't used GDB with QEMU that much for debugging 64bit kernel code since that time. But I'm also quite curious for that patch. Maybe you should even send it to the GDB mailing list.
All that was a few months ago and I haven't used GDB with QEMU that much for debugging 64bit kernel code since that time. But I'm also quite curious for that patch. Maybe you should even send it to the GDB mailing list.
Re: GDB and QEMU on Win64
Hi! I don't have problem to share the patch but and I am not sure about if gdb's comunity likes it because it is too simple and just fixed the problem on Windows.
When you start to debug the emulator is in real mode , So When the emulator jumps to long mode packet's size changes and GDB says "G packets too big" or something that. My patch just changes the size of buffer . So if you do "SET ARCH I386:86_64"... the packet's size is correct and it never change.
I can upload the file "remote.c" if you want.
Saludos .
When you start to debug the emulator is in real mode , So When the emulator jumps to long mode packet's size changes and GDB says "G packets too big" or something that. My patch just changes the size of buffer . So if you do "SET ARCH I386:86_64"... the packet's size is correct and it never change.
I can upload the file "remote.c" if you want.
Saludos .
Re: GDB and QEMU on Win64
I always fail to get QEMU (or in this case 'Q.app') to work correctly in x86_64 mode.
I use Mac OS X Snow Leopard (but I haven't try to start QEMU on 64 bit kernel, default to 32 bit).
QEMU always hang just after started...
Anyone know how to do it?
I use Mac OS X Snow Leopard (but I haven't try to start QEMU on 64 bit kernel, default to 32 bit).
QEMU always hang just after started...
Anyone know how to do it?
Re: GDB and QEMU on Win64
Hey!
i've had some problems with this too. I discovered with some playing, that qemu-0.11.0 without kqemu and/or kvm works well for debugging even the mode transition etc. with qemu-kvm-0.12.0 and qemu-kvm-0.13.0 it doesn't work. z0rr0, you have a patch? against which gdb version? can you share it?
Edit: ah, and i'm on linux of course - not windows, but i guess it doesn't matter for this...
cheers, markus
i've had some problems with this too. I discovered with some playing, that qemu-0.11.0 without kqemu and/or kvm works well for debugging even the mode transition etc. with qemu-kvm-0.12.0 and qemu-kvm-0.13.0 it doesn't work. z0rr0, you have a patch? against which gdb version? can you share it?
Edit: ah, and i'm on linux of course - not windows, but i guess it doesn't matter for this...
cheers, markus
Re: GDB and QEMU on Win64
Well, I changed a few lines of GDB for WIN 2003 x64. Can It help you?. See ya.
Re: GDB and QEMU on Win64
possibly. can you pastebin a diff? thanks
Re: GDB and QEMU on Win64
Here It is the patch, I was using gdb-7.1, It works but I am not sure if it has others problems. See ya.
PD: I tested using QEMU+ECLIPSE.
PD2: Tell me if it worked.
PD: I tested using QEMU+ECLIPSE.
PD2: Tell me if it worked.
- Attachments
-
[The extension patch has been deactivated and can no longer be displayed.]
Re: GDB and QEMU on Win64
For those interested, and building qemu themselves: revert commit 5f30fa18ad043a841fe9f0c3917ac60f2519ebd1 from the qemu git repo to restore full 64 bit debugability with vanilla gdb. note however, that debugging 32 bit with qemu-system-x86_64 will not work then...
also see those threads:
1) http://thread.gmane.org/gmane.comp.emulators.qemu/80327
2) http://www.mail-archive.com/qemu-devel@ ... 50402.html
also see those threads:
1) http://thread.gmane.org/gmane.comp.emulators.qemu/80327
2) http://www.mail-archive.com/qemu-devel@ ... 50402.html
Re: GDB and QEMU on Win64
I can verify that this works for me and my simple hobby kernel. I am using qemu git version (commit f6317a6ef16841d9d4a90e3aa664f715e26f978c Date: Thu Mar 10 12:33:56 2011 +0100), to which I applied the revert patch operation. Now I can debug with gdb just fine using gdb git version (commit 009e307e0442527da3cd3f56aea57ed71dbb13a4 Date: Thu Mar 10 12:29:06 2011 +0000).mduft wrote:For those interested, and building qemu themselves: revert commit 5f30fa18ad043a841fe9f0c3917ac60f2519ebd1 from the qemu git repo to restore full 64 bit debugability with vanilla gdb. note however, that debugging 32 bit with qemu-system-x86_64 will not work then...
Before I just got the "Remote 'g' packet is too long" error.
I have not tried the other solution, using the patch in z0rr0's post above.
-Riku
Re: GDB and QEMU on Win64
Hi,
I had this problem too, while attempting to get some way of debugging EFI code.
I couldn't find the original patch, so as a work-around I found each occurrence of "if (TARGET_LONG_BITS == 64 && env->hflags & HF_CS64_MASK) {" in the file "gdbstub.c" and replaced it with "if (TARGET_LONG_BITS == 64) {". This seems to work for me, but I'm not too sure how it'd handle debugging 32-bit code after this, and it's probably a good idea to compile an unmodified version for debugging 32-bit OSs and a modified version for debugging 64-bit OSs.
To be honest, I just wish the debugger built into Qemu was useful so I didn't have to bother with GDB at all (or alternatively, wish that the EFI firmware worked in Bochs so I didn't need to bother with Qemu).
Cheers,
Brendan
I had this problem too, while attempting to get some way of debugging EFI code.
I couldn't find the original patch, so as a work-around I found each occurrence of "if (TARGET_LONG_BITS == 64 && env->hflags & HF_CS64_MASK) {" in the file "gdbstub.c" and replaced it with "if (TARGET_LONG_BITS == 64) {". This seems to work for me, but I'm not too sure how it'd handle debugging 32-bit code after this, and it's probably a good idea to compile an unmodified version for debugging 32-bit OSs and a modified version for debugging 64-bit OSs.
To be honest, I just wish the debugger built into Qemu was useful so I didn't have to bother with GDB at all (or alternatively, wish that the EFI firmware worked in Bochs so I didn't need to bother with Qemu).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.