From: Doug Evans <dje@google.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Only try to load libthread_db when we load libpthread.
Date: Mon, 10 Oct 2011 05:01:00 -0000 [thread overview]
Message-ID: <CADPb22R8Czx79tGM1QLNQBrPOmg+dCwjRp5PPn4yi_J6pfW4Mw@mail.gmail.com> (raw)
In-Reply-To: <201110071209.18376.pedro@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 1544 bytes --]
On Fri, Oct 7, 2011 at 4:09 AM, Pedro Alves <pedro@codesourcery.com> wrote:
> Well, at least things should work the same as before, which IMO
> is good thing as it makes this change an optimization only.
That's the intent.
>> Blech, I forgot one bit of cleanup.
>> Revised patch attached.
>
> Still breaks activating thread_db when debugging cores of
> static executables.
Used wrong sandbox for the before case, sigh.
[...]
> Did you try this suggestion?:
>
>> I think we'll no longer activate thread_db when debugging core
>> files of static executables (e.g., a core of gdb.threads/staticthreads).
>> It works with live debugging since we call check_for_thread_db
>> from linux_child_post_attach/linux_child_post_startup_inferior.
>> Maybe moving that to an inferior_created observer in
>> linux-thread-db.c would work.
It turns out things work today accidentally.
At least I doubt it's by design. :-)
My previous patch didn't work because it skipped calling
check_for_thread_db when the new_objfile observer was called for
vsyscall (which incidentally is called by the inferior_created
observer for vsyscall, heh).
[Which explains why it didn't surprise me when my before-test failed,
that's a pretty unexpected way to load libthread_db.]
How about this.
2011-10-09 Doug Evans <dje@google.com>
* linux-thread-db.c (thread_db_new_objfile): Only try to load
libthread_db when we load libpthread.
(thread_db_inferior_created): New function.
(_initialize_thread_db): Attach inferior_created observer.
[-- Attachment #2: gdb-111009-libthread-db-4.patch.txt --]
[-- Type: text/plain, Size: 2129 bytes --]
2011-10-09 Doug Evans <dje@google.com>
* linux-thread-db.c (thread_db_new_objfile): Only try to load
libthread_db when we load libpthread.
(thread_db_inferior_created): New function.
(_initialize_thread_db): Attach inferior_created observer.
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.91
diff -u -p -r1.91 linux-thread-db.c
--- linux-thread-db.c 13 Sep 2011 19:27:01 -0000 1.91
+++ linux-thread-db.c 10 Oct 2011 03:52:27 -0000
@@ -1077,16 +1077,32 @@ check_for_thread_db (void)
return;
}
+/* This function is called via the new_objfile observer. */
+
static void
thread_db_new_objfile (struct objfile *objfile)
{
/* This observer must always be called with inferior_ptid set
correctly. */
- if (objfile != NULL)
+ if (objfile != NULL
+ /* Only check for thread_db if we loaded libpthread.
+ For dynamically linked executables, libpthread can be near the end
+ of the list of shared libraries to load, and in an app of several
+ thousand shared libraries, this can otherwise be painful. */
+ && libpthread_name_p (objfile->name))
check_for_thread_db ();
}
+/* This function is called via the inferior_created observer.
+ This handles the case of debugging statically linked executables. */
+
+static void
+thread_db_inferior_created (struct target_ops *target, int from_tty)
+{
+ check_for_thread_db ();
+}
+
/* Attach to a new thread. This function is called when we receive a
TD_CREATE event or when we iterate over all threads and find one
that wasn't already in our list. Returns true on success. */
@@ -1845,4 +1861,9 @@ When non-zero, libthread-db debugging is
/* Add ourselves to objfile event chain. */
observer_attach_new_objfile (thread_db_new_objfile);
+
+ /* Add ourselves to inferior_created event chain.
+ This is needed to handle debugging statically linked programs where
+ the new_objfile observer won't get called for libpthread. */
+ observer_attach_inferior_created (thread_db_inferior_created);
}
next prev parent reply other threads:[~2011-10-10 5:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-05 18:27 Doug Evans
2011-10-06 11:22 ` Pedro Alves
2011-10-06 19:56 ` Pedro Alves
2011-10-06 20:08 ` Doug Evans
2011-10-06 20:26 ` Pedro Alves
2011-10-06 21:56 ` Doug Evans
2011-10-06 22:06 ` Doug Evans
2011-10-07 11:09 ` Pedro Alves
2011-10-10 5:01 ` Doug Evans [this message]
2011-10-10 18:23 ` Pedro Alves
2011-10-11 3:38 ` 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=CADPb22R8Czx79tGM1QLNQBrPOmg+dCwjRp5PPn4yi_J6pfW4Mw@mail.gmail.com \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.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