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

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