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

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