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

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