gdb delay guile initialization until gdbscm_finish_initialization
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 22 Apr 2021 17:17:01 +0000 (18:17 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 28 Apr 2021 08:56:20 +0000 (09:56 +0100)
Like with the previous commit, this commit delays the initialisation
of the guile extension language until gdbscm_finish_initialization.

This is mostly about splitting the existing gdbscm_initialize_*
functions in two, all the calls to register_objfile_data_with_cleanup,
gdbarch_data_register_post_init, etc are moved into new _initialize_*
functions, but everything else is left in the gdbscm_initialize_*
functions.

Then the call to code previously in _initialize_guile is moved into
gdbscm_finish_initialization.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* guile/guile.c (gdbscm_set_backtrace): Add declaration.
(gdbscm_finish_initialization): Add code moved from
_initialize_guile.
(_initialize_guile): Move code to gdbscm_finish_initialization.
* guile/scm-arch.c (gdbscm_initialize_arches): Move some code into
_initialize_scm_arch.
(_initialize_scm_arch): New function.
* guile/scm-block.c (gdbscm_initialize_blocks): Move some code
into _initialize_scm_block.
(_initialize_scm_block): New function.
* guile/scm-frame.c (gdbscm_initialize_frames): Move some code
into _initialize_scm_frame.
(_initialize_scm_frame): New function.
* guile/scm-objfile.c (gdbscm_initialize_objfiles): Move some code
into _initialize_scm_objfile.
(_initialize_scm_objfile): New function.
* guile/scm-progspace.c (gdbscm_initialize_pspaces): Move some
code into _initialize_scm_progspace.
(_initialize_scm_progspace): New function.
* guile/scm-symbol.c (gdbscm_initialize_symbols): Move some code
into _initialize_scm_symbol.
(_initialize_scm_symbol): New function.
* guile/scm-symtab.c (gdbscm_initialize_symtabs): Move some code
into _initialize_scm_symtab.
(_initialize_scm_symtab): New function.
* guile/scm-type.c (gdbscm_initialize_types): Move some code into
_initialize_scm_type.
(_initialize_scm_type): New function.

gdb/ChangeLog
gdb/guile/guile.c
gdb/guile/scm-arch.c
gdb/guile/scm-block.c
gdb/guile/scm-frame.c
gdb/guile/scm-objfile.c
gdb/guile/scm-progspace.c
gdb/guile/scm-symbol.c
gdb/guile/scm-symtab.c
gdb/guile/scm-type.c

index c3156a8d07350f6aca760378f590da8e6d42c0cd..9c7dcd8eee78afc00d86f16f94d5f372314fa205 100644 (file)
@@ -1,3 +1,34 @@
+2021-04-28  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * guile/guile.c (gdbscm_set_backtrace): Add declaration.
+       (gdbscm_finish_initialization): Add code moved from
+       _initialize_guile.
+       (_initialize_guile): Move code to gdbscm_finish_initialization.
+       * guile/scm-arch.c (gdbscm_initialize_arches): Move some code into
+       _initialize_scm_arch.
+       (_initialize_scm_arch): New function.
+       * guile/scm-block.c (gdbscm_initialize_blocks): Move some code
+       into _initialize_scm_block.
+       (_initialize_scm_block): New function.
+       * guile/scm-frame.c (gdbscm_initialize_frames): Move some code
+       into _initialize_scm_frame.
+       (_initialize_scm_frame): New function.
+       * guile/scm-objfile.c (gdbscm_initialize_objfiles): Move some code
+       into _initialize_scm_objfile.
+       (_initialize_scm_objfile): New function.
+       * guile/scm-progspace.c (gdbscm_initialize_pspaces): Move some
+       code into _initialize_scm_progspace.
+       (_initialize_scm_progspace): New function.
+       * guile/scm-symbol.c (gdbscm_initialize_symbols): Move some code
+       into _initialize_scm_symbol.
+       (_initialize_scm_symbol): New function.
+       * guile/scm-symtab.c (gdbscm_initialize_symtabs): Move some code
+       into _initialize_scm_symtab.
+       (_initialize_scm_symtab): New function.
+       * guile/scm-type.c (gdbscm_initialize_types): Move some code into
+       _initialize_scm_type.
+       (_initialize_scm_type): New function.
+
 2021-04-28  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * python/py-arch.c (_initialize_py_arch): New function.
index 68c4532b3900308b23ab4a474389bb05af984d3f..9c2a40b61be7eb8994d9ab22290d89309800586a 100644 (file)
@@ -81,6 +81,7 @@ static int gdbscm_initialized (const struct extension_language_defn *);
 static void gdbscm_eval_from_control_command
   (const struct extension_language_defn *, struct command_line *);
 static script_sourcer_func gdbscm_source_script;
+static void gdbscm_set_backtrace (int enable);
 
 int gdb_scheme_initialized;
 
@@ -644,6 +645,40 @@ call_initialize_gdb_module (void *data)
 static void
 gdbscm_finish_initialization (const struct extension_language_defn *extlang)
 {
+#if HAVE_GUILE
+  /* 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.  */
+
+#if HAVE_GUILE_MANUAL_FINALIZATION
+  /* Our SMOB free functions are not thread-safe, as GDB itself is not
+     intended to be thread-safe.  Disable automatic finalization so that
+     finalizers aren't run in other threads.  */
+  scm_set_automatic_finalization_enabled (0);
+#endif
+
+  /* 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.  */
+  {
+    gdb::block_signals blocker;
+
+    /* 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.]  But only do this after
+     we've initialized Guile, it's nice to see a backtrace if there's an
+     error during initialization.  OTOH, if the error is that gdb/init.scm
+     wasn't found because gdb is being run from the build tree, the
+     backtrace is more noise than signal.  Sigh.  */
+  gdbscm_set_backtrace (0);
+#endif
+
   /* Restore the environment to the user interaction one.  */
   scm_set_current_module (scm_interaction_environment ());
 }
@@ -770,43 +805,4 @@ void
 _initialize_guile ()
 {
   install_gdb_commands ();
-
-#if HAVE_GUILE
-  {
-    /* 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.  */
-
-#if HAVE_GUILE_MANUAL_FINALIZATION
-    /* Our SMOB free functions are not thread-safe, as GDB itself is not
-       intended to be thread-safe.  Disable automatic finalization so that
-       finalizers aren't run in other threads.  */
-    scm_set_automatic_finalization_enabled (0);
-#endif
-
-    /* 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.  */
-    {
-      gdb::block_signals blocker;
-
-      /* 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.]
-       But only do this after we've initialized Guile, it's nice to see a
-       backtrace if there's an error during initialization.
-       OTOH, if the error is that gdb/init.scm wasn't found because gdb is
-       being run from the build tree, the backtrace is more noise than signal.
-       Sigh.  */
-    gdbscm_set_backtrace (0);
-  }
-#endif
 }
index f4f871d736ec0033b1b8eff8fbebfdf9070e7569..863e5026b4c31b0c52a0f8b5a612a4017acc7f50 100644 (file)
@@ -650,7 +650,12 @@ gdbscm_initialize_arches (void)
   scm_set_smob_print (arch_smob_tag, arscm_print_arch_smob);
 
   gdbscm_define_functions (arch_functions, 1);
+}
 
+void _initialize_scm_arch ();
+void
+_initialize_scm_arch ()
+{
   arch_object_data
     = gdbarch_data_register_post_init (arscm_object_data_init);
 }
index 05263a4202bfa2f5672bfa8d751e6d6ab09f9fbd..e7a1083fdc99a1f7bb1a7bc6aef65073268c3bd7 100644 (file)
@@ -799,7 +799,12 @@ gdbscm_initialize_blocks (void)
                                gdbscm_documentation_symbol,
                                gdbscm_scm_from_c_string ("\
 Internal function to assist the block symbols iterator."));
+}
 
+void _initialize_scm_block ();
+void
+_initialize_scm_block ()
+{
   /* Register an objfile "free" callback so we can properly
      invalidate blocks when an object file is about to be deleted.  */
   bkscm_objfile_data_key
index e932c2af7cdc92bf584fcb8ae38b2d7e66aa8b66..9d5dfa698bca0ed0ec2dcb31c1971722ebd6aec9 100644 (file)
@@ -1174,7 +1174,12 @@ gdbscm_initialize_frames (void)
   gdbscm_define_functions (frame_functions, 1);
 
   block_keyword = scm_from_latin1_keyword ("block");
+}
 
+void _initialize_scm_frame ();
+void
+_initialize_scm_frame ()
+{
   /* Register an inferior "free" callback so we can properly
      invalidate frames when an inferior file is about to be deleted.  */
   frscm_inferior_data_key
index 44c5f2da06a462f0c367f2836a058b015e808ba7..30e63f374e7410363a224f1a4893108085d81d5a 100644 (file)
@@ -428,7 +428,12 @@ gdbscm_initialize_objfiles (void)
   scm_set_smob_print (objfile_smob_tag, ofscm_print_objfile_smob);
 
   gdbscm_define_functions (objfile_functions, 1);
+}
 
+void _initialize_scm_objfile ();
+void
+_initialize_scm_objfile ()
+{
   ofscm_objfile_data_key
     = register_objfile_data_with_cleanup (NULL, ofscm_handle_objfile_deleted);
 }
index 561a848beaa45167a6d235651c5e1738e302170f..d28dba9e3f7da491255b6b2685ef07f227d1feac 100644 (file)
@@ -417,7 +417,12 @@ gdbscm_initialize_pspaces (void)
   scm_set_smob_print (pspace_smob_tag, psscm_print_pspace_smob);
 
   gdbscm_define_functions (pspace_functions, 1);
+}
 
+void _initialize_scm_progspace ();
+void
+_initialize_scm_progspace ()
+{
   psscm_pspace_data_key
     = register_program_space_data_with_cleanup (NULL,
                                                psscm_handle_pspace_deleted);
index 3a60d1bc8a102f25f318c1e7d256ff7f8cfa4ea9..324f64a149213d663f645f8948a3e51214be1372 100644 (file)
@@ -817,7 +817,12 @@ gdbscm_initialize_symbols (void)
   block_keyword = scm_from_latin1_keyword ("block");
   domain_keyword = scm_from_latin1_keyword ("domain");
   frame_keyword = scm_from_latin1_keyword ("frame");
+}
 
+void _initialize_scm_symbol ();
+void
+_initialize_scm_symbol ()
+{
   /* Register an objfile "free" callback so we can properly
      invalidate symbols when an object file is about to be deleted.  */
   syscm_objfile_data_key
index 3f4b6764ac19755ae974322a275a89af2cb42e93..b4edcef8678e89e03764f640f059720d9fa39cea 100644 (file)
@@ -688,7 +688,12 @@ gdbscm_initialize_symtabs (void)
   scm_set_smob_print (sal_smob_tag, stscm_print_sal_smob);
 
   gdbscm_define_functions (symtab_functions, 1);
+}
 
+void _initialize_scm_symtab ();
+void
+_initialize_scm_symtab ()
+{
   /* Register an objfile "free" callback so we can properly
      invalidate symbol tables, and symbol table and line data
      structures when an object file that is about to be deleted.  */
index 11693844edcb85b8fa47cfd9a0e6dd6f05666264..8d9c2c5f9a4e5b54c4c493393db9e762be40e2ba 100644 (file)
@@ -1505,11 +1505,16 @@ Internal function to assist the type fields iterator."));
 
   block_keyword = scm_from_latin1_keyword ("block");
 
+  global_types_map = gdbscm_create_eqable_gsmob_ptr_map (tyscm_hash_type_smob,
+                                                        tyscm_eq_type_smob);
+}
+
+void _initialize_scm_type ();
+void
+_initialize_scm_type ()
+{
   /* Register an objfile "free" callback so we can properly copy types
      associated with the objfile when it's about to be deleted.  */
   tyscm_objfile_data_key
     = register_objfile_data_with_cleanup (save_objfile_types, NULL);
-
-  global_types_map = gdbscm_create_eqable_gsmob_ptr_map (tyscm_hash_type_smob,
-                                                        tyscm_eq_type_smob);
 }
This page took 0.040319 seconds and 4 git commands to generate.