From 407aabda7c2d395e521b7e003e8e12d9822f3ce0 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@cs.stanford.edu>
Date: Sun, 25 Nov 2012 09:04:54 -0800
Subject: [PATCH] Remove feature to automatically connect to GDB when debugging
 is enabled.

This feature caused a few problems in "make check" on some distributions
when debugging was enabled at compile time.  It is probably possible to
find and fix those particular problems, but the feature itself is
little-used, so this commit instead removes it.

Bug #37444.
Reported by Mindaugas.
---
 configure.ac              |  2 +-
 src/ui/automake.mk        |  1 -
 src/ui/debugger.c         | 72 ---------------------------------------
 src/ui/debugger.h         | 26 --------------
 src/ui/terminal/main.c    |  6 +---
 tests/ui/terminal/main.at |  3 +-
 6 files changed, 3 insertions(+), 107 deletions(-)
 delete mode 100644 src/ui/debugger.c
 delete mode 100644 src/ui/debugger.h

diff --git a/configure.ac b/configure.ac
index ec5ee2eae2..d681929940 100644
--- a/configure.ac
+++ b/configure.ac
@@ -324,7 +324,7 @@ AC_SUBST([SIZEOF_SIZE_T])
 
 AC_C_BIGENDIAN
 
-AC_CHECK_FUNCS([__setfpucw fork execl execlp isinf isnan finite getpid feholdexcept fpsetmask popen round])
+AC_CHECK_FUNCS([__setfpucw fork execl isinf isnan finite getpid feholdexcept fpsetmask popen round])
 
 AC_PROG_LN_S
 
diff --git a/src/ui/automake.mk b/src/ui/automake.mk
index a4eeebf11c..db634cee16 100644
--- a/src/ui/automake.mk
+++ b/src/ui/automake.mk
@@ -7,7 +7,6 @@ include $(top_srcdir)/src/ui/gui/automake.mk
 noinst_LTLIBRARIES += src/ui/libuicommon.la
 
 src_ui_libuicommon_la_SOURCES = \
-	src/ui/debugger.c src/ui/debugger.h \
 	src/ui/source-init-opts.c src/ui/source-init-opts.h \
 	src/ui/syntax-gen.c src/ui/syntax-gen.h
 
diff --git a/src/ui/debugger.c b/src/ui/debugger.c
deleted file mode 100644
index f3f678461f..0000000000
--- a/src/ui/debugger.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/* PSPP - a program for statistical analysis.
-   Copyright (C) 2006 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#include "debugger.h"
-
-#if HAVE_FORK && HAVE_EXECLP
-#include <errno.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-
-/* Fork, start gdb and connect to the parent process.
-   If that happens successfully, then this function does not return,
-   but exits with EXIT_FAILURE. Otherwise it returns.
- */
-void
-connect_debugger (void)
-{
-  char pidstr[20];
-  pid_t pid;
-
-  snprintf (pidstr, 20, "%d", getpid ());
-  pid = fork ();
-  if ( pid  == -1 )
-    {
-      perror ("Cannot fork");
-      return ;
-    }
-  if ( pid == 0 )
-    {
-      /* child */
-      execlp ("gdb", "gdb", "-p", pidstr, NULL);
-      perror ("Cannot exec debugger");
-      exit (EXIT_FAILURE);
-    }
-  else
-    {
-      int status;
-      wait (&status);
-      if ( EXIT_SUCCESS != WEXITSTATUS (status) )
-	return ;
-    }
-
-  exit (EXIT_FAILURE);
-}
-
-#else /* !(HAVE_FORK && HAVE_EXECLP) */
-/* Don't know how to connect to gdb.
-   Just return.
- */
-void
-connect_debugger (void)
-{
-}
-#endif /* !(HAVE_FORK && HAVE_EXECLP) */
diff --git a/src/ui/debugger.h b/src/ui/debugger.h
deleted file mode 100644
index 321e6ca543..0000000000
--- a/src/ui/debugger.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* PSPP - a program for statistical analysis.
-   Copyright (C) 2006 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef DEBUGGER_H
-#define DEBUGGER_H
-
-
-/* Fork, start gdb and connect to the parent process.
-   Exit with EXIT_FAILURE.
- */
-void connect_debugger (void) ;
-
-#endif
diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c
index a0ba84d898..3f4139b85d 100644
--- a/src/ui/terminal/main.c
+++ b/src/ui/terminal/main.c
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-2000, 2006-2007, 2009-2012 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -49,7 +49,6 @@
 #include "math/random.h"
 #include "output/driver.h"
 #include "output/message-item.h"
-#include "ui/debugger.h"
 #include "ui/source-init-opts.h"
 #include "ui/terminal/terminal-opts.h"
 #include "ui/terminal/terminal-reader.h"
@@ -194,9 +193,6 @@ bug_handler(int sig)
      recurse. */
   signal (sig, SIG_DFL);
 
-#if DEBUGGING
-  connect_debugger ();
-#endif
   switch (sig)
     {
     case SIGABRT:
diff --git a/tests/ui/terminal/main.at b/tests/ui/terminal/main.at
index 1a22f7a0e8..38a88eca14 100644
--- a/tests/ui/terminal/main.at
+++ b/tests/ui/terminal/main.at
@@ -34,6 +34,5 @@ include the syntax file that triggered it and a sample
 of any data file used for input.
 proximate cause:     Segmentation Violation
 ])
-AT_CHECK([sed -n '/\*\*\*/,$p
-/proximate/q' < stderr], [0], [expout])
+AT_CHECK([sed '/proximate/q' < stderr], [0], [expout])
 AT_CLEANUP
-- 
2.30.2