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

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