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

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