Closed rayc345 closed 1 month ago
Huh, that's very interesting indeed! And thank you for including a full packet log - that is very useful!
Can you please also share what version of the GDB client you are using? Also, can you include a transcript of any GDB client commands you sent (if any) to generate this packet log?
Poking around gdbstub
's current implementation, it seems that past-me assumed that a '0' ThreadId (AKA: "pick any thread") wouldn't actually be valid in the context of vCont. I assumed this would be reasonable, as why would GDB send over an "ambiguous" thread id, when it could query what threads are live itself, and pick a specific TID (or, at the very least, pass '-1' to resume all threads)?
As such - the current code in the vCont packet parser discards these packets as malformed.
...but if GDB itself is sending over these sorts of packets, then it does seem that gdbstub
will need to be updated to properly handle this.
Hello Daniel: Thank you for your reply! The GDB client I use is not a standalone GDB client, it's part of an IDE named 'Segger Embedded Studio', produced by Segger GmbH. This is not an open-source implementation of GDB client. The software is used for MCU development, debugging etc. The example I provided above was performed on a STM32F1 MCU which has an Arm Cortex-M3 CPU core inside, which runs bare-metal firmware with only one hardware thread. I attached the debugger to the MCU successfully, and I got the error message right after I clicked the 'start run' button.
I currently mitigate this issue by change the source code of 'IdKind::Any => return Err(()),' to 'IdKind::Any => SpecificIdKind::All,' in thread_id.rs line 110 of version 0.7.1
This is not an open-source implementation of GDB client
That certainly raises an eyebrow for me, and makes me think gdbstub
might not be so wrong here after all...
That said - I'm OK with being a bit pragmatic with the implementation, and tweaking gdbstub
to handle this somewhat ambiguous packet in a reasonable manner.
I currently mitigate this issue by change the source code of 'IdKind::Any => return Err(()),' to 'IdKind::Any => SpecificIdKind::All,' in thread_id.rs line 110 of version 0.7.1
This was precisely the workaround I was going to propose, so if this works for you, I'll go ahead and land that in-tree, and push out the fix as part of 0.7.2
@rayc345, I've pushed up a slight variant on the proposed fix to master.
Could you test that this new version works for you? Once you've confirmed the fix, I'll go ahead and publish 0.7.2 to crates.io :)
Thanks Danial. With this patch, the connect problem with Segger Embedded Studio is fixed, thanks. I still have some questions about the implementation of gdbstub, I will open new issues since they are not relevant to this issue.
Thanks for testing!
Marking as closed, via e9a5296
gdbstub 0.7.2 has been published to crates.io, which includes this fix :)
Hello everyone. I used a GDB client to debug a chip using 'probe-rs' which relies on this library for GDB command processing. I found the GDB client not able to run, and issue lies in this library. When GDB client sends out '$vCont;c:0#12', gdbstub library would regard this as a malformed command. But OpenOCD correctly handles this commands and replies '$T05#b9'.
Here is the full GDB communication: