public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] guile.c: Replace call to scm_init_guile with scm_with_guile.
@ 2014-02-17  5:55 Doug Evans
  2014-03-11  4:10 ` Doug Evans
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Evans @ 2014-02-17  5:55 UTC (permalink / raw)
  To: gdb-patches

Hi.

scm_with_guile is a better way to initialize Guile than scm_init_guile
(scm_init_guile is less portable according to the docs),
plus it's good to do all the initialization from within a call to
scm_with_guile.

This patch does that.
Regression tested on amd64-linux with guile 2.0.9.

2014-02-17  Doug Evans  <xdje42@gmail.com>

	* guile/guile.c (call_initialize_gdb_module): New function.
	(initialize_guile): Replace call to scm_init_guile with call to
	scm_with_guile.

diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index b7134f7..f2fd8d8 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -561,6 +561,20 @@ initialize_gdb_module (void *data)
   gdb_scheme_initialized = 1;
 }
 
+/* Utility to call scm_c_define_module+initialize_gdb_module from
+   within scm_with_guile.  */
+
+static void *
+call_initialize_gdb_module (void *data)
+{
+  /* Most of the initialization is done by initialize_gdb_module.
+     It is called via scm_c_define_module so that the initialization is
+     performed within the desired module.  */
+  scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL);
+
+  return NULL;
+}
+
 /* A callback to finish Guile initialization after gdb has finished all its
    initialization.
    This is the extension_language_ops.finish_initialization "method".  */
@@ -697,20 +711,14 @@ _initialize_guile (void)
   install_gdb_commands ();
 
 #if HAVE_GUILE
-  /* The Guile docs say scm_init_guile isn't as portable as the other Guile
-     initialization routines.  However, this is the easiest to use.
-     We can switch to a more portable routine if/when the need arises
-     and if it can be used with gdb.  */
-  scm_init_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.  */
 
-  /* The rest of the initialization is done by initialize_gdb_module.
-     scm_c_define_module is used as it allows us to perform the initialization
-     within the desired module.  */
-  scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL);
+  /* 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.]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] guile.c: Replace call to scm_init_guile with scm_with_guile.
  2014-02-17  5:55 [PATCH] guile.c: Replace call to scm_init_guile with scm_with_guile Doug Evans
@ 2014-03-11  4:10 ` Doug Evans
  0 siblings, 0 replies; 2+ messages in thread
From: Doug Evans @ 2014-03-11  4:10 UTC (permalink / raw)
  To: gdb-patches

On Sun, Feb 16, 2014 at 9:55 PM, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> scm_with_guile is a better way to initialize Guile than scm_init_guile
> (scm_init_guile is less portable according to the docs),
> plus it's good to do all the initialization from within a call to
> scm_with_guile.
>
> This patch does that.
> Regression tested on amd64-linux with guile 2.0.9.
>
> 2014-02-17  Doug Evans  <xdje42@gmail.com>
>
>         * guile/guile.c (call_initialize_gdb_module): New function.
>         (initialize_guile): Replace call to scm_init_guile with call to
>         scm_with_guile.

Committed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-11  4:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17  5:55 [PATCH] guile.c: Replace call to scm_init_guile with scm_with_guile Doug Evans
2014-03-11  4:10 ` Doug Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).