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

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