This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Cell multi-arch broken (Re: [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter)
- From: Doug Evans <xdje42 at gmail dot com>
- To: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- Cc: palves at redhat dot com (Pedro Alves), gdb-patches at sourceware dot org
- Date: Fri, 18 Sep 2015 23:20:13 -0700
- Subject: Re: Cell multi-arch broken (Re: [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter)
- Authentication-results: sourceware.org; auth=none
- References: <20150826190157 dot EE3D939FA at oc7340732750 dot ibm dot com> <m34mjkexxd dot fsf at sspiff dot org>
Doug Evans <xdje42@gmail.com> writes:
> "Ulrich Weigand" <uweigand@de.ibm.com> writes:
>> Ah, indeed that works for me. The attached patch also fixes the
>> problem for me.
>>
>> Bye,
>> Ulrich
>>
>> Index: binutils-gdb/gdb/linux-thread-db.c
>> ===================================================================
>> --- binutils-gdb.orig/gdb/linux-thread-db.c
>> +++ binutils-gdb/gdb/linux-thread-db.c
>> @@ -1851,13 +1851,16 @@ thread_db_get_thread_local_address (stru
>> struct thread_info *thread_info;
>> struct target_ops *beneath;
>>
>> - /* If we have not discovered any threads yet, check now. */
>> - if (!have_threads (ptid))
>> - thread_db_find_new_threads_1 (ptid);
>> -
>> /* Find the matching thread. */
>> thread_info = find_thread_ptid (ptid);
>>
>> + /* We may not have discovered the thread yet. */
>> + if (thread_info != NULL && thread_info->priv == NULL)
>> + {
>> + thread_from_lwp (ptid);
>> + thread_info = find_thread_ptid (ptid);
>> + }
>> +
>> if (thread_info != NULL && thread_info->priv != NULL)
>> {
>> td_err_e err;
>
> Hi.
>
> Just a thought.
>
> It's kinda clumsy that thread_from_lwp ends with this:
>
> /* Fill the cache. */
> tp = find_thread_ptid (ptid);
> record_thread (info, tp, ptid, &th, &ti);
>
> and then we just call find_thread_ptid again after it returns:
>
>> + thread_from_lwp (ptid);
>> + thread_info = find_thread_ptid (ptid);
>
> One might ask "Why doesn't thread_from_lwp just return thread_info?"
>
> From record_thread things seem to be a be more subtle.
> Even if we pass in a non-NULL TP we may still create a new one.
>
> /* Add the thread to GDB's thread list. If we already know about a
> thread with this PTID, but it's marked exited, then the kernel
> reused the tid of an old thread. */
> if (tp == NULL || tp->state == THREAD_EXITED)
> tp = add_thread_with_info (ptid, priv);
> else
> tp->priv = priv;
>
> So it'd be helpful if record_thread also returned tp.
> Sound about right?
>
> 2015-08-27 Doug Evans <xdje42@gmail.com>
>
> * linux-thread-db.c (record_thread): Return the created thread.
> (thread_from_lwp): Likewise.
> (thread_db_get_thread_local_address): Update.
Committed.