This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Q: mutlithreaded tracees && clone/exit

> Yes, but this doesn't necessarily mean gdbserver can forget its exit
> code (or some internal state), I do not see anything about this in docs.

It means that any protocol requirement about this would almost certainly be
broken, if there were one.  It couldn't be implemented robustly.

> > It's not really clear to me when gdb decides to ask for the thread
> > list.
> Never in my (limited) testing.

It clearly does have paths to do it in the code.
So we need gdb folks to clarify how those are reached.

> > > Q2: Shouldn't gdbstub let debugger know about sub-threads somehow?
> >
> > That's what I would expect in the abstract.  But I know that gdb
> > didn't used to get new-thread notifications from ptrace either.  It
> > looks like the linux-nat code does track PTRACE_EVENT_CLONE now.
> > But it may be that the gdbserver code and remote protocol were made
> > to match how things were when the native ptrace case didn't do that.
> gdbserver tracks PTRACE_EVENT_CLONE, yes. But it doesn't inform gdb.

I was talking about the non-remote gdb code, not gdbserver.
gdbserver does attach new threads implicitly, but indeed that is
only noticed by gdb if a new thread happens to hit a signal
(breakpoint or whatever).

> I have already looked at this code in horror. I really hope this magic
> is not needed for our purposes.
> It is gdbserver, not gdb, who uses libthread_db to find sub-threads and
> do other things.

Again, I was talking about what gdb does in the non-remote case.
AFAIK, it does the same stuff on top of the remote layer too, but
I'm not sure about that.

> OK, so far it is not clear to me what should we do. If nothing else,
> I can replicate the gdbserver's behaviour. But imho it makes sense to
> do something more clever.

We need some more feedback from the gdb folks.

> However, there is the complication I already mentioned. If the main
> thread exits, this confuses gdbserver at least. It sends the "$T05"
> packets to gdb, then eventually gdb does vCont;c:pTGID.-1 and gdbserver
> doesn't work. It doesn't resume sub-threads, doesn't react to ^C, etc.
> I guess, gdbserver shouldn't send '$W' packet in this case, this can
> confuse gdb (but I didn't verify this yet). OTOH, it is not clear if
> gdbserver can delay this notification until all threads exit. Say,
> what should gdbserver do if gdb sends a private signal to the exited
> main thread? Or do something else which assumes it alive.

Yes, it's not clear what is intended or would be right here.
The X/W packets are documented as talking about "the process".
Perhaps some new flavors of notification packets are needed to
distinguish thread-granularity events from process-granularity.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]