Blame SOURCES/gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch

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