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

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