-
-
Notifications
You must be signed in to change notification settings - Fork 54
[mingw, x64] gdbstub seems to send a packet 24 bytes too long on connect #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for sending in this bug report! Assuming I found the right repo - this is the A few initial observations:
This is most perplexing indeed... As a next step, could you confirm I'm understanding the situation right, and also, try this one thing for me? Can you try removing the explicit |
Yes that is the correct repo. I'm currently working out of the packetrx branch, which is slightly different on the gdbstub (but probably not enough to matter yet). I tried removing the set architecture line from the script. It did not change the results.
I tried removing the extra 24 bytes in core64.rs in gdbstub_arch and it seems to fix the problem. Probably not the best solution. Maybe it is a deviation specific to the mingw version of gdb? |
That's very interesting indeed... While it would certainly be good to get to the bottom of why your particular GDB client version isn't playing nice with the existing arch implementation, I'm not particularly inclined to change the current implementation in If you'd like to help me debug here, I would certainly appreciate it if you could try connecting to your kernel using an alternative GDB client. e.g: you could install In the meantime though, my actionable advice for you would be to "fork" a copy of the If you don't mind - I'll just go ahead and keep this issue open, renaming it to something a bit more generic, in case other folks run into this same issue. |
I don't mind at all. I'll see about doing some of the debugging with other gdb. |
In wsl2, ubuntu gdb works both with and without the 24 bytes at the end. |
Very interesting indeed. What GDB version were you running inside WSL2? |
Gdb version in wsl2 is |
It would be good to narrow down if the issue is related to the GDB version, or the mingw version of GDB. If you have a chance, it'd be great to smoke-test some other versions of GDB (both via mingw, and in wsl2), and see what the behavior matrix looks like. |
I'm facing a similar issue when trying to debug a 32-bit Windows executable, my GDB client doesn't like the 4 bytes of "padding" here: gdbstub/gdbstub_arch/src/x86/reg/core32.rs Lines 88 to 89 in 5f59068
I think I figured out where this "padding" comes from. For 32-bit x86, it's this Linux-only And for x86-64, the 24 extra bytes are So, the x86 implementation in |
Excellent sleuthing! Given that this extra padding data is not user-controllable, it seems reasonable to publish a new minor revision of @jamcleod, as the original implementer of i386 support (via #23), do you have any thoughts / concerns about that? In the meantime though, @cadmic, feel free to send in a PR tweaking this behavior. I don't mind shipping a new Of course, the meta-issue here is that until we have a reasonable approach towards #12, |
Turns out these were actually Linux-specific registers, namely `orig_eax` for 32-bit and `orig_eax`/`fs_base`/`gs_base` for 64-bit. GDB will gracefully handle a too-short packet but not a too-long one, so removing this padding should make this work for all x86 targets and not just Linux. Fixes daniel5151#165
Turns out these were actually Linux-specific registers, namely `orig_eax` for 32-bit and `orig_eax`/`fs_base`/`gs_base` for 64-bit. GDB will gracefully handle a too-short packet but not a too-long one, so removing this padding should make this work for all x86 targets and not just Linux. Fixes daniel5151#165
Turns out these were actually Linux-specific registers, namely `orig_eax` for 32-bit and `orig_eax`/`fs_base`/`gs_base` for 64-bit. GDB will gracefully handle a too-short packet but not a too-long one, so removing this padding should make this work for all x86 targets and not just Linux. Fixes daniel5151#165
Turns out these were actually Linux-specific registers, namely `orig_eax` for 32-bit and `orig_eax`/`fs_base`/`gs_base` for 64-bit. GDB will gracefully handle a too-short packet but not a too-long one, so removing this padding should make this work for all x86 targets and not just Linux. Fixes #165
I am running on windows, with mingw gdb (GNU gdb (GDB) 14.2 according to gdb -v)
I have implemented the gdbstub blocking event loop in a dedicated thread in my kernel.
The target system is virtualbox, running a tcp server to a serial port on my kernel.
I setup gdb with this script.
Here is my gdb output when I try to connect to my system.
The text was updated successfully, but these errors were encountered: