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

2f9ed3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
2f9ed3
From: Fedora GDB patches <invalid@email.com>
2f9ed3
Date: Fri, 27 Oct 2017 21:07:50 +0200
2f9ed3
Subject: gdb-rhbz947564-findvar-assertion-frame-failed-testcase.patch
2f9ed3
2f9ed3
;; Import regression test for `gdb/findvar.c:417: internal-error:
2f9ed3
;; read_var_value: Assertion `frame' failed.' (RH BZ 947564) from RHEL 6.5.
2f9ed3
;;=fedoratest
2f9ed3
2f9ed3
diff --git a/gdb/testsuite/gdb.threads/tls-rhbz947564.cc b/gdb/testsuite/gdb.threads/tls-rhbz947564.cc
2f9ed3
new file mode 100644
2f9ed3
--- /dev/null
2f9ed3
+++ b/gdb/testsuite/gdb.threads/tls-rhbz947564.cc
2f9ed3
@@ -0,0 +1,53 @@
2f9ed3
+#include <iostream>
2f9ed3
+#include <pthread.h>
2f9ed3
+
2f9ed3
+class x
2f9ed3
+  {
2f9ed3
+  public:
2f9ed3
+    int n;
2f9ed3
+
2f9ed3
+    x() : n(0) {}
2f9ed3
+  };
2f9ed3
+
2f9ed3
+class y
2f9ed3
+  {
2f9ed3
+  public:
2f9ed3
+    int v;
2f9ed3
+
2f9ed3
+    y() : v(0) {}
2f9ed3
+    static __thread x *xp;
2f9ed3
+  };
2f9ed3
+
2f9ed3
+__thread x *y::xp;
2f9ed3
+
2f9ed3
+static void
2f9ed3
+foo (y *yp)
2f9ed3
+{
2f9ed3
+  yp->v = 1;   /* foo_marker */
2f9ed3
+}
2f9ed3
+
2f9ed3
+static void *
2f9ed3
+bar (void *unused)
2f9ed3
+{
2f9ed3
+  x xinst;
2f9ed3
+  y::xp= &xinst;
2f9ed3
+
2f9ed3
+  y yy;
2f9ed3
+  foo(&yy;;
2f9ed3
+
2f9ed3
+  return NULL;
2f9ed3
+}
2f9ed3
+
2f9ed3
+int
2f9ed3
+main(int argc, char *argv[])
2f9ed3
+{
2f9ed3
+  pthread_t t[2];
2f9ed3
+
2f9ed3
+  pthread_create (&t[0], NULL, bar, NULL);
2f9ed3
+  pthread_create (&t[1], NULL, bar, NULL);
2f9ed3
+
2f9ed3
+  pthread_join (t[0], NULL);
2f9ed3
+  pthread_join (t[1], NULL);
2f9ed3
+
2f9ed3
+  return 0;
2f9ed3
+}
2f9ed3
diff --git a/gdb/testsuite/gdb.threads/tls-rhbz947564.exp b/gdb/testsuite/gdb.threads/tls-rhbz947564.exp
2f9ed3
new file mode 100644
2f9ed3
--- /dev/null
2f9ed3
+++ b/gdb/testsuite/gdb.threads/tls-rhbz947564.exp
2f9ed3
@@ -0,0 +1,75 @@
2f9ed3
+# Copyright (C) 2013 Free Software Foundation, Inc.
2f9ed3
+
2f9ed3
+# This program is free software; you can redistribute it and/or modify
2f9ed3
+# it under the terms of the GNU General Public License as published by
2f9ed3
+# the Free Software Foundation; either version 3 of the License, or
2f9ed3
+# (at your option) any later version.
2f9ed3
+#
2f9ed3
+# This program is distributed in the hope that it will be useful,
2f9ed3
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2f9ed3
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2f9ed3
+# GNU General Public License for more details.
2f9ed3
+#
2f9ed3
+# You should have received a copy of the GNU General Public License
2f9ed3
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
2f9ed3
+
2f9ed3
+set testfile tls-rhbz947564
2f9ed3
+set srcfile ${testfile}.cc
2f9ed3
+set binfile [standard_output_file ${testfile}]
2f9ed3
+
2f9ed3
+if [istarget "*-*-linux"] then {
2f9ed3
+    set target_cflags "-D_MIT_POSIX_THREADS"
2f9ed3
+} else {
2f9ed3
+    set target_cflags ""
2f9ed3
+}
2f9ed3
+
2f9ed3
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list c++ debug]] != "" } {
2f9ed3
+    return -1
2f9ed3
+}
2f9ed3
+
2f9ed3
+gdb_exit
2f9ed3
+gdb_start
2f9ed3
+gdb_reinitialize_dir $srcdir/$subdir
2f9ed3
+
2f9ed3
+gdb_load ${binfile}
2f9ed3
+
2f9ed3
+if { ![runto_main] } {
2f9ed3
+    fail "Can't run to function main"
2f9ed3
+    return 0
2f9ed3
+}
2f9ed3
+
2f9ed3
+gdb_breakpoint "foo"
2f9ed3
+gdb_continue_to_breakpoint "foo" ".* foo_marker .*"
2f9ed3
+
2f9ed3
+proc get_xp_val {try} {
2f9ed3
+    global expect_out
2f9ed3
+    global gdb_prompt
2f9ed3
+    global hex
2f9ed3
+
2f9ed3
+    set xp_val ""
2f9ed3
+    gdb_test_multiple "print *yp" "print yp value" {
2f9ed3
+	-re { = \{v = 0, static xp = (0x[0-9a-f]+)\}.* } {
2f9ed3
+	    pass "print $try value of *yp"
2f9ed3
+	    set xp_val $expect_out(1,string)
2f9ed3
+	}
2f9ed3
+	-re "$gdb_prompt $" {
2f9ed3
+	    fail "print $try value of *yp"
2f9ed3
+	}
2f9ed3
+	timeout {
2f9ed3
+	    fail "print $try value of *yp (timeout)"
2f9ed3
+	}
2f9ed3
+    }
2f9ed3
+    return $xp_val
2f9ed3
+}
2f9ed3
+
2f9ed3
+set first_run [get_xp_val "first"]
2f9ed3
+
2f9ed3
+gdb_test "continue" "Breakpoint \[0-9\]+, foo \\\(yp=$hex\\\) at.*"
2f9ed3
+
2f9ed3
+set second_run [get_xp_val "second"]
2f9ed3
+
2f9ed3
+if { $first_run != $second_run } {
2f9ed3
+    pass "different values for TLS variable"
2f9ed3
+} else {
2f9ed3
+    fail "different values for TLS variable"
2f9ed3
+}