From a5d0c135c0bbff2fdcfb68cf8a7b4013f3b9aa58 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 27 Nov 2013 22:30:15 +0100 Subject: [PATCH] Remove nonfunctional gdb interface * libguile/gdb_interface.h: * libguile/gdbint.c: * libguile/gdbint.h: Remove. These were last modified significantly in 1997 and I think they are unused. * libguile/guile.c: Remove use. * libguile.h: Remove inclusion. * libguile/Makefile.am: Remove reference. * libguile/init.c: Remove use. --- libguile.h | 3 +- libguile/Makefile.am | 3 - libguile/gdb_interface.h | 154 ----------------------- libguile/gdbint.c | 266 --------------------------------------- libguile/gdbint.h | 40 ------ libguile/guile.c | 6 - libguile/init.c | 2 - 7 files changed, 1 insertion(+), 473 deletions(-) delete mode 100644 libguile/gdb_interface.h delete mode 100644 libguile/gdbint.c delete mode 100644 libguile/gdbint.h diff --git a/libguile.h b/libguile.h index 9a9742919..b067b28a5 100644 --- a/libguile.h +++ b/libguile.h @@ -1,7 +1,7 @@ #ifndef SCM_LIBGUILE_H #define SCM_LIBGUILE_H -/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -54,7 +54,6 @@ extern "C" { #include "libguile/foreign.h" #include "libguile/fports.h" #include "libguile/gc.h" -#include "libguile/gdbint.h" #include "libguile/generalized-arrays.h" #include "libguile/generalized-vectors.h" #include "libguile/goops.h" diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 273e1b6e4..24d36f242 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -151,7 +151,6 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \ frames.c \ gc-malloc.c \ gc.c \ - gdbint.c \ gettext.c \ generalized-arrays.c \ generalized-vectors.c \ @@ -559,8 +558,6 @@ modinclude_HEADERS = \ fports.h \ frames.h \ gc.h \ - gdb_interface.h \ - gdbint.h \ gettext.h \ generalized-arrays.h \ generalized-vectors.h \ diff --git a/libguile/gdb_interface.h b/libguile/gdb_interface.h deleted file mode 100644 index 2278fc2c2..000000000 --- a/libguile/gdb_interface.h +++ /dev/null @@ -1,154 +0,0 @@ -/* classes: h_files */ - -#ifndef GDB_INTERFACE_H -#define GDB_INTERFACE_H -/* Simple interpreter interface for GDB, the GNU debugger. - Copyright (C) 1996, 2000, 2001, 2006 Free Software Foundation - - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - -The author can be reached at djurfeldt@nada.kth.se -Mikael Djurfeldt, SANS/NADA KTH, 10044 STOCKHOLM, SWEDEN */ - -/* This is the header file for GDB's interpreter interface. The - interpreter must supply definitions of all symbols declared in this - file. - - Before including this file, you must #define GDB_TYPE to be the - data type used for communication with the interpreter. */ - -/* The following macro can be used to anchor the symbols of the - interface in your main program. This is necessary if the interface - is defined in a library, such as Guile. */ - -#if !defined (__MINGW32__) && !defined (__CYGWIN__) -#define GDB_INTERFACE \ -void *gdb_interface[] = { \ - &gdb_options, \ - &gdb_language, \ - &gdb_result, \ - &gdb_output, \ - &gdb_output_length, \ - (void *) gdb_maybe_valid_type_p, \ - (void *) gdb_read, \ - (void *) gdb_eval, \ - (void *) gdb_print, \ - (void *) gdb_binding \ -} -#else /* __MINGW32__, __CYGWIN__ */ -/* Because the following functions are imported from a DLL (some kind of - shared library) these are NO static initializers. That is why you need to - define them and assign the functions and data items at run time. */ -#define GDB_INTERFACE \ -void *gdb_interface[] = \ - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; -#define GDB_INTERFACE_INIT \ - do { \ - gdb_interface[0] = &gdb_options; \ - gdb_interface[1] = &gdb_language; \ - gdb_interface[2] = &gdb_result; \ - gdb_interface[3] = &gdb_output; \ - gdb_interface[4] = &gdb_output_length; \ - gdb_interface[5] = (void *) gdb_maybe_valid_type_p; \ - gdb_interface[6] = (void *) gdb_read; \ - gdb_interface[7] = (void *) gdb_eval; \ - gdb_interface[8] = (void *) gdb_print; \ - gdb_interface[9] = (void *) gdb_binding; \ - } while (0); -#endif /* __MINGW32__ */ - -/* GDB_OPTIONS is a set of flags informing gdb what features are present - in the interface. Currently only one option is supported: */ - -/* GDB_HAVE_BINDINGS: Set this bit if your interpreter can create new - top level bindings on demand (through gdb_top_level_binding) */ - -#define GDB_HAVE_BINDINGS 1 - -SCM_API unsigned short gdb_options; - -/* GDB_LANGUAGE holds the name of the preferred language mode for this - interpreter. For lisp interpreters, the suggested mode is "lisp/c". */ - -SCM_API char *gdb_language; - -/* GDB_RESULT is used for passing results from the interpreter to GDB */ - -SCM_API GDB_TYPE gdb_result; - -/* The interpreter passes strings to GDB in GDB_OUTPUT and - GDB_OUTPUT_LENGTH. GDB_OUTPUT should hold the pointer to the - string. GDB_OUTPUT_LENGTH should hold its length. The string - doesn't need to be terminated by '\0'. */ - -SCM_API char *gdb_output; - -SCM_API int gdb_output_length; - -/* Return TRUE if the interpreter regards VALUE's type as valid. A - lazy implementation is allowed to pass TRUE always. FALSE should - only be returned when it is certain that VALUE is not valid. - - In the "lisp/c" language mode, this is used to heuristically - discriminate lisp values from C values during printing. */ - -SCM_API int gdb_maybe_valid_type_p (GDB_TYPE value); - -/* Parse expression in string STR. Store result in GDB_RESULT, then - return 0 to indicate success. On error, return -1 to indicate - failure. An error string can be passed in GDB_OUTPUT and - GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero if - no message is passed. Please note that the resulting value should - be protected against garbage collection. */ - -SCM_API int gdb_read (char *str); - -/* Evaluate expression EXP. Store result in GDB_RESULT, then return 0 - to indicate success. On error, return -1 to indicate failure. Any - output (both on success and failure) can be passed in GDB_OUTPUT - and GDB_OUTPUT_LENGTH. Be careful to set GDB_OUTPUT_LENGTH to zero - if no output is passed. Please note that the resulting lisp object - should be protected against garbage collection. */ - -SCM_API int gdb_eval (GDB_TYPE exp); - -/* Print VALUE. Store output in GDB_OUTPUT and GDB_OUTPUT_LENGTH. - Return 0 to indicate success. On error, return -1 to indicate - failure. GDB will not look at GDB_OUTPUT or GDB_OUTPUT_LENGTH on - failure. Note that this function should be robust against strange - values. It could in fact be passed any kind of value. */ - -SCM_API int gdb_print (GDB_TYPE value); - -/* Bind NAME to VALUE in interpreter. (GDB has previously obtained - NAME by passing a string to gdb_read.) Return 0 to indicate - success or -1 to indicate failure. This feature is optional. GDB - will only call this function if the GDB_HAVE_BINDINGS flag is set - in gdb_options. Note that GDB may call this function many times - for the same name. - - For scheme interpreters, this function should introduce top-level - bindings. */ - -SCM_API int gdb_binding (GDB_TYPE name, GDB_TYPE value); - -#endif /* GDB_INTERFACE_H */ - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ diff --git a/libguile/gdbint.c b/libguile/gdbint.c deleted file mode 100644 index 2df3c5c46..000000000 --- a/libguile/gdbint.c +++ /dev/null @@ -1,266 +0,0 @@ -/* GDB interface for Guile - * Copyright (C) 1996,1997,1999,2000,2001,2002,2004,2009,2011,2012 - * Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "libguile/_scm.h" - -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "libguile/strports.h" -#include "libguile/read.h" -#include "libguile/eval.h" -#include "libguile/chars.h" -#include "libguile/modules.h" -#include "libguile/ports.h" -#include "libguile/fluids.h" -#include "libguile/strings.h" -#include "libguile/init.h" - -#include "libguile/gdbint.h" - -/* {Support for debugging with gdb} - * - * TODO: - * - * 1. Redirect outputs - * 2. Catch errors - * 3. Prevent print from causing segmentation fault when given broken pairs - */ - -#define GDB_TYPE SCM - -#include "libguile/gdb_interface.h" - - - -/* Be carefull when this macro is true. - scm_gc_running_p is set during gc. - */ -#define SCM_GC_P (scm_gc_running_p) - -/* Macros that encapsulate blocks of code which can be called by the - * debugger. - */ -#define SCM_BEGIN_FOREIGN_BLOCK \ -do { \ - scm_print_carefully_p = 1; \ -} while (0) - - -#define SCM_END_FOREIGN_BLOCK \ -do { \ - scm_print_carefully_p = 0; \ -} while (0) - - -#define RESET_STRING { gdb_output_length = 0; } - -#define SEND_STRING(str) \ -do { \ - gdb_output = (char *) (str); \ - gdb_output_length = strlen ((const char *) (str)); \ -} while (0) - - -/* {Gdb interface} - */ - -unsigned short gdb_options = GDB_HAVE_BINDINGS; - -char *gdb_language = "lisp/c"; - -SCM gdb_result; - -char *gdb_output; - -int gdb_output_length; - -int scm_print_carefully_p; - -static SCM gdb_input_port; -static SCM gdb_output_port; - - -int -gdb_maybe_valid_type_p (SCM value) -{ - return SCM_IMP (value); /* || scm_in_heap_p (value); */ /* FIXME: What to - do? */ -} - - -int -gdb_read (char *str) -{ -#if 0 - SCM ans; - int status = 0; - RESET_STRING; - /* Need to be restrictive about what to read? */ - if (1) /* (SCM_GC_P) */ /* FIXME */ - { - char *p; - for (p = str; *p != '\0'; ++p) - switch (*p) - { - case '(': - case '\'': - case '"': - SEND_STRING ("Can't read this kind of expressions during gc"); - return -1; - case '#': - if (*++p == '\0') - goto premature; - if (*p == '\\') - { - if (*++p != '\0') - continue; - premature: - SEND_STRING ("Premature end of lisp expression"); - return -1; - } - default: - continue; - } - } - SCM_BEGIN_FOREIGN_BLOCK; - unmark_port (gdb_input_port); - scm_seek (gdb_input_port, SCM_INUM0, scm_from_int (SEEK_SET)); - scm_puts_unlocked (str, gdb_input_port); - scm_truncate_file (gdb_input_port, SCM_UNDEFINED); - scm_seek (gdb_input_port, SCM_INUM0, scm_from_int (SEEK_SET)); - - /* Read one object */ - ans = scm_read (gdb_input_port); - if (SCM_GC_P) - { - if (SCM_HEAP_OBJECT_P (ans)) - { - SEND_STRING ("Non-immediate created during gc. Memory may be trashed."); - status = -1; - goto exit; - } - } - gdb_result = ans; - /* Protect answer from future GC (FIXME: still needed with BDW-GC?) */ - if (SCM_HEAP_OBJECT_P (ans)) - scm_permanent_object (ans); -exit: - remark_port (gdb_input_port); - SCM_END_FOREIGN_BLOCK; - return status; -#else - abort (); -#endif -} - - -int -gdb_eval (SCM exp) -{ - RESET_STRING; - if (SCM_GC_P) - { - SEND_STRING ("Can't evaluate lisp expressions during gc"); - return -1; - } - SCM_BEGIN_FOREIGN_BLOCK; - { - gdb_result = scm_permanent_object (scm_primitive_eval (exp)); - } - SCM_END_FOREIGN_BLOCK; - return 0; -} - - -int -gdb_print (SCM obj) -{ - if (!scm_initialized_p) - SEND_STRING ("*** Guile not initialized ***"); - else - { - RESET_STRING; - SCM_BEGIN_FOREIGN_BLOCK; - /* Reset stream */ - scm_seek (gdb_output_port, SCM_INUM0, scm_from_int (SEEK_SET)); - scm_write (obj, gdb_output_port); - scm_truncate_file (gdb_output_port, SCM_UNDEFINED); - { - scm_t_port *pt = SCM_PTAB_ENTRY (gdb_output_port); - - scm_flush_unlocked (gdb_output_port); - *(pt->write_buf + pt->read_buf_size) = 0; - SEND_STRING (pt->read_buf); - } - SCM_END_FOREIGN_BLOCK; - } - return 0; -} - - -int -gdb_binding (SCM name, SCM value) -{ - RESET_STRING; - if (SCM_GC_P) - { - SEND_STRING ("Can't create new bindings during gc"); - return -1; - } - SCM_BEGIN_FOREIGN_BLOCK; - { - scm_define (name, value); - } - SCM_END_FOREIGN_BLOCK; - return 0; -} - -void -scm_init_gdbint () -{ - static char *s = "scm_init_gdb_interface"; - SCM port; - - scm_print_carefully_p = 0; - - port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F, - SCM_OPN | SCM_WRTNG, - s); - gdb_output_port = scm_permanent_object (port); - - port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F, - SCM_OPN | SCM_RDNG | SCM_WRTNG, - s); - gdb_input_port = scm_permanent_object (port); -} - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ diff --git a/libguile/gdbint.h b/libguile/gdbint.h deleted file mode 100644 index d7c6cf31e..000000000 --- a/libguile/gdbint.h +++ /dev/null @@ -1,40 +0,0 @@ -/* classes: h_files */ - -#ifndef SCM_GDBINT_H -#define SCM_GDBINT_H - -/* Copyright (C) 1996,2000, 2006, 2008 Free Software Foundation, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 3 of - * the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - - - -#include "libguile/__scm.h" - - - -SCM_API int scm_print_carefully_p; - -SCM_INTERNAL void scm_init_gdbint (void); - -#endif /* SCM_GDBINT_H */ - -/* - Local Variables: - c-file-style: "gnu" - End: -*/ diff --git a/libguile/guile.c b/libguile/guile.c index 03b603eb2..f827d2642 100644 --- a/libguile/guile.c +++ b/libguile/guile.c @@ -43,11 +43,6 @@ #include #endif -/* Debugger interface (don't change the order of the following lines) */ -#define GDB_TYPE SCM -#include -GDB_INTERFACE; - static void inner_main (void *closure SCM_UNUSED, int argc, char **argv) { @@ -55,7 +50,6 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv) /* This is necessary to startup the Winsock API under Win32. */ WSADATA WSAData; WSAStartup (0x0202, &WSAData); - GDB_INTERFACE_INIT; #endif /* __MINGW32__ */ /* module initializations would go here */ diff --git a/libguile/init.c b/libguile/init.c index da6a857a7..54f73a92d 100644 --- a/libguile/init.c +++ b/libguile/init.c @@ -64,7 +64,6 @@ #include "libguile/fports.h" #include "libguile/frames.h" #include "libguile/gc.h" -#include "libguile/gdbint.h" #include "libguile/generalized-arrays.h" #include "libguile/generalized-vectors.h" #include "libguile/goops.h" @@ -438,7 +437,6 @@ scm_i_init_guile (void *base) scm_init_stime (); scm_init_gc (); /* Requires hooks and `get_internal_run_time' */ scm_init_gc_protect_object (); /* requires threads_prehistory */ - scm_init_gdbint (); /* Requires strports, gc_protect_object */ scm_init_gettext (); scm_init_ioext (); scm_init_keywords (); /* Requires smob_prehistory */