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

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