make calls to help_list use enumerator
[platform/upstream/binutils.git] / gdb / guile / guile.c
1 /* General GDB/Guile code.
2
3    Copyright (C) 2014 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 /* See README file in this directory for implementation notes, coding
21    conventions, et.al.  */
22
23 #include "defs.h"
24 #include <string.h>
25 #include "breakpoint.h"
26 #include "cli/cli-cmds.h"
27 #include "cli/cli-script.h"
28 #include "cli/cli-utils.h"
29 #include "command.h"
30 #include "gdbcmd.h"
31 #include "interps.h"
32 #include "extension-priv.h"
33 #include "utils.h"
34 #include "version.h"
35 #ifdef HAVE_GUILE
36 #include "guile.h"
37 #include "guile-internal.h"
38 #endif
39
40 /* The Guile version we're using.
41    We *could* use the macros in libguile/version.h but that would preclude
42    handling the user switching in a different version with, e.g.,
43    LD_LIBRARY_PATH (using a different version than what gdb was compiled with
44    is not something to be done lightly, but can be useful).  */
45 int gdbscm_guile_major_version;
46 int gdbscm_guile_minor_version;
47 int gdbscm_guile_micro_version;
48
49 /* The guile subdirectory within gdb's data-directory.  */
50 static const char *guile_datadir;
51
52 /* Declared constants and enum for guile exception printing.  */
53 const char gdbscm_print_excp_none[] = "none";
54 const char gdbscm_print_excp_full[] = "full";
55 const char gdbscm_print_excp_message[] = "message";
56
57 /* "set guile print-stack" choices.  */
58 static const char *const guile_print_excp_enums[] =
59   {
60     gdbscm_print_excp_none,
61     gdbscm_print_excp_full,
62     gdbscm_print_excp_message,
63     NULL
64   };
65
66 /* The exception printing variable.  'full' if we want to print the
67    error message and stack, 'none' if we want to print nothing, and
68    'message' if we only want to print the error message.  'message' is
69    the default.  */
70 const char *gdbscm_print_excp = gdbscm_print_excp_message;
71
72 #ifdef HAVE_GUILE
73 /* Forward decls, these are defined later.  */
74 static const struct extension_language_script_ops guile_extension_script_ops;
75 static const struct extension_language_ops guile_extension_ops;
76 #endif
77
78 /* The main struct describing GDB's interface to the Guile
79    extension language.  */
80 const struct extension_language_defn extension_language_guile =
81 {
82   EXT_LANG_GUILE,
83   "guile",
84   "Guile",
85
86   ".scm",
87   "-gdb.scm",
88
89   guile_control,
90
91 #ifdef HAVE_GUILE
92   &guile_extension_script_ops,
93   &guile_extension_ops
94 #else
95   NULL,
96   NULL
97 #endif
98 };
99 \f
100 #ifdef HAVE_GUILE
101
102 static void gdbscm_finish_initialization
103   (const struct extension_language_defn *);
104 static int gdbscm_initialized (const struct extension_language_defn *);
105 static void gdbscm_eval_from_control_command
106   (const struct extension_language_defn *, struct command_line *);
107 static script_sourcer_func gdbscm_source_script;
108
109 int gdb_scheme_initialized;
110
111 /* Symbol for setting documentation strings.  */
112 SCM gdbscm_documentation_symbol;
113
114 /* Keywords used by various functions.  */
115 static SCM from_tty_keyword;
116 static SCM to_string_keyword;
117
118 /* The name of the various modules (without the surrounding parens).  */
119 const char gdbscm_module_name[] = "gdb";
120 const char gdbscm_init_module_name[] = "gdb init";
121
122 /* The name of the bootstrap file.  */
123 static const char boot_scm_filename[] = "boot.scm";
124
125 /* The interface between gdb proper and loading of python scripts.  */
126
127 static const struct extension_language_script_ops guile_extension_script_ops =
128 {
129   gdbscm_source_script,
130   gdbscm_source_objfile_script,
131   gdbscm_auto_load_enabled
132 };
133
134 /* The interface between gdb proper and guile scripting.  */
135
136 static const struct extension_language_ops guile_extension_ops =
137 {
138   gdbscm_finish_initialization,
139   gdbscm_initialized,
140
141   gdbscm_eval_from_control_command,
142
143   NULL, /* gdbscm_start_type_printers, */
144   NULL, /* gdbscm_apply_type_printers, */
145   NULL, /* gdbscm_free_type_printers, */
146
147   gdbscm_apply_val_pretty_printer,
148
149   NULL, /* gdbscm_apply_frame_filter, */
150
151   gdbscm_preserve_values,
152
153   gdbscm_breakpoint_has_cond,
154   gdbscm_breakpoint_cond_says_stop,
155
156   NULL, /* gdbscm_check_quit_flag, */
157   NULL, /* gdbscm_clear_quit_flag, */
158   NULL, /* gdbscm_set_quit_flag, */
159 };
160
161 /* Implementation of the gdb "guile-repl" command.  */
162
163 static void
164 guile_repl_command (char *arg, int from_tty)
165 {
166   struct cleanup *cleanup;
167
168   cleanup = make_cleanup_restore_integer (&interpreter_async);
169   interpreter_async = 0;
170
171   arg = skip_spaces (arg);
172
173   /* This explicitly rejects any arguments for now.
174      "It is easier to relax a restriction than impose one after the fact."
175      We would *like* to be able to pass arguments to the interactive shell
176      but that's not what python-interactive does.  Until there is time to
177      sort it out, we forbid arguments.  */
178
179   if (arg && *arg)
180     error (_("guile-repl currently does not take any arguments."));
181   else
182     {
183       dont_repeat ();
184       gdbscm_enter_repl ();
185     }
186
187   do_cleanups (cleanup);
188 }
189
190 /* Implementation of the gdb "guile" command.
191    Note: Contrary to the Python version this displays the result.
192    Have to see which is better.
193
194    TODO: Add the result to Guile's history?  */
195
196 static void
197 guile_command (char *arg, int from_tty)
198 {
199   struct cleanup *cleanup;
200
201   cleanup = make_cleanup_restore_integer (&interpreter_async);
202   interpreter_async = 0;
203
204   arg = skip_spaces (arg);
205
206   if (arg && *arg)
207     {
208       char *msg = gdbscm_safe_eval_string (arg, 1);
209
210       if (msg != NULL)
211         {
212           make_cleanup (xfree, msg);
213           error ("%s", msg);
214         }
215     }
216   else
217     {
218       struct command_line *l = get_command_line (guile_control, "");
219
220       make_cleanup_free_command_lines (&l);
221       execute_control_command_untraced (l);
222     }
223
224   do_cleanups (cleanup);
225 }
226
227 /* Given a command_line, return a command string suitable for passing
228    to Guile.  Lines in the string are separated by newlines.  The return
229    value is allocated using xmalloc and the caller is responsible for
230    freeing it.  */
231
232 static char *
233 compute_scheme_string (struct command_line *l)
234 {
235   struct command_line *iter;
236   char *script = NULL;
237   int size = 0;
238   int here;
239
240   for (iter = l; iter; iter = iter->next)
241     size += strlen (iter->line) + 1;
242
243   script = xmalloc (size + 1);
244   here = 0;
245   for (iter = l; iter; iter = iter->next)
246     {
247       int len = strlen (iter->line);
248
249       strcpy (&script[here], iter->line);
250       here += len;
251       script[here++] = '\n';
252     }
253   script[here] = '\0';
254   return script;
255 }
256
257 /* Take a command line structure representing a "guile" command, and
258    evaluate its body using the Guile interpreter.
259    This is the extension_language_ops.eval_from_control_command "method".  */
260
261 static void
262 gdbscm_eval_from_control_command
263   (const struct extension_language_defn *extlang, struct command_line *cmd)
264 {
265   char *script, *msg;
266   struct cleanup *cleanup;
267
268   if (cmd->body_count != 1)
269     error (_("Invalid \"guile\" block structure."));
270
271   cleanup = make_cleanup (null_cleanup, NULL);
272
273   script = compute_scheme_string (cmd->body_list[0]);
274   msg = gdbscm_safe_eval_string (script, 0);
275   xfree (script);
276   if (msg != NULL)
277     {
278       make_cleanup (xfree, msg);
279       error ("%s", msg);
280     }
281
282   do_cleanups (cleanup);
283 }
284
285 /* Read a file as Scheme code.
286    This is the extension_language_script_ops.script_sourcer "method".
287    FILE is the file to run.  FILENAME is name of the file FILE.
288    This does not throw any errors.  If an exception occurs an error message
289    is printed.  */
290
291 static void
292 gdbscm_source_script (const struct extension_language_defn *extlang,
293                       FILE *file, const char *filename)
294 {
295   char *msg = gdbscm_safe_source_script (filename);
296
297   if (msg != NULL)
298     {
299       fprintf_filtered (gdb_stderr, "%s\n", msg);
300       xfree (msg);
301     }
302 }
303 \f
304 /* (execute string [#:from-tty boolean] [#:to-string boolean\
305    A Scheme function which evaluates a string using the gdb CLI.  */
306
307 static SCM
308 gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
309 {
310   int from_tty_arg_pos = -1, to_string_arg_pos = -1;
311   int from_tty = 0, to_string = 0;
312   volatile struct gdb_exception except;
313   const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F };
314   char *command;
315   char *result = NULL;
316   struct cleanup *cleanups;
317
318   gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt",
319                               command_scm, &command, rest,
320                               &from_tty_arg_pos, &from_tty,
321                               &to_string_arg_pos, &to_string);
322
323   /* Note: The contents of "command" may get modified while it is
324      executed.  */
325   cleanups = make_cleanup (xfree, command);
326
327   TRY_CATCH (except, RETURN_MASK_ALL)
328     {
329       struct cleanup *inner_cleanups;
330
331       inner_cleanups = make_cleanup_restore_integer (&interpreter_async);
332       interpreter_async = 0;
333
334       prevent_dont_repeat ();
335       if (to_string)
336         result = execute_command_to_string (command, from_tty);
337       else
338         {
339           execute_command (command, from_tty);
340           result = NULL;
341         }
342
343       /* Do any commands attached to breakpoint we stopped at.  */
344       bpstat_do_actions ();
345
346       do_cleanups (inner_cleanups);
347     }
348   do_cleanups (cleanups);
349   GDBSCM_HANDLE_GDB_EXCEPTION (except);
350
351   if (result)
352     {
353       SCM r = gdbscm_scm_from_c_string (result);
354       xfree (result);
355       return r;
356     }
357   return SCM_UNSPECIFIED;
358 }
359
360 /* (data-directory) -> string */
361
362 static SCM
363 gdbscm_data_directory (void)
364 {
365   return gdbscm_scm_from_c_string (gdb_datadir);
366 }
367
368 /* (guile-data-directory) -> string */
369
370 static SCM
371 gdbscm_guile_data_directory (void)
372 {
373   return gdbscm_scm_from_c_string (guile_datadir);
374 }
375
376 /* (gdb-version) -> string */
377
378 static SCM
379 gdbscm_gdb_version (void)
380 {
381   return gdbscm_scm_from_c_string (version);
382 }
383
384 /* (host-config) -> string */
385
386 static SCM
387 gdbscm_host_config (void)
388 {
389   return gdbscm_scm_from_c_string (host_name);
390 }
391
392 /* (target-config) -> string */
393
394 static SCM
395 gdbscm_target_config (void)
396 {
397   return gdbscm_scm_from_c_string (target_name);
398 }
399
400 #else /* ! HAVE_GUILE */
401
402 /* Dummy implementation of the gdb "guile-repl" and "guile"
403    commands. */
404
405 static void
406 guile_repl_command (char *arg, int from_tty)
407 {
408   arg = skip_spaces (arg);
409   if (arg && *arg)
410     error (_("guile-repl currently does not take any arguments."));
411   error (_("Guile scripting is not supported in this copy of GDB."));
412 }
413
414 static void
415 guile_command (char *arg, int from_tty)
416 {
417   arg = skip_spaces (arg);
418   if (arg && *arg)
419     error (_("Guile scripting is not supported in this copy of GDB."));
420   else
421     {
422       /* Even if Guile isn't enabled, we still have to slurp the
423          command list to the corresponding "end".  */
424       struct command_line *l = get_command_line (guile_control, "");
425       struct cleanup *cleanups = make_cleanup_free_command_lines (&l);
426
427       execute_control_command_untraced (l);
428       do_cleanups (cleanups);
429     }
430 }
431
432 #endif /* ! HAVE_GUILE */
433 \f
434 /* Lists for 'set,show,info guile' commands.  */
435
436 static struct cmd_list_element *set_guile_list;
437 static struct cmd_list_element *show_guile_list;
438 static struct cmd_list_element *info_guile_list;
439
440 /* Function for use by 'set guile' prefix command.  */
441
442 static void
443 set_guile_command (char *args, int from_tty)
444 {
445   help_list (set_guile_list, "set guile ", all_commands, gdb_stdout);
446 }
447
448 /* Function for use by 'show guile' prefix command.  */
449
450 static void
451 show_guile_command (char *args, int from_tty)
452 {
453   cmd_show_list (show_guile_list, from_tty, "");
454 }
455
456 /* The "info scheme" command is defined as a prefix, with
457    allow_unknown 0.  Therefore, its own definition is called only for
458    "info scheme" with no args.  */
459
460 static void
461 info_guile_command (char *args, int from_tty)
462 {
463   printf_unfiltered (_("\"info guile\" must be followed"
464                        " by the name of an info command.\n"));
465   help_list (info_guile_list, "info guile ", all_commands, gdb_stdout);
466 }
467 \f
468 /* Initialization.  */
469
470 #ifdef HAVE_GUILE
471
472 static const scheme_function misc_guile_functions[] =
473 {
474   { "execute", 1, 0, 1, gdbscm_execute_gdb_command,
475   "\
476 Execute the given GDB command.\n\
477 \n\
478   Arguments: string [#:to-string boolean] [#:from-tty boolean]\n\
479     If #:from-tty is true then the command executes as if entered\n\
480     from the keyboard.  The default is false (#f).\n\
481     If #:to-string is true then the result is returned as a string.\n\
482     Otherwise output is sent to the current output port,\n\
483     which is the default.\n\
484   Returns: The result of the command if #:to-string is true.\n\
485     Otherwise returns unspecified." },
486
487   { "data-directory", 0, 0, 0, gdbscm_data_directory,
488     "\
489 Return the name of GDB's data directory." },
490
491   { "guile-data-directory", 0, 0, 0, gdbscm_guile_data_directory,
492     "\
493 Return the name of the Guile directory within GDB's data directory." },
494
495   { "gdb-version", 0, 0, 0, gdbscm_gdb_version,
496     "\
497 Return GDB's version string." },
498
499   { "host-config", 0, 0, 0, gdbscm_host_config,
500     "\
501 Return the name of the host configuration." },
502
503   { "target-config", 0, 0, 0, gdbscm_target_config,
504     "\
505 Return the name of the target configuration." },
506
507   END_FUNCTIONS
508 };
509
510 /* Load gdb/boot.scm, the Scheme side of GDB/Guile support.
511    Note: This function assumes it's called within the gdb module.  */
512
513 static void
514 initialize_scheme_side (void)
515 {
516   char *boot_scm_path;
517   char *msg;
518
519   guile_datadir = concat (gdb_datadir, SLASH_STRING, "guile", NULL);
520   boot_scm_path = concat (guile_datadir, SLASH_STRING, "gdb",
521                           SLASH_STRING, boot_scm_filename, NULL);
522
523   /* While scm_c_primitive_load works, the loaded code is not compiled,
524      instead it is left to be interpreted.  Eh?
525      Anyways, this causes a ~100x slowdown, so we only use it to load
526      gdb/boot.scm, and then let boot.scm do the rest.  */
527   msg = gdbscm_safe_source_script (boot_scm_path);
528
529   if (msg != NULL)
530     {
531       fprintf_filtered (gdb_stderr, "%s", msg);
532       xfree (msg);
533       warning (_("\n"
534                  "Could not complete Guile gdb module initialization from:\n"
535                  "%s.\n"
536                  "Limited Guile support is available.\n"
537                  "Suggest passing --data-directory=/path/to/gdb/data-directory.\n"),
538                boot_scm_path);
539     }
540
541   xfree (boot_scm_path);
542 }
543
544 /* Install the gdb scheme module.
545    The result is a boolean indicating success.
546    If initializing the gdb module fails an error message is printed.
547    Note: This function runs in the context of the gdb module.  */
548
549 static void
550 initialize_gdb_module (void *data)
551 {
552   /* Computing these is a pain, so only do it once.
553      Also, do it here and save the result so that obtaining the values
554      is thread-safe.  */
555   gdbscm_guile_major_version = gdbscm_scm_string_to_int (scm_major_version ());
556   gdbscm_guile_minor_version = gdbscm_scm_string_to_int (scm_minor_version ());
557   gdbscm_guile_micro_version = gdbscm_scm_string_to_int (scm_micro_version ());
558
559   /* The documentation symbol needs to be defined before any calls to
560      gdbscm_define_{variables,functions}.  */
561   gdbscm_documentation_symbol = scm_from_latin1_symbol ("documentation");
562
563   /* The smob and exception support must be initialized early.  */
564   gdbscm_initialize_smobs ();
565   gdbscm_initialize_exceptions ();
566
567   /* The rest are initialized in alphabetical order.  */
568   gdbscm_initialize_arches ();
569   gdbscm_initialize_auto_load ();
570   gdbscm_initialize_blocks ();
571   gdbscm_initialize_breakpoints ();
572   gdbscm_initialize_commands ();
573   gdbscm_initialize_disasm ();
574   gdbscm_initialize_frames ();
575   gdbscm_initialize_iterators ();
576   gdbscm_initialize_lazy_strings ();
577   gdbscm_initialize_math ();
578   gdbscm_initialize_objfiles ();
579   gdbscm_initialize_parameters ();
580   gdbscm_initialize_ports ();
581   gdbscm_initialize_pretty_printers ();
582   gdbscm_initialize_pspaces ();
583   gdbscm_initialize_strings ();
584   gdbscm_initialize_symbols ();
585   gdbscm_initialize_symtabs ();
586   gdbscm_initialize_types ();
587   gdbscm_initialize_values ();
588
589   gdbscm_define_functions (misc_guile_functions, 1);
590
591   from_tty_keyword = scm_from_latin1_keyword ("from-tty");
592   to_string_keyword = scm_from_latin1_keyword ("to-string");
593
594   initialize_scheme_side ();
595
596   gdb_scheme_initialized = 1;
597 }
598
599 /* Utility to call scm_c_define_module+initialize_gdb_module from
600    within scm_with_guile.  */
601
602 static void *
603 call_initialize_gdb_module (void *data)
604 {
605   /* Most of the initialization is done by initialize_gdb_module.
606      It is called via scm_c_define_module so that the initialization is
607      performed within the desired module.  */
608   scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL);
609
610   return NULL;
611 }
612
613 /* A callback to finish Guile initialization after gdb has finished all its
614    initialization.
615    This is the extension_language_ops.finish_initialization "method".  */
616
617 static void
618 gdbscm_finish_initialization (const struct extension_language_defn *extlang)
619 {
620   /* Restore the environment to the user interaction one.  */
621   scm_set_current_module (scm_interaction_environment ());
622 }
623
624 /* The extension_language_ops.initialized "method".  */
625
626 static int
627 gdbscm_initialized (const struct extension_language_defn *extlang)
628 {
629   return gdb_scheme_initialized;
630 }
631
632 /* Enable or disable Guile backtraces.  */
633
634 static void
635 gdbscm_set_backtrace (int enable)
636 {
637   static const char disable_bt[] = "(debug-disable 'backtrace)";
638   static const char enable_bt[] = "(debug-enable 'backtrace)";
639
640   if (enable)
641     gdbscm_safe_eval_string (enable_bt, 0);
642   else
643     gdbscm_safe_eval_string (disable_bt, 0);
644 }
645
646 #endif /* HAVE_GUILE */
647
648 /* Install the various gdb commands used by Guile.  */
649
650 static void
651 install_gdb_commands (void)
652 {
653   add_com ("guile-repl", class_obscure,
654            guile_repl_command,
655 #ifdef HAVE_GUILE
656            _("\
657 Start an interactive Guile prompt.\n\
658 \n\
659 To return to GDB, type the EOF character (e.g., Ctrl-D on an empty\n\
660 prompt) or ,quit.")
661 #else /* HAVE_GUILE */
662            _("\
663 Start a Guile interactive prompt.\n\
664 \n\
665 Guile scripting is not supported in this copy of GDB.\n\
666 This command is only a placeholder.")
667 #endif /* HAVE_GUILE */
668            );
669   add_com_alias ("gr", "guile-repl", class_obscure, 1);
670
671   /* Since "help guile" is easy to type, and intuitive, we add general help
672      in using GDB+Guile to this command.  */
673   add_com ("guile", class_obscure, guile_command,
674 #ifdef HAVE_GUILE
675            _("\
676 Evaluate one or more Guile expressions.\n\
677 \n\
678 The expression(s) can be given as an argument, for instance:\n\
679 \n\
680     guile (display 23)\n\
681 \n\
682 The result of evaluating the last expression is printed.\n\
683 \n\
684 If no argument is given, the following lines are read and passed\n\
685 to Guile for evaluation.  Type a line containing \"end\" to indicate\n\
686 the end of the set of expressions.\n\
687 \n\
688 The Guile GDB module must first be imported before it can be used.\n\
689 Do this with:\n\
690 (gdb) guile (use-modules (gdb))\n\
691 or if you want to import the (gdb) module with a prefix, use:\n\
692 (gdb) guile (use-modules ((gdb) #:renamer (symbol-prefix-proc 'gdb:)))\n\
693 \n\
694 The Guile interactive session, started with the \"guile-repl\"\n\
695 command, provides extensive help and apropos capabilities.\n\
696 Type \",help\" once in a Guile interactive session.")
697 #else /* HAVE_GUILE */
698            _("\
699 Evaluate a Guile expression.\n\
700 \n\
701 Guile scripting is not supported in this copy of GDB.\n\
702 This command is only a placeholder.")
703 #endif /* HAVE_GUILE */
704            );
705   add_com_alias ("gu", "guile", class_obscure, 1);
706
707   add_prefix_cmd ("guile", class_obscure, set_guile_command,
708                   _("Prefix command for Guile preference settings."),
709                   &set_guile_list, "set guile ", 0,
710                   &setlist);
711   add_alias_cmd ("gu", "guile", class_obscure, 1, &setlist);
712
713   add_prefix_cmd ("guile", class_obscure, show_guile_command,
714                   _("Prefix command for Guile preference settings."),
715                   &show_guile_list, "show guile ", 0,
716                   &showlist);
717   add_alias_cmd ("gu", "guile", class_obscure, 1, &showlist);
718
719   add_prefix_cmd ("guile", class_obscure, info_guile_command,
720                   _("Prefix command for Guile info displays."),
721                   &info_guile_list, "info guile ", 0,
722                   &infolist);
723   add_info_alias ("gu", "guile", 1);
724
725   /* The name "print-stack" is carried over from Python.
726      A better name is "print-exception".  */
727   add_setshow_enum_cmd ("print-stack", no_class, guile_print_excp_enums,
728                         &gdbscm_print_excp, _("\
729 Set mode for Guile exception printing on error."), _("\
730 Show the mode of Guile exception printing on error."), _("\
731 none  == no stack or message will be printed.\n\
732 full == a message and a stack will be printed.\n\
733 message == an error message without a stack will be printed."),
734                         NULL, NULL,
735                         &set_guile_list, &show_guile_list);
736 }
737
738 /* Provide a prototype to silence -Wmissing-prototypes.  */
739 extern initialize_file_ftype _initialize_guile;
740
741 void
742 _initialize_guile (void)
743 {
744   char *msg;
745
746   install_gdb_commands ();
747
748 #if HAVE_GUILE
749   /* The Python support puts the C side in module "_gdb", leaving the Python
750      side to define module "gdb" which imports "_gdb".  There is evidently no
751      similar convention in Guile so we skip this.  */
752
753   /* scm_with_guile is the most portable way to initialize Guile.
754      Plus we need to initialize the Guile support while in Guile mode
755      (e.g., called from within a call to scm_with_guile).  */
756   scm_with_guile (call_initialize_gdb_module, NULL);
757
758   /* Set Guile's backtrace to match the "set guile print-stack" default.
759      [N.B. The two settings are still separate.]
760      But only do this after we've initialized Guile, it's nice to see a
761      backtrace if there's an error during initialization.
762      OTOH, if the error is that gdb/init.scm wasn't found because gdb is being
763      run from the build tree, the backtrace is more noise than signal.
764      Sigh.  */
765   gdbscm_set_backtrace (0);
766 #endif
767 }