Blame SOURCES/gdb-rhbz1149205-catch-syscall-after-fork-test.patch

93189d
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
93189d
From: Fedora GDB patches <invalid@email.com>
93189d
Date: Fri, 27 Oct 2017 21:07:50 +0200
93189d
Subject: gdb-rhbz1149205-catch-syscall-after-fork-test.patch
93189d
93189d
;; Fix '`catch syscall' doesn't work for parent after `fork' is called'
93189d
;; (Philippe Waroquiers, RH BZ 1149205).
93189d
;;=fedoratest
93189d
93189d
URL: <https://sourceware.org/ml/gdb-patches/2013-05/msg00364.html>
93189d
Message-ID: <1368136582.30058.7.camel@soleil>
93189d
93189d
  From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
93189d
  To: gdb-patches at sourceware dot org
93189d
  Subject: RFA: fix gdb_assert caused by 'catch signal ...' and fork
93189d
  Date: Thu, 09 May 2013 23:56:22 +0200
93189d
93189d
  The attached patch fixes a gdb_assert caused by the combination of catch
93189d
  signal and fork:
93189d
    break-catch-sig.c:152: internal-error: signal_catchpoint_remove_location: Assertion `signal_catch_counts[iter] > 0' failed.
93189d
93189d
  The problem is that the signal_catch_counts is decremented by detach_breakpoints.
93189d
  The fix consists in not detaching breakpoint locations of type bp_loc_other.
93189d
  The patch introduces a new test.
93189d
93189d
Comments by Sergio Durigan Junior:
93189d
93189d
  I addded a specific testcase for this patch, which tests exactly the
93189d
  issue that the customer is facing.  This patch does not solve the
93189d
  whole problem of catching a syscall and forking (for more details,
93189d
  see <https://sourceware.org/bugzilla/show_bug.cgi?id=13457>,
93189d
  specifically comment #3), but it solves the issue reported by the
93189d
  customer.
93189d
93189d
  I also removed the original testcase of this patch, because it
93189d
  relied on "catch signal", which is a command that is not implemented
93189d
  in this version of GDB.
93189d
93189d
commit bd9673a4ded96ea5c108601501c8e59003ea1be6
93189d
Author: Philippe Waroquiers <philippe@sourceware.org>
93189d
Date:   Tue May 21 18:47:05 2013 +0000
93189d
93189d
    Fix internal error caused by interaction between catch signal and fork
93189d
93189d
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c
93189d
new file mode 100644
93189d
--- /dev/null
93189d
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.c
93189d
@@ -0,0 +1,11 @@
93189d
+#include <stdio.h>
93189d
+#include <unistd.h>
93189d
+
93189d
+int
93189d
+main (int argc, char **argv)
93189d
+{
93189d
+  if (fork () == 0)
93189d
+    sleep (1);
93189d
+  chdir (".");
93189d
+  return 0;
93189d
+}
93189d
diff --git a/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp
93189d
new file mode 100644
93189d
--- /dev/null
93189d
+++ b/gdb/testsuite/gdb.base/gdb-rhbz1149205-catch-syscall-fork.exp
93189d
@@ -0,0 +1,58 @@
93189d
+# Copyright 2015 Free Software Foundation, Inc.
93189d
+
93189d
+# This program is free software; you can redistribute it and/or modify
93189d
+# it under the terms of the GNU General Public License as published by
93189d
+# the Free Software Foundation; either version 3 of the License, or
93189d
+# (at your option) any later version.
93189d
+#
93189d
+# This program is distributed in the hope that it will be useful,
93189d
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
93189d
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
93189d
+# GNU General Public License for more details.
93189d
+#
93189d
+# You should have received a copy of the GNU General Public License
93189d
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
93189d
+
93189d
+if { [is_remote target] || ![isnative] } then {
93189d
+    continue
93189d
+}
93189d
+
93189d
+set testfile "gdb-rhbz1149205-catch-syscall-fork"
93189d
+set srcfile ${testfile}.c
93189d
+set binfile [standard_output_file ${testfile}]
93189d
+
93189d
+# Until "catch syscall" is implemented on other targets...
93189d
+if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
93189d
+    continue
93189d
+}
93189d
+
93189d
+# This shall be updated whenever 'catch syscall' is implemented
93189d
+# on some architecture.
93189d
+#if { ![istarget "i\[34567\]86-*-linux*"]
93189d
+if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
93189d
+     && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"]
93189d
+     && ![istarget "sparc-*-linux*"] && ![istarget "sparc64-*-linux*"] } {
93189d
+     continue
93189d
+}
93189d
+
93189d
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
93189d
+    untested ${testfile}.exp
93189d
+    return -1
93189d
+}
93189d
+
93189d
+gdb_exit
93189d
+gdb_start
93189d
+gdb_reinitialize_dir $srcdir/$subdir
93189d
+gdb_load $binfile
93189d
+
93189d
+if { ![runto_main] } {
93189d
+    return -1
93189d
+}
93189d
+
93189d
+gdb_test "catch syscall chdir" \
93189d
+  "Catchpoint $decimal \\\(syscall (.)?chdir(.)? \\\[$decimal\\\]\\\)" \
93189d
+  "catch syscall chdir"
93189d
+
93189d
+gdb_test "continue" \
93189d
+  "Continuing\.\r\n.*\r\nCatchpoint $decimal \\\(call to syscall .?chdir.?.*" \
93189d
+  "continue from catch syscall after fork"