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

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