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

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