mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-30 15:56:36 +08:00
Constify add_com
This changes add_com to take a cmd_const_cfunc_ftype, and then fixes up all the command implementations. In most cases this is trivial. In a couple of places I had to again introduce a temporary non-const overload. These overloads will be removed when add_info is constified. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * solib.h (no_shared_libraries): Constify. * frame.h (return_command): Constify. * cli/cli-cmds.h (quit_command): Constify. * top.h (quit_command, execute_command): Constify. * target.h (flash_erase_command): Constify. * inferior.h (set_inferior_args, attach_command): Constify. * tracepoint.h (start_tracing, stop_tracing): Constify. * breakpoint.h (break_command, tbreak_command) (hbreak_command_wrapper, thbreak_command_wrapper) (rbreak_command_wrapper, watch_command_wrapper) (awatch_command_wrapper, rwatch_command_wrapper) (get_tracepoint_by_number): Constify. * symtab.c (info_variables_command, rbreak_command) (symtab_symbol_info): Constify. (info_variables_command): Add non-const overload. * top.c (dont_repeat_command): Constify. * breakpoint.c (ignore_command, commands_command) (condition_command, tbreak_command, hbreak_command) (thbreak_command, clear_command, break_command) (info_breakpoints_command, watch_command, rwatch_command) (awatch_command, trace_command, ftrace_command, strace_command) (trace_pass_command, break_range_command, dprintf_command) (agent_printf_command, get_tracepoint_by_number) (watch_maybe_just_location, trace_pass_command): Constify. (info_breakpoints_command): Add non-const overload. * tracefile.c (tsave_command): Constify. * infcmd.c (attach_command, disconnect_command, signal_command) (queue_signal_command, stepi_command, nexti_command) (finish_command, next_command, step_command, until_command) (advance_command, jump_command, continue_command, run_command) (start_command, starti_command, interrupt_command) (run_command_1, set_inferior_args, step_1): Constify. * inferior.c (add_inferior_command, remove_inferior_command) (clone_inferior_command): Constify. * linux-fork.c (checkpoint_command, restart_command): Constify. * windows-nat.c (signal_event_command): Constify. * guile/guile.c (guile_repl_command, guile_command): Constify. * printcmd.c (x_command, display_command, printf_command) (output_command, set_command, call_command, print_command) (eval_command): Constify. (non_const_set_command): Remove. (_initialize_printcmd): Update. * source.c (forward_search_command, reverse_search_command): Constify. * jit.c (jit_reader_load_command, jit_reader_unload_command): Constify. * infrun.c (handle_command): Constify. * memattr.c (mem_command): Constify. * stack.c (return_command, up_command, up_silently_command) (down_command, down_silently_command, frame_command) (backtrace_command, func_command, backtrace_command_1): Constify. (backtrace_command): Add non-const overload. * remote-sim.c (simulator_command): Constify. * exec.c (set_section_command): Constify. * tracepoint.c (tdump_command, trace_variable_command) (tstatus_command, tstop_command, tstart_command) (end_actions_pseudocommand, while_stepping_pseudocommand) (collect_pseudocommand, teval_pseudocommand, actions_command) (start_tracing, stop_tracing): Constify. * value.c (init_if_undefined_command): Constify. * tui/tui-stack.c (tui_update_command): Constify. * tui/tui-win.c (tui_refresh_all_command) (tui_set_tab_width_command, tui_set_win_height_command) (tui_set_focus_command, tui_scroll_forward_command) (tui_scroll_backward_command, tui_scroll_left_command) (tui_scroll_right_command, parse_scrolling_args, tui_set_focus) (tui_set_win_height): Constify. * tui/tui-layout.c (tui_layout_command): Constify. * procfs.c (proc_trace_syscalls, proc_trace_sysentry_cmd) (proc_trace_sysexit_cmd, proc_untrace_sysentry_cmd) (proc_untrace_sysexit_cmd): Constify. * remote.c (threadlist_test_cmd, threadinfo_test_cmd) (threadset_test_cmd, threadlist_update_test_cmd) (threadalive_test): Constify. * objc-lang.c (print_object_command): Constify. * command.h (add_com): Constify. * cli/cli-dump.c (restore_command): Constify. * cli/cli-cmds.c (pwd_command, echo_command, quit_command) (help_command, complete_command, shell_command, edit_command) (list_command, disassemble_command, make_command) (apropos_command, alias_command): Constify. * cli/cli-script.c (document_command, define_command) (while_command, if_command, validate_comname): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * target.c (do_monitor_command, flash_erase_command): Constify. * regcache.c (reg_flush_command): Constify. * reverse.c (reverse_step, reverse_next, reverse_stepi) (reverse_nexti, reverse_continue, reverse_finish) (save_bookmark_command, goto_bookmark_command) (exec_reverse_once): Constify. * python/python.c (python_interactive_command, python_command): Constify. * typeprint.c (ptype_command, whatis_command, whatis_exp): Constify. * solib.c (sharedlibrary_command, no_shared_libraries): Constify. * gcore.c (gcore_command): Constify.
This commit is contained in:
@ -673,7 +673,7 @@ execute_control_command_untraced (struct command_line *cmd)
|
||||
loop condition is nonzero. */
|
||||
|
||||
static void
|
||||
while_command (char *arg, int from_tty)
|
||||
while_command (const char *arg, int from_tty)
|
||||
{
|
||||
control_level = 1;
|
||||
command_line_up command = get_command_line (while_control, arg);
|
||||
@ -690,7 +690,7 @@ while_command (char *arg, int from_tty)
|
||||
on the value of the if conditional. */
|
||||
|
||||
static void
|
||||
if_command (char *arg, int from_tty)
|
||||
if_command (const char *arg, int from_tty)
|
||||
{
|
||||
control_level = 1;
|
||||
command_line_up command = get_command_line (if_control, arg);
|
||||
@ -1366,10 +1366,10 @@ copy_command_lines (struct command_line *cmds)
|
||||
prefix. */
|
||||
|
||||
static struct cmd_list_element **
|
||||
validate_comname (char **comname)
|
||||
validate_comname (const char **comname)
|
||||
{
|
||||
struct cmd_list_element **list = &cmdlist;
|
||||
char *p, *last_word;
|
||||
const char *p, *last_word;
|
||||
|
||||
if (*comname == 0)
|
||||
error_no_arg (_("name of command to define"));
|
||||
@ -1386,19 +1386,16 @@ validate_comname (char **comname)
|
||||
if (last_word != *comname)
|
||||
{
|
||||
struct cmd_list_element *c;
|
||||
char saved_char;
|
||||
const char *tem = *comname;
|
||||
|
||||
/* Separate the prefix and the command. */
|
||||
saved_char = last_word[-1];
|
||||
last_word[-1] = '\0';
|
||||
std::string prefix (*comname, last_word - 1);
|
||||
const char *tem = prefix.c_str ();
|
||||
|
||||
c = lookup_cmd (&tem, cmdlist, "", 0, 1);
|
||||
if (c->prefixlist == NULL)
|
||||
error (_("\"%s\" is not a prefix command."), *comname);
|
||||
error (_("\"%s\" is not a prefix command."), prefix.c_str ());
|
||||
|
||||
list = c->prefixlist;
|
||||
last_word[-1] = saved_char;
|
||||
*comname = last_word;
|
||||
}
|
||||
|
||||
@ -1420,7 +1417,7 @@ user_defined_command (const char *ignore, int from_tty)
|
||||
}
|
||||
|
||||
static void
|
||||
define_command (char *comname, int from_tty)
|
||||
define_command (const char *comname, int from_tty)
|
||||
{
|
||||
#define MAX_TMPBUF 128
|
||||
enum cmd_hook_type
|
||||
@ -1430,8 +1427,7 @@ define_command (char *comname, int from_tty)
|
||||
CMD_POST_HOOK
|
||||
};
|
||||
struct cmd_list_element *c, *newc, *hookc = 0, **list;
|
||||
char *tem, *comfull;
|
||||
const char *tem_c;
|
||||
const char *tem, *comfull;
|
||||
char tmpbuf[MAX_TMPBUF];
|
||||
int hook_type = CMD_NO_HOOK;
|
||||
int hook_name_size = 0;
|
||||
@ -1445,8 +1441,8 @@ define_command (char *comname, int from_tty)
|
||||
list = validate_comname (&comname);
|
||||
|
||||
/* Look it up, and verify that we got an exact match. */
|
||||
tem_c = comname;
|
||||
c = lookup_cmd (&tem_c, *list, "", -1, 1);
|
||||
tem = comname;
|
||||
c = lookup_cmd (&tem, *list, "", -1, 1);
|
||||
if (c && strcmp (comname, c->name) != 0)
|
||||
c = 0;
|
||||
|
||||
@ -1480,8 +1476,8 @@ define_command (char *comname, int from_tty)
|
||||
if (hook_type != CMD_NO_HOOK)
|
||||
{
|
||||
/* Look up cmd it hooks, and verify that we got an exact match. */
|
||||
tem_c = comname + hook_name_size;
|
||||
hookc = lookup_cmd (&tem_c, *list, "", -1, 0);
|
||||
tem = comname + hook_name_size;
|
||||
hookc = lookup_cmd (&tem, *list, "", -1, 0);
|
||||
if (hookc && strcmp (comname + hook_name_size, hookc->name) != 0)
|
||||
hookc = 0;
|
||||
if (!hookc)
|
||||
@ -1531,11 +1527,11 @@ define_command (char *comname, int from_tty)
|
||||
}
|
||||
|
||||
static void
|
||||
document_command (char *comname, int from_tty)
|
||||
document_command (const char *comname, int from_tty)
|
||||
{
|
||||
struct cmd_list_element *c, **list;
|
||||
const char *tem;
|
||||
char *comfull;
|
||||
const char *comfull;
|
||||
char tmpbuf[128];
|
||||
|
||||
comfull = comname;
|
||||
|
Reference in New Issue
Block a user