ba67a79
If you provided some relative path to the shared library, such as with
ba67a79
	export LD_LIBRARY_PATH=.
ba67a79
then gdb would fail to match the shared library name during the TLS lookup.
ba67a79
ba67a79
ba67a79
The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'.
ba67a79
The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
ba67a79
ba67a79
ba67a79
2006-09-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
ba67a79
ba67a79
	* solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute
ba67a79
	requested pathnames to the internal loaded relative pathnames.
ba67a79
eb9d945
2007-10-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
ba67a79
eb9d945
	Port to GDB-6.7.
eb9d945
25ff8a1
2008-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
25ff8a1
25ff8a1
	Port to gdb-6.7.50.20080227.
25ff8a1
25ff8a1
Index: gdb-6.7.50.20080227/gdb/solib-svr4.c
ba67a79
===================================================================
25ff8a1
--- gdb-6.7.50.20080227.orig/gdb/solib-svr4.c	2008-02-27 08:59:06.000000000 +0100
25ff8a1
+++ gdb-6.7.50.20080227/gdb/solib-svr4.c	2008-02-27 09:00:44.000000000 +0100
25ff8a1
@@ -1017,10 +1017,14 @@ CORE_ADDR
ba67a79
 svr4_fetch_objfile_link_map (struct objfile *objfile)
ba67a79
 {
ba67a79
   CORE_ADDR lm;
ba67a79
+  int resolve;
ba67a79
 
25ff8a1
   if (locate_base () == 0)
ba67a79
     return 0;   /* failed somehow... */
ba67a79
 
eb9d945
+for (resolve = 0; resolve <= 1; resolve++)
eb9d945
+{
ba67a79
+
eb9d945
   /* Position ourselves on the first link map.  */
eb9d945
   lm = solib_svr4_r_map ();  
eb9d945
   while (lm)
25ff8a1
@@ -1059,6 +1063,21 @@ svr4_fetch_objfile_link_map (struct objf
eb9d945
 		 safe_strerror (errcode));
eb9d945
       else
eb9d945
   	{
eb9d945
+	  /* solib_svr4_r_map() may contain relative pathnames while
eb9d945
+	     `objfile->name' is absolute.  */
eb9d945
+	  if (resolve && buffer && buffer[0] != '/')
ba67a79
+	    {
eb9d945
+	      char *absolute;
eb9d945
+	      int fd;
ba67a79
+
eb9d945
+	      fd = solib_open (buffer, &absolute);
eb9d945
+	      if (fd != -1)
ba67a79
+		{
eb9d945
+		  make_cleanup (xfree, absolute);
eb9d945
+		  buffer = absolute;
eb9d945
+		  close (fd);
ba67a79
+		}
ba67a79
+	    }
eb9d945
 	  /* Is this the linkmap for the file we want?  */
eb9d945
 	  /* If the file is not a shared library and has no name,
eb9d945
 	     we are sure it is the main executable, so we return that.  */
25ff8a1
@@ -1077,6 +1096,9 @@ svr4_fetch_objfile_link_map (struct objf
eb9d945
 				  builtin_type_void_data_ptr);
eb9d945
       do_cleanups (old_chain);
ba67a79
     }
eb9d945
+
eb9d945
+}	/* resolve */
eb9d945
+
ba67a79
   return 0;
ba67a79
 }
eb9d945
 
25ff8a1
Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
ba67a79
===================================================================
eb9d945
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
25ff8a1
+++ gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-main.c	2008-02-27 09:00:15.000000000 +0100
ba67a79
@@ -0,0 +1,25 @@
ba67a79
+/* This testcase is part of GDB, the GNU debugger.
ba67a79
+
ba67a79
+   Copyright 2006 Free Software Foundation, Inc.
ba67a79
+
ba67a79
+   This program is free software; you can redistribute it and/or modify
ba67a79
+   it under the terms of the GNU General Public License as published by
ba67a79
+   the Free Software Foundation; either version 2 of the License, or
ba67a79
+   (at your option) any later version.
ba67a79
+
ba67a79
+   This program is distributed in the hope that it will be useful,
ba67a79
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ba67a79
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ba67a79
+   GNU General Public License for more details.
ba67a79
+ 
ba67a79
+   You should have received a copy of the GNU General Public License
ba67a79
+   along with this program; if not, write to the Free Software
ba67a79
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ba67a79
+
ba67a79
+   Please email any bugs, comments, and/or additions to this file to:
ba67a79
+   bug-gdb@prep.ai.mit.edu  */
ba67a79
+
ba67a79
+int main()
ba67a79
+{
ba67a79
+  return 0;
ba67a79
+}
25ff8a1
Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
ba67a79
===================================================================
eb9d945
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
25ff8a1
+++ gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c	2008-02-27 09:00:15.000000000 +0100
ba67a79
@@ -0,0 +1,22 @@
ba67a79
+/* This testcase is part of GDB, the GNU debugger.
ba67a79
+
ba67a79
+   Copyright 2006 Free Software Foundation, Inc.
ba67a79
+
ba67a79
+   This program is free software; you can redistribute it and/or modify
ba67a79
+   it under the terms of the GNU General Public License as published by
ba67a79
+   the Free Software Foundation; either version 2 of the License, or
ba67a79
+   (at your option) any later version.
ba67a79
+
ba67a79
+   This program is distributed in the hope that it will be useful,
ba67a79
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ba67a79
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ba67a79
+   GNU General Public License for more details.
ba67a79
+ 
ba67a79
+   You should have received a copy of the GNU General Public License
ba67a79
+   along with this program; if not, write to the Free Software
ba67a79
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
ba67a79
+
ba67a79
+   Please email any bugs, comments, and/or additions to this file to:
ba67a79
+   bug-gdb@prep.ai.mit.edu  */
ba67a79
+
ba67a79
+__thread int var = 42;
25ff8a1
Index: gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug.exp
ba67a79
===================================================================
eb9d945
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
25ff8a1
+++ gdb-6.7.50.20080227/gdb/testsuite/gdb.threads/tls-sepdebug.exp	2008-02-27 09:00:15.000000000 +0100
ba67a79
@@ -0,0 +1,81 @@
ba67a79
+# Copyright 2006 Free Software Foundation, Inc.
ba67a79
+
ba67a79
+# This program is free software; you can redistribute it and/or modify
ba67a79
+# it under the terms of the GNU General Public License as published by
ba67a79
+# the Free Software Foundation; either version 2 of the License, or
ba67a79
+# (at your option) any later version.
ba67a79
+# 
ba67a79
+# This program is distributed in the hope that it will be useful,
ba67a79
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ba67a79
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ba67a79
+# GNU General Public License for more details.
ba67a79
+# 
ba67a79
+# You should have received a copy of the GNU General Public License
ba67a79
+# along with this program; if not, write to the Free Software
ba67a79
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
ba67a79
+
ba67a79
+if $tracelevel then {
ba67a79
+    strace $tracelevel
ba67a79
+}
ba67a79
+
ba67a79
+set testfile tls-sepdebug
ba67a79
+set srcmainfile   ${testfile}-main.c
ba67a79
+set srcsharedfile ${testfile}-shared.c
ba67a79
+
ba67a79
+# DO NOT use ${objdir} obsolute reference here as we test relative directories
ba67a79
+# below and the absolute pathnames must not get encoded to the binaries.
ba67a79
+
ba67a79
+set binmainfile        ${testfile}-main
ba67a79
+set binsharedfile      ${testfile}-shared.so
ba67a79
+set binshareddebugfile ${testfile}-shared.so.debug
ba67a79
+
ba67a79
+if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" {debug}] != "" } {
ba67a79
+    untested "Couldn't compile test library"
ba67a79
+    return -1
ba67a79
+}
ba67a79
+
ba67a79
+# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'.
ba67a79
+if 0 then {
ba67a79
+    remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}"
ba67a79
+} else {
ba67a79
+    remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}"
ba67a79
+    remote_exec build "objcopy --strip-debug ${binsharedfile}"
ba67a79
+    remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}"
ba67a79
+}
ba67a79
+
ba67a79
+if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile}" "${binmainfile}" executable [list debug shlib=${binsharedfile}]] != "" } {
ba67a79
+    untested "Couldn't compile test program"
ba67a79
+    return -1
ba67a79
+}
ba67a79
+
ba67a79
+# Get things started.
ba67a79
+
ba67a79
+# Test also the proper resolving of relative library names to absolute ones.
ba67a79
+# \$PWD is easy - it is the absolute way
ba67a79
+# ${subdir} would fail on "print var"
ba67a79
+
ba67a79
+foreach ld_library_path { \$PWD ${subdir} } name { absolute relative }  {
ba67a79
+
ba67a79
+    gdb_exit
ba67a79
+    gdb_start
ba67a79
+    ###gdb_reinitialize_dir $srcdir/$subdir
ba67a79
+    
ba67a79
+    gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \
ba67a79
+             "" \
ba67a79
+             "set env LD_LIBRARY_PATH is $name"
ba67a79
+    
ba67a79
+    gdb_load ${binmainfile}
ba67a79
+    
ba67a79
+    # For C programs, "start" should stop in main().
ba67a79
+    
ba67a79
+    gdb_test "start" \
ba67a79
+             "main \\(\\) at .*${srcmainfile}.*" \
ba67a79
+             "start"
ba67a79
+    
ba67a79
+    # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list
ba67a79
+    # as happens with TLS variables and `separate_debug_objfile_backlink'.
ba67a79
+    
ba67a79
+    gdb_test "print var" \
ba67a79
+             "\\\$1 = \[0-9\].*" \
ba67a79
+             "print TLS variable from a shared library with $name-directory separate debug info file"
ba67a79
+}