+Thu Nov 16 20:44:58 WST 2006 John Darrington <john@darrington.wattle.id.au>
+
+ * debugger.c debugger.h New files.
+
Mon Jul 17 18:22:18 WST 2006 John Darrington <john@darrington.wattle.id.au>
* flexifile.c flexifile.h: New files. Implementations of casefiles.
noinst_LIBRARIES += src/ui/libuicommon.a
src_ui_libuicommon_a_SOURCES = \
+ src/ui/debugger.c \
+ src/ui/debugger.h \
src/ui/flexifile.c \
src/ui/flexifile.h
--- /dev/null
+/* PSPP - computes sample statistics.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ Written by John Darrington <john@darrington.wattle.id.au>
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#include <config.h>
+
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+
+
+#include "debugger.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);
+}
+
--- /dev/null
+/* PSPP - computes sample statistics.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ Written by John Darrington <john@darrington.wattle.id.au>
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA. */
+
+#ifndef DEBUGGER_H
+#define DEBUGGER_H
+
+
+/* Fork, start gdb and connect to the parent process.
+ Exit with EXIT_FAILURE.
+ */
+void connect_debugger (void) ;
+
+#endif
+Thu Nov 16 20:46:35 WST 2006 John Darrington <john@darrington.wattle.id.au>
+
+ * main.c: Connect debugger on errors.
+
Tue Nov 7 20:54:32 WST 2006 John Darrington <john@darrington.wattle.id.au>
* command-line.c msg-ui.c msg-ui.h main.c: Added an -e
#include <signal.h>
#include <stdio.h>
+#include <ui/debugger.h>
#include "command-line.h"
#include "msg-ui.h"
#include "progname.h"
{
int result = cmd_parse (the_lexer, the_dataset,
proc_has_source (the_dataset)
- ? CMD_STATE_DATA : CMD_STATE_INITIAL);
+ ? CMD_STATE_DATA : CMD_STATE_INITIAL);
if (result == CMD_EOF || result == CMD_FINISH)
break;
if (result == CMD_CASCADING_FAILURE && !getl_is_interactive ())
void
bug_handler(int sig)
{
+#if DEBUGGING
+ connect_debugger ();
+#endif
switch (sig)
{
case SIGABRT: