Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] load lipthread symbols even when auto-solib-add is off
@ 2006-10-17 23:19 Joel Brobecker
  2006-10-19  0:07 ` Kevin Buettner
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2006-10-17 23:19 UTC (permalink / raw)
  To: gdb-patches

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

Hello,

Between having to document a side-effect of "set auto-solib-add 0"
and fixing the actual issue, I finally decided to try to fix the issue...
If you don't remember what the issue is, we started discussing it at:

        http://www.sourceware.org/ml/gdb/2006-09/msg00065.html

In short, when doing "set auto-solib-add 0", and then running
a multi-threaded program on x86-linux, the "thread" layer doesn't
get pushed on the target stack. I couldn't demonstrate a visibly
bad behavior with GDB from CVS, but with gdb-6.4, I get:

    (gdb) c
    Continuing.

    Program terminated with signal SIGTRAP, Trace/breakpoint trap.
    The program no longer exists.

After discussing this a bit with Daniel, we determined that we could
always load the symbols for libpthread. This is what this patch
implements.

2006-10-17  Joel Brobecker  <brobecker@adacore.com>

        * solib.c (libpthread_solib_p): New function.
        (solib_add): Always read the symbols from the libpthread library.

Tested on x86-linux, no regression. I verified that this also makes
GDB push the thread layer despite "set auto-solib-add 0".

Is this OK?

Thanks,
-- 
Joel

[-- Attachment #2: solib.c.diff --]
[-- Type: text/plain, Size: 1495 bytes --]

Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.86
diff -u -p -r1.86 solib.c
--- solib.c	9 Oct 2006 20:16:10 -0000	1.86
+++ solib.c	17 Oct 2006 23:14:19 -0000
@@ -615,6 +615,17 @@ update_solib_list (int from_tty, struct 
     }
 }
 
+/* Return non-zero if SO is the libpthread shared library.
+
+   Uses a fairly simplistic heuristic approach where we check
+   the file name against "/libpthread".  This can lead to false
+   positives, but this should be good enough in practice.  */
+
+static int
+libpthread_solib_p (struct so_list *so)
+{
+  return (strstr (so->so_name, "/libpthread") != NULL);
+}
 
 /* GLOBAL FUNCTION
 
@@ -661,8 +672,16 @@ solib_add (char *pattern, int from_tty, 
     for (gdb = so_list_head; gdb; gdb = gdb->next)
       if (! pattern || re_exec (gdb->so_name))
 	{
+          /* Normally, we would read the symbols from that library
+             only if READSYMS is set.  However, we're making a small
+             exception for the pthread library, because we sometimes
+             need the library symbols to be loaded in order to provide
+             thread support (x86-linux for instance).  */
+          const int add_this_solib =
+            (readsyms || libpthread_solib_p (gdb));
+
 	  any_matches = 1;
-	  if (readsyms && solib_read_symbols (gdb, from_tty))
+	  if (add_this_solib && solib_read_symbols (gdb, from_tty))
 	    loaded_any_symbols = 1;
 	}
 

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

* Re: [RFA] load lipthread symbols even when auto-solib-add is off
  2006-10-17 23:19 [RFA] load lipthread symbols even when auto-solib-add is off Joel Brobecker
@ 2006-10-19  0:07 ` Kevin Buettner
  2006-10-19 19:58   ` Joel Brobecker
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2006-10-19  0:07 UTC (permalink / raw)
  To: gdb-patches

On Tue, 17 Oct 2006 19:19:11 -0400
Joel Brobecker <brobecker@adacore.com> wrote:

> 2006-10-17  Joel Brobecker  <brobecker@adacore.com>
> 
>         * solib.c (libpthread_solib_p): New function.
>         (solib_add): Always read the symbols from the libpthread library.

Okay.

Kevin


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

* Re: [RFA] load lipthread symbols even when auto-solib-add is off
  2006-10-19  0:07 ` Kevin Buettner
@ 2006-10-19 19:58   ` Joel Brobecker
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2006-10-19 19:58 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

> > 2006-10-17  Joel Brobecker  <brobecker@adacore.com>
> > 
> >         * solib.c (libpthread_solib_p): New function.
> >         (solib_add): Always read the symbols from the libpthread library.
> 
> Okay.

Thank you! Checked in.

-- 
Joel


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

end of thread, other threads:[~2006-10-19 19:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-17 23:19 [RFA] load lipthread symbols even when auto-solib-add is off Joel Brobecker
2006-10-19  0:07 ` Kevin Buettner
2006-10-19 19:58   ` Joel Brobecker

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