- Fix gdbserver for threaded applications and recent glibc (BZ 328021).

This commit is contained in:
Jan Kratochvil 2007-10-12 09:20:08 +00:00
parent 7969725ab1
commit 84f82bf43b
2 changed files with 85 additions and 1 deletions

View File

@ -1163,3 +1163,84 @@ http://sourceware.org/ml/binutils/2007-08/msg00296.html
:
else
MAKEINFO="$MISSING makeinfo"
https://bugzilla.redhat.com/show_bug.cgi?id=328021
2007-06-27 Daniel Jacobowitz <dan@codesourcery.com>
* thread-db.c (thread_db_find_new_threads): Add prototype.
(thread_db_create_event): Check for the main thread before adding
a new thread.
(maybe_attach_thread): Only enable event reporting if TID == 0.
(thread_db_get_tls_address): Check for new threads.
--- ./gdb/gdbserver/thread-db.c 9 Jan 2007 17:59:08 -0000 1.9
+++ ./gdb/gdbserver/thread-db.c 27 Jun 2007 11:52:02 -0000 1.10
@@ -41,6 +41,7 @@ static struct ps_prochandle proc_handle;
/* Connection to the libthread_db library. */
static td_thragent_t *thread_agent;
+static void thread_db_find_new_threads (void);
static int find_new_threads_callback (const td_thrhandle_t *th_p, void *data);
static char *
@@ -135,6 +136,8 @@ thread_db_create_event (CORE_ADDR where)
td_event_msg_t msg;
td_err_e err;
struct inferior_linux_data *tdata;
+ struct thread_info *inferior;
+ struct process_info *process;
if (debug_threads)
fprintf (stderr, "Thread creation event.\n");
@@ -150,6 +153,14 @@ thread_db_create_event (CORE_ADDR where)
fprintf (stderr, "thread getmsg err: %s\n",
thread_db_err_str (err));
+ /* If we do not know about the main thread yet, this would be a good time to
+ find it. We need to do this to pick up the main thread before any newly
+ created threads. */
+ inferior = (struct thread_info *) all_threads.head;
+ process = get_thread_process (inferior);
+ if (process->thread_known == 0)
+ thread_db_find_new_threads ();
+
/* msg.event == TD_EVENT_CREATE */
find_new_threads_callback (msg.th_p, NULL);
@@ -232,8 +243,24 @@ maybe_attach_thread (const td_thrhandle_
{
inferior = (struct thread_info *) all_threads.head;
process = get_thread_process (inferior);
+
if (process->thread_known == 0)
{
+ /* If the new thread ID is zero, a final thread ID will be
+ available later. Do not enable thread debugging yet. */
+ if (ti_p->ti_tid == 0)
+ {
+ err = td_thr_event_enable (th_p, 1);
+ if (err != TD_OK)
+ error ("Cannot enable thread event reporting for %d: %s",
+ ti_p->ti_lid, thread_db_err_str (err));
+ return;
+ }
+
+ if (process->lwpid != ti_p->ti_lid)
+ fatal ("PID mismatch! Expected %ld, got %ld",
+ (long) process->lwpid, (long) ti_p->ti_lid);
+
/* Switch to indexing the threads list by TID. */
change_inferior_id (&all_threads, ti_p->ti_tid);
goto found;
@@ -332,6 +359,8 @@ thread_db_get_tls_address (struct thread
process = get_thread_process (thread);
if (!process->thread_known)
+ thread_db_find_new_threads ();
+ if (!process->thread_known)
return TD_NOTHR;
/* Note the cast through uintptr_t: this interface only works if

View File

@ -11,7 +11,7 @@ Name: gdb
Version: 6.6
# The release always contains a leading reserved number, start it at 1.
Release: 33%{?dist}
Release: 34%{?dist}
License: GPL
Group: Development/Debuggers
@ -697,6 +697,9 @@ fi
# don't include the files in include, they are part of binutils
%changelog
* Fri Oct 12 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-34
- Fix gdbserver for threaded applications and recent glibc (BZ 328021).
* Tue Oct 9 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.6-33
- Fix debug load for sparse assembler files (such as vDSO32 for i386-on-x86_64).