Jan Kratochvil 22d1e60
Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.threads/tls-rhbz947564.cc
9dd2140
===================================================================
Jan Kratochvil 22d1e60
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 22d1e60
+++ gdb-7.10.90.20160211/gdb/testsuite/gdb.threads/tls-rhbz947564.cc	2016-02-15 23:39:21.791458927 +0100
9dd2140
@@ -0,0 +1,53 @@
9dd2140
+#include <iostream>
9dd2140
+#include <pthread.h>
9dd2140
+
9dd2140
+class x
9dd2140
+  {
9dd2140
+  public:
9dd2140
+    int n;
9dd2140
+
9dd2140
+    x() : n(0) {}
9dd2140
+  };
9dd2140
+
9dd2140
+class y
9dd2140
+  {
9dd2140
+  public:
9dd2140
+    int v;
9dd2140
+
9dd2140
+    y() : v(0) {}
9dd2140
+    static __thread x *xp;
9dd2140
+  };
9dd2140
+
9dd2140
+__thread x *y::xp;
9dd2140
+
9dd2140
+static void
9dd2140
+foo (y *yp)
9dd2140
+{
9dd2140
+  yp->v = 1;   /* foo_marker */
9dd2140
+}
9dd2140
+
9dd2140
+static void *
9dd2140
+bar (void *unused)
9dd2140
+{
9dd2140
+  x xinst;
9dd2140
+  y::xp= &xinst;
9dd2140
+
9dd2140
+  y yy;
9dd2140
+  foo(&yy;;
9dd2140
+
9dd2140
+  return NULL;
9dd2140
+}
9dd2140
+
9dd2140
+int
9dd2140
+main(int argc, char *argv[])
9dd2140
+{
9dd2140
+  pthread_t t[2];
9dd2140
+
9dd2140
+  pthread_create (&t[0], NULL, bar, NULL);
9dd2140
+  pthread_create (&t[1], NULL, bar, NULL);
9dd2140
+
9dd2140
+  pthread_join (t[0], NULL);
9dd2140
+  pthread_join (t[1], NULL);
9dd2140
+
9dd2140
+  return 0;
9dd2140
+}
Jan Kratochvil 22d1e60
Index: gdb-7.10.90.20160211/gdb/testsuite/gdb.threads/tls-rhbz947564.exp
9dd2140
===================================================================
Jan Kratochvil 22d1e60
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 22d1e60
+++ gdb-7.10.90.20160211/gdb/testsuite/gdb.threads/tls-rhbz947564.exp	2016-02-15 23:39:30.029517418 +0100
9dd2140
@@ -0,0 +1,75 @@
9dd2140
+# Copyright (C) 2013 Free Software Foundation, Inc.
9dd2140
+
9dd2140
+# This program is free software; you can redistribute it and/or modify
9dd2140
+# it under the terms of the GNU General Public License as published by
9dd2140
+# the Free Software Foundation; either version 3 of the License, or
9dd2140
+# (at your option) any later version.
9dd2140
+#
9dd2140
+# This program is distributed in the hope that it will be useful,
9dd2140
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
9dd2140
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9dd2140
+# GNU General Public License for more details.
9dd2140
+#
9dd2140
+# You should have received a copy of the GNU General Public License
9dd2140
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
9dd2140
+
9dd2140
+set testfile tls-rhbz947564
9dd2140
+set srcfile ${testfile}.cc
Jan Kratochvil 22d1e60
+set binfile [standard_output_file ${testfile}]
9dd2140
+
9dd2140
+if [istarget "*-*-linux"] then {
9dd2140
+    set target_cflags "-D_MIT_POSIX_THREADS"
9dd2140
+} else {
9dd2140
+    set target_cflags ""
9dd2140
+}
9dd2140
+
9dd2140
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list c++ debug]] != "" } {
9dd2140
+    return -1
9dd2140
+}
9dd2140
+
9dd2140
+gdb_exit
9dd2140
+gdb_start
9dd2140
+gdb_reinitialize_dir $srcdir/$subdir
9dd2140
+
9dd2140
+gdb_load ${binfile}
9dd2140
+
9dd2140
+if { ![runto_main] } {
9dd2140
+    fail "Can't run to function main"
9dd2140
+    return 0
9dd2140
+}
9dd2140
+
9dd2140
+gdb_breakpoint "foo"
9dd2140
+gdb_continue_to_breakpoint "foo" ".* foo_marker .*"
9dd2140
+
9dd2140
+proc get_xp_val {try} {
9dd2140
+    global expect_out
9dd2140
+    global gdb_prompt
9dd2140
+    global hex
9dd2140
+
9dd2140
+    set xp_val ""
9dd2140
+    gdb_test_multiple "print *yp" "print yp value" {
9dd2140
+	-re { = \{v = 0, static xp = (0x[0-9a-f]+)\}.* } {
9dd2140
+	    pass "print $try value of *yp"
9dd2140
+	    set xp_val $expect_out(1,string)
9dd2140
+	}
9dd2140
+	-re "$gdb_prompt $" {
9dd2140
+	    fail "print $try value of *yp"
9dd2140
+	}
9dd2140
+	timeout {
9dd2140
+	    fail "print $try value of *yp (timeout)"
9dd2140
+	}
9dd2140
+    }
9dd2140
+    return $xp_val
9dd2140
+}
9dd2140
+
9dd2140
+set first_run [get_xp_val "first"]
9dd2140
+
9dd2140
+gdb_test "continue" "Breakpoint \[0-9\]+, foo \\\(yp=$hex\\\) at.*"
9dd2140
+
9dd2140
+set second_run [get_xp_val "second"]
9dd2140
+
9dd2140
+if { $first_run != $second_run } {
9dd2140
+    pass "different values for TLS variable"
9dd2140
+} else {
9dd2140
+    fail "different values for TLS variable"
9dd2140
+}