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

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