Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: teawater <teawater@gmail.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [RFA] Output a warning when inferior load in a stripped libpthread.so  	make multi-thread debug not ok
Date: Wed, 11 Feb 2009 08:29:00 -0000	[thread overview]
Message-ID: <daef60380902110029s15874c26h839aa6224980de11@mail.gmail.com> (raw)

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

Hi,

I met a lot of people that have trouble with GDB multithread debug
just because their libpthread.so is stripped.
So I make a patch to output a warning when the libpthread.so is stripped.

2009-02-11  Hui Zhu  <teawater@gmail.com>

	* linux-thread-db.c (LIBPTHREAD_SO): New macro for
	the name of libpthread.
	(check_for_thread_db): Add a argument "objfile".
	If td_ta_new_p return TD_NOLIBTHREAD
	and "objfile->obfd->filename" include LIBPTHREAD_SO,
	output a warning.
	(thread_db_new_objfile): Add a argument "objfile" to
	"check_for_thread_db".
	* linux-nat.h (check_for_thread_db): Ditto.
	* linux-nat.c (linux_child_post_attach): Ditto.
	(linux_child_post_startup_inferior): Ditto.
	(linux_child_follow_fork): Ditto.


OK to in?


Thanks,
Hui

[-- Attachment #2: linux-thread-db-warning.txt --]
[-- Type: text/plain, Size: 2470 bytes --]

---
 linux-nat.c       |    6 +++---
 linux-nat.h       |    2 +-
 linux-thread-db.c |   14 ++++++++++++--
 3 files changed, 16 insertions(+), 6 deletions(-)

--- a/linux-nat.c
+++ b/linux-nat.c
@@ -683,14 +683,14 @@ static void
 linux_child_post_attach (int pid)
 {
   linux_enable_event_reporting (pid_to_ptid (pid));
-  check_for_thread_db ();
+  check_for_thread_db (NULL);
 }
 
 static void
 linux_child_post_startup_inferior (ptid_t ptid)
 {
   linux_enable_event_reporting (ptid);
-  check_for_thread_db ();
+  check_for_thread_db (NULL);
 }
 
 static int
@@ -891,7 +891,7 @@ linux_child_follow_fork (struct target_o
       inferior_ptid = ptid_build (child_pid, child_pid, 0);
 
       linux_nat_switch_fork (inferior_ptid);
-      check_for_thread_db ();
+      check_for_thread_db (NULL);
 
       tp = inferior_thread ();
       tp->step_resume_breakpoint = step_resume_breakpoint;
--- a/linux-nat.h
+++ b/linux-nat.h
@@ -92,7 +92,7 @@ extern struct lwp_info *lwp_list;
 #define BUILD_LWP(lwp, pid)	ptid_build (pid, lwp, 0)
 
 /* Attempt to initialize libthread_db.  */
-void check_for_thread_db (void);
+void check_for_thread_db (struct objfile *objfile);
 
 int thread_db_attach_lwp (ptid_t ptid);
 
--- a/linux-thread-db.c
+++ b/linux-thread-db.c
@@ -48,6 +48,8 @@
 #define LIBTHREAD_DB_SO "libthread_db.so.1"
 #endif
 
+#define LIBPTHREAD_SO	"libpthread.so"
+
 /* GNU/Linux libthread_db support.
 
    libthread_db is a library, provided along with libpthread.so, which
@@ -590,7 +592,7 @@ check_thread_signals (void)
    and when new shared libraries are loaded into a running process.  */
 
 void
-check_for_thread_db (void)
+check_for_thread_db (struct objfile *objfile)
 {
   td_err_e err;
   static int already_loaded;
@@ -645,6 +647,14 @@ check_for_thread_db (void)
     {
     case TD_NOLIBTHREAD:
       /* No thread library was detected.  */
+      if (objfile && objfile->obfd && objfile->obfd->filename)
+        {
+	  if (strstr(objfile->obfd->filename, LIBPTHREAD_SO))
+	    warning (_("Your %s has been stripped.\n"
+		       "GDB will not see other threads, "
+		       "and multithread debugging will be unreliable."),
+		     objfile->obfd->filename);
+	}
       break;
 
     case TD_OK:
@@ -669,7 +679,7 @@ static void
 thread_db_new_objfile (struct objfile *objfile)
 {
   if (objfile != NULL)
-    check_for_thread_db ();
+    check_for_thread_db (objfile);
 }
 
 /* Attach to a new thread.  This function is called when we receive a

             reply	other threads:[~2009-02-11  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-11  8:29 teawater [this message]
2009-02-11  8:43 ` teawater

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=daef60380902110029s15874c26h839aa6224980de11@mail.gmail.com \
    --to=teawater@gmail.com \
    --cc=gdb-patches@sourceware.org \
    /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