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

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