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

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