Blame SOURCES/gdb-simultaneous-step-resume-breakpoint-test.patch

4a80f0
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4a80f0
From: Fedora GDB patches <invalid@email.com>
4a80f0
Date: Fri, 27 Oct 2017 21:07:50 +0200
4a80f0
Subject: gdb-simultaneous-step-resume-breakpoint-test.patch
4a80f0
4a80f0
;; New test for step-resume breakpoint placed in multiple threads at once.
4a80f0
;;=fedoratest
4a80f0
4a80f0
diff --git a/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c b/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c
4a80f0
new file mode 100644
4a80f0
--- /dev/null
4a80f0
+++ b/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.c
4a80f0
@@ -0,0 +1,79 @@
4a80f0
+/* Copyright 2009 Free Software Foundation, Inc.
4a80f0
+
4a80f0
+   Written by Fred Fish of Cygnus Support
4a80f0
+   Contributed by Cygnus Support
4a80f0
+
4a80f0
+   This file is part of GDB.
4a80f0
+
4a80f0
+   This program is free software; you can redistribute it and/or modify
4a80f0
+   it under the terms of the GNU General Public License as published by
4a80f0
+   the Free Software Foundation; either version 3 of the License, or
4a80f0
+   (at your option) any later version.
4a80f0
+
4a80f0
+   This program is distributed in the hope that it will be useful,
4a80f0
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4a80f0
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4a80f0
+   GNU General Public License for more details.
4a80f0
+
4a80f0
+   You should have received a copy of the GNU General Public License
4a80f0
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4a80f0
+
4a80f0
+/* Test multiple threads stepping into a .debug_line-less function with
4a80f0
+   a breakpoint placed on its return-to-caller point.  */
4a80f0
+
4a80f0
+#include <pthread.h>
4a80f0
+#include <assert.h>
4a80f0
+#include <unistd.h>
4a80f0
+#include <errno.h>
4a80f0
+#include <stdio.h>
4a80f0
+
4a80f0
+#define THREADS 3
4a80f0
+
4a80f0
+static void *
4a80f0
+func (void *unused)
4a80f0
+{
4a80f0
+  int i;
4a80f0
+
4a80f0
+  errno = 0;
4a80f0
+  i = 0xdeadf00d;
4a80f0
+  i = sleep (THREADS);	/* sleep-call */
4a80f0
+  if (errno != 0)	/* sleep-after */
4a80f0
+    perror ("sleep");
4a80f0
+
4a80f0
+  /* The GDB bug with forgotten step-resume breakpoint could leave stale
4a80f0
+     breakpoint on the I assignment making it a nop.  */
4a80f0
+  if (i == 0xdeadf00d)
4a80f0
+    assert (0);
4a80f0
+
4a80f0
+  assert (i == 0);
4a80f0
+
4a80f0
+  pthread_exit (NULL);
4a80f0
+}
4a80f0
+
4a80f0
+int
4a80f0
+main (void)
4a80f0
+{
4a80f0
+  pthread_t threads[THREADS];
4a80f0
+  int threadi;
4a80f0
+
4a80f0
+  for (threadi = 0; threadi < THREADS; threadi++)
4a80f0
+    {
4a80f0
+      int i;
4a80f0
+
4a80f0
+      i = pthread_create (&threads[threadi], NULL, func, NULL);
4a80f0
+      assert (i == 0);
4a80f0
+
4a80f0
+      i = sleep (1);
4a80f0
+      assert (i == 0);
4a80f0
+    }
4a80f0
+
4a80f0
+  for (threadi = 0; threadi < THREADS; threadi++)
4a80f0
+    {
4a80f0
+      int i;
4a80f0
+
4a80f0
+      i = pthread_join (threads[threadi], NULL);
4a80f0
+      assert (i == 0);
4a80f0
+    }
4a80f0
+
4a80f0
+  return 0;	/* final-exit */
4a80f0
+}
4a80f0
diff --git a/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp b/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp
4a80f0
new file mode 100644
4a80f0
--- /dev/null
4a80f0
+++ b/gdb/testsuite/gdb.threads/simultaneous-step-resume-breakpoint.exp
4a80f0
@@ -0,0 +1,65 @@
4a80f0
+# Copyright (C) 2009 Free Software Foundation, Inc.
4a80f0
+
4a80f0
+# This program is free software; you can redistribute it and/or modify
4a80f0
+# it under the terms of the GNU General Public License as published by
4a80f0
+# the Free Software Foundation; either version 3 of the License, or
4a80f0
+# (at your option) any later version.
4a80f0
+#
4a80f0
+# This program is distributed in the hope that it will be useful,
4a80f0
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4a80f0
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4a80f0
+# GNU General Public License for more details.
4a80f0
+#
4a80f0
+# You should have received a copy of the GNU General Public License
4a80f0
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
4a80f0
+
4a80f0
+# Test multiple threads stepping into a .debug_line-less function with
4a80f0
+# a breakpoint placed on its return-to-caller point.
4a80f0
+
4a80f0
+set testfile simultaneous-step-resume-breakpoint
4a80f0
+set srcfile ${testfile}.c
4a80f0
+set binfile [standard_output_file ${testfile}]
4a80f0
+
4a80f0
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
4a80f0
+    return -1
4a80f0
+}
4a80f0
+
4a80f0
+gdb_exit
4a80f0
+gdb_start
4a80f0
+gdb_reinitialize_dir $srcdir/$subdir
4a80f0
+
4a80f0
+# Ensure we have no debuginfo for the `sleep' call itself (=for libc).
4a80f0
+gdb_test "set debug-file-directory /DoesNotExist"
4a80f0
+
4a80f0
+gdb_load ${binfile}
4a80f0
+if ![runto_main] {
4a80f0
+   return -1
4a80f0
+}
4a80f0
+
4a80f0
+# Red Hat vendor patch does set it to "step" by default.
4a80f0
+gdb_test "set scheduler-locking off"
4a80f0
+
4a80f0
+gdb_breakpoint [gdb_get_line_number "final-exit"]
4a80f0
+
4a80f0
+gdb_breakpoint [gdb_get_line_number "sleep-call"]
4a80f0
+gdb_continue_to_breakpoint "sleep-call"
4a80f0
+
4a80f0
+gdb_test "step" "sleep-call.*" "step thread 1"
4a80f0
+gdb_test "step" "sleep-call.*" "step thread 2"
4a80f0
+gdb_test "step" "sleep-after.*" "step thread 3"
4a80f0
+
4a80f0
+set test "first continue"
4a80f0
+gdb_test_multiple "continue" $test {
4a80f0
+    -re "final-exit.*$gdb_prompt $" {
4a80f0
+	# gdb-7.0.
4a80f0
+	pass $test
4a80f0
+	return
4a80f0
+    }
4a80f0
+    -re "sleep-after.*$gdb_prompt $" {
4a80f0
+	# Fedora/RHEL branch.
4a80f0
+	pass $test
4a80f0
+    }
4a80f0
+}
4a80f0
+
4a80f0
+gdb_test "continue" "sleep-after.*" "second continue"
4a80f0
+gdb_test "continue" "final-exit.*" "third continue"