public inbox for
 help / color / mirror / Atom feed
From: Adrian Oltean <>
To: Pedro Alves <>, Tom Tromey <>
Cc: Adrian Oltean via Gdb <>
Subject: RE: [EXT] Re: Semihosting in GDB 11.1 | Proposed patch for interrupting in sync mode
Date: Thu, 10 Mar 2022 10:02:58 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Hi guys,

Unfortunately, my knowledge on GDB's internals is quite limited... I'm leaving below two old mail threads, [1] and [2],
that describe the GDB's behavior in a custom use case and what makes it difficult to handle when target-async
is enabled. GDB 8.3 is referred in those threads but behavior is mostly the same in GDB 11.1. The key is the execution
of post_event("cont").

As far as 'H' packet handling is concerned, note that the GDB server I'm referring is a proprietary implementation
that is used for JTAG debugging. Threads are numbered from 1. However, in the old implementation "Hg0" was always
switching to thread 1 ("first thread") internally, even though some other core/thread was suspended. The original
implementation assumed "Hg0" must *always* switch to "first thread" (thread 1 in my case) but this doesn't seem
to be enforced in the RSP specs. I updated the code and assimilate "arbitrary" (from spec) as "if there's no suspended
thread/core internally selected, find a valid one".

Thank you,


-----Original Message-----
From: Pedro Alves <> 
Sent: Thursday, March 10, 2022 11:48 AM
To: Tom Tromey <>; Adrian Oltean <>
Cc: Adrian Oltean via Gdb <>
Subject: [EXT] Re: Semihosting in GDB 11.1 | Proposed patch for interrupting in sync mode

Caution: EXT Email

On 2022-03-09 19:49, Tom Tromey wrote:
> Adrian> Unfortunately, I could not find ways to adapt all the other 
> Adrian> components I have around GDB to 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.

  reply	other threads:[~2022-03-10 10:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09  7:25 Adrian Oltean
2022-03-09 19:49 ` Tom Tromey
2022-03-10  9:47   ` Pedro Alves
2022-03-10 10:02     ` Adrian Oltean [this message]
2022-03-10 11:30       ` [EXT] " Pedro Alves
2022-03-10 12:32         ` Pedro Alves
2022-03-14  7:33           ` Adrian Oltean
2022-03-17 17:48             ` Pedro Alves

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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).