76 static struct interp *interp_list = NULL;
77 static struct interp *current_interpreter = NULL;
78 static struct interp *top_level_interpreter_ptr = NULL;
86 struct interp *new_interp;
88 new_interp = XNEW (
struct interp);
90 new_interp->
name = xstrdup (name);
91 new_interp->
data = NULL;
110 interp_list = interp;
136 gdb_assert (!top_level || !current_interpreter);
137 gdb_assert (!top_level || !top_level_interpreter_ptr);
139 if (current_interpreter != NULL)
146 error (
_(
"Could not suspend interpreter \"%s\"."),
147 current_interpreter->
name);
155 current_interpreter = interp;
157 top_level_interpreter_ptr = interp;
189 if (old_interp == NULL || !
interp_set (old_interp, 0))
191 _(
"Failed to initialize new interp \"%s\" %s"),
192 interp->
name,
"and could not restore old interp!\n");
199 "Switching to interpreter \"%.24s\".\n", interp->
name);
212 struct interp *interp;
214 if (name == NULL || strlen (name) == 0)
217 for (interp = interp_list; interp != NULL; interp = interp->
next)
219 if (strcmp (interp->
name, name) == 0)
241 if (current_interpreter == NULL
258 current_interpreter = interp;
282 if (current_interpreter)
283 return (strcmp (current_interpreter->
name, interp_name) == 0);
305 if (command_interpreter != NULL)
326 return current_interpreter->
quiet_p;
345 struct interp *save_command_interp;
347 gdb_assert (interp->procs->exec_proc != NULL);
351 command_interpreter = interp;
353 ex = interp->procs->exec_proc (interp->data, command_str);
355 command_interpreter = save_command_interp;
383 struct interp *old_interp, *interp_to_use;
384 char **prules = NULL;
388 int old_quiet, use_quiet;
398 for (trule = prules; *trule != NULL; trule++)
402 error (
_(
"usage: interpreter-exec <interpreter> [ <command> ... ]"));
407 if (interp_to_use == NULL)
408 error (
_(
"Could not find interpreter \"%s\"."), prules[0]);
415 error (
_(
"Could not switch to interpreter \"%s\"."), prules[0]);
417 for (i = 1; i < nrules; i++)
426 error (
_(
"error in command: \"%s\"."), prules[i]);
440 const char *text,
const char *
word)
444 struct interp *interp;
446 textlen = strlen (text);
447 for (interp = interp_list; interp != NULL; interp = interp->
next)
449 if (strncmp (interp->
name, text, textlen) == 0)
453 match = (
char *)
xmalloc (strlen (word) + strlen (interp->
name) + 1);
455 strcpy (match, interp->
name);
456 else if (word > text)
459 strcpy (match, interp->
name + (word - text));
464 strncpy (match, word, text - word);
465 match[text -
word] =
'\0';
466 strcat (match, interp->
name);
485 return top_level_interpreter_ptr->
data;
496 Execute a command in an interpreter. It takes two arguments:\n\
497 The first argument is the name of the interpreter to use.\n\
498 The second argument is the command to execute.\n"), &
cmdlist);
void error_no_arg(const char *why)
struct cleanup * make_cleanup_freeargv(char **arg)
void(* deprecated_register_changed_hook)(int regno)
int interp_quiet_p(struct interp *interp)
interp_resume_ftype * resume_proc
int(* deprecated_query_hook)(const char *, va_list) ATTRIBUTE_FPTR_PRINTF(1
void internal_error(const char *file, int line, const char *fmt,...)
struct ui_out * interp_ui_out(struct interp *interp)
interp_suspend_ftype * suspend_proc
static void interpreter_exec_cmd(char *args, int from_tty)
void(* deprecated_context_hook)(int)
void(* deprecated_print_frame_info_listing_hook)(struct symtab *s, int line, int stopline, int noerror)
void _initialize_interpreter(void)
#define VEC_safe_push(T, V, O)
struct cmd_list_element * cmdlist
void interp_add(struct interp *interp)
ptid_t(* deprecated_target_wait_hook)(ptid_t ptid, struct target_waitstatus *status, int options)
void ui_out_text(struct ui_out *uiout, const char *string)
interp_command_loop_ftype * command_loop_proc
int interp_set(struct interp *interp, int top_level)
void ui_out_flush(struct ui_out *uiout)
void(* deprecated_call_command_hook)(struct cmd_list_element *c, char *cmd, int from_tty)
static struct interp * current_interpreter
int(*) void(* deprecated_warning_hook)(const char *, va_list) ATTRIBUTE_FPTR_PRINTF(1
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
void clear_interpreter_hooks(void)
void * interp_data(struct interp *interp)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
struct interp * interp_new(const char *name, const struct interp_procs *procs)
int current_interp_set_logging(int start_log, struct ui_file *out, struct ui_file *logfile)
void(* deprecated_error_begin_hook)(void)
struct interp * interp_lookup(const char *name)
static struct interp * top_level_interpreter_ptr
int(*) void(*) void(* deprecated_interactive_hook)(void)
const char * interp_name(struct interp *interp)
interp_ui_out_ftype * ui_out_proc
struct gdb_exception interp_exec(struct interp *interp, const char *command_str)
const struct interp_procs * procs
void * top_level_interpreter_data(void)
void(* deprecated_readline_end_hook)(void)
int xsnprintf(char *str, size_t size, const char *format,...)
struct interp * command_interp(void)
void(* deprecated_readline_begin_hook)(char *,...) ATTRIBUTE_FPTR_PRINTF_1
char ** gdb_buildargv(const char *s)
static int interp_set_quiet(struct interp *interp, int quiet)
interp_init_ftype * init_proc
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static struct interp * command_interpreter
struct interp * top_level_interpreter(void)
static struct interp * interp_list
interp_set_logging_ftype * set_logging_proc
struct ui_out * current_uiout
void current_interp_command_loop(void)
int current_interp_named_p(const char *interp_name)
void error(const char *fmt,...)
void do_cleanups(struct cleanup *old_chain)
enum return_reason reason
struct interp * interp_set_temp(const char *name)
char *(* deprecated_readline_hook)(const char *)