(build_command_line): Require arguments only for if and while commands.
(get_command_line, execute_user_command, execute_control_command):
Fix wording of warning messages.
(print_command_lines): Print breakpoint commands.
(execute_control_command): Call commands_from_control_command to
handle the `commands' command inside a body of a flow-control command.
(read_next_line): Recognize the `commands' command and build a
command line structure for it.
(recurse_read_control_structure, read_command_lines): Handle
`commands' similarly to `if' and `while'.
* breakpoint.c (get_number_trailer): Document the special meaning
of NULL as the first argument PP.
(commands_from_control_command): New function.
* breakpoint.h (commands_from_control_command): Add prototype.
* defs.h (commands_control): New enumerated value for enum
command_control_type.
gdb/
* cli/cli-script.c (struct user_args): Add command field.
(arg_cleanup): Free command string.
(setup_user_args): Copy the command line before relying on it.
gdb/testsuite/
* gdb.base/commands.exp (recursive_source_test): New test.
* remote.c (remote_open_1): Move "ex"'s declaration to where it is
used.
(remote_get_thread_local_address): Use throw_error, include a
printed string.
* linux-thread-db.c (thread_db_get_thread_local_address): Ditto.
* dwarf2loc.c (dwarf_expr_tls_address): Ditto.
* cli/cli-script.c (script_from_file): Mark up throw_error message.
* linespec.c (symtab_from_filename, decode_variable): Ditto.
* top.h (source_error, source_pre_error): Delete declaration.
* cli/cli-script.c (source_error_allocated, source_error): Delete.
(script_from_file, source_cleanup_lines): Do not manipulate
source_error_allocated, error_pre_print and source_error.
(struct source_cleanup_lines_args): Delete fields old_pre_error,
and old_error_pre_print.
* top.c (source_error_allocated, source_error)
(source_pre_error): Delete.
(command_line_input): Do not set error_pre_print.
* event-top.c (command_line_handler): Do not set error_pre_print.
* cli/cli-script.c: Include "exceptions.h".
(struct wrapped_read_command_file_args): Define.
(wrapped_read_command_file): New function.
(script_from_file): Replace direct call to read_command_file by
one wrapped by an exception handler.
* exceptions.c (throw_it): Free the old message after creating the
new.
* Makefile.in: Update dependencies.
Index: testsuite/ChangeLog
2005-01-16 Andrew Cagney <cagney@gnu.org>
* gdb.base/source.exp: Delete KFAIL gdb/1846, simplify.
PR cli/1566. Problem found, and fix suggested by David Allan.
* cli/cli-script.c (execute_control_command): Unconditionally
install a cleanup. Default "ret" to "invalid_control". Use
"break" instead of "return" to escape from the switch.
clear_proceed_status doesn't free the command tree we're
evaluating out from under us, zero the bpstat's pointer to it, and
take care of freeing it ourselves.
* cli/cli-script.c (make_cleanup_free_command_lines): Make this
function externally visible.
* cli/cli-script.h (make_cleanup_free_command_lines): New
declaration.
* cli/cli-script.c (copy_command_lines): New function.
* defs.h (copy_command_lines): Export.
* testsuite/gdb.base/commands.exp: New tests for commands
attached to a temporary breakpoint, and for commands that
delete the breakpoint they are attached to.
2002-08-26 Michael Snyder <msnyder@redhat.com>
* breakpoint.c (bpstat_stop_status): Instead of copying the
pointer to the breakpoint commands struct, make a new copy
of the struct and point to that.
(bpstat_clear): Free the commands struct.
(bpstat_clear_actions): Free the commands struct.
(bpstat_do_actions): Free the command actions. Also execute
the local cleanups, instead of deleting them.
(delete_breakpoint): Leave the commands field of the bpstat
chain alone -- it will be freed later.
* cli/cli-cmds.c (init_cli_cmds): Add new user settable value:
max_user_call_depth.
(init_cmd_lists): Initialize the new value;
* cli/cli-script.c (execute_user_command): Limit the call depth of
user defined commands. This avoids a core-dump when user commands
are infinitly recursive.
(execute_cmd_pre_hook): Declare.
* cli/cli-script.c (clear_hook_in_cleanup): New function.
(execute_cmd_post_hook, execute_cmd_pre_hook): New
functions. Execute pre/post hook while ensuring that afterwords
hook_in is cleared.
* top.c (execute_command): Use execute_cmd_post_hook, and
execute_cmd_pre_hook to execute pre/post commands.
* infrun.c (normal_stop): Pass stop_command and not pre_hook to
hook_stop_stub.
(hook_stop_stub): Call execute_cmd_pre_hook.
2001-12-13 Jackie Smith Cashion <jsmith@redhat.com>
* cli/cli-script.c (print_command_lines): Remove extra
"if", "else", "while", and "end" from show user output.
testsuite/ChangeLog
2001-12-13 Jackie Smith Cashion <jsmith@redhat.com>
* gdb.base/commands.exp (user_defined_command_test): Make "show user"
test expect string more specific.
* cli/cli-decode.c: New file. Handle lists of commands, their decoding
and documentation.
(add_cmd, deprecate_cmd, add_abbrev_cmd, add_alias_cmd, add_prefix_cmd,
add_abbrev_prefix_cmd, not_just_help_class_command, empty_sfunc,
add_set_cmd, add_set_enum_cmd, add_set_auto_boolean_cmd,
add_show_from_set, delete_cmd, apropos_cmd, help_cmd, help_list,
help_all, print_doc_line, help_cmd_list, find_cmd, lookup_cmd_1,
undef_cmd_error, lookup_cmd, deprecated_cmd_warning,
lookup_cmd_composition, complete_on_cmdlist, complete_on_enum):
Moved here from command.c.
(add_info, add_info_alias, add_com, add_com_alias): Moved here from
top.c.
* cli/cli-decode.h: Definitions/declarations for the above.
* cli/cli-cmds.c: New file. GDB CLI commands.
(error_no_arg, info_command, show_command, help_command, show_version,
quit_command, pwd_command, cd_command, echo_command, shell_escape,
make_command, show_user, set_debug, show_debug, init_cmd_lists):
Moved here from top.c.
(apropos_command): Moved here from command.c.
(complete_command, source_command): Moved here (part) from top.c.
(is_complete_command): New function. Checks if a command is the
"complete" command.
(init_cli_cmds): New function. Add commands to the CLI (from code
previously in top.c.
* cli/cli-cmds.h: Definitions/declarations for the above.
* cli/cli-script.c: New file. GDB CLI command scripting.
(build_command_line, get_command_line, print_command_lines,
print_command_line, execute_user_command, execute_control_command,
while_command, if_command, arg_cleanup, setup_user_args, locate_arg,
insert_args, realloc_body_list, read_next_line,
recurse_read_control_structure, read_command_lines, free_command_lines,
do_free_command_lines_cleanup, make_cleanup_free_command_lines,
validate_comname, user_defined_command, define_command,
document_command, source_cleanup_lines, do_fclose_cleanup,
show_user_1): Moved here from top.c.
(script_from_file): New function. Implements execution of a script
contained in a file (part of code for the source_command() that used
to exist in top.c).
* cli/cli-script.h: Definitions/declarations for the above.
* cli/cli-setshow.c: New file. Handle set and show GDB CLI commands.
(parse_auto_binary_operation, parse_binary_operation,
do_setshow_command, cmd_show_list): Moved here from command.c.
* cli/cli-setshow.h: Definitions/declarations for the above.
* top.c: Remove all CLI code, except the command loop.
(gdb_init): Call init_cli_cmds().
* command.c: Remove obsolete file.
* command.h: Mark as DEPRECATED.
* gdbcmd.h: Ditto.
* call-cmds.h: Ditto.
* Makefile.in (SFILES): Remove command.c.
(COMMON_OBS): Remove command.o.
(command.o): Remove obsolete target.
(cli_decode_h, cli_cmds_h, cli_script_h, cli_setshow_h): New macros.
Refer to CLI header files.
(cli-decode.o, cli-cmds.o, cli-setshow.o, cli-script.o): New targets.
(SUBDIR_CLI_OBS, SUBDIR_CLI_SRCS, SUBDIR_CLI_DEPS, SUBDIR_CLI_INITS,
SUBDIR_CLI_LDFLAGS, SUBDIR_CLI_CFLAGS, SUBDIR_CLI_ALL, SUBDIR_CLI_CLEAN,
SUBDIR_CLI_INSTALL, SUBDIR_CLI_UNINSTALL): New macros for new cli
subdirectory.
* configure.in (enable_gdbcli): New option. Include the CLI in the
executable (cannot be disabled yet).
(CONFIG_OBS, CONFIG_DEPS, CONFIG_SRCS, CONFIG_INITS, ENABLE_CFLAGS,
CONFIG_ALL, CONFIG_CLEAN, CONFIG_INSTALL, CONFIG_UNINSTALL): Add
the corresponding SUBDIR_CLI_* macros if CLI requested.
* configure: Regenerate.