Semihosting in GDB 11.1 | Proposed patch for interrupting in sync mode

Pedro Alves pedro@palves.net
Thu Mar 10 09:47:48 GMT 2022


On 2022-03-09 19:49, Tom Tromey wrote:
> Adrian> Unfortunately, I could not find ways to adapt all the other components I have around GDB to 
> Adrian> work with target-async mode enabled. It is what it is...
> 
> I'm a little lost about this, because my mental model is that target
> async shouldn't really change anything.  I think it is just an
> implementation detail about where gdb waits for events -- is it in
> wait() or in select()?
> 
> So, it would be interesting to learn what the differences are.  Perhaps
> this can be patched up.
> 
> Adrian> Regarding the 'H' packet, I had a second look in the RSP specs
> Adrian> where it's stated that '0' indicates an arbitrary
> Adrian> process/thread. So, as you mentioned, I changed the GDB server
> Adrian> code to simply ensure there's a valid thread stopped marked as
> Adrian> 'current'. The original implementation incorrectly assimilated
> Adrian> '0' with 'first thread' (always).
> 
> I'm a little surprised this matters as well, but anyway I think it's
> fine to submit a patch like this.  Maybe others have some idea of what's
> going on.

I'm not sure that I get what Adrian is callilng "first thread", but I take
it to mean that the server was numbering threads starting at "0".
But, in the RSP, you can't use '0' as thread id, as it has a special meaning.
I.e., if the server is numbering threads like, 0,1,2,3,... then it will
run into problems, because when GDB says "Hg0", it doesn't mean "select
the first thread, the one with id "0".  The typical fix is to just start
numbering threads at 1 instead of 0, for example.


More information about the Gdb mailing list