public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Question on RiscV GDB remote protocol command 'T' in all-stop mode
@ 2022-04-07 17:42 Denio, Mike
  0 siblings, 0 replies; only message in thread
From: Denio, Mike @ 2022-04-07 17:42 UTC (permalink / raw)
  To: gdb

I have my GDB server running pretty will in non-stop mode. I have very little use for all-stop mode, other than I was considering using it for a pseudo "lock-step" mode where all my threads start and stop simultaneously. The issue I have is when all threads stop, what thread I should report as stopped?

Here is my inclination:
- Report the "current" thread if it is at a breakpoint
- Else report any other thread that is at a breakpoint
- Else report the "current" thread if nothing at a breakpoint

The issue I have is that I don't have a sure-fire way to know which thread GDB believes to be the current thread. The only 'Hc' command I get is 'Hc-1'. On the vCont, no thread is specified for continue (although there is for step). And finally, I have verified that the most recent 'Hg' does not always match the current thread when 'vCont' is sent.

The only command that seems to work is 'T'. When I swap threads using the thread command in GDB, I get a 'T' command with the current thread number. However, this does not match the definition of the 'T' command, which is "Find out if the thread thread-id is alive".

Below is a snippet of some GBD commands and the resulting server log. You can see that when I do "i threads", GDB puts a little '*' next to thread 3, which is the current thread. The only way for my server to track the current thread is via the 'T' command. Is this a safe way do to it, or is there another way?

Thanks,
Mike

GDB Log:
==================== 
(gdb) tar ext :9999
Remote debugging using :9999
startup () at r5_tests/c_test/boot.S:12
12        lui  x1, 0x70000          // LUI loads upper 20 bits of address (point to virtual DMA)
(gdb) thread 3 
[Switching to thread 3 (Thread 3)]
#0  startup () at r5_tests/c_test/boot.S:14
14        bne  x1, x0, endz         // Jump to IDLE if not core 0
(gdb) c&
Continuing.
(gdb) interrupt
(gdb) 
Thread 3 received signal SIGINT, Interrupt.
startup () at r5_tests/c_test/boot.S:14
14        bne  x1, x0, endz         // Jump to IDLE if not core 0
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
(gdb) 
Thread 3 received signal SIGINT, Interrupt.
startup () at r5_tests/c_test/boot.S:14
14        bne  x1, x0, endz         // Jump to IDLE if not core 0


GDB Remote Server Log:
====================
Bound to port 9999
New connection
'+'                     --->
'qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+' --->
                        <--- '+$hwbreak+;vContSupported+;QStartNoAckMode+;QNonStop+;PacketSize=410#e3'
'+'                     --->
'vMustReplyEmpty'       --->
                        <--- '+$#00'
'+'                     --->
'QStartNoAckMode'       --->
                        <--- '+$OK#9a'
'+'                     --->
'!'                     --->
                        <--- '$OK#9a'
'Hg0'                   --->
                        <--- '$OK#9a'
'QNonStop:0'            --->
                        <--- '$OK#9a'
'qTStatus'              --->
                        <--- '$#00'
'?'                     --->
                        <--- '$T00thread:1;#d2'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'
'qAttached'             --->
                        <--- '$1#31'
'Hc-1'                  --->
                        <--- '$OK#9a'
'qOffsets'              --->
                        <--- '$#00'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'
'qSymbol::'             --->
                        <--- '$OK#9a'
'T3'                    --->
                        <--- '$OK#9a'
'Hg3'                   --->
                        <--- '$OK#9a'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'vCont?'                --->
                        <--- '$vCont;c;C;s;t#83'
'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'                --->
                        <--- '$T02thread:3;#d6'
'g'                     --->
                        <--- '$0000000000000000000000000000000000000000000000000000000000...'
'qfThreadInfo'          --->
                        <--- '$m1,2,3,4#bb'
'qsThreadInfo'          --->
                        <--- '$l#6c'





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-07 17:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 17:42 Question on RiscV GDB remote protocol command 'T' in all-stop mode 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).