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

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