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

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