From: "Denio, Mike" <miked@ti.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: RiscV GDB remote protocol seems to expect stop reply to change Hg in all-stop mode
Date: Fri, 8 Apr 2022 15:36:27 +0000 [thread overview]
Message-ID: <f29bbaba8a5048f68b708fd739b1d2f3@ti.com> (raw)
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'
next reply other threads:[~2022-04-08 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-08 15:36 Denio, Mike [this message]
2022-04-08 21:41 ` Pedro Alves
2022-04-08 21:56 ` [EXTERNAL] " Denio, Mike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f29bbaba8a5048f68b708fd739b1d2f3@ti.com \
--to=miked@ti.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).