GDB (xrefs)
|
#include "defs.h"
#include "value.h"
#include "language.h"
#include <ctype.h>
#include "ui-out.h"
#include "gdb_string.h"
#include "exceptions.h"
#include "top.h"
#include "breakpoint.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
#include "cli/cli-script.h"
#include "gdb_assert.h"
#include "python/python.h"
#include "interps.h"
Go to the source code of this file.
Classes | |
struct | user_args |
struct | source_cleanup_lines_args |
Defines | |
#define | MAXUSERARGS 10 |
#define | END_MESSAGE "End with a line saying just \"end\"." |
#define | MAX_TMPBUF 128 |
#define | HOOK_STRING "hook-" |
#define | HOOK_LEN 5 |
#define | HOOK_POST_STRING "hookpost-" |
#define | HOOK_POST_LEN 9 |
Functions | |
static enum command_control_type | recurse_read_control_structure (char *(*read_next_line_func)(void), struct command_line *current_cmd, void(*validator)(char *, void *), void *closure) |
static char * | insert_args (char *line) |
static struct cleanup * | setup_user_args (char *p) |
static char * | read_next_line (void) |
static struct command_line * | build_command_line (enum command_control_type type, char *args) |
struct command_line * | get_command_line (enum command_control_type type, char *arg) |
void | print_command_lines (struct ui_out *uiout, struct command_line *cmd, unsigned int depth) |
static void | clear_hook_in_cleanup (void *data) |
void | execute_cmd_pre_hook (struct cmd_list_element *c) |
void | execute_cmd_post_hook (struct cmd_list_element *c) |
static void | do_restore_user_call_depth (void *call_depth) |
void | execute_user_command (struct cmd_list_element *c, char *args) |
void | reset_command_nest_depth (void) |
void | print_command_trace (const char *cmd) |
enum command_control_type | execute_control_command (struct command_line *cmd) |
enum command_control_type | execute_control_command_untraced (struct command_line *cmd) |
static void | while_command (char *arg, int from_tty) |
static void | if_command (char *arg, int from_tty) |
static void | arg_cleanup (void *ignore) |
static char * | locate_arg (char *p) |
static void | realloc_body_list (struct command_line *command, int new_length) |
static enum misc_command_type | process_next_line (char *p, struct command_line **command, int parse_commands, void(*validator)(char *, void *), void *closure) |
static void | restore_interp (void *arg) |
struct command_line * | read_command_lines (char *prompt_arg, int from_tty, int parse_commands, void(*validator)(char *, void *), void *closure) |
struct command_line * | read_command_lines_1 (char *(*read_next_line_func)(void), int parse_commands, void(*validator)(char *, void *), void *closure) |
void | free_command_lines (struct command_line **lptr) |
static void | do_free_command_lines_cleanup (void *arg) |
struct cleanup * | make_cleanup_free_command_lines (struct command_line **arg) |
struct command_line * | copy_command_lines (struct command_line *cmds) |
static struct cmd_list_element ** | validate_comname (char **comname) |
static void | user_defined_command (char *ignore, int from_tty) |
static void | define_command (char *comname, int from_tty) |
static void | document_command (char *comname, int from_tty) |
static void | source_cleanup_lines (void *args) |
void | script_from_file (FILE *stream, const char *file) |
void | show_user_1 (struct cmd_list_element *c, const char *prefix, const char *name, struct ui_file *stream) |
void | _initialize_cli_script (void) |
Variables | |
static int | control_level |
static int | command_nest_depth = 1 |
static int | suppress_next_print_command_trace = 0 |
struct user_args * | user_args |
initialize_file_ftype | _initialize_cli_script |
#define END_MESSAGE "End with a line saying just \"end\"." |
Definition at line 1195 of file cli-script.c.
Referenced by read_command_lines().
#define HOOK_LEN 5 |
Referenced by define_command().
#define HOOK_POST_LEN 9 |
Referenced by define_command().
#define HOOK_POST_STRING "hookpost-" |
Referenced by define_command().
#define HOOK_STRING "hook-" |
Referenced by define_command().
#define MAX_TMPBUF 128 |
Referenced by define_command().
#define MAXUSERARGS 10 |
Definition at line 62 of file cli-script.c.
Referenced by setup_user_args().
void _initialize_cli_script | ( | void | ) |
Definition at line 1699 of file cli-script.c.
References _, add_com(), class_support, define_command(), document_command(), if_command(), and while_command().
static void arg_cleanup | ( | void * | ignore | ) | [static] |
Definition at line 648 of file cli-script.c.
References _, user_args::command, internal_error(), user_args::next, user_args, and xfree().
Referenced by setup_user_args().
static struct command_line* build_command_line | ( | enum command_control_type | type, |
char * | args | ||
) | [static, read] |
Definition at line 85 of file cli-script.c.
References _, command_line::body_count, command_line::body_list, command_line::control_type, error(), gdb_assert, if_control, command_line::line, memset(), command_line::next, type, while_control, and xmalloc().
Referenced by get_command_line(), and process_next_line().
static void clear_hook_in_cleanup | ( | void * | data | ) | [static] |
Definition at line 266 of file cli-script.c.
References cmd_list_element::hook_in.
Referenced by execute_cmd_post_hook(), and execute_cmd_pre_hook().
struct command_line* copy_command_lines | ( | struct command_line * | cmds | ) | [read] |
Definition at line 1354 of file cli-script.c.
References command_line::body_count, command_line::body_list, command_line::control_type, copy_command_lines(), command_line::line, command_line::next, and xmalloc().
Referenced by copy_command_lines(), and do_map_commands_command().
static void define_command | ( | char * | comname, |
int | from_tty | ||
) | [static] |
Definition at line 1444 of file cli-script.c.
References _, add_cmd(), cmd_list_element::class, class_alias, class_user, cmd_list_element::doc, error(), free_command_lines(), HOOK_LEN, cmd_list_element::hook_post, HOOK_POST_LEN, HOOK_POST_STRING, cmd_list_element::hook_pre, HOOK_STRING, cmd_list_element::hookee_post, cmd_list_element::hookee_pre, internal_error(), lookup_cmd(), MAX_TMPBUF, cmd_list_element::name, query(), read_command_lines(), cmd_list_element::user_commands, user_defined_command(), validate_comname(), warning(), and xsnprintf().
Referenced by _initialize_cli_script().
static void do_free_command_lines_cleanup | ( | void * | arg | ) | [static] |
Definition at line 1342 of file cli-script.c.
References free_command_lines().
Referenced by make_cleanup_free_command_lines().
static void do_restore_user_call_depth | ( | void * | call_depth | ) | [static] |
Definition at line 300 of file cli-script.c.
References in_user_command.
Referenced by execute_user_command().
static void document_command | ( | char * | comname, |
int | from_tty | ||
) | [static] |
Definition at line 1562 of file cli-script.c.
References _, cmd_list_element::class, class_user, cmd_list_element::doc, error(), free_command_lines(), len, command_line::line, lookup_cmd(), command_line::next, read_command_lines(), validate_comname(), xfree(), xmalloc(), and xsnprintf().
Referenced by _initialize_cli_script().
void execute_cmd_post_hook | ( | struct cmd_list_element * | c | ) |
Definition at line 286 of file cli-script.c.
References clear_hook_in_cleanup(), do_cleanups(), execute_user_command(), cmd_list_element::hook_in, cmd_list_element::hook_post, and make_cleanup().
Referenced by execute_command().
void execute_cmd_pre_hook | ( | struct cmd_list_element * | c | ) |
Definition at line 274 of file cli-script.c.
References clear_hook_in_cleanup(), do_cleanups(), execute_user_command(), cmd_list_element::hook_in, cmd_list_element::hook_pre, and make_cleanup().
Referenced by execute_command(), and hook_stop_stub().
enum command_control_type execute_control_command | ( | struct command_line * | cmd | ) |
Definition at line 399 of file cli-script.c.
References _, command_line::body_count, command_line::body_list, break_control, commands_control, commands_from_control_command(), continue_control, command_line::control_type, do_cleanups(), eval_python_from_control_command(), evaluate_expression(), execute_command(), execute_control_command(), free_current_contents(), if_control, insert_args(), invalid_control, len, command_line::line, make_cleanup(), command_line::next, null_cleanup(), parse_expression(), print_command_trace(), python_control, QUIT, simple_control, value_free_to_mark(), value_mark(), value_true(), warning(), while_control, and xsnprintf().
Referenced by bpstat_do_actions_1(), execute_control_command(), execute_control_command_untraced(), and execute_user_command().
enum command_control_type execute_control_command_untraced | ( | struct command_line * | cmd | ) |
Definition at line 591 of file cli-script.c.
References execute_control_command().
Referenced by if_command(), python_interactive_command(), and while_command().
void execute_user_command | ( | struct cmd_list_element * | c, |
char * | args | ||
) |
Definition at line 311 of file cli-script.c.
References _, break_control, do_cleanups(), do_restore_instream_cleanup(), do_restore_user_call_depth(), error(), execute_control_command(), in_user_command, instream, interpreter_async, make_cleanup(), make_cleanup_restore_integer(), max_user_call_depth, command_line::next, setup_user_args(), simple_control, cmd_list_element::user_commands, and warning().
Referenced by execute_cmd_post_hook(), execute_cmd_pre_hook(), and execute_command().
void free_command_lines | ( | struct command_line ** | lptr | ) |
Definition at line 1318 of file cli-script.c.
References command_line::body_count, command_line::body_list, free_command_lines(), command_line::line, command_line::next, and xfree().
Referenced by decref_counted_command_line(), define_command(), do_free_command_lines_cleanup(), document_command(), free_command_lines(), if_command(), and while_command().
struct command_line* get_command_line | ( | enum command_control_type | type, |
char * | arg | ||
) | [read] |
Definition at line 111 of file cli-script.c.
References _, build_command_line(), discard_cleanups(), do_cleanups(), invalid_control, make_cleanup_free_command_lines(), read_next_line(), recurse_read_control_structure(), and warning().
Referenced by if_command(), python_interactive_command(), and while_command().
static void if_command | ( | char * | arg, |
int | from_tty | ||
) | [static] |
Definition at line 626 of file cli-script.c.
References do_cleanups(), execute_control_command_untraced(), free_command_lines(), get_command_line(), if_control, interpreter_async, and make_cleanup_restore_integer().
Referenced by _initialize_cli_script().
static char * insert_args | ( | char * | line | ) | [static] |
Definition at line 763 of file cli-script.c.
References _, user_args::a, user_args::arg, user_args::count, error(), gdb_assert, len, user_args::len, line, locate_arg(), memcpy(), p, and xmalloc().
Referenced by execute_control_command().
static char* locate_arg | ( | char * | p | ) | [static] |
struct cleanup* make_cleanup_free_command_lines | ( | struct command_line ** | arg | ) | [read] |
Definition at line 1348 of file cli-script.c.
References do_free_command_lines_cleanup(), and make_cleanup().
Referenced by get_command_line(), python_interactive_command(), and read_command_lines_1().
void print_command_lines | ( | struct ui_out * | uiout, |
struct command_line * | cmd, | ||
unsigned int | depth | ||
) |
Definition at line 137 of file cli-script.c.
References command_line::body_count, command_line::body_list, break_control, commands_control, continue_control, command_line::control_type, if_control, command_line::line, command_line::next, print_command_lines(), python_control, simple_control, ui_out_field_fmt(), ui_out_field_string(), ui_out_spaces(), ui_out_text(), while_control, and while_stepping_control.
Referenced by bppy_get_commands(), print_command_lines(), print_one_breakpoint_location(), save_breakpoints(), and show_user_1().
void print_command_trace | ( | const char * | cmd | ) |
Definition at line 379 of file cli-script.c.
References command_nest_depth, printf_filtered(), source_verbose, and trace_commands.
Referenced by execute_command(), and execute_control_command().
static enum misc_command_type process_next_line | ( | char * | p, |
struct command_line ** | command, | ||
int | parse_commands, | ||
void(*)(char *, void *) | validator, | ||
void * | closure | ||
) | [static] |
Definition at line 915 of file cli-script.c.
References break_control, build_command_line(), commands_control, continue_control, else_command, end_command, if_control, nop_command, ok_command, python_control, gdb_exception::reason, RETURN_MASK_ALL, savestring(), simple_control, throw_exception(), TRY_CATCH, while_control, while_stepping_control, xfree(), and xmalloc().
Referenced by read_command_lines_1(), and recurse_read_control_structure().
struct command_line* read_command_lines | ( | char * | prompt_arg, |
int | from_tty, | ||
int | parse_commands, | ||
void(*)(char *, void *) | validator, | ||
void * | closure | ||
) | [read] |
Definition at line 1198 of file cli-script.c.
References current_interp_named_p(), deprecated_readline_begin_hook, deprecated_readline_end_hook, do_cleanups(), END_MESSAGE, gdb_flush(), gdb_stdout, input_from_terminal_p(), INTERP_CONSOLE, interp_set_temp(), make_cleanup(), printf_unfiltered(), read_command_lines_1(), read_next_line(), and restore_interp().
Referenced by define_command(), do_map_commands_command(), document_command(), and trace_actions_command().
struct command_line* read_command_lines_1 | ( | char *(*)(void) | read_next_line_func, |
int | parse_commands, | ||
void(*)(char *, void *) | validator, | ||
void * | closure | ||
) | [read] |
Definition at line 1245 of file cli-script.c.
References commands_control, command_line::control_type, discard_cleanups(), do_cleanups(), dont_repeat(), end_command, if_control, invalid_control, make_cleanup(), make_cleanup_free_command_lines(), cleanup::next, command_line::next, nop_command, null_cleanup(), ok_command, process_next_line(), python_control, recurse_read_control_structure(), simple_control, while_control, and while_stepping_control.
Referenced by create_tracepoint_from_upload(), gdb_actions_command(), mi_cmd_break_commands(), and read_command_lines().
static char * read_next_line | ( | void | ) | [static] |
Definition at line 883 of file cli-script.c.
References _, command_line_input(), control_level, deprecated_readline_hook, error(), and instream.
Referenced by get_command_line(), and read_command_lines().
static void realloc_body_list | ( | struct command_line * | command, |
int | new_length | ||
) | [static] |
Definition at line 856 of file cli-script.c.
References command_line::body_count, command_line::body_list, memcpy(), memset(), xfree(), and xmalloc().
Referenced by recurse_read_control_structure().
static enum command_control_type recurse_read_control_structure | ( | char *(*)(void) | read_next_line_func, |
struct command_line * | current_cmd, | ||
void(*)(char *, void *) | validator, | ||
void * | closure | ||
) | [static] |
Definition at line 1070 of file cli-script.c.
References _, command_line::body_count, command_line::body_list, commands_control, command_line::control_type, dont_repeat(), else_command, end_command, error(), if_control, invalid_control, command_line::next, nop_command, process_next_line(), python_control, realloc_body_list(), simple_control, while_control, and while_stepping_control.
Referenced by get_command_line(), and read_command_lines_1().
void reset_command_nest_depth | ( | void | ) |
Definition at line 362 of file cli-script.c.
Referenced by display_gdb_prompt().
static void restore_interp | ( | void * | arg | ) | [static] |
Definition at line 1181 of file cli-script.c.
References interp_name(), and interp_set_temp().
Referenced by read_command_lines().
void script_from_file | ( | FILE * | stream, |
const char * | file | ||
) |
Definition at line 1626 of file cli-script.c.
References _, do_cleanups(), gdb_exception::error, internal_error(), make_cleanup(), gdb_exception::message, source_cleanup_lines_args::old_file, source_cleanup_lines_args::old_line, read_command_file(), gdb_exception::reason, RETURN_ERROR, RETURN_MASK_ERROR, source_cleanup_lines(), source_file_name, source_line_number, throw_error(), and TRY_CATCH.
Referenced by source_gdb_script_for_objfile(), and source_script_from_stream().
static struct cleanup * setup_user_args | ( | char * | p | ) | [static, read] |
Definition at line 665 of file cli-script.c.
References _, user_args::a, user_args::arg, arg_cleanup(), user_args::command, user_args::count, error(), user_args::len, make_cleanup(), MAXUSERARGS, memset(), user_args::next, user_args, and xmalloc().
Referenced by execute_user_command().
void show_user_1 | ( | struct cmd_list_element * | c, |
const char * | prefix, | ||
const char * | name, | ||
struct ui_file * | stream | ||
) |
Definition at line 1670 of file cli-script.c.
References cmd_list_element::class, class_user, current_uiout, fprintf_filtered(), fputs_filtered(), gdb_stdout, cmd_list_element::name, cmd_list_element::next, cmd_list_element::prefixlist, cmd_list_element::prefixname, print_command_lines(), show_user_1(), and cmd_list_element::user_commands.
Referenced by show_user(), and show_user_1().
static void source_cleanup_lines | ( | void * | args | ) | [static] |
Definition at line 1614 of file cli-script.c.
References source_cleanup_lines_args::old_file, source_cleanup_lines_args::old_line, source_file_name, and source_line_number.
Referenced by script_from_file().
static void user_defined_command | ( | char * | ignore, |
int | from_tty | ||
) | [static] |
Definition at line 1439 of file cli-script.c.
Referenced by define_command().
static struct cmd_list_element** validate_comname | ( | char ** | comname | ) | [static, read] |
Definition at line 1390 of file cli-script.c.
References _, cmdlist, error(), error_no_arg(), lookup_cmd(), and cmd_list_element::prefixlist.
Referenced by define_command(), and document_command().
static void while_command | ( | char * | arg, |
int | from_tty | ||
) | [static] |
Definition at line 602 of file cli-script.c.
References do_cleanups(), execute_control_command_untraced(), free_command_lines(), get_command_line(), interpreter_async, make_cleanup_restore_integer(), and while_control.
Referenced by _initialize_cli_script().
Definition at line 1696 of file cli-script.c.
Referenced by initialize_all_files().
int command_nest_depth = 1 [static] |
Definition at line 56 of file cli-script.c.
Referenced by print_command_trace().
int control_level [static] |
Definition at line 53 of file cli-script.c.
Referenced by read_next_line().
int suppress_next_print_command_trace = 0 [static] |
Definition at line 59 of file cli-script.c.
Referenced by arg_cleanup(), and setup_user_args().