Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Output a warning when inferior load in a stripped libpthread.so   make multi-thread debug not ok
@ 2009-02-11  8:29 teawater
  2009-02-11  8:43 ` teawater
  0 siblings, 1 reply; 2+ messages in thread
From: teawater @ 2009-02-11  8:29 UTC (permalink / raw)
  To: gdb-patches

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFA] Output a warning when inferior load in a stripped   libpthread.so make multi-thread debug not ok
  2009-02-11  8:29 [RFA] Output a warning when inferior load in a stripped libpthread.so make multi-thread debug not ok teawater
@ 2009-02-11  8:43 ` teawater
  0 siblings, 0 replies; 2+ messages in thread
From: teawater @ 2009-02-11  8:43 UTC (permalink / raw)
  To: gdb-patches

It test with Ubuntu-x86 is OK.

On Wed, Feb 11, 2009 at 16:29, teawater <teawater@gmail.com> wrote:
> 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
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-11  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11  8:29 [RFA] Output a warning when inferior load in a stripped libpthread.so make multi-thread debug not ok teawater
2009-02-11  8:43 ` teawater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox