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

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