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

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