92 &guile_extension_script_ops,
102 static void gdbscm_finish_initialization
105 static void gdbscm_eval_from_control_command
115 static SCM from_tty_keyword;
116 static SCM to_string_keyword;
123 static const char boot_scm_filename[] =
"boot.scm";
129 gdbscm_source_script,
139 gdbscm_finish_initialization,
142 gdbscm_eval_from_control_command,
167 struct cleanup *cleanup;
181 error (
_(
"guile-repl currently does not take any arguments."));
200 struct cleanup *cleanup;
241 for (iter = l; iter; iter = iter->
next)
242 size += strlen (iter->
line) + 1;
246 for (iter = l; iter; iter = iter->
next)
250 strcpy (&script[here], iter->
line);
252 script[here++] =
'\n';
263 gdbscm_eval_from_control_command
267 struct cleanup *cleanup;
270 error (
_(
"Invalid \"guile\" block structure."));
274 script = compute_scheme_string (cmd->
body_list[0]);
294 FILE *file,
const char *filename)
309 gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
311 int from_tty_arg_pos = -1, to_string_arg_pos = -1;
312 int from_tty = 0, to_string = 0;
313 const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F };
316 struct cleanup *cleanups;
320 command_scm, &command, rest,
321 &from_tty_arg_pos, &from_tty,
322 &to_string_arg_pos, &to_string);
330 struct cleanup *inner_cleanups;
364 return SCM_UNSPECIFIED;
370 gdbscm_data_directory (
void)
378 gdbscm_guile_data_directory (
void)
386 gdbscm_gdb_version (
void)
394 gdbscm_host_config (
void)
402 gdbscm_target_config (
void)
417 error (
_(
"guile-repl currently does not take any arguments."));
418 error (
_(
"Guile scripting is not supported in this copy of GDB."));
426 error (
_(
"Guile scripting is not supported in this copy of GDB."));
471 " by the name of an info command.\n"));
481 {
"execute", 1, 0, 1, gdbscm_execute_gdb_command,
483 Execute the given GDB command.\n\
485 Arguments: string [#:to-string boolean] [#:from-tty boolean]\n\
486 If #:from-tty is true then the command executes as if entered\n\
487 from the keyboard. The default is false (#f).\n\
488 If #:to-string is true then the result is returned as a string.\n\
489 Otherwise output is sent to the current output port,\n\
490 which is the default.\n\
491 Returns: The result of the command if #:to-string is true.\n\
492 Otherwise returns unspecified." },
494 {
"data-directory", 0, 0, 0, gdbscm_data_directory,
496 Return the name of GDB's data directory." },
498 {
"guile-data-directory", 0, 0, 0, gdbscm_guile_data_directory,
500 Return the name of the Guile directory within GDB's data directory." },
502 {
"gdb-version", 0, 0, 0, gdbscm_gdb_version,
504 Return GDB's version string." },
506 {
"host-config", 0, 0, 0, gdbscm_host_config,
508 Return the name of the host configuration." },
510 {
"target-config", 0, 0, 0, gdbscm_target_config,
512 Return the name of the target configuration." },
520 boot_guile_support (
void *boot_scm_file)
528 return scm_c_primitive_load ((
const char *) boot_scm_file);
537 standard_throw_args_p (SCM args)
540 && scm_ilength (args) >= 3)
543 SCM arg0 = scm_list_ref (args, scm_from_int (0));
545 SCM arg1 = scm_list_ref (args, scm_from_int (1));
547 SCM arg2 = scm_list_ref (args, scm_from_int (2));
550 && scm_is_string (arg1)
561 print_standard_throw_error (SCM args)
564 SCM arg0 = scm_list_ref (args, scm_from_int (0));
566 SCM arg1 = scm_list_ref (args, scm_from_int (1));
568 SCM arg2 = scm_list_ref (args, scm_from_int (2));
573 scm_simple_format (scm_current_error_port (),
574 scm_from_latin1_string (
_(
"Error in function ~s:~%")),
577 scm_simple_format (scm_current_error_port (), arg1, arg2);
586 print_throw_error (SCM key, SCM args)
593 if (standard_throw_args_p (args))
594 print_standard_throw_error (args);
597 scm_simple_format (scm_current_error_port (),
598 scm_from_latin1_string (
_(
"Throw to key `~a' with args `~s'.~%")),
599 scm_list_2 (key, args));
606 handle_boot_error (
void *boot_scm_file, SCM key, SCM args)
610 print_throw_error (key, args);
613 warning (
_(
"Could not complete Guile gdb module initialization from:\n"
615 "Limited Guile support is available.\n"
616 "Suggest passing --data-directory=/path/to/gdb/data-directory.\n"),
617 (
const char *) boot_scm_file);
619 return SCM_UNSPECIFIED;
626 initialize_scheme_side (
void)
632 boot_scm_path = concat (guile_datadir,
SLASH_STRING,
"gdb",
635 scm_c_catch (SCM_BOOL_T, boot_guile_support, boot_scm_path,
636 handle_boot_error, boot_scm_path, NULL, NULL);
638 xfree (boot_scm_path);
647 initialize_gdb_module (
void *data)
658 gdbscm_documentation_symbol = scm_from_latin1_symbol (
"documentation");
688 from_tty_keyword = scm_from_latin1_keyword (
"from-tty");
689 to_string_keyword = scm_from_latin1_keyword (
"to-string");
691 initialize_scheme_side ();
693 gdb_scheme_initialized = 1;
700 call_initialize_gdb_module (
void *data)
705 scm_c_define_module (gdbscm_module_name, initialize_gdb_module, NULL);
707 #if HAVE_GUILE_MANUAL_FINALIZATION
708 scm_run_finalizers ();
722 scm_set_current_module (scm_interaction_environment ());
736 gdbscm_set_backtrace (
int enable)
738 static const char disable_bt[] =
"(debug-disable 'backtrace)";
739 static const char enable_bt[] =
"(debug-enable 'backtrace)";
758 Start an interactive Guile prompt.\n\
760 To return to GDB, type the EOF character (e.g., Ctrl-D on an empty\n\
764 Start a Guile interactive prompt.\n\
766 Guile scripting is not supported in this copy of GDB.\n\
767 This command is only a placeholder.")
777 Evaluate one or more Guile expressions.\n\
779 The expression(s) can be given as an argument, for instance:\n\
781 guile (display 23)\n\
783 The result of evaluating the last expression is printed.\n\
785 If no argument is given, the following lines are read and passed\n\
786 to Guile for evaluation. Type a line containing \"end\" to indicate\n\
787 the end of the set of expressions.\n\
789 The Guile GDB module must first be imported before it can be used.\n\
791 (gdb) guile (use-modules (gdb))\n\
792 or if you want to import the (gdb) module with a prefix, use:\n\
793 (gdb) guile (use-modules ((gdb) #:renamer (symbol-prefix-proc 'gdb:)))\n\
795 The Guile interactive session, started with the \"guile-repl\"\n\
796 command, provides extensive help and apropos capabilities.\n\
797 Type \",help\" once in a Guile interactive session.")
800 Evaluate a Guile expression.\n\
802 Guile scripting is not supported in this copy of GDB.\n\
803 This command is only a placeholder.")
809 _(
"Prefix command for Guile preference settings."),
810 &set_guile_list,
"set guile ", 0,
815 _(
"Prefix command for Guile preference settings."),
816 &show_guile_list,
"show guile ", 0,
821 _(
"Prefix command for Guile info displays."),
822 &info_guile_list,
"info guile ", 0,
829 &gdbscm_print_excp,
_(
"\
830 Set mode for Guile exception printing on error."),
_(
"\
831 Show the mode of Guile exception printing on error."),
_(
"\
832 none == no stack or message will be printed.\n\
833 full == a message and a stack will be printed.\n\
834 message == an error message without a stack will be printed."),
836 &set_guile_list, &show_guile_list);
849 #ifdef HAVE_SIGPROCMASK
850 sigset_t sigchld_mask, prev_mask;
857 #if HAVE_GUILE_MANUAL_FINALIZATION
861 scm_set_automatic_finalization_enabled (0);
864 #ifdef HAVE_SIGPROCMASK
870 sigemptyset (&sigchld_mask);
871 sigaddset (&sigchld_mask, SIGCHLD);
872 sigprocmask (SIG_BLOCK, &sigchld_mask, &prev_mask);
878 scm_with_guile (call_initialize_gdb_module, NULL);
880 #ifdef HAVE_SIGPROCMASK
881 sigprocmask (SIG_SETMASK, &prev_mask, NULL);
891 gdbscm_set_backtrace (0);
void gdbscm_initialize_exceptions(void)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
static const char *const guile_print_excp_enums[]
void gdbscm_define_functions(const scheme_function *, int is_public)
enum command_control_type execute_control_command_untraced(struct command_line *cmd)
void gdbscm_initialize_frames(void)
static void guile_repl_command(char *arg, int from_tty)
void 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_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void warning(const char *fmt,...)
void gdbscm_initialize_values(void)
const char * gdbscm_print_excp
struct ui_file * gdb_stdout
static void install_gdb_commands(void)
char * execute_command_to_string(char *p, int from_tty)
const struct gdb_exception exception_none
const char gdbscm_print_excp_full[]
int gdbscm_guile_micro_version
static void set_guile_command(char *args, int from_tty)
char * skip_spaces(char *chp)
const char gdbscm_print_excp_message[]
void execute_command(char *, int)
static struct cmd_list_element * show_guile_list
char * gdbscm_safe_source_script(const char *filename)
#define gdbscm_is_true(scm)
void null_cleanup(void *arg)
void gdbscm_initialize_iterators(void)
struct command_line * get_command_line(enum command_control_type type, char *arg)
void gdbscm_initialize_pspaces(void)
const char gdbscm_print_excp_none[]
struct cmd_list_element * infolist
struct cmd_list_element * setlist
initialize_file_ftype _initialize_guile
objfile_script_executor_func gdbscm_execute_objfile_script
int gdbscm_auto_load_enabled(const struct extension_language_defn *)
void gdbscm_initialize_smobs(void)
#define CATCH(EXCEPTION, MASK)
struct cleanup * make_cleanup_restore_integer(int *variable)
void gdbscm_initialize_objfiles(void)
void initialize_file_ftype(void)
SCM gdbscm_scm_from_c_string(const char *string)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
#define gdbscm_is_false(scm)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
struct cmd_list_element * showlist
void gdbscm_initialize_pretty_printers(void)
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
static void info_guile_command(char *args, int from_tty)
int gdbscm_guile_minor_version
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
void gdbscm_initialize_auto_load(void)
void script_sourcer_func(const struct extension_language_defn *, FILE *stream, const char *filename)
static void show_guile_command(char *args, int from_tty)
struct cleanup * prevent_dont_repeat(void)
int gdbscm_guile_major_version
void gdbscm_initialize_breakpoints(void)
static const char * guile_datadir
struct cmd_list_element * add_alias_cmd(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
void gdbscm_initialize_commands(void)
void printf_unfiltered(const char *format,...)
objfile_script_sourcer_func gdbscm_source_objfile_script
int gdbscm_scm_string_to_int(SCM string)
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
void gdbscm_initialize_symtabs(void)
enum ext_lang_bp_stop gdbscm_breakpoint_cond_says_stop(const struct extension_language_defn *, struct breakpoint *b)
enum ext_lang_rc gdbscm_apply_val_pretty_printer(const struct extension_language_defn *, struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, const struct language_defn *language)
void gdbscm_initialize_math(void)
char * gdbscm_safe_eval_string(const char *string, int display_result)
struct command_line * next
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void gdbscm_initialize_arches(void)
void gdbscm_enter_repl(void)
void gdbscm_initialize_symbols(void)
void gdbscm_preserve_values(const struct extension_language_defn *, struct objfile *, htab_t copied_types)
struct ui_file * gdb_stderr
static void guile_command(char *arg, int from_tty)
SCM gdbscm_documentation_symbol
static struct cmd_list_element * set_guile_list
void gdbscm_initialize_lazy_strings(void)
const char gdbscm_module_name[]
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
void gdbscm_initialize_blocks(void)
struct cleanup * make_cleanup_free_command_lines(struct command_line **arg)
int gdbscm_breakpoint_has_cond(const struct extension_language_defn *, struct breakpoint *b)
struct cmd_list_element * add_info_alias(const char *name, const char *oldname, int abbrev_flag)
void gdbscm_initialize_parameters(void)
static struct cmd_list_element * info_guile_list
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
void gdbscm_initialize_strings(void)
void gdbscm_initialize_types(void)
void bpstat_do_actions(void)
int gdb_scheme_initialized
const char gdbscm_init_module_name[]
struct command_line ** body_list
void error(const char *fmt,...)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc)
void do_cleanups(struct cleanup *old_chain)
void gdbscm_initialize_ports(void)
void gdbscm_initialize_disasm(void)
const ULONGEST const LONGEST len