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

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