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

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