public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* RiscV GDB remote protocol seems to expect stop reply to change Hg in all-stop mode
@ 2022-04-08 15:36 Denio, Mike
  2022-04-08 21:41 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Denio, Mike @ 2022-04-08 15:36 UTC (permalink / raw)
  To: gdb

I noticed that in all stop mode, GDB expects the current Hg thread to be changed to the thread reported in the stop reply message, without sending an Hg command. This can most easily be seen by using the "i threads" command. GDB will read the registers of each (non-current) thread using 'Hg' / 'g', so it can display the PC location in the threads list. However, after a stop message, GDB appears to assume that the Hg thread is set to the current thread, even though it changed the Hg thread during 'i threads'. I could not find where this was documented.

The 'fix' for me was to assume both Hg and Hc are auto-changed to whatever thread is reported in the stop reply when in all-stop mode.

Here is an example (reusing it from my other e-mail question):

(gdb) thread 3 
[Switching to thread 3 (Thread 3)]
 (gdb) c&
Continuing.
(gdb) interrupt
Thread 3 received signal SIGINT, Interrupt.
 (gdb)  i threads
  Id   Target Id                 Frame 
  1    Thread 1 (ACTIVE) startup () at r5_tests/c_test/boot.S:12
  2    Thread 2 (ACTIVE) startup () at r5_tests/c_test/boot.S:13
* 3    Thread 3 (ACTIVE) startup () at r5_tests/c_test/boot.S:14
  4    Thread 4 (ACTIVE) startup () at r5_tests/c_test/boot.S:15
(gdb) c&
Continuing.
(gdb) interrupt
Thread 3 received signal SIGINT, Interrupt.


GDB Remote Server Log:
====================

// When I first swap to thread 3, GDB first sends 'T3'
'T3'                    --->
                        <--- '$OK#9a'
// Then GDB sends 'Hg3' so it can read the registers
'Hg3'                   --->
                        <--- '$OK#9a'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'vCont;c'               --->
'Ctrl-C'                --->
                        <--- '$T02thread:3;#d6'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'
'qThreadExtraInfo,1'    --->
                        <--- '$414354495645#a9'
'qThreadExtraInfo,2'    --->
                        <--- '$414354495645#aa'
'qThreadExtraInfo,3'    --->
                        <--- '$414354495645#ab'
'qThreadExtraInfo,4'    --->
                        <--- '$414354495645#ac'
'Hg1'                   --->
                        <--- '$OK#9a'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'Hg2'                   --->
                        <--- '$OK#9a'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'Hg4'                   --->
                        <--- '$OK#9a'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'vCont;c'               --->
'Ctrl-C'                --->
// Here the server stops again on thread 3. Since GDB's current thread is 3, it does not swap threads
                        <--- '$T02thread:3;#d6'
// Here GDB is attempting to read the registers for thread 3, but the last Hg sent out was Hg4
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-08 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 15:36 RiscV GDB remote protocol seems to expect stop reply to change Hg in all-stop mode Denio, Mike
2022-04-08 21:41 ` Pedro Alves
2022-04-08 21:56   ` [EXTERNAL] " Denio, Mike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).