From: Doug Evans <xdje42@gmail.com>
To: "Ulrich Weigand" <uweigand@de.ibm.com>, palves@redhat.com (Pedro Alves)
Cc: gdb-patches@sourceware.org
Subject: Re: Cell multi-arch broken (Re: [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter)
Date: Fri, 28 Aug 2015 06:21:00 -0000 [thread overview]
Message-ID: <m34mjkexxd.fsf@sspiff.org> (raw)
In-Reply-To: <20150826190157.EE3D939FA@oc7340732750.ibm.com> (Ulrich Weigand's message of "Wed, 26 Aug 2015 21:01:57 +0200 (CEST)")
"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.
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 855629b..b5719eb 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -198,10 +198,9 @@ static void thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new);
static void check_thread_signals (void);
-static void record_thread (struct thread_db_info *info,
- struct thread_info *tp,
- ptid_t ptid, const td_thrhandle_t *th_p,
- const td_thrinfo_t *ti_p);
+static struct thread_info *record_thread
+ (struct thread_db_info *info, struct thread_info *tp,
+ ptid_t ptid, const td_thrhandle_t *th_p, const td_thrinfo_t *ti_p);
/* Add the current inferior to the list of processes using libpthread.
Return a pointer to the newly allocated object that was added to
@@ -386,7 +385,7 @@ have_threads (ptid_t ptid)
\f
/* Fetch the user-level thread id of PTID. */
-static void
+static struct thread_info *
thread_from_lwp (ptid_t ptid)
{
td_thrhandle_t th;
@@ -419,7 +418,7 @@ thread_from_lwp (ptid_t ptid)
/* Fill the cache. */
tp = find_thread_ptid (ptid);
- record_thread (info, tp, ptid, &th, &ti);
+ return record_thread (info, tp, ptid, &th, &ti);
}
\f
@@ -1287,10 +1286,10 @@ attach_thread (ptid_t ptid, const td_thrhandle_t *th_p,
}
/* Record a new thread in GDB's thread list. Creates the thread's
- private info. If TP is NULL, creates a new thread. Otherwise,
- uses TP. */
+ private info. If TP is NULL or TP is marked as having exited,
+ creates a new thread. Otherwise, uses TP. */
-static void
+static struct thread_info *
record_thread (struct thread_db_info *info,
struct thread_info *tp,
ptid_t ptid, const td_thrhandle_t *th_p,
@@ -1304,7 +1303,7 @@ record_thread (struct thread_db_info *info,
initialized yet. Leave private == NULL until the thread library
has initialized. */
if (ti_p->ti_tid == 0)
- return;
+ return tp;
/* Construct the thread's private data. */
priv = XCNEW (struct private_thread_info);
@@ -1333,6 +1332,8 @@ record_thread (struct thread_db_info *info,
if (target_has_execution)
check_thread_signals ();
+
+ return tp;
}
static void
@@ -1854,10 +1855,7 @@ thread_db_get_thread_local_address (struct target_ops *ops,
/* 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);
- }
+ thread_info = thread_from_lwp (ptid);
if (thread_info != NULL && thread_info->priv != NULL)
{
next prev parent reply other threads:[~2015-08-28 6:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-08 19:11 [PATCH 0/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter Pedro Alves
2015-02-08 19:11 ` [PATCH 1/2] linux-nat.c: fix a few lin_lwp_attach_lwp issues Pedro Alves
2015-02-08 19:11 ` [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter Pedro Alves
2015-08-26 17:39 ` Cell multi-arch broken (Re: [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter) Ulrich Weigand
2015-08-26 18:23 ` Pedro Alves
2015-08-26 19:02 ` Ulrich Weigand
2015-08-26 19:42 ` Pedro Alves
2015-08-27 17:40 ` Ulrich Weigand
2015-08-28 6:21 ` Doug Evans [this message]
2015-08-28 13:11 ` Ulrich Weigand
2015-09-08 10:31 ` Pedro Alves
2015-09-19 6:21 ` Doug Evans
2015-02-20 21:46 ` [PATCH 0/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m34mjkexxd.fsf@sspiff.org \
--to=xdje42@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=uweigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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