Replies: 2 comments 1 reply
-
GDB supports this by adding a SIGIO handler. But I don't know how to implement this in Rust😅 |
Beta Was this translation helpful? Give feedback.
-
I don't think the snippet of code you've offered has enough context for me to answer your question, since as per the docs:
...and in your case, that selection mechanism is happening in your implementation of I don't know how you're using that function to poll for incoming data. In my examples - I run my emulator for some number of cycles and then invoke that callbacks, but you might be doing something else - I'm not sure. @bet4it has suggested another interesting mechanism to accomplish this that I didn't point out via the docs (namely: using a SIGIO handler), and indeed, that approach could certainly be implemented in Rust (e.g: using something like https://docs.rs/signal-hook/latest/signal_hook/, plus some additional safe/unsafe code to do the Ultimately, you'll have to decide which approach is best suited for your application. Polling is "easy", but if you're running the target on the same thread as your server, you're going to need to periodically pause in order to check the socket. If you don't want to do this, you'll need to restructure your code appropriately. |
Beta Was this translation helpful? Give feedback.
-
My problem:
I'm running the gdbstub with a full implementation, and sending Ctrl+C. While the gdbstub is in the Idle state the polling does a blocking read and successfully reads data, and registers the interrupt packet is sent.
If the gdbstub is currently running, the custom peek sets the socket to non blocking and never successfully reads data from the socket. The moment it hit a breakpoint and stops (artificially added one that triggers at 20ish seconds into a spin loop), the gdbstub goes into the idle state and successfully reads bytes from the socket.
I'm on 18.04 Ubuntu, so there shouldn't be anything super exotic at play, any ideas on how to get the gdbstub peek to return any data while in the running state?
EDIT:
Tomorrow going to just provide a timeout to a blocking read and try every n cycles. But obviously this is going to slow things down
Relevant code snippet: basically copied from examples.
Beta Was this translation helpful? Give feedback.
All reactions