Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] load lipthread symbols even when auto-solib-add is off
Date: Tue, 17 Oct 2006 23:19:00 -0000	[thread overview]
Message-ID: <20061017231911.GR1903@adacore.com> (raw)

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

             reply	other threads:[~2006-10-17 23:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 23:19 Joel Brobecker [this message]
2006-10-19  0:07 ` Kevin Buettner
2006-10-19 19:58   ` Joel Brobecker

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=20061017231911.GR1903@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sources.redhat.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