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