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

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