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