Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Doug Evans <dje@google.com>
Cc: Michael Snyder <msnyder@vmware.com>,
	        "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [patch] Fix for gdb.threads/staticthreads.exp failure on Linux
Date: Thu, 16 Jul 2009 20:45:00 -0000	[thread overview]
Message-ID: <8ac60eac0907161248yf46afa8o2abe3b36d0f6d599@mail.gmail.com> (raw)
In-Reply-To: <e394668d0907151825t12283c66rc1856a242d50332a@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2276 bytes --]

On Wed, Jul 15, 2009 at 6:25 PM, Doug Evans<dje@google.com> wrote:

> I like the patch. If thread enumeration fails during
> try_thread_db_load_1 we ignore it and leave gdb to try again later.
> When we get to this point we've already verified libthread_db is
> (mostly) happy.
> I kinda wonder, though, if that works then maybe gdb shouldn't do
> thread enumeration at all here.

There is the 'attach' scenario under which (I believe) we *should* do
thread enumeration here.

> I think a comment needs to be added to your patch, probably to the
> call site of thread_db_find_new_threads_silently, that thoroughly
> explains what's going on (assuming that's still the best solution).

Added.

> btw, the reason for the 1 known failure is, I'm guessing, because gdb
> was built with the same toolchain that uses the older glibc, but the
> test was run using a native toolchain that uses a newer glibc and the
> mismatch is sufficient to trigger the failure.  At least that explains
> things in my sandbox.  If I rebuild gdb with native gcc, or set
> libthread-db-search-path to find the newer glibc, the kfail goes away.

When gdb is built with native toolchain (glibc-2.7) and the test is built
with the same, then there is no failure.

When gdb is built with native toolchain, but the test is built against
glibc-2.3.6, I see one KFAIL.

When both gdb and the test are built against glibc-2.3.6, I see this:

FAIL: gdb.threads/staticthreads.exp: running to main in runto
FAIL: gdb.threads/staticthreads.exp: Continue to main's call of sem_post
FAIL: gdb.threads/staticthreads.exp: handle SIG32 helps

# of expected passes            6
# of unexpected failures        3
# of known failures             1

When gdb is built against glibc-2.3.6, but test with glibc-2.7, I see
one KFAIL.

I've retested attached patch under all four combinations above, which
results in:

gdb-glibc-2.7   test-glibc-2.7:   no failures
gdb-glibc-2.7   test-glibc-2.3.6: KFAIL:
gdb.threads/staticthreads.exp: info threads (PRMS: gdb/1328)
gdb-glibc-2.3.6 test-glibc-2.3.6: no failures
gdb-glibc-2.3.6 test-glibc-2.7:   KFAIL:
gdb.threads/staticthreads.exp: info threads (PRMS: gdb/1328)

and checked this in.

Thanks,
-- 
Paul Pluzhnikov

[-- Attachment #2: gdb-staticthreads-20090716.txt --]
[-- Type: text/plain, Size: 1495 bytes --]

Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.62
diff -u -p -u -r1.62 linux-thread-db.c
--- linux-thread-db.c	2 Jul 2009 17:12:25 -0000	1.62
+++ linux-thread-db.c	16 Jul 2009 19:40:07 -0000
@@ -588,6 +588,25 @@ enable_thread_event_reporting (void)
     }
 }
 
+/* Same as thread_db_find_new_threads_1, but silently ignore errors.  */
+
+static void
+thread_db_find_new_threads_silently (ptid_t ptid)
+{
+  volatile struct gdb_exception except;
+
+  TRY_CATCH (except, RETURN_MASK_ERROR)
+    {
+      thread_db_find_new_threads_1 (ptid);
+    }
+
+  if (except.reason < 0 && info_verbose)
+  {
+    exception_fprintf (gdb_stderr, except,
+                       "Warning: thread_db_find_new_threads_silently: ");
+  }
+}
+
 /* Lookup a library in which given symbol resides.
    Note: this is looking in GDB process, not in the inferior.
    Returns library name, or NULL.  */
@@ -705,7 +724,13 @@ try_thread_db_load_1 (struct thread_db_i
     push_target (&thread_db_ops);
 
   enable_thread_event_reporting ();
-  thread_db_find_new_threads_1 (inferior_ptid);
+
+  /* There appears to be a bug glibc-2.3.6: call to td_thr_get_info fails
+     with TD_ERR for statically linked executables if td_thr_get_info is
+     called before glibc has initialized itself.  Silently ignore such
+     errors.  */
+
+  thread_db_find_new_threads_silently (inferior_ptid);
   return 1;
 }
 

  parent reply	other threads:[~2009-07-16 19:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-05 22:22 Paul Pluzhnikov
2009-06-15 18:39 ` Paul Pluzhnikov
2009-06-22 16:10   ` Paul Pluzhnikov
2009-06-22 18:10     ` Michael Snyder
2009-06-22 20:21       ` Paul Pluzhnikov
2009-06-29 14:36         ` Paul Pluzhnikov
2009-07-09  6:36           ` Paul Pluzhnikov
2009-07-16  2:42         ` Doug Evans
2009-07-16  2:43           ` Doug Evans
2009-07-16 20:45           ` Paul Pluzhnikov [this message]
2009-07-16 20:54             ` Paul Pluzhnikov
2009-07-16 21:16             ` Doug Evans

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=8ac60eac0907161248yf46afa8o2abe3b36d0f6d599@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=msnyder@vmware.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