Replace most calls to help_list and cmd_show_list
[deliverable/binutils-gdb.git] / gdb / guile / guile.c
index 55929f4455177ba443d03fe50fdf7a4d7f7a643d..2b82f82820fe3612451214f1c1b5f6c625a55d56 100644 (file)
@@ -1,6 +1,6 @@
 /* General GDB/Guile code.
 
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -36,6 +36,7 @@
 #include "guile-internal.h"
 #endif
 #include <signal.h>
+#include "gdbsupport/block-signals.h"
 
 /* The Guile version we're using.
    We *could* use the macros in libguile/version.h but that would preclude
@@ -395,33 +396,6 @@ static struct cmd_list_element *set_guile_list;
 static struct cmd_list_element *show_guile_list;
 static struct cmd_list_element *info_guile_list;
 
-/* Function for use by 'set guile' prefix command.  */
-
-static void
-set_guile_command (const char *args, int from_tty)
-{
-  help_list (set_guile_list, "set guile ", all_commands, gdb_stdout);
-}
-
-/* Function for use by 'show guile' prefix command.  */
-
-static void
-show_guile_command (const char *args, int from_tty)
-{
-  cmd_show_list (show_guile_list, from_tty, "");
-}
-
-/* The "info scheme" command is defined as a prefix, with
-   allow_unknown 0.  Therefore, its own definition is called only for
-   "info scheme" with no args.  */
-
-static void
-info_guile_command (const char *args, int from_tty)
-{
-  printf_unfiltered (_("\"info guile\" must be followed"
-                      " by the name of an info command.\n"));
-  help_list (info_guile_list, "info guile ", all_commands, gdb_stdout);
-}
 \f
 /* Initialization.  */
 
@@ -760,22 +734,22 @@ This command is only a placeholder.")
           );
   add_com_alias ("gu", "guile", class_obscure, 1);
 
-  add_prefix_cmd ("guile", class_obscure, set_guile_command,
-                 _("Prefix command for Guile preference settings."),
-                 &set_guile_list, "set guile ", 0,
-                 &setlist);
+  add_basic_prefix_cmd ("guile", class_obscure,
+                       _("Prefix command for Guile preference settings."),
+                       &set_guile_list, "set guile ", 0,
+                       &setlist);
   add_alias_cmd ("gu", "guile", class_obscure, 1, &setlist);
 
-  add_prefix_cmd ("guile", class_obscure, show_guile_command,
-                 _("Prefix command for Guile preference settings."),
-                 &show_guile_list, "show guile ", 0,
-                 &showlist);
+  add_show_prefix_cmd ("guile", class_obscure,
+                      _("Prefix command for Guile preference settings."),
+                      &show_guile_list, "show guile ", 0,
+                      &showlist);
   add_alias_cmd ("gu", "guile", class_obscure, 1, &showlist);
 
-  add_prefix_cmd ("guile", class_obscure, info_guile_command,
-                 _("Prefix command for Guile info displays."),
-                 &info_guile_list, "info guile ", 0,
-                 &infolist);
+  add_basic_prefix_cmd ("guile", class_obscure,
+                       _("Prefix command for Guile info displays."),
+                       &info_guile_list, "info guile ", 0,
+                       &infolist);
   add_info_alias ("gu", "guile", 1);
 
   /* The name "print-stack" is carried over from Python.
@@ -791,17 +765,14 @@ message == an error message without a stack will be printed."),
                        &set_guile_list, &show_guile_list);
 }
 
+void _initialize_guile ();
 void
-_initialize_guile (void)
+_initialize_guile ()
 {
   install_gdb_commands ();
 
 #if HAVE_GUILE
   {
-#ifdef HAVE_SIGPROCMASK
-    sigset_t sigchld_mask, prev_mask;
-#endif
-
     /* The Python support puts the C side in module "_gdb", leaving the Python
        side to define module "gdb" which imports "_gdb".  There is evidently no
        similar convention in Guile so we skip this.  */
@@ -813,25 +784,20 @@ _initialize_guile (void)
     scm_set_automatic_finalization_enabled (0);
 #endif
 
-#ifdef HAVE_SIGPROCMASK
-    /* Before we initialize Guile, block SIGCHLD.
+    /* Before we initialize Guile, block signals needed by gdb
+       (especially SIGCHLD).
        This is done so that all threads created during Guile initialization
        have SIGCHLD blocked.  PR 17247.
        Really libgc and Guile should do this, but we need to work with
        libgc 7.4.x.  */
-    sigemptyset (&sigchld_mask);
-    sigaddset (&sigchld_mask, SIGCHLD);
-    sigprocmask (SIG_BLOCK, &sigchld_mask, &prev_mask);
-#endif
-
-    /* scm_with_guile is the most portable way to initialize Guile.
-       Plus we need to initialize the Guile support while in Guile mode
-       (e.g., called from within a call to scm_with_guile).  */
-    scm_with_guile (call_initialize_gdb_module, NULL);
+    {
+      gdb::block_signals blocker;
 
-#ifdef HAVE_SIGPROCMASK
-    sigprocmask (SIG_SETMASK, &prev_mask, NULL);
-#endif
+      /* scm_with_guile is the most portable way to initialize Guile.
+        Plus we need to initialize the Guile support while in Guile mode
+        (e.g., called from within a call to scm_with_guile).  */
+      scm_with_guile (call_initialize_gdb_module, NULL);
+    }
 
     /* Set Guile's backtrace to match the "set guile print-stack" default.
        [N.B. The two settings are still separate.]
This page took 0.027521 seconds and 4 git commands to generate.