GDB (xrefs)
Loading...
Searching...
No Matches
guile.c
Go to the documentation of this file.
1/* General GDB/Guile code.
2
3 Copyright (C) 2014-2023 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 "breakpoint.h"
25#include "cli/cli-cmds.h"
26#include "cli/cli-script.h"
27#include "cli/cli-utils.h"
28#include "command.h"
29#include "gdbcmd.h"
30#include "top.h"
31#include "ui.h"
32#include "extension-priv.h"
33#include "utils.h"
34#include "gdbsupport/version.h"
35#ifdef HAVE_GUILE
36#include "guile.h"
37#include "guile-internal.h"
38#endif
39#include <signal.h>
40#include "gdbsupport/block-signals.h"
41
42/* The Guile version we're using.
43 We *could* use the macros in libguile/version.h but that would preclude
44 handling the user switching in a different version with, e.g.,
45 LD_LIBRARY_PATH (using a different version than what gdb was compiled with
46 is not something to be done lightly, but can be useful). */
50
51#ifdef HAVE_GUILE
52/* The guile subdirectory within gdb's data-directory. */
53static const char *guile_datadir;
54#endif
55
56/* Declared constants and enum for guile exception printing. */
57const char gdbscm_print_excp_none[] = "none";
58const char gdbscm_print_excp_full[] = "full";
59const char gdbscm_print_excp_message[] = "message";
60
61/* "set guile print-stack" choices. */
62static const char *const guile_print_excp_enums[] =
63 {
67 NULL
68 };
69
70/* The exception printing variable. 'full' if we want to print the
71 error message and stack, 'none' if we want to print nothing, and
72 'message' if we only want to print the error message. 'message' is
73 the default. */
75
76
77#ifdef HAVE_GUILE
78
79static void gdbscm_initialize (const struct extension_language_defn *);
80static int gdbscm_initialized (const struct extension_language_defn *);
81static void gdbscm_eval_from_control_command
82 (const struct extension_language_defn *, struct command_line *);
83static script_sourcer_func gdbscm_source_script;
84static void gdbscm_set_backtrace (int enable);
85
87
88/* Symbol for setting documentation strings. */
90
91/* Keywords used by various functions. */
92static SCM from_tty_keyword;
93static SCM to_string_keyword;
94
95/* The name of the various modules (without the surrounding parens). */
96const char gdbscm_module_name[] = "gdb";
97const char gdbscm_init_module_name[] = "gdb";
98
99/* The name of the bootstrap file. */
100static const char boot_scm_filename[] = "boot.scm";
101
102/* The interface between gdb proper and loading of python scripts. */
103
104static const struct extension_language_script_ops guile_extension_script_ops =
105{
106 gdbscm_source_script,
110};
111
112/* The interface between gdb proper and guile scripting. */
113
114static const struct extension_language_ops guile_extension_ops =
115{
116 gdbscm_initialize,
117 gdbscm_initialized,
118
119 gdbscm_eval_from_control_command,
120
121 NULL, /* gdbscm_start_type_printers, */
122 NULL, /* gdbscm_apply_type_printers, */
123 NULL, /* gdbscm_free_type_printers, */
124
126
127 NULL, /* gdbscm_apply_frame_filter, */
128
130
133
134 NULL, /* gdbscm_set_quit_flag, */
135 NULL, /* gdbscm_check_quit_flag, */
136 NULL, /* gdbscm_before_prompt, */
137 NULL, /* gdbscm_get_matching_xmethod_workers */
138 NULL, /* gdbscm_colorize */
139 NULL, /* gdbscm_print_insn */
140};
141#endif
142
143/* The main struct describing GDB's interface to the Guile
144 extension language. */
146{
148 "guile",
149 "Guile",
150
151 ".scm",
152 "-gdb.scm",
153
155
156#ifdef HAVE_GUILE
157 &guile_extension_script_ops,
158 &guile_extension_ops
159#else
160 NULL,
161 NULL
162#endif
163};
164
165#ifdef HAVE_GUILE
166/* Implementation of the gdb "guile-repl" command. */
167
168static void
169guile_repl_command (const char *arg, int from_tty)
170{
171 scoped_restore restore_async = make_scoped_restore (&current_ui->async, 0);
172
173 arg = skip_spaces (arg);
174
175 /* This explicitly rejects any arguments for now.
176 "It is easier to relax a restriction than impose one after the fact."
177 We would *like* to be able to pass arguments to the interactive shell
178 but that's not what python-interactive does. Until there is time to
179 sort it out, we forbid arguments. */
180
181 if (arg && *arg)
182 error (_("guile-repl currently does not take any arguments."));
183 else
184 {
185 dont_repeat ();
187 }
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
196static void
197guile_command (const char *arg, int from_tty)
198{
199 scoped_restore restore_async = make_scoped_restore (&current_ui->async, 0);
200
201 arg = skip_spaces (arg);
202
203 if (arg && *arg)
204 {
205 gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_eval_string (arg, 1);
206
207 if (msg != NULL)
208 error ("%s", msg.get ());
209 }
210 else
211 {
213
215 }
216}
217
218/* Given a command_line, return a command string suitable for passing
219 to Guile. Lines in the string are separated by newlines. The return
220 value is allocated using xmalloc and the caller is responsible for
221 freeing it. */
222
223static char *
224compute_scheme_string (struct command_line *l)
225{
226 struct command_line *iter;
227 char *script = NULL;
228 int size = 0;
229 int here;
230
231 for (iter = l; iter; iter = iter->next)
232 size += strlen (iter->line) + 1;
233
234 script = (char *) xmalloc (size + 1);
235 here = 0;
236 for (iter = l; iter; iter = iter->next)
237 {
238 int len = strlen (iter->line);
239
240 strcpy (&script[here], iter->line);
241 here += len;
242 script[here++] = '\n';
243 }
244 script[here] = '\0';
245 return script;
246}
247
248/* Take a command line structure representing a "guile" command, and
249 evaluate its body using the Guile interpreter.
250 This is the extension_language_ops.eval_from_control_command "method". */
251
252static void
253gdbscm_eval_from_control_command
254 (const struct extension_language_defn *extlang, struct command_line *cmd)
255{
256 char *script;
257
258 if (cmd->body_list_1 != nullptr)
259 error (_("Invalid \"guile\" block structure."));
260
261 script = compute_scheme_string (cmd->body_list_0.get ());
262 gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_eval_string (script, 0);
263 xfree (script);
264 if (msg != NULL)
265 error ("%s", msg.get ());
266}
267
268/* Read a file as Scheme code.
269 This is the extension_language_script_ops.script_sourcer "method".
270 FILE is the file to run. FILENAME is name of the file FILE.
271 This does not throw any errors. If an exception occurs an error message
272 is printed. */
273
274static void
275gdbscm_source_script (const struct extension_language_defn *extlang,
276 FILE *file, const char *filename)
277{
278 gdb::unique_xmalloc_ptr<char> msg = gdbscm_safe_source_script (filename);
279
280 if (msg != NULL)
281 gdb_printf (gdb_stderr, "%s\n", msg.get ());
282}
283
284/* (execute string [#:from-tty boolean] [#:to-string boolean])
285 A Scheme function which evaluates a string using the gdb CLI. */
286
287static SCM
288gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
289{
290 int from_tty_arg_pos = -1, to_string_arg_pos = -1;
291 int from_tty = 0, to_string = 0;
292 const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F };
293 char *command;
294
295 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt",
296 command_scm, &command, rest,
297 &from_tty_arg_pos, &from_tty,
298 &to_string_arg_pos, &to_string);
299
300 return gdbscm_wrap ([=]
301 {
302 gdb::unique_xmalloc_ptr<char> command_holder (command);
303 std::string to_string_res;
304
305 scoped_restore restore_async = make_scoped_restore (&current_ui->async,
306 0);
307
308 scoped_restore preventer = prevent_dont_repeat ();
309 if (to_string)
310 execute_command_to_string (to_string_res, command, from_tty, false);
311 else
312 execute_command (command, from_tty);
313
314 /* Do any commands attached to breakpoint we stopped at. */
316
317 if (to_string)
318 return gdbscm_scm_from_c_string (to_string_res.c_str ());
319 return SCM_UNSPECIFIED;
320 });
321}
322
323/* (data-directory) -> string */
324
325static SCM
326gdbscm_data_directory (void)
327{
328 return gdbscm_scm_from_c_string (gdb_datadir.c_str ());
329}
330
331/* (guile-data-directory) -> string */
332
333static SCM
334gdbscm_guile_data_directory (void)
335{
336 return gdbscm_scm_from_c_string (guile_datadir);
337}
338
339/* (gdb-version) -> string */
340
341static SCM
342gdbscm_gdb_version (void)
343{
345}
346
347/* (host-config) -> string */
348
349static SCM
350gdbscm_host_config (void)
351{
353}
354
355/* (target-config) -> string */
356
357static SCM
358gdbscm_target_config (void)
359{
361}
362
363#else /* ! HAVE_GUILE */
364
365/* Dummy implementation of the gdb "guile-repl" and "guile"
366 commands. */
367
368static void
369guile_repl_command (const char *arg, int from_tty)
370{
371 arg = skip_spaces (arg);
372 if (arg && *arg)
373 error (_("guile-repl currently does not take any arguments."));
374 error (_("Guile scripting is not supported in this copy of GDB."));
375}
376
377static void
378guile_command (const char *arg, int from_tty)
379{
380 arg = skip_spaces (arg);
381 if (arg && *arg)
382 error (_("Guile scripting is not supported in this copy of GDB."));
383 else
384 {
385 /* Even if Guile isn't enabled, we still have to slurp the
386 command list to the corresponding "end". */
388
390 }
391}
392
393#endif /* ! HAVE_GUILE */
394
395/* Lists for 'set,show,info guile' commands. */
396
400
401
402/* Initialization. */
403
404#ifdef HAVE_GUILE
405
406static const scheme_function misc_guile_functions[] =
407{
408 { "execute", 1, 0, 1, as_a_scm_t_subr (gdbscm_execute_gdb_command),
409 "\
410Execute the given GDB command.\n\
411\n\
412 Arguments: string [#:to-string boolean] [#:from-tty boolean]\n\
413 If #:from-tty is true then the command executes as if entered\n\
414 from the keyboard. The default is false (#f).\n\
415 If #:to-string is true then the result is returned as a string.\n\
416 Otherwise output is sent to the current output port,\n\
417 which is the default.\n\
418 Returns: The result of the command if #:to-string is true.\n\
419 Otherwise returns unspecified." },
420
421 { "data-directory", 0, 0, 0, as_a_scm_t_subr (gdbscm_data_directory),
422 "\
423Return the name of GDB's data directory." },
424
425 { "guile-data-directory", 0, 0, 0,
426 as_a_scm_t_subr (gdbscm_guile_data_directory),
427 "\
428Return the name of the Guile directory within GDB's data directory." },
429
430 { "gdb-version", 0, 0, 0, as_a_scm_t_subr (gdbscm_gdb_version),
431 "\
432Return GDB's version string." },
433
434 { "host-config", 0, 0, 0, as_a_scm_t_subr (gdbscm_host_config),
435 "\
436Return the name of the host configuration." },
437
438 { "target-config", 0, 0, 0, as_a_scm_t_subr (gdbscm_target_config),
439 "\
440Return the name of the target configuration." },
441
443};
444
445/* Load BOOT_SCM_FILE, the first Scheme file that gets loaded. */
446
447static SCM
448boot_guile_support (void *boot_scm_file)
449{
450 /* Load boot.scm without compiling it (there's no need to compile it).
451 The other files should have been compiled already, and boot.scm is
452 expected to adjust '%load-compiled-path' accordingly. If they haven't
453 been compiled, Guile will auto-compile them. The important thing to keep
454 in mind is that there's a >= 100x speed difference between compiled and
455 non-compiled files. */
456 return scm_c_primitive_load ((const char *) boot_scm_file);
457}
458
459/* Return non-zero if ARGS has the "standard" format for throw args.
460 The standard format is:
461 (function format-string (format-string-args-list) ...).
462 FUNCTION is #f if no function was recorded. */
463
464static int
465standard_throw_args_p (SCM args)
466{
467 if (gdbscm_is_true (scm_list_p (args))
468 && scm_ilength (args) >= 3)
469 {
470 /* The function in which the error occurred. */
471 SCM arg0 = scm_list_ref (args, scm_from_int (0));
472 /* The format string. */
473 SCM arg1 = scm_list_ref (args, scm_from_int (1));
474 /* The arguments of the format string. */
475 SCM arg2 = scm_list_ref (args, scm_from_int (2));
476
477 if ((scm_is_string (arg0) || gdbscm_is_false (arg0))
478 && scm_is_string (arg1)
479 && gdbscm_is_true (scm_list_p (arg2)))
480 return 1;
481 }
482
483 return 0;
484}
485
486/* Print the error recorded in a "standard" throw args. */
487
488static void
489print_standard_throw_error (SCM args)
490{
491 /* The function in which the error occurred. */
492 SCM arg0 = scm_list_ref (args, scm_from_int (0));
493 /* The format string. */
494 SCM arg1 = scm_list_ref (args, scm_from_int (1));
495 /* The arguments of the format string. */
496 SCM arg2 = scm_list_ref (args, scm_from_int (2));
497
498 /* ARG0 is #f if no function was recorded. */
499 if (gdbscm_is_true (arg0))
500 {
501 scm_simple_format (scm_current_error_port (),
502 scm_from_latin1_string (_("Error in function ~s:~%")),
503 scm_list_1 (arg0));
504 }
505 scm_simple_format (scm_current_error_port (), arg1, arg2);
506}
507
508/* Print the error message recorded in KEY, ARGS, the arguments to throw.
509 Normally we let Scheme print the error message.
510 This function is used when Scheme initialization fails.
511 We can still use the Scheme C API though. */
512
513static void
514print_throw_error (SCM key, SCM args)
515{
516 /* IWBN to call gdbscm_print_exception_with_stack here, but Guile didn't
517 boot successfully so play it safe and avoid it. The "format string" and
518 its args are embedded in ARGS, but the content of ARGS depends on KEY.
519 Make sure ARGS has the expected canonical content before trying to use
520 it. */
521 if (standard_throw_args_p (args))
522 print_standard_throw_error (args);
523 else
524 {
525 scm_simple_format (scm_current_error_port (),
526 scm_from_latin1_string (_("Throw to key `~a' with args `~s'.~%")),
527 scm_list_2 (key, args));
528 }
529}
530
531/* Handle an exception thrown while loading BOOT_SCM_FILE. */
532
533static SCM
534handle_boot_error (void *boot_scm_file, SCM key, SCM args)
535{
536 gdb_printf (gdb_stderr, ("Exception caught while booting Guile.\n"));
537
538 print_throw_error (key, args);
539
540 gdb_printf (gdb_stderr, "\n");
541 warning (_("Could not complete Guile gdb module initialization from:\n"
542 "%s.\n"
543 "Limited Guile support is available.\n"
544 "Suggest passing --data-directory=/path/to/gdb/data-directory."),
545 (const char *) boot_scm_file);
546
547 return SCM_UNSPECIFIED;
548}
549
550/* Load gdb/boot.scm, the Scheme side of GDB/Guile support.
551 Note: This function assumes it's called within the gdb module. */
552
553static void
554initialize_scheme_side (void)
555{
556 char *boot_scm_path;
557
558 guile_datadir = concat (gdb_datadir.c_str (), SLASH_STRING, "guile",
559 (char *) NULL);
560 boot_scm_path = concat (guile_datadir, SLASH_STRING, "gdb",
561 SLASH_STRING, boot_scm_filename, (char *) NULL);
562
563 scm_c_catch (SCM_BOOL_T, boot_guile_support, boot_scm_path,
564 handle_boot_error, boot_scm_path, NULL, NULL);
565
566 xfree (boot_scm_path);
567}
568
569/* Install the gdb scheme module.
570 The result is a boolean indicating success.
571 If initializing the gdb module fails an error message is printed.
572 Note: This function runs in the context of the gdb module. */
573
574static void
575initialize_gdb_module (void *data)
576{
577 /* Computing these is a pain, so only do it once.
578 Also, do it here and save the result so that obtaining the values
579 is thread-safe. */
583
584 /* The documentation symbol needs to be defined before any calls to
585 gdbscm_define_{variables,functions}. */
586 gdbscm_documentation_symbol = scm_from_latin1_symbol ("documentation");
587
588 /* The smob and exception support must be initialized early. */
591
592 /* The rest are initialized in alphabetical order. */
613
614 gdbscm_define_functions (misc_guile_functions, 1);
615
616 from_tty_keyword = scm_from_latin1_keyword ("from-tty");
617 to_string_keyword = scm_from_latin1_keyword ("to-string");
618
619 initialize_scheme_side ();
620
622}
623
624/* Utility to call scm_c_define_module+initialize_gdb_module from
625 within scm_with_guile. */
626
627static void *
628call_initialize_gdb_module (void *data)
629{
630 /* Most of the initialization is done by initialize_gdb_module.
631 It is called via scm_c_define_module so that the initialization is
632 performed within the desired module. */
633 scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL);
634
635#if HAVE_GUILE_MANUAL_FINALIZATION
636 scm_run_finalizers ();
637#endif
638
639 return NULL;
640}
641
642/* A callback to initialize Guile after gdb has finished all its
643 initialization. This is the extension_language_ops.initialize "method". */
644
645static void
646gdbscm_initialize (const struct extension_language_defn *extlang)
647{
648#if HAVE_GUILE
649 /* The Python support puts the C side in module "_gdb", leaving the
650 Python side to define module "gdb" which imports "_gdb". There is
651 evidently no similar convention in Guile so we skip this. */
652
653#if HAVE_GUILE_MANUAL_FINALIZATION
654 /* Our SMOB free functions are not thread-safe, as GDB itself is not
655 intended to be thread-safe. Disable automatic finalization so that
656 finalizers aren't run in other threads. */
657 scm_set_automatic_finalization_enabled (0);
658#endif
659
660 /* Before we initialize Guile, block signals needed by gdb (especially
661 SIGCHLD). This is done so that all threads created during Guile
662 initialization have SIGCHLD blocked. PR 17247. Really libgc and
663 Guile should do this, but we need to work with libgc 7.4.x. */
664 {
665 gdb::block_signals blocker;
666
667 /* There are libguile versions (f.i. v3.0.5) that by default call
668 mp_get_memory_functions during initialization to install custom
669 libgmp memory functions. This is considered a bug and should be
670 fixed starting v3.0.6.
671 Before gdb commit 880ae75a2b7 "gdb delay guile initialization until
672 gdbscm_finish_initialization", that bug had no effect for gdb,
673 because gdb subsequently called mp_get_memory_functions to install
674 its own custom functions in _initialize_gmp_utils. However, since
675 aforementioned gdb commit the initialization order is reversed,
676 allowing libguile to install a custom malloc that is incompatible
677 with the custom free as used in gmp-utils.c, resulting in a
678 "double free or corruption (out)" error.
679 Work around the libguile bug by disabling the installation of the
680 libgmp memory functions by guile initialization. */
681
682 /* The scm_install_gmp_memory_functions variable should be removed after
683 version 3.0, so limit usage to 3.0 and before. */
684#if SCM_MAJOR_VERSION < 3 || (SCM_MAJOR_VERSION == 3 && SCM_MINOR_VERSION == 0)
685 /* This variable is deprecated in Guile 3.0.8 and later but remains
686 available in the whole 3.0 series. */
687#pragma GCC diagnostic push
688#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
689 scm_install_gmp_memory_functions = 0;
690#pragma GCC diagnostic pop
691#endif
692
693 /* scm_with_guile is the most portable way to initialize Guile. Plus
694 we need to initialize the Guile support while in Guile mode (e.g.,
695 called from within a call to scm_with_guile). */
696 scm_with_guile (call_initialize_gdb_module, NULL);
697 }
698
699 /* Set Guile's backtrace to match the "set guile print-stack" default.
700 [N.B. The two settings are still separate.] But only do this after
701 we've initialized Guile, it's nice to see a backtrace if there's an
702 error during initialization. OTOH, if the error is that gdb/init.scm
703 wasn't found because gdb is being run from the build tree, the
704 backtrace is more noise than signal. Sigh. */
705 gdbscm_set_backtrace (0);
706#endif
707
708 /* Restore the environment to the user interaction one. */
709 scm_set_current_module (scm_interaction_environment ());
710}
711
712/* The extension_language_ops.initialized "method". */
713
714static int
715gdbscm_initialized (const struct extension_language_defn *extlang)
716{
718}
719
720/* Enable or disable Guile backtraces. */
721
722static void
723gdbscm_set_backtrace (int enable)
724{
725 static const char disable_bt[] = "(debug-disable 'backtrace)";
726 static const char enable_bt[] = "(debug-enable 'backtrace)";
727
728 if (enable)
729 gdbscm_safe_eval_string (enable_bt, 0);
730 else
731 gdbscm_safe_eval_string (disable_bt, 0);
732}
733
734#endif /* HAVE_GUILE */
735
736/* See guile.h. */
738
739/* Install the various gdb commands used by Guile. */
740
741static void
743{
744 cmd_list_element *guile_repl_cmd
745 = add_com ("guile-repl", class_obscure, guile_repl_command,
746#ifdef HAVE_GUILE
747 _("\
748Start an interactive Guile prompt.\n\
749\n\
750To return to GDB, type the EOF character (e.g., Ctrl-D on an empty\n\
751prompt) or ,quit.")
752#else /* HAVE_GUILE */
753 _("\
754Start a Guile interactive prompt.\n\
755\n\
756Guile scripting is not supported in this copy of GDB.\n\
757This command is only a placeholder.")
758#endif /* HAVE_GUILE */
759 );
760 add_com_alias ("gr", guile_repl_cmd, class_obscure, 1);
761
762 /* Since "help guile" is easy to type, and intuitive, we add general help
763 in using GDB+Guile to this command. */
765#ifdef HAVE_GUILE
766 _("\
767Evaluate one or more Guile expressions.\n\
768\n\
769The expression(s) can be given as an argument, for instance:\n\
770\n\
771 guile (display 23)\n\
772\n\
773The result of evaluating the last expression is printed.\n\
774\n\
775If no argument is given, the following lines are read and passed\n\
776to Guile for evaluation. Type a line containing \"end\" to indicate\n\
777the end of the set of expressions.\n\
778\n\
779The Guile GDB module must first be imported before it can be used.\n\
780Do this with:\n\
781(gdb) guile (use-modules (gdb))\n\
782or if you want to import the (gdb) module with a prefix, use:\n\
783(gdb) guile (use-modules ((gdb) #:renamer (symbol-prefix-proc 'gdb:)))\n\
784\n\
785The Guile interactive session, started with the \"guile-repl\"\n\
786command, provides extensive help and apropos capabilities.\n\
787Type \",help\" once in a Guile interactive session.")
788#else /* HAVE_GUILE */
789 _("\
790Evaluate a Guile expression.\n\
791\n\
792Guile scripting is not supported in this copy of GDB.\n\
793This command is only a placeholder.")
794#endif /* HAVE_GUILE */
795 );
797
798 set_show_commands setshow_guile_cmds
800 _("\
801Prefix command for Guile preference settings."),
802 _("\
803Prefix command for Guile preference settings."),
805 &setlist, &showlist);
806
807 add_alias_cmd ("gu", setshow_guile_cmds.set, class_obscure, 1, &setlist);
808 add_alias_cmd ("gu", setshow_guile_cmds.show, class_obscure, 1, &showlist);
809
810 cmd_list_element *info_guile_cmd
812 _("Prefix command for Guile info displays."),
814 add_info_alias ("gu", info_guile_cmd, 1);
815
816 /* The name "print-stack" is carried over from Python.
817 A better name is "print-exception". */
819 &gdbscm_print_excp, _("\
820Set mode for Guile exception printing on error."), _("\
821Show the mode of Guile exception printing on error."), _("\
822none == no stack or message will be printed.\n\
823full == a message and a stack will be printed.\n\
824message == an error message without a stack will be printed."),
825 NULL, NULL,
827}
828
829void _initialize_guile ();
830void
void * xmalloc(YYSIZE_T)
void xfree(void *)
void bpstat_do_actions(void)
struct cmd_list_element * showlist
Definition cli-cmds.c:127
struct cmd_list_element * infolist
Definition cli-cmds.c:91
struct cmd_list_element * setlist
Definition cli-cmds.c:119
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:688
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:428
cmd_list_element * add_info_alias(const char *name, cmd_list_element *target, int abbrev_flag)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:391
counted_command_line get_command_line(enum command_control_type type, const char *arg)
Definition cli-script.c:182
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
Definition cli-script.c:716
@ guile_control
Definition cli-script.h:45
std::shared_ptr< command_line > counted_command_line
Definition cli-script.h:67
scoped_restore_tmpl< int > prevent_dont_repeat(void)
Definition top.c:735
void dont_repeat()
Definition top.c:696
@ class_obscure
Definition command.h:64
@ no_class
Definition command.h:53
#define HAVE_GUILE
Definition config.h:216
std::string to_string(cooked_index_flag flags)
std::string gdb_datadir
Definition main.c:67
@ EXT_LANG_GUILE
Definition extension.h:65
void script_sourcer_func(const struct extension_language_defn *, FILE *stream, const char *filename)
Definition extension.h:42
void execute_command_to_string(std::string &res, const char *p, int from_tty, bool term_out)
Definition top.c:670
void execute_command(const char *, int)
Definition top.c:459
size_t size
Definition go32-nat.c:239
int gdbscm_scm_string_to_int(SCM string)
Definition scm-string.c:32
void gdbscm_initialize_symtabs(void)
Definition scm-symtab.c:677
#define gdbscm_is_true(scm)
void gdbscm_initialize_types(void)
Definition scm-type.c:1465
SCM gdbscm_wrap(Function &&func, Args &&... args)
void gdbscm_initialize_parameters(void)
Definition scm-param.c:1278
void gdbscm_initialize_strings(void)
Definition scm-string.c:273
void gdbscm_initialize_commands(void)
Definition scm-cmd.c:852
void gdbscm_initialize_pspaces(void)
#define END_FUNCTIONS
int gdbscm_breakpoint_has_cond(const struct extension_language_defn *, struct breakpoint *b)
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
Definition scm-utils.c:528
enum ext_lang_rc gdbscm_apply_val_pretty_printer(const struct extension_language_defn *, struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
void gdbscm_initialize_iterators(void)
SCM gdbscm_documentation_symbol
void gdbscm_preserve_values(const struct extension_language_defn *, struct objfile *, htab_t copied_types)
Definition scm-value.c:89
void gdbscm_initialize_symbols(void)
Definition scm-symbol.c:801
enum ext_lang_bp_stop gdbscm_breakpoint_cond_says_stop(const struct extension_language_defn *, struct breakpoint *b)
objfile_script_sourcer_func gdbscm_source_objfile_script
void gdbscm_initialize_exceptions(void)
const char gdbscm_module_name[]
void gdbscm_initialize_disasm(void)
Definition scm-disasm.c:306
void gdbscm_initialize_values(void)
Definition scm-value.c:1530
void gdbscm_initialize_math(void)
Definition scm-math.c:968
#define gdbscm_is_false(scm)
void gdbscm_initialize_arches(void)
Definition scm-arch.c:648
gdb::unique_xmalloc_ptr< char > gdbscm_safe_source_script(const char *filename)
void gdbscm_initialize_lazy_strings(void)
void gdbscm_initialize_smobs(void)
Definition scm-gsmob.c:274
void gdbscm_initialize_blocks(void)
Definition scm-block.c:773
void gdbscm_initialize_frames(void)
Definition scm-frame.c:1193
void gdbscm_initialize_auto_load(void)
gdb::unique_xmalloc_ptr< char > gdbscm_safe_eval_string(const char *string, int display_result)
const char gdbscm_init_module_name[]
void gdbscm_initialize_pretty_printers(void)
void gdbscm_initialize_breakpoints(void)
void gdbscm_define_functions(const scheme_function *, int is_public)
Definition scm-utils.c:44
void gdbscm_initialize_objfiles(void)
bool gdbscm_auto_load_enabled(const struct extension_language_defn *)
int gdb_scheme_initialized
void gdbscm_initialize_ports(void)
Definition scm-ports.c:1614
objfile_script_executor_func gdbscm_execute_objfile_script
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
#define FUNC_NAME
SCM gdbscm_scm_from_c_string(const char *string)
Definition scm-string.c:45
void gdbscm_enter_repl(void)
static struct cmd_list_element * show_guile_list
Definition guile.c:398
const char gdbscm_print_excp_none[]
Definition guile.c:57
const char * gdbscm_print_excp
Definition guile.c:74
static const char *const guile_print_excp_enums[]
Definition guile.c:62
int gdbscm_guile_minor_version
Definition guile.c:48
cmd_list_element * guile_cmd_element
Definition guile.c:737
void _initialize_guile()
Definition guile.c:831
const char gdbscm_print_excp_message[]
Definition guile.c:59
int gdbscm_guile_major_version
Definition guile.c:47
static void guile_command(const char *arg, int from_tty)
Definition guile.c:378
const char gdbscm_print_excp_full[]
Definition guile.c:58
static void guile_repl_command(const char *arg, int from_tty)
Definition guile.c:369
static void install_gdb_commands(void)
Definition guile.c:742
static struct cmd_list_element * info_guile_list
Definition guile.c:399
static struct cmd_list_element * set_guile_list
Definition guile.c:397
int gdbscm_guile_micro_version
Definition guile.c:49
const struct extension_language_defn extension_language_guile
#define enable()
Definition ser-go32.c:239
counted_command_line body_list_0
Definition cli-script.h:102
counted_command_line body_list_1
Definition cli-script.h:103
struct command_line * next
Definition cli-script.h:86
char * line
Definition cli-script.h:87
cmd_list_element * set
Definition command.h:422
cmd_list_element * show
Definition command.h:422
int async
Definition ui.h:106
struct ui * current_ui
Definition ui.c:35
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
#define gdb_stderr
Definition utils.h:187
const char host_name[]
Definition version.c:3
const char version[]
Definition version.c:2
const char target_name[]
Definition version.c:4