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

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