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

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