GDB (xrefs)

Classes | Macros | Functions | Variables
cli-script.c File Reference
`#include "defs.h"`
`#include "value.h"`
`#include "language.h"`
`#include <ctype.h>`
`#include "ui-out.h"`
`#include "top.h"`
`#include "breakpoint.h"`
`#include "cli/cli-cmds.h"`
`#include "cli/cli-decode.h"`
`#include "cli/cli-script.h"`
`#include "extension.h"`
`#include "interps.h"`
`#include "compile/compile.h"`
`#include <vector>`

Go to the source code of this file.

## Classes
struct | string_view
class | user_args
struct | scoped_user_args_level
class | scoped_restore_hook_in

## Macros
#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 * | read_next_line (void)
static int | multi_line_command_p (enum command_control_type type)
static struct command_line * | build_command_line (enum command_control_type type, const char *args)
command_line_up | get_command_line (enum command_control_type type, const char *arg)
void | print_command_lines (struct ui_out *uiout, struct command_line *cmd, unsigned int depth)
void | execute_cmd_pre_hook (struct cmd_list_element *c)
void | execute_cmd_post_hook (struct cmd_list_element *c)
void | execute_user_command (struct cmd_list_element *c, const char *args)
void | reset_command_nest_depth (void)
void | print_command_trace (const char *cmd)
static enum command_control_type | execute_control_command_1 (struct command_line *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 (const char *arg, int from_tty)
static void | if_command (const char *arg, int from_tty)
static const char * | locate_arg (const char *p)
std::string | insert_user_defined_cmd_args (const char *line)
static void | realloc_body_list (struct command_line *command, int new_length)
static bool | command_name_equals (struct cmd_list_element *cmd, const char *name)
static const char * | line_first_arg (const char *p)
static enum misc_command_type | process_next_line (char *p, struct command_line **command, int parse_commands, void(*validator)(char *, void *), void *closure)
command_line_up | read_command_lines (char *prompt_arg, int from_tty, int parse_commands, void(*validator)(char *, void *), void *closure)
command_line_up | 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)
command_line_up | copy_command_lines (struct command_line *cmds)
static struct cmd_list_element ** | validate_comname (const char **comname)
static void | user_defined_command (const char *ignore, int from_tty)
static void | define_command (const char *comname, int from_tty)
static void | document_command (const char *comname, int from_tty)
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
static std::vector< std::unique_ptr< user_args > > | user_args_stack

## Macro Definition Documentation

## ◆ END_MESSAGE

#define END_MESSAGE "End with a line saying just \"end\"."

Definition at line 1195 of file cli-script.c.

Referenced by read_command_lines().

## ◆ HOOK_LEN

#define HOOK_LEN 5

Referenced by define_command().

## ◆ HOOK_POST_LEN

#define HOOK_POST_LEN 9

Referenced by define_command().

## ◆ HOOK_POST_STRING

#define HOOK_POST_STRING "hookpost-"

Referenced by define_command().

## ◆ HOOK_STRING

#define HOOK_STRING "hook-"

Referenced by define_command().

## ◆ MAX_TMPBUF

#define MAX_TMPBUF 128

Referenced by define_command().

## Function Documentation

## ◆ _initialize_cli_script()

void _initialize_cli_script | ( | void |  | ) |

Definition at line 1635 of file cli-script.c.

References _, add_com(), class_support, define_command(), document_command(), if_command(), and while_command().

## ◆ build_command_line()

static struct command_line* build_command_line | ( | enum command_control_type | type,
|  | const char * | args
| ) |  |
| static

Definition at line 146 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, command_line::next, type, while_control, XCNEWVEC, and XNEW.

Referenced by get_command_line(), and process_next_line().

## ◆ command_name_equals()

static bool command_name_equals | ( | struct cmd_list_element * | cmd,
|  | const char * | name
| ) |  |
| static

Definition at line 901 of file cli-script.c.

References CMD_LIST_AMBIGUOUS, cmd_list_element::name, and name.

Referenced by process_next_line().

## ◆ copy_command_lines()

command_line_up copy_command_lines | ( | struct command_line * | cmds | ) |

Definition at line 1333 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, XNEW, and XNEWVEC.

Referenced by commands_command_1(), and copy_command_lines().

## ◆ define_command()

static void define_command | ( | const char * | comname,
|  | int | from_tty
| ) |  |
| static

Definition at line 1420 of file cli-script.c.

References _, add_cmd(), 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::theclass, cmd_list_element::user_commands, user_defined_command(), validate_comname(), warning(), and xsnprintf().

Referenced by _initialize_cli_script().

## ◆ document_command()

static void document_command | ( | const char * | comname,
|  | int | from_tty
| ) |  |
| static

Definition at line 1530 of file cli-script.c.

References _, class_user, cmd_list_element::doc, error(), command_line::line, lookup_cmd(), command_line::next, read_command_lines(), cmd_list_element::theclass, validate_comname(), xfree(), xmalloc(), and xsnprintf().

Referenced by _initialize_cli_script().

## ◆ execute_cmd_post_hook()

void execute_cmd_post_hook | ( | struct cmd_list_element * | c | ) |

Definition at line 377 of file cli-script.c.

References execute_user_command(), cmd_list_element::hook_in, and cmd_list_element::hook_post.

Referenced by execute_command().

## ◆ execute_cmd_pre_hook()

void execute_cmd_pre_hook | ( | struct cmd_list_element * | c | ) |

Definition at line 366 of file cli-script.c.

References execute_user_command(), cmd_list_element::hook_in, and cmd_list_element::hook_pre.

Referenced by execute_command(), and normal_stop().

## ◆ execute_control_command()

enum command_control_type execute_control_command | ( | struct command_line * | cmd | ) |

Definition at line 650 of file cli-script.c.

References current_ui, current_uiout, execute_control_command_1(), INTERP_CONSOLE, interp_lookup(), interp_ui_out(), and make_scoped_restore().

Referenced by bpstat_do_actions_1(), execute_control_command_untraced(), and execute_user_command().

## ◆ execute_control_command_1()

static enum command_control_type execute_control_command_1 | ( | struct command_line * | cmd | ) |
| static

Definition at line 469 of file cli-script.c.

References _, command_line::body_count, command_line::body_list, break_control, command_nest_depth, commands_control, commands_from_control_command(), command_line::compile, compile_control, continue_control, command_line::control_type, command_line::control_u, eval_compile_command(), eval_ext_lang_from_control_command(), evaluate_expression(), execute_command(), guile_control, if(), if_control, insert_user_defined_cmd_args(), invalid_control, command_line::line, make_scoped_restore(), command_line::next, parse_expression(), print_command_trace(), python_control, QUIT, simple_control, string, value_free_to_mark(), value_mark(), value_true(), warning(), while_control, and xsnprintf().

Referenced by execute_control_command().

## ◆ execute_control_command_untraced()

enum command_control_type execute_control_command_untraced | ( | struct command_line * | cmd | ) |

Definition at line 665 of file cli-script.c.

References execute_control_command(), and suppress_next_print_command_trace.

Referenced by compile_code_command(), compile_print_command(), guile_command(), if_command(), python_command(), and while_command().

## ◆ execute_user_command()

void execute_user_command | ( | struct cmd_list_element * | c,
|  | const char * | args
| ) |  |

Definition at line 388 of file cli-script.c.

References _, ui::async, break_control, command_nest_depth, current_ui, error(), execute_control_command(), ui::instream, make_scoped_restore(), max_user_call_depth, command_line::next, simple_control, user_args_stack, cmd_list_element::user_commands, and warning().

Referenced by execute_cmd_post_hook(), execute_cmd_pre_hook(), and execute_command().

## ◆ free_command_lines()

void free_command_lines | ( | struct command_line ** | lptr | ) |

Definition at line 1309 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 define_command(), free_command_lines(), and command_lines_deleter::operator()().

## ◆ get_command_line()

command_line_up get_command_line | ( | enum command_control_type | type,
|  | const char * | arg
| ) |  |

Definition at line 170 of file cli-script.c.

References _, build_command_line(), invalid_control, read_next_line(), recurse_read_control_structure(), and warning().

Referenced by compile_code_command(), compile_print_command(), guile_command(), if_command(), python_command(), and while_command().

## ◆ if_command()

static void if_command | ( | const char * | arg,
|  | int | from_tty
| ) |  |
| static

Definition at line 693 of file cli-script.c.

References ui::async, control_level, current_ui, execute_control_command_untraced(), get_command_line(), if_control, and make_scoped_restore().

Referenced by _initialize_cli_script().

## ◆ insert_user_defined_cmd_args()

std::string insert_user_defined_cmd_args | ( | const char * | line | ) |

Definition at line 788 of file cli-script.c.

References user_args_stack.

Referenced by eval_command(), and execute_control_command_1().

## ◆ line_first_arg()

static const char* line_first_arg | ( | const char * | p | ) |
| static

Definition at line 912 of file cli-script.c.

References find_command_name_length(), and skip_spaces().

Referenced by process_next_line().

## ◆ locate_arg()

static const char* locate_arg | ( | const char * | p | ) |
| static

Definition at line 773 of file cli-script.c.

References startswith().

Referenced by user_args::insert_args().

## ◆ multi_line_command_p()

static int multi_line_command_p | ( | enum command_control_type | type | ) |
| static

Definition at line 125 of file cli-script.c.

References commands_control, compile_control, guile_control, if_control, python_control, while_control, and while_stepping_control.

Referenced by read_command_lines_1(), and recurse_read_control_structure().

## ◆ print_command_lines()

void print_command_lines | ( | struct ui_out * | uiout,
|  | struct command_line * | cmd,
|  | unsigned int | depth
| ) |  |

Definition at line 189 of file cli-script.c.

References command_line::body_count, command_line::body_list, break_control, commands_control, compile_control, continue_control, command_line::control_type, ui_out::field_fmt(), ui_out::field_string(), guile_control, if_control, command_line::line, command_line::next, print_command_lines(), python_control, simple_control, ui_out::spaces(), ui_out::text(), while_control, and while_stepping_control.

Referenced by bppy_get_commands(), gdbscm_breakpoint_commands(), print_command_lines(), print_one_breakpoint_location(), save_breakpoints(), and show_user_1().

## ◆ print_command_trace()

void print_command_trace | ( | const char * | cmd | ) |

Definition at line 447 of file cli-script.c.

References command_nest_depth, printf_filtered(), source_verbose, suppress_next_print_command_trace, and trace_commands.

Referenced by execute_command(), and execute_control_command_1().

## ◆ process_next_line()

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 928 of file cli-script.c.

References break_control, build_command_line(), CATCH, cmdlist, command_name_equals(), commands_control, compile_control, COMPILE_I_INVALID_SCOPE, continue_control, else_command, END_CATCH, end_command, guile_control, if_control, line_first_arg(), lookup_cmd_1(), nop_command, ok_command, python_control, RETURN_MASK_ALL, savestring(), simple_control, skip_spaces(), startswith(), throw_exception(), TRY, while_control, while_stepping_control, xfree(), and XNEW.

Referenced by read_command_lines_1(), and recurse_read_control_structure().

## ◆ read_command_lines()

command_line_up read_command_lines | ( | char * | prompt_arg,
|  | int | from_tty,
|  | int | parse_commands,
|  | void(*)(char *, void *) | validator,
|  | void * | closure
| ) |  |

Definition at line 1198 of file cli-script.c.

References current_interp_named_p(), current_ui, deprecated_readline_begin_hook, deprecated_readline_end_hook, END_MESSAGE, gdb_flush(), gdb_stdout, input_interactive_p(), INTERP_CONSOLE, printf_unfiltered(), read_command_lines_1(), and read_next_line().

Referenced by actions_command(), define_command(), and document_command().

## ◆ read_command_lines_1()

command_line_up read_command_lines_1 | ( | char *(*)(void) | read_next_line_func,
|  | int | parse_commands,
|  | void(*)(char *, void *) | validator,
|  | void * | closure
| ) |  |

Definition at line 1243 of file cli-script.c.

References control_level, command_line::control_type, dont_repeat(), end_command, invalid_control, multi_line_command_p(), command_line::next, nop_command, ok_command, process_next_line(), recurse_read_control_structure(), and simple_control.

Referenced by create_tracepoint_from_upload(), mi_cmd_break_commands(), and read_command_lines().

## ◆ read_next_line()

static char * read_next_line | ( | void |  | ) |
| static

Definition at line 872 of file cli-script.c.

References _, command_line_input(), control_level, current_ui, deprecated_readline_hook, error(), ui::instream, and ui::stdin_stream.

Referenced by get_command_line(), and read_command_lines().

## ◆ realloc_body_list()

static void realloc_body_list | ( | struct command_line * | command,
|  | int | new_length
| ) |  |
| static

Definition at line 847 of file cli-script.c.

References command_line::body_count, command_line::body_list, XCNEWVEC, and xfree().

Referenced by recurse_read_control_structure().

## ◆ 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 1082 of file cli-script.c.

References _, command_line::body_count, command_line::body_list, compile_control, control_level, command_line::control_type, dont_repeat(), else_command, end_command, error(), guile_control, if_control, invalid_control, multi_line_command_p(), command_line::next, nop_command, process_next_line(), python_control, realloc_body_list(), and simple_control.

Referenced by get_command_line(), and read_command_lines_1().

## ◆ reset_command_nest_depth()

void reset_command_nest_depth | ( | void |  | ) |

Definition at line 430 of file cli-script.c.

References command_nest_depth, and suppress_next_print_command_trace.

Referenced by display_gdb_prompt().

## ◆ script_from_file()

void script_from_file | ( | FILE * | stream,
|  | const char * | file
| ) |  |

Definition at line 1578 of file cli-script.c.

References _, ui::async, CATCH, current_ui, END_CATCH, internal_error(), make_scoped_restore(), read_command_file(), RETURN_MASK_ERROR, source_file_name, source_line_number, throw_error(), and TRY.

Referenced by source_gdb_objfile_script(), source_gdb_script(), and source_script_from_stream().

## ◆ show_user_1()

void show_user_1 | ( | struct cmd_list_element * | c,
|  | const char * | prefix,
|  | const char * | name,
|  | struct ui_file * | stream
| ) |  |

Definition at line 1610 of file cli-script.c.

References class_user, current_uiout, fprintf_filtered(), fputs_filtered(), gdb_stdout, cmd_list_element::name, name, cmd_list_element::next, cmd_list_element::prefixlist, cmd_list_element::prefixname, print_command_lines(), show_user_1(), cmd_list_element::theclass, and cmd_list_element::user_commands.

Referenced by show_user(), and show_user_1().

## ◆ user_defined_command()

static void user_defined_command | ( | const char * | ignore,
|  | int | from_tty
| ) |  |
| static

Definition at line 1415 of file cli-script.c.

Referenced by define_command().

## ◆ validate_comname()

static struct cmd_list_element** validate_comname | ( | const char ** | comname | ) |
| static

Definition at line 1369 of file cli-script.c.

References _, cmdlist, error(), error_no_arg(), lookup_cmd(), cmd_list_element::prefix, cmd_list_element::prefixlist, and string.

Referenced by define_command(), and document_command().

## ◆ while_command()

static void while_command | ( | const char * | arg,
|  | int | from_tty
| ) |  |
| static

Definition at line 676 of file cli-script.c.

References ui::async, control_level, current_ui, execute_control_command_untraced(), get_command_line(), make_scoped_restore(), and while_control.

Referenced by _initialize_cli_script().

## Variable Documentation

## ◆ command_nest_depth

int command_nest_depth = 1
| static

Definition at line 52 of file cli-script.c.

Referenced by execute_control_command_1(), execute_user_command(), print_command_trace(), and reset_command_nest_depth().

## ◆ control_level

int control_level
| static

Definition at line 49 of file cli-script.c.

Referenced by if_command(), read_command_lines_1(), read_next_line(), recurse_read_control_structure(), and while_command().

## ◆ suppress_next_print_command_trace

int suppress_next_print_command_trace = 0
| static

Definition at line 55 of file cli-script.c.

Referenced by execute_control_command_untraced(), print_command_trace(), and reset_command_nest_depth().

## ◆ user_args_stack

std::vector<std::unique_ptr<user_args> > user_args_stack
| static

Definition at line 100 of file cli-script.c.

Referenced by execute_user_command(), insert_user_defined_cmd_args(), scoped_user_args_level::scoped_user_args_level(), and scoped_user_args_level::~scoped_user_args_level().