This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [Fwd: Re: [Fwd: Re: gdb/725: Crash using debug target and regcaches (in 5.3 branch?)]]
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>
- Cc: Mark Kettenis <kettenis at chello dot nl>, msnyder at redhat dot com,gdb-patches at sources dot redhat dot com
- Date: Tue, 3 Dec 2002 14:33:22 -0500
- Subject: Re: [Fwd: Re: [Fwd: Re: gdb/725: Crash using debug target and regcaches (in 5.3 branch?)]]
- References: <3DE3F135.6030605@redhat.com> <3DE53144.3020502@redhat.com> <200211301613.gAUGDInq000267@elgar.kettenis.dyndns.org> <3DE8E9F8.5000902@redhat.com> <3DECE58A.6090001@redhat.com> <20021203171926.GA10631@nevyn.them.org> <3DED03F1.6070601@redhat.com>
On Tue, Dec 03, 2002 at 02:20:17PM -0500, Andrew Cagney wrote:
>
> >>Er, no I wont :-(
> >>
> >>The attached is the refind patch. I added the comment:
> >>
> >>+ /* NOTE: cagney/2002-12-02: This assumes that the target code can
> >>+ directly transfer the register values into the register cache.
> >>+ This works fine when there is a 1:1 mapping between light weight
> >>+ process (LWP) (a.k.a. process on GNU/Linux) and the thread. On
> >>+ an N:1 (user-land threads), or N:M (combination of user-land and
> >>+ LWP threading), this does not work. An LWP can be sitting in the
> >>+ thread context switch code and hence, the LWP's registers belong
> >>+ to no thread. */
> >
> >
> >First of all, this comment is wrong.
>
> Why?
>
> The code is assuming that the LWP registers belong to the currently
> selected thread's regcache. That is a pretty scary assumption.
>
> [I'll use that wording]
It's not an assumption at this point. proc-service.c:230 to
thread_db_fetch_registers is the only path into lin_lwp_fetch_registers.
And that does:
inferior_ptid = BUILD_LWP (lwpid, ph->pid);
So at this point we _know_ that the thread we're querying has its
registers in the LWP. That's the whole point.
>
> > I think we're miscommunicating
> >on what the patch does. At this point the fetch_inferior_registers
> >code has an inferior_ptid which looks like this:
> > PID = pid, LWPID = 0, TID = 0
> >or
> > PID = pid, LWPID = otherpid, TID = 0
>
> >Don't get confused by the use of TIDGET. Look at the definition of
> >TIDGET; it gets the _LWP_ id. This's a search and destroy candidate if
> >I ever saw one.
>
> I'll add that.
>
> >Some upper layer has already taken the TID, mapped it to an LWP id, and
> >is asking for that LWP's registers by the time we get here. So the LWP
> >is known to belong to the thread we are querying.
>
>
> >>however, with the patch applied, I see (and consistently, well 2 out of
> >>2, which is pretty amasing for the thread testsuite) the new failure:
> >>
> >>
> >>gdb.threads/killed.exp: GDB exits after multi-threaded program exits
> >>messily
> >>
> >>looking at the log file:
> >>
> >>(gdb) run
> >>Starting program: /home/cagney/gdb/native/gdb/testsuite/gdb.threads/killed
> >>[New Thread 1024 (LWP 6831)]
> >>[New Thread 2049 (LWP 6832)]
> >>[New Thread 1026 (LWP 6833)]
> >>Cannot find user-level thread for LWP 6833: generic error
> >>(gdb) PASS: gdb.threads/killed.exp: run program to completion
> >>quit
> >>The program is running. Exit anyway? (y or n) y
> >>Cannot find thread 2049: generic error
> >>(gdb) FAIL: gdb.threads/killed.exp: GDB exits after multi-threaded
> >>program exits
> >> messily (gdb/568)
> >>
> >>Which doesn't occure when the patch isn't applied.
> >
> >
> >Are you sure about this last bit? I see this failure even without the
> >patch, on an i386 SMP system. I just checked it moments ago.
>
> Yes. Not on an SMP machine though.
According to Michael it already shows up in all of his configurations
in current CVS... I see the same thing here. It's a little timing
sensitive, I don't know why it didn't show up beforehand for you.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer