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

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