[Fwd: Re: [Fwd: Re: gdb/725: Crash using debug target and regcaches (in 5.3 branch?)]]
Andrew Cagney
ac131313@redhat.com
Tue Dec 3 11:20:00 GMT 2002
>> 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]
> 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.
Andrew
More information about the Gdb-patches
mailing list