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

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