34#include "gdbsupport/version.h"
40#include "gdbsupport/block-signals.h"
53static const char *guile_datadir;
81static void gdbscm_eval_from_control_command
84static void gdbscm_set_backtrace (
int enable);
92static SCM from_tty_keyword;
93static SCM to_string_keyword;
100static const char boot_scm_filename[] =
"boot.scm";
106 gdbscm_source_script,
119 gdbscm_eval_from_control_command,
157 &guile_extension_script_ops,
171 scoped_restore restore_async = make_scoped_restore (&
current_ui->
async, 0);
173 arg = skip_spaces (arg);
182 error (_(
"guile-repl currently does not take any arguments."));
199 scoped_restore restore_async = make_scoped_restore (&
current_ui->
async, 0);
201 arg = skip_spaces (arg);
208 error (
"%s", msg.get ());
231 for (iter = l; iter; iter = iter->
next)
236 for (iter = l; iter; iter = iter->
next)
238 int len = strlen (iter->
line);
240 strcpy (&script[here], iter->
line);
242 script[here++] =
'\n';
253gdbscm_eval_from_control_command
259 error (_(
"Invalid \"guile\" block structure."));
261 script = compute_scheme_string (cmd->
body_list_0.get ());
265 error (
"%s", msg.get ());
276 FILE *file,
const char *filename)
288gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
290 int from_tty_arg_pos = -1, to_string_arg_pos = -1;
292 const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F };
296 command_scm, &command, rest,
297 &from_tty_arg_pos, &from_tty,
302 gdb::unique_xmalloc_ptr<char> command_holder (command);
303 std::string to_string_res;
305 scoped_restore restore_async = make_scoped_restore (&
current_ui->
async,
319 return SCM_UNSPECIFIED;
326gdbscm_data_directory (
void)
334gdbscm_guile_data_directory (
void)
342gdbscm_gdb_version (
void)
350gdbscm_host_config (
void)
358gdbscm_target_config (
void)
371 arg = skip_spaces (arg);
373 error (_(
"guile-repl currently does not take any arguments."));
374 error (_(
"Guile scripting is not supported in this copy of GDB."));
380 arg = skip_spaces (arg);
382 error (_(
"Guile scripting is not supported in this copy of GDB."));
410Execute the given GDB command.\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." },
423Return the name of GDB's data directory." },
425 {
"guile-data-directory", 0, 0, 0,
428Return the name of the Guile directory within GDB's data directory." },
432Return GDB's version string." },
436Return the name of the host configuration." },
440Return the name of the target configuration." },
448boot_guile_support (
void *boot_scm_file)
456 return scm_c_primitive_load ((
const char *) boot_scm_file);
465standard_throw_args_p (SCM args)
468 && scm_ilength (args) >= 3)
471 SCM arg0 = scm_list_ref (args, scm_from_int (0));
473 SCM arg1 = scm_list_ref (args, scm_from_int (1));
475 SCM arg2 = scm_list_ref (args, scm_from_int (2));
478 && scm_is_string (arg1)
489print_standard_throw_error (SCM args)
492 SCM arg0 = scm_list_ref (args, scm_from_int (0));
494 SCM arg1 = scm_list_ref (args, scm_from_int (1));
496 SCM arg2 = scm_list_ref (args, scm_from_int (2));
501 scm_simple_format (scm_current_error_port (),
502 scm_from_latin1_string (_(
"Error in function ~s:~%")),
505 scm_simple_format (scm_current_error_port (), arg1, arg2);
514print_throw_error (SCM key, SCM args)
521 if (standard_throw_args_p (args))
522 print_standard_throw_error (args);
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));
534handle_boot_error (
void *boot_scm_file, SCM key, SCM args)
538 print_throw_error (key, args);
541 warning (_(
"Could not complete Guile gdb module initialization from:\n"
543 "Limited Guile support is available.\n"
544 "Suggest passing --data-directory=/path/to/gdb/data-directory."),
545 (
const char *) boot_scm_file);
547 return SCM_UNSPECIFIED;
554initialize_scheme_side (
void)
558 guile_datadir = concat (
gdb_datadir.c_str (), SLASH_STRING,
"guile",
560 boot_scm_path = concat (guile_datadir, SLASH_STRING,
"gdb",
561 SLASH_STRING, boot_scm_filename, (
char *) NULL);
563 scm_c_catch (SCM_BOOL_T, boot_guile_support, boot_scm_path,
564 handle_boot_error, boot_scm_path, NULL, NULL);
566 xfree (boot_scm_path);
575initialize_gdb_module (
void *data)
616 from_tty_keyword = scm_from_latin1_keyword (
"from-tty");
617 to_string_keyword = scm_from_latin1_keyword (
"to-string");
619 initialize_scheme_side ();
628call_initialize_gdb_module (
void *data)
635#if HAVE_GUILE_MANUAL_FINALIZATION
636 scm_run_finalizers ();
653#if HAVE_GUILE_MANUAL_FINALIZATION
657 scm_set_automatic_finalization_enabled (0);
665 gdb::block_signals blocker;
684#if SCM_MAJOR_VERSION < 3 || (SCM_MAJOR_VERSION == 3 && SCM_MINOR_VERSION == 0)
687#pragma GCC diagnostic push
688#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
689 scm_install_gmp_memory_functions = 0;
690#pragma GCC diagnostic pop
696 scm_with_guile (call_initialize_gdb_module, NULL);
705 gdbscm_set_backtrace (0);
709 scm_set_current_module (scm_interaction_environment ());
723gdbscm_set_backtrace (
int enable)
725 static const char disable_bt[] =
"(debug-disable 'backtrace)";
726 static const char enable_bt[] =
"(debug-enable 'backtrace)";
748Start an interactive Guile prompt.\n\
750To return to GDB, type the EOF character (e.g., Ctrl-D on an empty\n\
754Start a Guile interactive prompt.\n\
756Guile scripting is not supported in this copy of GDB.\n\
757This command is only a placeholder.")
767Evaluate one or more Guile expressions.\n\
769The expression(s) can be given as an argument, for instance:\n\
771 guile (display 23)\n\
773The result of evaluating the last expression is printed.\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\
779The Guile GDB module must first be imported before it can be used.\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\
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.")
790Evaluate a Guile expression.\n\
792Guile scripting is not supported in this copy of GDB.\n\
793This command is only a placeholder.")
801Prefix command for Guile preference settings."),
803Prefix command for Guile preference settings."),
812 _(
"Prefix command for Guile info displays."),
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."),
void bpstat_do_actions(void)
struct cmd_list_element * showlist
struct cmd_list_element * infolist
struct cmd_list_element * setlist
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)
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)
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)
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)
counted_command_line get_command_line(enum command_control_type type, const char *arg)
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
std::shared_ptr< command_line > counted_command_line
scoped_restore_tmpl< int > prevent_dont_repeat(void)
std::string to_string(cooked_index_flag flags)
void script_sourcer_func(const struct extension_language_defn *, FILE *stream, const char *filename)
void execute_command_to_string(std::string &res, const char *p, int from_tty, bool term_out)
void execute_command(const char *, int)
int gdbscm_scm_string_to_int(SCM string)
void gdbscm_initialize_symtabs(void)
#define gdbscm_is_true(scm)
void gdbscm_initialize_types(void)
SCM gdbscm_wrap(Function &&func, Args &&... args)
void gdbscm_initialize_parameters(void)
void gdbscm_initialize_strings(void)
void gdbscm_initialize_commands(void)
void gdbscm_initialize_pspaces(void)
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,...)
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)
void gdbscm_initialize_symbols(void)
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)
void gdbscm_initialize_values(void)
void gdbscm_initialize_math(void)
#define gdbscm_is_false(scm)
void gdbscm_initialize_arches(void)
gdb::unique_xmalloc_ptr< char > gdbscm_safe_source_script(const char *filename)
void gdbscm_initialize_lazy_strings(void)
void gdbscm_initialize_smobs(void)
void gdbscm_initialize_blocks(void)
void gdbscm_initialize_frames(void)
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)
void gdbscm_initialize_objfiles(void)
bool gdbscm_auto_load_enabled(const struct extension_language_defn *)
int gdb_scheme_initialized
void gdbscm_initialize_ports(void)
objfile_script_executor_func gdbscm_execute_objfile_script
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
SCM gdbscm_scm_from_c_string(const char *string)
void gdbscm_enter_repl(void)
static struct cmd_list_element * show_guile_list
const char gdbscm_print_excp_none[]
const char * gdbscm_print_excp
static const char *const guile_print_excp_enums[]
int gdbscm_guile_minor_version
cmd_list_element * guile_cmd_element
const char gdbscm_print_excp_message[]
int gdbscm_guile_major_version
static void guile_command(const char *arg, int from_tty)
const char gdbscm_print_excp_full[]
static void guile_repl_command(const char *arg, int from_tty)
static void install_gdb_commands(void)
static struct cmd_list_element * info_guile_list
static struct cmd_list_element * set_guile_list
int gdbscm_guile_micro_version
const struct extension_language_defn extension_language_guile
counted_command_line body_list_0
counted_command_line body_list_1
struct command_line * next
void gdb_printf(struct ui_file *stream, const char *format,...)