binutils-gdb/gdb/command.h

545 lines
19 KiB
C
Raw Permalink Normal View History

/* Header file for command creation.
Copyright (C) 1986-2020 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
1999-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#if !defined (COMMAND_H)
#define COMMAND_H 1
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/gdb_vecs.h"
#include "gdbsupport/scoped_restore.h"
* ada-lang.c (ada_make_symbol_completion_list): Return a VEC. * breakpoint.c (catch_syscall_completer): Return a VEC. * cli/cli-cmds.c (complete_command): Update. * cli/cli-decode.c (complete_on_cmdlist): Return a VEC. (complete_on_enum): Likewise. * command.h: Include gdb_vecs.h. (completer_ftype): Change return type. (complete_on_cmdlist, complete_on_enum): Likewise. * completer.c (noop_completer, filename_completer) (location_completer): Return a VEC. (add_struct_fields): Remove 'nextp' argument. Change 'output' to a VEC. (expression_completer, complete_line_internal, complete_line) (command_completer): Return a VEC. (gdb_completion_word_break_characters, line_completion_function): Update. * completer.h: Include gdb_vecs.h. (complete_line, noop_completer, filename_completer) (expression_completer, location_completer, command_completer): Update. * f-lang.c (f_word_break_characters): Return a VEC. * interps.c (interpreter_completer): Return a VEC. * language.h (struct language_defn) <la_make_symbol_completion_list>: Return a VEC. * python/py-cmd.c (cmdpy_completer): Return a VEC. * symtab.c (free_completion_list): Take a VEC. (return_val_size, return_val_index): Remove. (return_val): Now a VEC. (completion_list_add_name): Update. (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_list_fn, make_file_symbol_completion_list): Return a VEC. (add_filename_to_list): Update. (struct add_partial_filename_data) <list_used, list_alloced>: Remove. <list>: Now a VEC. (maybe_add_partial_symtab_filename): Update. (make_source_files_completion_list): Return a VEC. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_list_fn, make_file_symbol_completion_list) (make_source_files_completion_list): Update.
2012-06-13 17:47:16 +02:00
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
struct completion_tracker;
/* This file defines the public interface for any code wanting to
create commands. */
/* Command classes are top-level categories into which commands are
broken down for "help" purposes.
The class_alias is used for the user-defined aliases, defined
using the "alias" command.
Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command)
are not using the class_alias.
Different pre-defined aliases of the same command do not necessarily
have the same classes. For example, class_stack is used for the
"backtrace" and its "bt" alias", while "info stack" (also an alias
of "backtrace" uses class_info. */
1999-09-28 23:55:21 +02:00
enum command_class
{
/* Classes of commands followed by a comment giving the name
to use in "help <classname>".
Note that help accepts unambiguous abbreviated class names. */
/* Special classes to help_list */
class_deprecated = -3,
all_classes = -2, /* help without <classname> */
all_commands = -1, /* all */
1999-09-28 23:55:21 +02:00
/* Classes of commands */
no_class = -1,
class_run = 0, /* running */
class_vars, /* data */
class_stack, /* stack */
class_files, /* files */
class_support, /* support */
class_info, /* status */
class_breakpoint, /* breakpoints */
class_trace, /* tracepoints */
class_alias, /* aliases */
class_bookmark,
class_obscure, /* obscure */
class_maintenance, /* internals */
class_tui, /* text-user-interface */
class_user, /* user-defined */
/* Used for "show" commands that have no corresponding "set" command. */
no_set_class
1999-09-28 23:55:21 +02:00
};
/* Types of "set" or "show" command. */
1999-07-07 22:19:36 +02:00
typedef enum var_types
{
Change boolean options to bool instead of int This is for add_setshow_boolean_cmd as well as the gdb::option interface. gdb/ChangeLog: 2019-09-17 Christian Biesinger <cbiesinger@google.com> * ada-lang.c (ada_ignore_descriptive_types_p): Change to bool. (print_signatures): Likewise. (trust_pad_over_xvs): Likewise. * arch/aarch64-insn.c (aarch64_debug): Likewise. * arch/aarch64-insn.h (aarch64_debug): Likewise. * arm-linux-nat.c (arm_apcs_32): Likewise. * arm-linux-tdep.c (arm_apcs_32): Likewise. * arm-nbsd-nat.c (arm_apcs_32): Likewise. * arm-tdep.c (arm_debug): Likewise. (arm_apcs_32): Likewise. * auto-load.c (debug_auto_load): Likewise. (auto_load_gdb_scripts): Likewise. (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * auto-load.h (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * breakpoint.c (disconnected_dprintf): Likewise. (breakpoint_proceeded): Likewise. (automatic_hardware_breakpoints): Likewise. (always_inserted_mode): Likewise. (target_exact_watchpoints): Likewise. (_initialize_breakpoint): Update. * breakpoint.h (target_exact_watchpoints): Change to bool. * btrace.c (maint_btrace_pt_skip_pad): Likewise. * cli/cli-cmds.c (trace_commands): Likewise. * cli/cli-cmds.h (trace_commands): Likewise. * cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument to bool*. * cli/cli-logging.c (logging_overwrite): Change to bool. (logging_redirect): Likewise. (debug_redirect): Likewise. * cli/cli-option.h (option_def) <boolean>: Change return type to bool*. (struct boolean_option_def) <get_var_address_cb_>: Change return type to bool. <boolean_option_def>: Update. (struct flag_option_def): Change default type of Context to bool from int. <flag_option_def>: Change return type of var_address_cb_ to bool*. * cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*. (get_setshow_command_value_string): Likewise. * cli/cli-style.c (cli_styling): Change to bool. (source_styling): Likewise. * cli/cli-style.h (source_styling): Likewise. (cli_styling): Likewise. * cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change to bool. * command.h (var_types): Update comment. (add_setshow_boolean_cmd): Change int* var argument to bool*. * compile/compile-cplus-types.c (debug_compile_cplus_types): Change to bool. (debug_compile_cplus_scopes): Likewise. * compile/compile-internal.h (compile_debug): Likewise. * compile/compile.c (compile_debug): Likewise. (struct compile_options) <raw>: Likewise. * cp-support.c (catch_demangler_crashes): Likewise. * cris-tdep.c (usr_cmd_cris_version_valid): Likewise. (usr_cmd_cris_dwarf2_cfi): Likewise. * csky-tdep.c (csky_debug): Likewise. * darwin-nat.c (enable_mach_exceptions): Likewise. * dcache.c (dcache_enabled_p): Likewise. * defs.h (info_verbose): Likewise. * demangle.c (demangle): Likewise. (asm_demangle): Likewise. * dwarf-index-cache.c (debug_index_cache): Likewise. * dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2read.c (check_physname): Likewise. (use_deprecated_index_sections): Likewise. (dwarf_always_disassemble): Likewise. * eval.c (overload_resolution): Likewise. * event-top.c (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * event-top.h (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * exec.c (write_files): Likewise. * fbsd-nat.c (debug_fbsd_lwp): Likewise (debug_fbsd_nat): Likewise. * frame.h (struct frame_print_options) <print_raw_frame_arguments>: Likewise. (struct set_backtrace_options) <backtrace_past_main>: Likewise. <backtrace_past_entry> Likewise. * gdb-demangle.h (demangle): Likewise. (asm_demangle): Likewise. * gdb_bfd.c (bfd_sharing): Likewise. * gdbcore.h (write_files): Likewise. * gdbsupport/common-debug.c (show_debug_regs): Likewise. * gdbsupport/common-debug.h (show_debug_regs): Likewise. * gdbthread.h (print_thread_events): Likewise. * gdbtypes.c (opaque_type_resolution): Likewise. (strict_type_checking): Likewise. * gnu-nat.c (gnu_debug_flag): Likewise. * guile/scm-auto-load.c (auto_load_guile_scripts): Likewise. * guile/scm-param.c (pascm_variable): Add boolval. (add_setshow_generic): Update. (pascm_param_value): Update. (pascm_set_param_value_x): Update. * hppa-tdep.c (hppa_debug): Change to bool.. * infcall.c (may_call_functions_p): Likewise. (coerce_float_to_double_p): Likewise. (unwind_on_signal_p): Likewise. (unwind_on_terminating_exception_p): Likewise. * infcmd.c (startup_with_shell): Likewise. * inferior.c (print_inferior_events): Likewise. * inferior.h (startup_with_shell): Likewise. (print_inferior_events): Likewise. * infrun.c (step_stop_if_no_debug): Likewise. (detach_fork): Likewise. (debug_displaced): Likewise. (disable_randomization): Likewise. (non_stop): Likewise. (non_stop_1): Likewise. (observer_mode): Likewise. (observer_mode_1): Likewise. (set_observer_mode): Update. (sched_multi): Change to bool. * infrun.h (debug_displaced): Likewise. (sched_multi): Likewise. (step_stop_if_no_debug): Likewise. (non_stop): Likewise. (disable_randomization): Likewise. * linux-tdep.c (use_coredump_filter): Likewise. (dump_excluded_mappings): Likewise. * linux-thread-db.c (auto_load_thread_db): Likewise. (check_thread_db_on_load): Likewise. * main.c (captured_main_1): Update. * maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt, xx2_opt, boolean_opt>: Change to bool. * maint-test-settings.c (maintenance_test_settings_boolean): Likewise. * maint.c (maintenance_profile_p): Likewise. (per_command_time): Likewise. (per_command_space): Likewise. (per_command_symtab): Likewise. * memattr.c (inaccessible_by_default): Likewise. * mi/mi-main.c (mi_async): Likewise. (mi_async_1): Likewise. * mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise. * nat/fork-inferior.h (startup_with_shell): Likewise. * nat/linux-namespaces.c (debug_linux_namespaces): Likewise. * nat/linux-namespaces.h (debug_linux_namespaces): Likewise. * nios2-tdep.c (nios2_debug): Likewise. * or1k-tdep.c (or1k_debug): Likewise. * parse.c (parser_debug): Likewise. * parser-defs.h (parser_debug): Likewise. * printcmd.c (print_symbol_filename): Likewise. * proc-api.c (procfs_trace): Likewise. * python/py-auto-load.c (auto_load_python_scripts): Likewise. * python/py-param.c (union parmpy_variable): Add "bool boolval" field. (set_parameter_value): Update. (add_setshow_generic): Update. * python/py-value.c (copy_py_bool_obj): Change argument from int* to bool*. * python/python.c (gdbpy_parameter_value): Cast to bool* instead of int*. * ravenscar-thread.c (ravenscar_task_support): Change to bool. * record-btrace.c (record_btrace_target::store_registers): Update. * record-full.c (record_full_memory_query): Change to bool. (record_full_stop_at_limit): Likewise. * record-full.h (record_full_memory_query): Likewise. * remote-notif.c (notif_debug): Likewise. * remote-notif.h (notif_debug): Likewise. * remote.c (use_range_stepping): Likewise. (interrupt_on_connect): Likewise. (remote_break): Likewise. * ser-tcp.c (tcp_auto_retry): Likewise. * ser-unix.c (serial_hwflow): Likewise. * skip.c (debug_skip): Likewise. * solib-aix.c (solib_aix_debug): Likewise. * spu-tdep.c (spu_stop_on_load_p): Likewise. (spu_auto_flush_cache_p): Likewise. * stack.c (struct backtrace_cmd_options) <full, no_filters, hide>: Likewise. (struct info_print_options) <quiet>: Likewise. * symfile-debug.c (debug_symfile): Likewise. * symfile.c (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symfile.h (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symtab.c (basenames_may_differ): Likewise. (struct filename_partial_match_opts) <dirname, basename>: Likewise. (struct info_print_options) <quiet, exclude_minsyms>: Likewise. (struct info_types_options) <quiet>: Likewise. * symtab.h (demangle): Likewise. (basenames_may_differ): Likewise. * target-dcache.c (stack_cache_enabled_1): Likewise. (code_cache_enabled_1): Likewise. * target.c (trust_readonly): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. (auto_connect_native_target): Likewise. (target_stop_and_wait): Update. (target_async_permitted): Change to bool. (target_async_permitted_1): Likewise. (may_write_registers_1): Likewise. (may_write_memory_1): Likewise. (may_insert_breakpoints_1): Likewise. (may_insert_tracepoints_1): Likewise. (may_insert_fast_tracepoints_1): Likewise. (may_stop_1): Likewise. * target.h (target_async_permitted): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. * thread.c (struct info_threads_opts) <show_global_ids>: Likewise. (make_thread_apply_all_options_def_group): Change argument from int* to bool*. (thread_apply_all_command): Update. (print_thread_events): Change to bool. * top.c (confirm): Likewise. (command_editing_p): Likewise. (history_expansion_p): Likewise. (write_history_p): Likewise. (info_verbose): Likewise. * top.h (confirm): Likewise. (history_expansion_p): Likewise. * tracepoint.c (disconnected_tracing): Likewise. (circular_trace_buffer): Likewise. * typeprint.c (print_methods): Likewise. (print_typedefs): Likewise. * utils.c (debug_timestamp): Likewise. (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * utils.h (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * valops.c (overload_resolution): Likewise. * valprint.h (struct value_print_options) <prettyformat_arrays, prettyformat_structs, vtblprint, unionprint, addressprint, objectprint, stop_print_at_null, print_array_indexes, deref_ref, static_field_print, pascal_static_field_print, raw, summary, symbol_print, finish_print>: Likewise. * windows-nat.c (new_console): Likewise. (cygwin_exceptions): Likewise. (new_group): Likewise. (debug_exec): Likewise. (debug_events): Likewise. (debug_memory): Likewise. (debug_exceptions): Likewise. (useshell): Likewise. * windows-tdep.c (maint_display_all_tib): Likewise. * xml-support.c (debug_xml): Likewise.
2019-09-14 21:36:58 +02:00
/* "on" or "off". *VAR is a bool which is true for on,
false for off. */
1999-07-07 22:19:36 +02:00
var_boolean,
/* "on" / "true" / "enable" or "off" / "false" / "disable" or
"auto. *VAR is an ``enum auto_boolean''. NOTE: In general a
custom show command will need to be implemented - one that for
"auto" prints both the "auto" and the current auto-selected
value. */
var_auto_boolean,
/* Unsigned Integer. *VAR is an unsigned int. The user can type
0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */
1999-07-07 22:19:36 +02:00
var_uinteger,
/* Like var_uinteger but signed. *VAR is an int. The user can
type 0 to mean "unlimited", which is stored in *VAR as
INT_MAX. The only remaining use of it is the Python API.
Don't use it elsewhere. */
1999-07-07 22:19:36 +02:00
var_integer,
/* String which the user enters with escapes (e.g. the user types
\n and it is a real newline in the stored string).
1999-07-07 22:19:36 +02:00
*VAR is a malloc'd string, or NULL if the string is empty. */
var_string,
/* String which stores what the user types verbatim.
*VAR is a malloc'd string, or NULL if the string is empty. */
var_string_noescape,
/* String which stores a filename. (*VAR) is a malloc'd string,
or "" if the string was empty. */
var_optional_filename,
/* String which stores a filename. (*VAR) is a malloc'd
string. */
1999-07-07 22:19:36 +02:00
var_filename,
/* ZeroableInteger. *VAR is an int. Like var_integer except
1999-07-07 22:19:36 +02:00
that zero really means zero. */
var_zinteger,
/* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
means zero. */
var_zuinteger,
/* ZeroableUnsignedInteger with unlimited value. *VAR is an int,
but its range is [0, INT_MAX]. -1 stands for unlimited and
other negative numbers are not allowed. */
var_zuinteger_unlimited,
/* Enumerated type. Can only have one of the specified values.
*VAR is a char pointer to the name of the element that we
find. */
1999-07-07 22:19:36 +02:00
var_enum
}
var_types;
/* This structure records one command'd definition. */
struct cmd_list_element;
typedef void cmd_const_cfunc_ftype (const char *args, int from_tty);
Emit inferior, thread and frame selection events to all UIs With this patch, when an inferior, thread or frame is explicitly selected by the user, notifications will appear on all CLI and MI UIs. When a GDB console is integrated in a front-end, this allows the front-end to follow a selection made by the user ont he CLI, and it informs the user about selection changes made behind the scenes by the front-end. This patch addresses PR gdb/20487. In order to communicate frame changes to the front-end, this patch adds a new field to the =thread-selected event for the selected frame. The idea is that since inferior/thread/frame can be seen as a composition, it makes sense to send them together in the same event. The vision would be to eventually send the inferior information as well, if we find that it's needed, although the "=thread-selected" event would be ill-named for that job. Front-ends need to handle this new field if they want to follow the frame selection changes that originate from the console. The format of the frame attribute is the same as what is found in the *stopped events. Here's a detailed example for each command and the events they generate: thread ------ 1. CLI command: thread 1.3 MI event: =thread-selected,id="3",frame={...} 2. MI command: -thread-select 3 CLI event: [Switching to thread 1.3 ...] 3. MI command (CLI-in-MI): thread 1.3 MI event/reply: &"thread 1.3\n" ~"#0 child_sub_function () ... =thread-selected,id="3",frame={level="0",...} ^done frame ----- 1. CLI command: frame 1 MI event: =thread-selected,id="3",frame={level="1",...} 2. MI command: -stack-select-frame 1 CLI event: #1 0x00000000004007f0 in child_function... 3. MI command (CLI-in-MI): frame 1 MI event/reply: &"frame 1\n" ~"#1 0x00000000004007f9 in ..." =thread-selected,id="3",frame={level="1"...} ^done inferior -------- Inferior selection events only go from the console to MI, since there's no way to select the inferior in pure MI. 1. CLI command: inferior 2 MI event: =thread-selected,id="3" Note that if the user selects an inferior that is not started or exited, the MI doesn't receive a notification. Since there is no threads to select, the =thread-selected event does not apply... 2. MI command (CLI-in-MI): inferior 2 MI event/reply: &"inferior 2\n" ~"[Switching to inferior 2 ...]" =thread-selected,id="4",frame={level="0"...} ^done Internal implementation detail: this patch makes it possible to suppress notifications caused by a CLI command, like what is done in mi-interp.c. This means that it's now possible to use the add_com_suppress_notification function to register a command with some event suppressed. It is used to implement the select-frame command in this patch. The function command_notifies_uscc_observer was added to extract the rather complicated logical expression from the if statement. It is also now clearer what that logic does: if the command used by the user already notifies the user_selected_context_changed observer, there is not need to notify it again. It therefore protects again emitting the event twice. No regressions, tested on ubuntu 14.04 x86 with target boards unix and native-extended-gdbserver. gdb/ChangeLog: YYYY-MM-DD Antoine Tremblay <antoine.tremblay@ericsson.com> YYYY-MM-DD Simon Marchi <simon.marchi@ericsson.com> PR gdb/20487 * NEWS: Mention new frame field of =thread-selected event. * cli/cli-decode.c (add_cmd): Initialize c->suppress_notification. (add_com_suppress_notification): New function definition. (cmd_func): Set and restore the suppress_notification flag. * cli/cli-deicode.h (struct cmd_list_element) <suppress_notification>: New field. * cli/cli-interp.c (cli_suppress_notification): New global variable. (cli_on_user_selected_context_changed): New function. (_initialize_cli_interp): Attach to user_selected_context_changed observer. * command.h (struct cli_suppress_notification): New structure. (cli_suppress_notification): New global variable declaration. (add_com_suppress_notification): New function declaration. * defs.h (enum user_selected_what_flag): New enum. (user_selected_what): New enum flag type. * frame.h (print_stack_frame_to_uiout): New function declaration. * gdbthread.h (print_selected_thread_frame): New function declaration. * inferior.c (print_selected_inferior): New function definition. (inferior_command): Remove printing of inferior/thread/frame switch notifications, notify user_selected_context_changed observer. * inferior.h (print_selected_inferior): New function declaration. * mi/mi-cmds.c (struct mi_cmd): Add user_selected_context suppression to stack-select-frame and thread-select commands. * mi/mi-interp.c (struct mi_suppress_notification) <user_selected_context>: Initialize. (mi_user_selected_context_changed): New function definition. (_initialize_mi_interp): Attach to user_selected_context_changed. * mi/mi-main.c (mi_cmd_thread_select): Print thread selection reply. (mi_execute_command): Handle notification suppression. Notify user_selected_context_changed observer on thread change instead of printing event directly. Don't send it if command already sends the notification. (command_notifies_uscc_observer): New function. (mi_cmd_execute): Don't handle notification suppression. * mi/mi-main.h (struct mi_suppress_notification) <user_selected_context>: New field. * stack.c (print_stack_frame_to_uiout): New function definition. (select_frame_command): Notify user_selected_context_changed observer. (frame_command): Call print_selected_thread_frame if there's no frame change or notify user_selected_context_changed observer if there is. (up_command): Notify user_selected_context_changed observer. (down_command): Likewise. (_initialize_stack): Suppress user_selected_context notification for command select-frame. * thread.c (thread_command): Notify user_selected_context_changed if the thread has changed, print thread info directly if it hasn't. (do_captured_thread_select): Do not print thread switch event. (print_selected_thread_frame): New function definition. * tui/tui-interp.c (tui_on_user_selected_context_changed): New function definition. (_initialize_tui_interp): Attach to user_selected_context_changed observer. gdb/doc/ChangeLog: PR gdb/20487 * gdb.texinfo (Context management): Update mention of frame change notifications. (gdb/mi Async Records): Document frame field in =thread-select event. * observer.texi (GDB Observers): New user_selected_context_changed observer. gdb/testsuite/ChangeLog: PR gdb/20487 * gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Adapt =thread-select-event check.
2016-10-03 22:52:44 +02:00
/* This structure specifies notifications to be suppressed by a cli
command interpreter. */
struct cli_suppress_notification
{
/* Inferior, thread, frame selected notification suppressed? */
int user_selected_context;
};
extern struct cli_suppress_notification cli_suppress_notification;
2002-02-23 22:30:23 +01:00
/* Forward-declarations of the entry-points of cli/cli-decode.c. */
/* API to the manipulation of command lists. */
/* Return TRUE if NAME is a valid user-defined command name.
This is a stricter subset of all gdb commands,
see find_command_name_length. */
extern bool valid_user_defined_cmd_name_p (const char *name);
/* Return TRUE if C is a valid command character. */
extern bool valid_cmd_char_p (int c);
/* Const-correct variant of the above. */
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
cmd_const_cfunc_ftype *fun,
const char *,
struct cmd_list_element **);
/* Like add_cmd, but no command function is specified. */
extern struct cmd_list_element *add_cmd (const char *, enum command_class,
const char *,
struct cmd_list_element **);
gdb: Change how frames are selected for 'frame' and 'info frame'. The 'frame' command, and thanks to code reuse the 'info frame' and 'select-frame' commands, currently have an overloaded mechanism for selecting a frame. These commands take one or two parameters, if it's one parameter then we first try to use the parameter as an integer to select a frame by level (or depth in the stack). If that fails then we treat the parameter as an address and try to select a stack frame by stack-address. If we still have not selected a stack frame, or we initially had two parameters, then GDB allows the user to view a stack frame that is not part of the current backtrace. Internally, a new frame is created with the given stack and pc addresses, and this is shown to the user. The result of this is that a typo by the user, entering the wrong stack frame level for example, can result in a brand new frame being viewed rather than an error. The purpose of this commit is to remove this overloading, while still offering the same functionality through some new sub-commands. By making the default behaviour of 'frame' (and friends) be to select a stack frame by level index, it is hoped that enough backwards-compatibility is maintained that users will not be overly inconvenienced. The 'frame', 'select-frame', and 'info frame' commands now all take a frame specification string as an argument, this string can be any of the following: (1) An integer. This is treated as a frame level. If a frame for that level does not exist then the user gets an error. (2) A string like 'level <LEVEL>', where <LEVEL> is a frame level as in option (1) above. (3) A string like 'address <STACK-ADDRESS>', where <STACK-ADDRESS> is a stack-frame address. If there is no frame for this address then the user gets an error. (4) A string like 'function <NAME>', where <NAME> is a function name, the inner most frame for function <NAME> is selected. If there is no frame for function <NAME> then the user gets an error. (5) A string like 'view <STACK-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS>. (6) A string like 'view <STACK-ADDRESS> <PC-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS> and the pc <PC-ADDRESS>. This change assumes that the most common use of the commands like 'frame' is to select a frame by frame level, it is for this reason that this is the behaviour that is kept for backwards compatibility. Any of the alternative behaviours, which are assumed to be less used, now require a change in user behaviour. The MI command '-stack-select-frame' has not been changed. This ensures that we maintain backwards compatibility for existing frontends. gdb/ChangeLog: (NEWS): Mention changes to frame related commands. * cli/cli-decode.c (add_cmd_suppress_notification): New function. (add_prefix_cmd_suppress_notification): New function. (add_com_suppress_notification): Call add_cmd_suppress_notification. * command.h (add_cmd_suppress_notification): Declare. (add_prefix_cmd_suppress_notification): Declare. * mi/mi-cmd-stack.c: Add 'safe-ctype.h' include. (parse_frame_specification): Moved from stack.c, with simplification to handle a single argument. (mi_cmd_stack_select_frame): Use parse_frame_specification, the switch to the selected frame. Add a header comment. * stack.c: Remove 'safe-ctype.h' include. (find_frame_for_function): Add declaration. (find_frame_for_address): New function. (parse_frame_specification): Moved into mi/mi-cmd-stack.c. (frame_selection_by_function_completer): New function. (info_frame_command): Rename to... (info_frame_command_core): ...this, and update parameter types. (select_frame_command): Rename to... (select_frame_command_core): ...this, and update parameter types. (frame_command): Rename to... (frame_command_core): ...this, and update parameter types. (class frame_command_helper): New class to wrap implementations of frame related sub-commands. (frame_apply_cmd_list): New static global. (frame_cmd_list): Make static. (select_frame_cmd_list): New global for sub-commands. (info_frame_cmd_list): New global for sub-commands. (_initialize_stack): Register sub-commands for 'frame', 'select-frame', and 'info frame'. Update 'frame apply' commands to use frame_apply_cmd_list. Move function local static frame_apply_list to file static frame_apply_cmd_list for consistency. * stack.h (select_frame_command): Delete declarationn. (select_frame_for_mi): Declare new function. gdb/doc/ChangeLog: * gdb.texinfo (Frames): Rewrite the description of 'frame number' to highlight that the number is also the frame's level. (Selection): Rewrite documentation for 'frame' and 'select-frame' commands. (Frame Info): Rewrite documentation for 'info frame' command. gdb/testsuite/ChangeLog: * gdb.base/frame-selection.exp: New file. * gdb.base/frame-selection.c: New file.
2015-09-10 14:06:16 +02:00
extern struct cmd_list_element *add_cmd_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun, const char *doc,
struct cmd_list_element **list,
int *suppress_notification);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
2000-05-28 03:12:42 +02:00
enum command_class, int,
struct cmd_list_element **);
extern struct cmd_list_element *add_alias_cmd (const char *,
cmd_list_element *,
enum command_class, int,
struct cmd_list_element **);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
Constify add_prefix_cmd This changes add_prefix_cmd to accept a const-taking function as an argument; then fixes up all the callers. In a couple of spots I had to add a non-const overload of a function, because the function is passed to two different command-adding "constructors". These overloads are temporary; once constification is complete they can be removed. This patch also fixes a typo I happened to notice while constifying. Note that this touches a couple of files (gnu-nat.c and go32-nat.c) that I can't build. So, while I made a best-effort there, I am not certain they will still compile. Tested by rebuilding. gdb/ChangeLog 2017-10-11 Tom Tromey <tom@tromey.com> * gdbthread.h (thread_command): Constify. * inferior.h (detach_command): Constify. * top.h (set_history, show_history): Constify. * arm-tdep.c (set_arm_command, show_arm_command): Constify. * serial.c (serial_set_cmd, serial_show_cmd): Constify. * bsd-kvm.c (bsd_kvm_cmd): Constify. * printcmd.c (set_command): Constify. (non_const_set_command): New function. * dcache.c (set_dcache_command, show_dcache_command): Constify. * breakpoint.c (enable_command, disable_command, delete_command) (catch_command, tcatch_command, set_breakpoint_cmd) (show_breakpoint_cmd): Constify. * macrocmd.c (macro_command): Constify. * infcmd.c (unset_command, kill_command, detach_command) (info_proc_cmd): Constify. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify. * auto-load.c (show_auto_load_cmd, set_auto_load_cmd) (info_auto_load_cmd): Constify. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Constify. * ada-lang.c (set_ada_command, show_ada_command) (maint_set_ada_cmd, maint_show_ada_cmd): Constify. * guile/guile.c (set_guile_command, show_guile_command) (info_guile_command): Constify. * tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd): Constify. * skip.c (skip_command): Constify. * compile/compile.c (_initialize_compile): Constify. * dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd): Constify. * remote.c (set_remote_cmd, show_remote_cmd, remote_command): Constify. * python/python.c (user_show_python, user_set_python): Constify. * mips-tdep.c (set_mips_command, show_mips_command) (set_mipsfpu_command): Constify. * record-btrace.c (cmd_record_btrace_start) (cmd_set_record_btrace, cmd_show_record_btrace) (cmd_set_record_btrace_bts, cmd_show_record_btrace_bts) (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command): Constify. * symfile.c (overlay_command): Constify. * spu-tdep.c (set_spu_command, show_spu_command): Constify. * cli/cli-logging.c (set_logging_command, show_logging_command): Constify. * cli/cli-dump.c (dump_command, append_command) (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * cli/cli-cmds.c (info_command, show_command, set_debug) (show_debug): Constify. (show_command): Add non-const overload. * top.c (set_history, show_history): Constify. * sh-tdep.c (set_sh_command, show_sh_command): Constify. * command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype. * target.c (target_command): Constify. * sparc64-tdep.c (info_adi_command): Constify. * record-full.c (cmd_record_full_start): Constify. (set_record_full_command): Constify. Fix typo. (show_record_full_command): Constify. * thread.c (thread_command, thread_apply_command): Constify. * memattr.c (dummy_cmd): Constify. * value.c (function_command): Constify. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify. * probe.c (info_probes_command): Constify. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify. * gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd) (show_thread_cmd, set_thread_default_cmd) (show_thread_default_cmd): Constify. (check_empty): Constify. * tracepoint.c (tfind_command): Constify. * cp-support.c (maint_cplus_command): Constify. * windows-tdep.c (info_w32_command): Constify. * record.c (cmd_record_start, set_record_command) (show_record_command, info_record_command, cmd_record_goto): Constify. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Constify. * utils.c (set_internal_problem_cmd, show_internal_problem_cmd): Constify. (add_internal_problem_command): Remove casts. * arc-tdep.c (maintenance_print_arc_command): Constify. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Constify. * maint.c (maintenance_command, maintenance_info_command) (maintenance_print_command, maintenance_set_cmd) (maintenance_show_cmd, set_per_command_cmd) (show_per_command_cmd, maintenance_check_command): Constify. * language.c (set_check, show_check): Constify. * typeprint.c (show_print_type, set_print_type): Constify. * go32-nat.c (go32_info_dos_command): Constify.
2017-09-26 06:28:30 +02:00
cmd_const_cfunc_ftype *fun,
const char *,
2000-05-28 03:12:42 +02:00
struct cmd_list_element **,
const char *, int,
2000-05-28 03:12:42 +02:00
struct cmd_list_element **);
Replace most calls to help_list and cmd_show_list Currently there are many prefix commands that do nothing but call either help_list or cmd_show_list. I happened to notice that one such call, for "set print type", used the wrong command list parameter, causing incorrect output. Rather than fix this bug in isolation, I decided to eliminate this possibility by adding two new ways to add prefix commands, which simply route the call to help_list or cmd_show_list, as appropriate. This makes it impossible for a mismatch to occur. In some cases, a bit of output was removed; however, I don't think this output in general was very useful. It seemed redundant with what's already printed by help_list. A representative example is this hunk, removed from ada-lang.c: - printf_unfiltered (_(\ -"\"set ada\" must be followed by the name of a setting.\n")); This simplified the CLI style set/show commands quite a bit, and allowed the deletion of a macro. This also cleans up some unusual code in windows-tdep.c. Tested on x86-64 Fedora 30. Note that I have no way to build the go32-nat.c change. gdb/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * auto-load.c (show_auto_load_cmd): Remove. (auto_load_show_cmdlist_get): Use add_show_prefix_cmd. * arc-tdep.c (_initialize_arc_tdep): Use add_show_prefix_cmd. (maintenance_print_arc_command): Remove. * tui/tui-win.c (tui_command): Remove. (tui_get_cmd_list): Use add_basic_prefix_cmd. * tui/tui-layout.c (tui_layout_command): Remove. (_initialize_tui_layout): Use add_basic_prefix_cmd. * python/python.c (user_set_python, user_show_python): Remove. (_initialize_python): Use add_basic_prefix_cmd, add_show_prefix_cmd. * guile/guile.c (set_guile_command, show_guile_command): Remove. (install_gdb_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_guile_command): Remove. * dwarf2/read.c (set_dwarf_cmd, show_dwarf_cmd): Remove. (_initialize_dwarf2_read): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-style.h (class cli_style_option) <add_setshow_commands>: Remove do_set and do_show parameters. * cli/cli-style.c (set_style, show_style): Remove. (_initialize_cli_style): Use add_basic_prefix_cmd, add_show_prefix_cmd. (cli_style_option::add_setshow_commands): Remove do_set and do_show parameters. (cli_style_option::add_setshow_commands): Use add_basic_prefix_cmd, add_show_prefix_cmd. (STYLE_ADD_SETSHOW_COMMANDS): Remove macro. (set_style_name): Remove. * cli/cli-dump.c (dump_command, append_command): Remove. (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Remove. (_initialize_cli_dump): Use add_basic_prefix_cmd. * windows-tdep.c (w32_prefix_command_valid): Remove global. (init_w32_command_list): Remove; move into ... (_initialize_windows_tdep): ... here. Use add_basic_prefix_cmd. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Remove. (_initialize_valprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * typeprint.c (set_print_type, show_print_type): Remove. (_initialize_typeprint): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record.c (set_record_command, show_record_command): Remove. (_initialize_record): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cli/cli-cmds.c (_initialize_cli_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (info_command, show_command, set_debug, show_debug): Remove. * top.h (set_history, show_history): Don't declare. * top.c (set_history, show_history): Remove. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Remove. (_initialize_target_descriptions): Use add_basic_prefix_cmd, add_show_prefix_cmd. * symtab.c (info_module_command): Remove. (_initialize_symtab): Use add_basic_prefix_cmd. * symfile.c (overlay_command): Remove. (_initialize_symfile): Use add_basic_prefix_cmd. * sparc64-tdep.c (info_adi_command): Remove. (_initialize_sparc64_adi_tdep): Use add_basic_prefix_cmd. * sh-tdep.c (show_sh_command, set_sh_command): Remove. (_initialize_sh_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * serial.c (serial_set_cmd, serial_show_cmd): Remove. (_initialize_serial): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Remove. (_initialize_ser_tcp): Use add_basic_prefix_cmd, add_show_prefix_cmd. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command) (_initialize_rs6000_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * riscv-tdep.c (show_riscv_command, set_riscv_command) (show_debug_riscv_command, set_debug_riscv_command): Remove. (_initialize_riscv_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * remote.c (remote_command, set_remote_cmd): Remove. (_initialize_remote): Use add_basic_prefix_cmd. * record-full.c (set_record_full_command) (show_record_full_command): Remove. (_initialize_record_full): Use add_basic_prefix_cmd, add_show_prefix_cmd. * record-btrace.c (cmd_set_record_btrace) (cmd_show_record_btrace, cmd_set_record_btrace_bts) (cmd_show_record_btrace_bts, cmd_set_record_btrace_pt) (cmd_show_record_btrace_pt): Remove. (_initialize_record_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Remove. (_initialize_ravenscar): Use add_basic_prefix_cmd, add_show_prefix_cmd. * mips-tdep.c (show_mips_command, set_mips_command) (_initialize_mips_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint.c (maintenance_command, maintenance_info_command) (maintenance_check_command, maintenance_print_command) (maintenance_set_cmd, maintenance_show_cmd): Remove. (_initialize_maint_cmds): Use add_basic_prefix_cmd, add_show_prefix_cmd. (show_per_command_cmd): Remove. * maint-test-settings.c (maintenance_set_test_settings_cmd): Remove. (maintenance_show_test_settings_cmd): Remove. (_initialize_maint_test_settings): Use add_basic_prefix_cmd, add_show_prefix_cmd. * maint-test-options.c (maintenance_test_options_command): Remove. (_initialize_maint_test_options): Use add_basic_prefix_cmd. * macrocmd.c (macro_command): Remove (_initialize_macrocmd): Use add_basic_prefix_cmd. * language.c (set_check, show_check): Remove. (_initialize_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * infcmd.c (unset_command): Remove. (_initialize_infcmd): Use add_basic_prefix_cmd. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Remove. (_initialize_i386_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * go32-nat.c (go32_info_dos_command): Remove. (_initialize_go32_nat): Use add_basic_prefix_cmd. * cli/cli-decode.c (do_prefix_cmd, add_basic_prefix_cmd) (do_show_prefix_cmd, add_show_prefix_cmd): New functions. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Remove. (_initialize_frame): Use add_basic_prefix_cmd, add_show_prefix_cmd. * dcache.c (set_dcache_command, show_dcache_command): Remove. (_initialize_dcache): Use add_basic_prefix_cmd, add_show_prefix_cmd. * cp-support.c (maint_cplus_command): Remove. (_initialize_cp_support): Use add_basic_prefix_cmd. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd, _initialize_btrace): Use add_basic_prefix_cmd, add_show_prefix_cmd. * breakpoint.c (save_command): Remove. (_initialize_breakpoint): Use add_basic_prefix_cmd. * arm-tdep.c (set_arm_command, show_arm_command): Remove. (_initialize_arm_tdep): Use add_basic_prefix_cmd, add_show_prefix_cmd. * ada-lang.c (maint_set_ada_cmd, maint_show_ada_cmd) (set_ada_command, show_ada_command): Remove. (_initialize_ada_language): Use add_basic_prefix_cmd, add_show_prefix_cmd. * command.h (add_basic_prefix_cmd, add_show_prefix_cmd): Declare. gdb/testsuite/ChangeLog 2020-04-17 Tom Tromey <tromey@adacore.com> * gdb.cp/maint.exp (test_help): Simplify multiple_help_body. Update tests. * gdb.btrace/cpu.exp: Update tests. * gdb.base/maint.exp: Update tests. * gdb.base/default.exp: Update tests. * gdb.base/completion.exp: Update tests.
2020-04-17 15:27:14 +02:00
/* Like add_prefix_cmd, but sets the callback to a function that
simply calls help_list. */
extern struct cmd_list_element *add_basic_prefix_cmd
(const char *, enum command_class, const char *, struct cmd_list_element **,
const char *, int, struct cmd_list_element **);
/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
callback to a function that simply calls cmd_show_list. */
extern struct cmd_list_element *add_show_prefix_cmd
(const char *, enum command_class, const char *, struct cmd_list_element **,
const char *, int, struct cmd_list_element **);
gdb: Change how frames are selected for 'frame' and 'info frame'. The 'frame' command, and thanks to code reuse the 'info frame' and 'select-frame' commands, currently have an overloaded mechanism for selecting a frame. These commands take one or two parameters, if it's one parameter then we first try to use the parameter as an integer to select a frame by level (or depth in the stack). If that fails then we treat the parameter as an address and try to select a stack frame by stack-address. If we still have not selected a stack frame, or we initially had two parameters, then GDB allows the user to view a stack frame that is not part of the current backtrace. Internally, a new frame is created with the given stack and pc addresses, and this is shown to the user. The result of this is that a typo by the user, entering the wrong stack frame level for example, can result in a brand new frame being viewed rather than an error. The purpose of this commit is to remove this overloading, while still offering the same functionality through some new sub-commands. By making the default behaviour of 'frame' (and friends) be to select a stack frame by level index, it is hoped that enough backwards-compatibility is maintained that users will not be overly inconvenienced. The 'frame', 'select-frame', and 'info frame' commands now all take a frame specification string as an argument, this string can be any of the following: (1) An integer. This is treated as a frame level. If a frame for that level does not exist then the user gets an error. (2) A string like 'level <LEVEL>', where <LEVEL> is a frame level as in option (1) above. (3) A string like 'address <STACK-ADDRESS>', where <STACK-ADDRESS> is a stack-frame address. If there is no frame for this address then the user gets an error. (4) A string like 'function <NAME>', where <NAME> is a function name, the inner most frame for function <NAME> is selected. If there is no frame for function <NAME> then the user gets an error. (5) A string like 'view <STACK-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS>. (6) A string like 'view <STACK-ADDRESS> <PC-ADDRESS>', this views a new frame with stack address <STACK-ADDRESS> and the pc <PC-ADDRESS>. This change assumes that the most common use of the commands like 'frame' is to select a frame by frame level, it is for this reason that this is the behaviour that is kept for backwards compatibility. Any of the alternative behaviours, which are assumed to be less used, now require a change in user behaviour. The MI command '-stack-select-frame' has not been changed. This ensures that we maintain backwards compatibility for existing frontends. gdb/ChangeLog: (NEWS): Mention changes to frame related commands. * cli/cli-decode.c (add_cmd_suppress_notification): New function. (add_prefix_cmd_suppress_notification): New function. (add_com_suppress_notification): Call add_cmd_suppress_notification. * command.h (add_cmd_suppress_notification): Declare. (add_prefix_cmd_suppress_notification): Declare. * mi/mi-cmd-stack.c: Add 'safe-ctype.h' include. (parse_frame_specification): Moved from stack.c, with simplification to handle a single argument. (mi_cmd_stack_select_frame): Use parse_frame_specification, the switch to the selected frame. Add a header comment. * stack.c: Remove 'safe-ctype.h' include. (find_frame_for_function): Add declaration. (find_frame_for_address): New function. (parse_frame_specification): Moved into mi/mi-cmd-stack.c. (frame_selection_by_function_completer): New function. (info_frame_command): Rename to... (info_frame_command_core): ...this, and update parameter types. (select_frame_command): Rename to... (select_frame_command_core): ...this, and update parameter types. (frame_command): Rename to... (frame_command_core): ...this, and update parameter types. (class frame_command_helper): New class to wrap implementations of frame related sub-commands. (frame_apply_cmd_list): New static global. (frame_cmd_list): Make static. (select_frame_cmd_list): New global for sub-commands. (info_frame_cmd_list): New global for sub-commands. (_initialize_stack): Register sub-commands for 'frame', 'select-frame', and 'info frame'. Update 'frame apply' commands to use frame_apply_cmd_list. Move function local static frame_apply_list to file static frame_apply_cmd_list for consistency. * stack.h (select_frame_command): Delete declarationn. (select_frame_for_mi): Declare new function. gdb/doc/ChangeLog: * gdb.texinfo (Frames): Rewrite the description of 'frame number' to highlight that the number is also the frame's level. (Selection): Rewrite documentation for 'frame' and 'select-frame' commands. (Frame Info): Rewrite documentation for 'info frame' command. gdb/testsuite/ChangeLog: * gdb.base/frame-selection.exp: New file. * gdb.base/frame-selection.c: New file.
2015-09-10 14:06:16 +02:00
extern struct cmd_list_element *add_prefix_cmd_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
const char *doc, struct cmd_list_element **prefixlist,
const char *prefixname, int allow_unknown,
struct cmd_list_element **list,
int *suppress_notification);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
2000-05-28 03:12:42 +02:00
enum command_class,
cmd_const_cfunc_ftype *fun,
const char *,
2000-05-28 03:12:42 +02:00
struct cmd_list_element
**, const char *, int,
2000-05-28 03:12:42 +02:00
struct cmd_list_element
**);
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
typedef void cmd_const_sfunc_ftype (const char *args, int from_tty,
struct cmd_list_element *c);
* cli/cli-decode.c (do_cfunc, set_cmd_cfunc): New functions. (do_sfunc, set_cmd_sfunc): New functions. * command.h (struct cmd_list_element): Add field func. * cli/cli-decode.h (struct cmd_list_element): Ditto. * command.h (set_cmd_sfunc, set_cmd_cfunc): Declare. * cli/cli-decode.h: Ditto. * cli/cli-decode.c (help_cmd): Test for func not cfunc/sfunc. (help_all, help_cmd_list): Ditto. (find_cmd, complete_on_cmdlist): Ditto. * top.c (execute_command): Ditto. * cli/cli-setshow.c (do_setshow_command): Call func instead of function.sfunc. * infcmd.c (notice_args_read): Fix function signature. * cli/cli-cmds.c (init_cli_cmds): Use set_cmd_sfunc. * cli/cli-decode.c (add_set_cmd): Ditto. * utils.c (initialize_utils): Ditto. * maint.c (_initialize_maint_cmds): Ditto. * infrun.c (_initialize_infrun): Ditto. * demangle.c (_initialize_demangler): Ditto. * remote.c (add_packet_config_cmd): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * cris-tdep.c (_initialize_cris_tdep): Ditto. * proc-api.c (_initialize_proc_api): Ditto. * kod.c (_initialize_kod): Ditto. * valprint.c (_initialize_valprint): Ditto. * top.c (init_main): Ditto. * infcmd.c (_initialize_infcmd): Ditto. * corefile.c (_initialize_core): Ditto. * arm-tdep.c (_initialize_arm_tdep): Ditto. * arch-utils.c (initialize_current_architecture): Ditto. (_initialize_gdbarch_utils): Ditto. * alpha-tdep.c (_initialize_alpha_tdep): Ditto. * cli/cli-decode.c (add_cmd): Use set_cmd_cfunc. * wince.c (_initialize_inftarg): Ditto. * symfile.c (_initialize_symfile): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * language.c (_initialize_language): Ditto. * arc-tdep.c (_initialize_arc_tdep): Ditto.
2002-02-05 05:37:23 +01:00
extern void set_cmd_sfunc (struct cmd_list_element *cmd,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *sfunc);
* cli/cli-decode.c (do_cfunc, set_cmd_cfunc): New functions. (do_sfunc, set_cmd_sfunc): New functions. * command.h (struct cmd_list_element): Add field func. * cli/cli-decode.h (struct cmd_list_element): Ditto. * command.h (set_cmd_sfunc, set_cmd_cfunc): Declare. * cli/cli-decode.h: Ditto. * cli/cli-decode.c (help_cmd): Test for func not cfunc/sfunc. (help_all, help_cmd_list): Ditto. (find_cmd, complete_on_cmdlist): Ditto. * top.c (execute_command): Ditto. * cli/cli-setshow.c (do_setshow_command): Call func instead of function.sfunc. * infcmd.c (notice_args_read): Fix function signature. * cli/cli-cmds.c (init_cli_cmds): Use set_cmd_sfunc. * cli/cli-decode.c (add_set_cmd): Ditto. * utils.c (initialize_utils): Ditto. * maint.c (_initialize_maint_cmds): Ditto. * infrun.c (_initialize_infrun): Ditto. * demangle.c (_initialize_demangler): Ditto. * remote.c (add_packet_config_cmd): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * cris-tdep.c (_initialize_cris_tdep): Ditto. * proc-api.c (_initialize_proc_api): Ditto. * kod.c (_initialize_kod): Ditto. * valprint.c (_initialize_valprint): Ditto. * top.c (init_main): Ditto. * infcmd.c (_initialize_infcmd): Ditto. * corefile.c (_initialize_core): Ditto. * arm-tdep.c (_initialize_arm_tdep): Ditto. * arch-utils.c (initialize_current_architecture): Ditto. (_initialize_gdbarch_utils): Ditto. * alpha-tdep.c (_initialize_alpha_tdep): Ditto. * cli/cli-decode.c (add_cmd): Use set_cmd_cfunc. * wince.c (_initialize_inftarg): Ditto. * symfile.c (_initialize_symfile): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * language.c (_initialize_language): Ditto. * arc-tdep.c (_initialize_arc_tdep): Ditto.
2002-02-05 05:37:23 +01:00
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
/* A completion routine. Add possible completions to tracker.
Clean up "completer_handle_brkchars" callback handling This patch cleans up "completer_handle_brkchars" callback handling: - Renames the function typedef to better match its intent: completer_ftype_void -> completer_handle_brkchars_ftype - Factors out common code in complete_line_internal handling the "handle_brkchars" callback to a separate function. - Centralizes all the "completer method" to "handle_brkchars method" mapping in a single function. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to renames. * cli/cli-decode.h (struct cmd_list_element) <completer>: Move comments to completer_ftype's declaration. <completer_handle_brkchars>: Change type to completer_handle_brkchars_ftype. * command.h (completer_ftype): Add describing comment and give names to parameters. (completer_ftype_void): Rename to ... (completer_handle_brkchars_ftype) ... this. Add describing comment. (set_cmd_completer_handle_brkchars): Adjust. * completer.c (filename_completer_handle_brkchars): New function. (complete_line_internal_normal_command): New function, factored out from ... (complete_line_internal): ... here. (command_completer_handle_brkchars) (default_completer_handle_brkchars) (completer_handle_brkchars_func_for_completer): New functions. * completer.h (set_gdb_completion_word_break_characters): Delete declaration. (completer_handle_brkchars_func_for_completer): New declaration. * python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use completer_handle_brkchars_func_for_completer.
2017-07-17 13:05:03 +02:00
TEXT is the text beyond what was matched for the command itself
(leading whitespace is skipped). It stops where we are supposed to
stop completing (rl_point) and is '\0' terminated. WORD points in
the same buffer as TEXT, and completions should be returned
relative to this position. For example, suppose TEXT is "foo" and
we want to complete to "foobar". If WORD is "oo", return "oobar";
if WORD is "baz/foo", return "baz/foobar". */
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
typedef void completer_ftype (struct cmd_list_element *,
completion_tracker &tracker,
const char *text, const char *word);
Clean up "completer_handle_brkchars" callback handling This patch cleans up "completer_handle_brkchars" callback handling: - Renames the function typedef to better match its intent: completer_ftype_void -> completer_handle_brkchars_ftype - Factors out common code in complete_line_internal handling the "handle_brkchars" callback to a separate function. - Centralizes all the "completer method" to "handle_brkchars method" mapping in a single function. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to renames. * cli/cli-decode.h (struct cmd_list_element) <completer>: Move comments to completer_ftype's declaration. <completer_handle_brkchars>: Change type to completer_handle_brkchars_ftype. * command.h (completer_ftype): Add describing comment and give names to parameters. (completer_ftype_void): Rename to ... (completer_handle_brkchars_ftype) ... this. Add describing comment. (set_cmd_completer_handle_brkchars): Adjust. * completer.c (filename_completer_handle_brkchars): New function. (complete_line_internal_normal_command): New function, factored out from ... (complete_line_internal): ... here. (command_completer_handle_brkchars) (default_completer_handle_brkchars) (completer_handle_brkchars_func_for_completer): New functions. * completer.h (set_gdb_completion_word_break_characters): Delete declaration. (completer_handle_brkchars_func_for_completer): New declaration. * python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use completer_handle_brkchars_func_for_completer.
2017-07-17 13:05:03 +02:00
/* Same, but for set_cmd_completer_handle_brkchars. */
typedef void completer_handle_brkchars_ftype (struct cmd_list_element *,
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
completion_tracker &tracker,
Clean up "completer_handle_brkchars" callback handling This patch cleans up "completer_handle_brkchars" callback handling: - Renames the function typedef to better match its intent: completer_ftype_void -> completer_handle_brkchars_ftype - Factors out common code in complete_line_internal handling the "handle_brkchars" callback to a separate function. - Centralizes all the "completer method" to "handle_brkchars method" mapping in a single function. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to renames. * cli/cli-decode.h (struct cmd_list_element) <completer>: Move comments to completer_ftype's declaration. <completer_handle_brkchars>: Change type to completer_handle_brkchars_ftype. * command.h (completer_ftype): Add describing comment and give names to parameters. (completer_ftype_void): Rename to ... (completer_handle_brkchars_ftype) ... this. Add describing comment. (set_cmd_completer_handle_brkchars): Adjust. * completer.c (filename_completer_handle_brkchars): New function. (complete_line_internal_normal_command): New function, factored out from ... (complete_line_internal): ... here. (command_completer_handle_brkchars) (default_completer_handle_brkchars) (completer_handle_brkchars_func_for_completer): New functions. * completer.h (set_gdb_completion_word_break_characters): Delete declaration. (completer_handle_brkchars_func_for_completer): New declaration. * python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use completer_handle_brkchars_func_for_completer.
2017-07-17 13:05:03 +02:00
const char *text, const char *word);
PR python/16699: GDB Python command completion with overriden complete vs. completer class This PR came from a Red Hat bug that was filed recently. I checked and it still exists on HEAD, so here's a proposed fix. Although this is marked as a Python backend bug, this is really about the completion mechanism used by GDB. Since this code reminds me of my first attempt to make a good noodle, it took me quite some time to fix it in a non-intrusive way. The problem is triggered when one registers a completion method inside a class in a Python script, rather than registering the command using a completer class directly. For example, consider the following script: class MyFirstCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'myfirstcommand',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') class MySecondCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'mysecondcommand',gdb.COMMAND_USER) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') def complete(self,text,word): return gdb.COMPLETE_FILENAME MyFirstCommand () MySecondCommand () When one loads this into GDB and tries to complete filenames for both myfirstcommand and mysecondcommand, she gets: (gdb) myfirstcommand /hom<TAB> (gdb) myfirstcommand /home/ ^ ... (gdb) mysecondcommand /hom<TAB> (gdb) mysecondcommand /home ^ (The "^" marks the final position of the cursor after the TAB). So we see that myfirstcommand honors the COMPLETE_FILENAME class (as specified in the command creation), but mysecondcommand does not. After some investigation, I found that the problem lies with the set of word break characters that is used for each case. The set should be the same for both commands, but it is not. During the process of deciding which type of completion should be used, the code in gdb/completer.c:complete_line_internal analyses the command that requested the completion and tries to determine the type of completion wanted by checking which completion function will be called (e.g., filename_completer for filenames, location_completer for locations, etc.). This all works fine for myfirstcommand, because immediately after the command registration the Python backend already sets its completion function to filename_completer (which then causes the complete_line_internal function to choose the right set of word break chars). However, for mysecondcommand, this decision is postponed to when the completer function is evaluated, and the Python backend uses an internal completer (called cmdpy_completer). complete_line_internal doesn't know about this internal completer, and can't choose the right set of word break chars in time, which then leads to a bad decision when completing the "/hom" word. So, after a few attempts, I decided to create another callback in "struct cmd_list_element" that will be responsible for handling the case when there is an unknown completer function for complete_line_internal to work with. So far, only the Python backend uses this callback, and only when the user provides a completer method instead of registering the command directly with a completer class. I think this is the best option because it not very intrusive (all the other commands will still work normally), but especially because the whole completion code is so messy that it would be hard to fix this without having to redesign things. I have regtested this on Fedora 18 x86_64, without regressions. I also included a testcase. gdb/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * cli/cli-decode.c (set_cmd_completer_handle_brkchars): New function. (add_cmd): Set "completer_handle_brkchars" to NULL. * cli/cli-decode.h (struct cmd_list_element) <completer_handle_brkchars>: New field. * command.h (completer_ftype_void): New typedef. (set_cmd_completer_handle_brkchars): New prototype. * completer.c (set_gdb_completion_word_break_characters): New function. (complete_line_internal): Call "completer_handle_brkchars" callback from command. * completer.h: Include "command.h". (set_gdb_completion_word_break_characters): New prototype. * python/py-cmd.c (cmdpy_completer_helper): New function. (cmdpy_completer_handle_brkchars): New function. (cmdpy_completer): Adjust to use cmdpy_completer_helper. (cmdpy_init): Set completer_handle_brkchars to cmdpy_completer_handle_brkchars. gdb/testsuite/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * gdb.python/py-completion.exp: New file. * gdb.python/py-completion.py: Likewise.
2014-09-03 22:30:28 +02:00
extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
PR python/16699: GDB Python command completion with overriden complete vs. completer class This PR came from a Red Hat bug that was filed recently. I checked and it still exists on HEAD, so here's a proposed fix. Although this is marked as a Python backend bug, this is really about the completion mechanism used by GDB. Since this code reminds me of my first attempt to make a good noodle, it took me quite some time to fix it in a non-intrusive way. The problem is triggered when one registers a completion method inside a class in a Python script, rather than registering the command using a completer class directly. For example, consider the following script: class MyFirstCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'myfirstcommand',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') class MySecondCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'mysecondcommand',gdb.COMMAND_USER) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') def complete(self,text,word): return gdb.COMPLETE_FILENAME MyFirstCommand () MySecondCommand () When one loads this into GDB and tries to complete filenames for both myfirstcommand and mysecondcommand, she gets: (gdb) myfirstcommand /hom<TAB> (gdb) myfirstcommand /home/ ^ ... (gdb) mysecondcommand /hom<TAB> (gdb) mysecondcommand /home ^ (The "^" marks the final position of the cursor after the TAB). So we see that myfirstcommand honors the COMPLETE_FILENAME class (as specified in the command creation), but mysecondcommand does not. After some investigation, I found that the problem lies with the set of word break characters that is used for each case. The set should be the same for both commands, but it is not. During the process of deciding which type of completion should be used, the code in gdb/completer.c:complete_line_internal analyses the command that requested the completion and tries to determine the type of completion wanted by checking which completion function will be called (e.g., filename_completer for filenames, location_completer for locations, etc.). This all works fine for myfirstcommand, because immediately after the command registration the Python backend already sets its completion function to filename_completer (which then causes the complete_line_internal function to choose the right set of word break chars). However, for mysecondcommand, this decision is postponed to when the completer function is evaluated, and the Python backend uses an internal completer (called cmdpy_completer). complete_line_internal doesn't know about this internal completer, and can't choose the right set of word break chars in time, which then leads to a bad decision when completing the "/hom" word. So, after a few attempts, I decided to create another callback in "struct cmd_list_element" that will be responsible for handling the case when there is an unknown completer function for complete_line_internal to work with. So far, only the Python backend uses this callback, and only when the user provides a completer method instead of registering the command directly with a completer class. I think this is the best option because it not very intrusive (all the other commands will still work normally), but especially because the whole completion code is so messy that it would be hard to fix this without having to redesign things. I have regtested this on Fedora 18 x86_64, without regressions. I also included a testcase. gdb/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * cli/cli-decode.c (set_cmd_completer_handle_brkchars): New function. (add_cmd): Set "completer_handle_brkchars" to NULL. * cli/cli-decode.h (struct cmd_list_element) <completer_handle_brkchars>: New field. * command.h (completer_ftype_void): New typedef. (set_cmd_completer_handle_brkchars): New prototype. * completer.c (set_gdb_completion_word_break_characters): New function. (complete_line_internal): Call "completer_handle_brkchars" callback from command. * completer.h: Include "command.h". (set_gdb_completion_word_break_characters): New prototype. * python/py-cmd.c (cmdpy_completer_helper): New function. (cmdpy_completer_handle_brkchars): New function. (cmdpy_completer): Adjust to use cmdpy_completer_helper. (cmdpy_init): Set completer_handle_brkchars to cmdpy_completer_handle_brkchars. gdb/testsuite/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * gdb.python/py-completion.exp: New file. * gdb.python/py-completion.py: Likewise.
2014-09-03 22:30:28 +02:00
/* Set the completer_handle_brkchars callback. */
extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
Clean up "completer_handle_brkchars" callback handling This patch cleans up "completer_handle_brkchars" callback handling: - Renames the function typedef to better match its intent: completer_ftype_void -> completer_handle_brkchars_ftype - Factors out common code in complete_line_internal handling the "handle_brkchars" callback to a separate function. - Centralizes all the "completer method" to "handle_brkchars method" mapping in a single function. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to renames. * cli/cli-decode.h (struct cmd_list_element) <completer>: Move comments to completer_ftype's declaration. <completer_handle_brkchars>: Change type to completer_handle_brkchars_ftype. * command.h (completer_ftype): Add describing comment and give names to parameters. (completer_ftype_void): Rename to ... (completer_handle_brkchars_ftype) ... this. Add describing comment. (set_cmd_completer_handle_brkchars): Adjust. * completer.c (filename_completer_handle_brkchars): New function. (complete_line_internal_normal_command): New function, factored out from ... (complete_line_internal): ... here. (command_completer_handle_brkchars) (default_completer_handle_brkchars) (completer_handle_brkchars_func_for_completer): New functions. * completer.h (set_gdb_completion_word_break_characters): Delete declaration. (completer_handle_brkchars_func_for_completer): New declaration. * python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use completer_handle_brkchars_func_for_completer.
2017-07-17 13:05:03 +02:00
completer_handle_brkchars_ftype *);
PR python/16699: GDB Python command completion with overriden complete vs. completer class This PR came from a Red Hat bug that was filed recently. I checked and it still exists on HEAD, so here's a proposed fix. Although this is marked as a Python backend bug, this is really about the completion mechanism used by GDB. Since this code reminds me of my first attempt to make a good noodle, it took me quite some time to fix it in a non-intrusive way. The problem is triggered when one registers a completion method inside a class in a Python script, rather than registering the command using a completer class directly. For example, consider the following script: class MyFirstCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'myfirstcommand',gdb.COMMAND_USER,gdb.COMPLETE_FILENAME) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') class MySecondCommand(gdb.Command): def __init__(self): gdb.Command.__init__(self,'mysecondcommand',gdb.COMMAND_USER) def invoke(self,argument,from_tty): raise gdb.GdbError('not implemented') def complete(self,text,word): return gdb.COMPLETE_FILENAME MyFirstCommand () MySecondCommand () When one loads this into GDB and tries to complete filenames for both myfirstcommand and mysecondcommand, she gets: (gdb) myfirstcommand /hom<TAB> (gdb) myfirstcommand /home/ ^ ... (gdb) mysecondcommand /hom<TAB> (gdb) mysecondcommand /home ^ (The "^" marks the final position of the cursor after the TAB). So we see that myfirstcommand honors the COMPLETE_FILENAME class (as specified in the command creation), but mysecondcommand does not. After some investigation, I found that the problem lies with the set of word break characters that is used for each case. The set should be the same for both commands, but it is not. During the process of deciding which type of completion should be used, the code in gdb/completer.c:complete_line_internal analyses the command that requested the completion and tries to determine the type of completion wanted by checking which completion function will be called (e.g., filename_completer for filenames, location_completer for locations, etc.). This all works fine for myfirstcommand, because immediately after the command registration the Python backend already sets its completion function to filename_completer (which then causes the complete_line_internal function to choose the right set of word break chars). However, for mysecondcommand, this decision is postponed to when the completer function is evaluated, and the Python backend uses an internal completer (called cmdpy_completer). complete_line_internal doesn't know about this internal completer, and can't choose the right set of word break chars in time, which then leads to a bad decision when completing the "/hom" word. So, after a few attempts, I decided to create another callback in "struct cmd_list_element" that will be responsible for handling the case when there is an unknown completer function for complete_line_internal to work with. So far, only the Python backend uses this callback, and only when the user provides a completer method instead of registering the command directly with a completer class. I think this is the best option because it not very intrusive (all the other commands will still work normally), but especially because the whole completion code is so messy that it would be hard to fix this without having to redesign things. I have regtested this on Fedora 18 x86_64, without regressions. I also included a testcase. gdb/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * cli/cli-decode.c (set_cmd_completer_handle_brkchars): New function. (add_cmd): Set "completer_handle_brkchars" to NULL. * cli/cli-decode.h (struct cmd_list_element) <completer_handle_brkchars>: New field. * command.h (completer_ftype_void): New typedef. (set_cmd_completer_handle_brkchars): New prototype. * completer.c (set_gdb_completion_word_break_characters): New function. (complete_line_internal): Call "completer_handle_brkchars" callback from command. * completer.h: Include "command.h". (set_gdb_completion_word_break_characters): New prototype. * python/py-cmd.c (cmdpy_completer_helper): New function. (cmdpy_completer_handle_brkchars): New function. (cmdpy_completer): Adjust to use cmdpy_completer_helper. (cmdpy_init): Set completer_handle_brkchars to cmdpy_completer_handle_brkchars. gdb/testsuite/ChangeLog: 2014-09-03 Sergio Durigan Junior <sergiodj@redhat.com> PR python/16699 * gdb.python/py-completion.exp: New file. * gdb.python/py-completion.py: Likewise.
2014-09-03 22:30:28 +02:00
/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
around in cmd objects to test the value of the commands sfunc(). */
extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
cmd_const_cfunc_ftype *cfun);
* cli/cli-decode.c (do_cfunc, set_cmd_cfunc): New functions. (do_sfunc, set_cmd_sfunc): New functions. * command.h (struct cmd_list_element): Add field func. * cli/cli-decode.h (struct cmd_list_element): Ditto. * command.h (set_cmd_sfunc, set_cmd_cfunc): Declare. * cli/cli-decode.h: Ditto. * cli/cli-decode.c (help_cmd): Test for func not cfunc/sfunc. (help_all, help_cmd_list): Ditto. (find_cmd, complete_on_cmdlist): Ditto. * top.c (execute_command): Ditto. * cli/cli-setshow.c (do_setshow_command): Call func instead of function.sfunc. * infcmd.c (notice_args_read): Fix function signature. * cli/cli-cmds.c (init_cli_cmds): Use set_cmd_sfunc. * cli/cli-decode.c (add_set_cmd): Ditto. * utils.c (initialize_utils): Ditto. * maint.c (_initialize_maint_cmds): Ditto. * infrun.c (_initialize_infrun): Ditto. * demangle.c (_initialize_demangler): Ditto. * remote.c (add_packet_config_cmd): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * cris-tdep.c (_initialize_cris_tdep): Ditto. * proc-api.c (_initialize_proc_api): Ditto. * kod.c (_initialize_kod): Ditto. * valprint.c (_initialize_valprint): Ditto. * top.c (init_main): Ditto. * infcmd.c (_initialize_infcmd): Ditto. * corefile.c (_initialize_core): Ditto. * arm-tdep.c (_initialize_arm_tdep): Ditto. * arch-utils.c (initialize_current_architecture): Ditto. (_initialize_gdbarch_utils): Ditto. * alpha-tdep.c (_initialize_alpha_tdep): Ditto. * cli/cli-decode.c (add_cmd): Use set_cmd_cfunc. * wince.c (_initialize_inftarg): Ditto. * symfile.c (_initialize_symfile): Ditto. * mips-tdep.c (_initialize_mips_tdep): Ditto. * language.c (_initialize_language): Ditto. * arc-tdep.c (_initialize_arc_tdep): Ditto.
2002-02-05 05:37:23 +01:00
/* Each command object has a local context attached to it. */
extern void set_cmd_context (struct cmd_list_element *cmd,
void *context);
extern void *get_cmd_context (struct cmd_list_element *cmd);
/* Execute CMD's pre/post hook. Throw an error if the command fails.
If already executing this pre/post hook, or there is no pre/post
hook, the call is silently ignored. */
extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
/* Flag for an ambiguous cmd_list result. */
#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *lookup_cmd (const char **,
-Wwrite-strings: The Rest This is the remainder boring constification that all looks more of less borderline obvious IMO. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * ada-exp.y (yyerror): Constify. * ada-lang.c (bound_name, get_selections) (ada_variant_discrim_type) (ada_variant_discrim_name, ada_value_struct_elt) (ada_lookup_struct_elt_type, is_unchecked_variant) (ada_which_variant_applies, standard_exc, ada_get_next_arg) (catch_ada_exception_command_split) (catch_ada_assert_command_split, catch_assert_command) (ada_op_name): Constify. * ada-lang.h (ada_yyerror, get_selections) (ada_variant_discrim_name, ada_value_struct_elt): Constify. * arc-tdep.c (arc_print_frame_cache): Constify. * arm-tdep.c (arm_skip_stub): Constify. * ax-gdb.c (gen_binop, gen_struct_ref_recursive, gen_struct_ref) (gen_aggregate_elt_ref): Constify. * bcache.c (print_bcache_statistics): Constify. * bcache.h (print_bcache_statistics): Constify. * break-catch-throw.c (catch_exception_command_1): * breakpoint.c (struct ep_type_description::description): Constify. (add_solib_catchpoint): Constify. (catch_fork_command_1): Add cast. (add_catch_command): Constify. * breakpoint.h (add_catch_command, add_solib_catchpoint): Constify. * bsd-uthread.c (bsd_uthread_state): Constify. * buildsym.c (patch_subfile_names): Constify. * buildsym.h (next_symbol_text_func, patch_subfile_names): Constify. * c-exp.y (yyerror): Constify. (token::oper): Constify. * c-lang.h (c_yyerror, cp_print_class_member): Constify. * c-varobj.c (cplus_describe_child): Constify. * charset.c (find_charset_names): Add cast. (find_charset_names): Constify array and add const_cast. * cli/cli-cmds.c (complete_command, cd_command): Constify. (edit_command): Constify. * cli/cli-decode.c (lookup_cmd): Constify. * cli/cli-dump.c (dump_memory_command, dump_value_command): Constify. (struct dump_context): Constify. (add_dump_command, restore_command): Constify. * cli/cli-script.c (get_command_line): Constify. * cli/cli-script.h (get_command_line): Constify. * cli/cli-utils.c (check_for_argument): Constify. * cli/cli-utils.h (check_for_argument): Constify. * coff-pe-read.c (struct read_pe_section_data): Constify. * command.h (lookup_cmd): Constify. * common/print-utils.c (decimal2str): Constify. * completer.c (gdb_print_filename): Constify. * corefile.c (set_gnutarget): Constify. * cp-name-parser.y (yyerror): Constify. * cp-valprint.c (cp_print_class_member): Constify. * cris-tdep.c (cris_register_name, crisv32_register_name): Constify. * d-exp.y (yyerror): Constify. (struct token::oper): Constify. * d-lang.h (d_yyerror): Constify. * dbxread.c (struct header_file_location::name): Constify. (add_old_header_file, add_new_header_file, last_function_name) (dbx_next_symbol_text, add_bincl_to_list) (find_corresponding_bincl_psymtab, set_namestring) (find_stab_function_addr, read_dbx_symtab, start_psymtab) (dbx_end_psymtab, read_ofile_symtab, process_one_symbol): * defs.h (command_line_input, print_address_symbolic) (deprecated_readline_begin_hook): Constify. * dwarf2read.c (anonymous_struct_prefix, dwarf_bool_name): Constify. * event-top.c (handle_line_of_input): Constify and add cast. * exceptions.c (catch_errors): Constify. * exceptions.h (catch_errors): Constify. * expprint.c (print_subexp_standard, op_string, op_name) (op_name_standard, dump_raw_expression, dump_raw_expression): * expression.h (op_name, op_string, dump_raw_expression): Constify. * f-exp.y (yyerror): Constify. (struct token::oper): Constify. (struct f77_boolean_val::name): Constify. * f-lang.c (f_word_break_characters): Constify. * f-lang.h (f_yyerror): Constify. * fork-child.c (fork_inferior): Add cast. * frv-tdep.c (struct gdbarch_tdep::register_names): Constify. (new_variant): Constify. * gdbarch.sh (pstring_ptr, pstring_list): Constify. * gdbarch.c: Regenerate. * gdbcore.h (set_gnutarget): Constify. * go-exp.y (yyerror): Constify. (token::oper): Constify. * go-lang.h (go_yyerror): Constify. * go32-nat.c (go32_sysinfo): Constify. * guile/scm-breakpoint.c (gdbscm_breakpoint_expression): Constify. * guile/scm-cmd.c (cmdscm_function): Constify. * guile/scm-param.c (pascm_param_value): Constify. * h8300-tdep.c (h8300_register_name, h8300s_register_name) (h8300sx_register_name): Constify. * hppa-tdep.c (hppa32_register_name, hppa64_register_name): Constify. * ia64-tdep.c (ia64_register_names): Constify. * infcmd.c (construct_inferior_arguments): Constify. (path_command, attach_post_wait): Constify. * language.c (show_range_command, show_case_command) (unk_lang_error): Constify. * language.h (language_defn::la_error) (language_defn::la_name_of_this): Constify. * linespec.c (decode_line_2): Constify. * linux-thread-db.c (thread_db_err_str): Constify. * lm32-tdep.c (lm32_register_name): Constify. * m2-exp.y (yyerror): Constify. * m2-lang.h (m2_yyerror): Constify. * m32r-tdep.c (m32r_register_names): Constify and make static. * m68hc11-tdep.c (m68hc11_register_names): Constify. * m88k-tdep.c (m88k_register_name): Constify. * macroexp.c (appendmem): Constify. * mdebugread.c (fdr_name, add_data_symbol, parse_type) (upgrade_type, parse_external, parse_partial_symbols) (mdebug_next_symbol_text, cross_ref, mylookup_symbol, new_psymtab) (new_symbol): Constify. * memattr.c (mem_info_command): Constify. * mep-tdep.c (register_name_from_keyword): Constify. * mi/mi-cmd-env.c (mi_cmd_env_path, _initialize_mi_cmd_env): Constify. * mi/mi-cmd-stack.c (list_args_or_locals): Constify. * mi/mi-cmd-var.c (mi_cmd_var_show_attributes): Constify. * mi/mi-main.c (captured_mi_execute_command): Constify and add cast. (mi_execute_async_cli_command): Constify. * mips-tdep.c (mips_register_name): Constify. * mn10300-tdep.c (register_name, mn10300_generic_register_name) (am33_register_name, am33_2_register_name) * moxie-tdep.c (moxie_register_names): Constify. * nat/linux-osdata.c (osdata_type): Constify fields. * nto-tdep.c (nto_parse_redirection): Constify. * objc-lang.c (lookup_struct_typedef, lookup_objc_class) (lookup_child_selector): Constify. (objc_methcall::name): Constify. * objc-lang.h (lookup_objc_class, lookup_child_selector) (lookup_struct_typedef): Constify. * objfiles.c (pc_in_section): Constify. * objfiles.h (pc_in_section): Constify. * p-exp.y (struct token::oper): Constify. (yyerror): Constify. * p-lang.h (pascal_yyerror): Constify. * parser-defs.h (op_name_standard): Constify. (op_print::string): Constify. (exp_descriptor::op_name): Constify. * printcmd.c (print_address_symbolic): Constify. * psymtab.c (print_partial_symbols): Constify. * python/py-breakpoint.c (stop_func): Constify. (bppy_get_expression): Constify. * python/py-cmd.c (cmdpy_completer::name): Constify. (cmdpy_function): Constify. * python/py-event.c (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-event.h (evpy_add_attribute) (gdbpy_initialize_event_generic): Constify. * python/py-evts.c (add_new_registry): Constify. * python/py-finishbreakpoint.c (outofscope_func): Constify. * python/py-framefilter.c (get_py_iter_from_func): Constify. * python/py-inferior.c (get_buffer): Add cast. * python/py-param.c (parm_constant::name): Constify. * python/py-unwind.c (fprint_frame_id): Constify. * python/python.c (gdbpy_parameter_value): Constify. * remote-fileio.c (remote_fio_func_map): Make 'name' const. * remote.c (memory_packet_config::name): Constify. (show_packet_config_cmd, remote_write_bytes) (remote_buffer_add_string): * reverse.c (exec_reverse_once): Constify. * rs6000-tdep.c (variant::name, variant::description): Constify. * rust-exp.y (rustyyerror): Constify. * rust-lang.c (rust_op_name): Constify. * rust-lang.h (rustyyerror): Constify. * serial.h (serial_ops::name): Constify. * sh-tdep.c (sh_sh_register_name, sh_sh3_register_name) (sh_sh3e_register_name, sh_sh2e_register_name) (sh_sh2a_register_name, sh_sh2a_nofpu_register_name) (sh_sh_dsp_register_name, sh_sh3_dsp_register_name) (sh_sh4_register_name, sh_sh4_nofpu_register_name) (sh_sh4al_dsp_register_name): Constify. * sh64-tdep.c (sh64_register_name): Constify. * solib-darwin.c (lookup_symbol_from_bfd): Constify. * spu-tdep.c (spu_register_name, info_spu_dma_cmdlist): Constify. * stabsread.c (patch_block_stabs, read_type_number) (ref_map::stabs, ref_add, process_reference) (symbol_reference_defined, define_symbol, define_symbol) (error_type, read_type, read_member_functions, read_cpp_abbrev) (read_one_struct_field, read_struct_fields, read_baseclasses) (read_tilde_fields, read_struct_type, read_array_type) (read_enum_type, read_sun_builtin_type, read_sun_floating_type) (read_huge_number, read_range_type, read_args, common_block_start) (find_name_end): Constify. * stabsread.h (common_block_start, define_symbol) (process_one_symbol, symbol_reference_defined, ref_add): * symfile.c (get_section_index, add_symbol_file_command): * symfile.h (get_section_index): Constify. * target-descriptions.c (tdesc_type::name): Constify. (tdesc_free_type): Add cast. * target.c (find_default_run_target): (add_deprecated_target_alias, find_default_run_target) (target_announce_detach): Constify. (do_option): Constify. * target.h (add_deprecated_target_alias): Constify. * thread.c (print_thread_info_1): Constify. * top.c (deprecated_readline_begin_hook, command_line_input): Constify. (init_main): Add casts. * top.h (handle_line_of_input): Constify. * tracefile-tfile.c (tfile_write_uploaded_tsv): Constify. * tracepoint.c (tvariables_info_1, trace_status_mi): Constify. (tfind_command): Rename to ... (tfind_command_1): ... this and constify. (tfind_command): New function. (tfind_end_command, tfind_start_command): Adjust. (encode_source_string): Constify. * tracepoint.h (encode_source_string): Constify. * tui/tui-data.c (tui_partial_win_by_name): Constify. * tui/tui-data.h (tui_partial_win_by_name): Constify. * tui/tui-source.c (tui_set_source_content_nil): Constify. * tui/tui-source.h (tui_set_source_content_nil): Constify. * tui/tui-win.c (parse_scrolling_args): Constify. * tui/tui-windata.c (tui_erase_data_content): Constify. * tui/tui-windata.h (tui_erase_data_content): Constify. * tui/tui-winsource.c (tui_erase_source_content): Constify. * tui/tui.c (tui_enable): Add cast. * utils.c (defaulted_query): Constify. (init_page_info): Add cast. (puts_debug, subset_compare): Constify. * utils.h (subset_compare): Constify. * varobj.c (varobj_format_string): Constify. * varobj.h (varobj_format_string): Constify. * vax-tdep.c (vax_register_name): Constify. * windows-nat.c (windows_detach): Constify. * xcoffread.c (process_linenos, xcoff_next_symbol_text): Constify. * xml-support.c (gdb_xml_end_element): Constify. * xml-tdesc.c (tdesc_start_reg): Constify. * xstormy16-tdep.c (xstormy16_register_name): Constify. * xtensa-tdep.c (xtensa_find_register_by_name): Constify. * xtensa-tdep.h (xtensa_register_t::name): Constify. gdb/gdbserver/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * gdbreplay.c (sync_error): Constify. * linux-x86-low.c (push_opcode): Constify.
2017-04-05 20:21:37 +02:00
struct cmd_list_element *,
const char *,
default-args: allow to define default arguments for aliases Currently, a user can define an alias, but cannot have default arguments for this alias. This patch modifies the 'alias' command so that default args can be provided. (gdb) h alias Define a new command that is an alias of an existing command. Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...] ALIAS is the name of the alias command to create. COMMAND is the command being aliased to. Options: -a Specify that ALIAS is an abbreviation of COMMAND. Abbreviations are not used in command completion.. GDB will automatically prepend the provided DEFAULT-ARGS to the list of arguments explicitly provided when using ALIAS. Use "help aliases" to list all user defined aliases and their default args. Examples: Make "spe" an alias of "set print elements": alias spe set print elements Make "elms" an alias of "elements" in the "set print" command: alias -a set print elms set print elements Make "btf" an alias of "backtrace -full -past-entry -past-main" : alias btf = backtrace -full -past-entry -past-main Make "wLapPeu" an alias of 2 nested "with": alias wLapPeu = with language pascal -- with print elements unlimited -- (gdb) The way 'default-args' is implemented makes it trivial to set default args also for GDB commands (such as "backtrace") and for GDB pre-defined aliases (such as "bt"). It was however deemed better to not allow to define default arguments for pre-defined commands and aliases, to avoid users believing that e.g. default args for "backtrace" would apply to "bt". If needed, default-args could be allowed for GDB predefined commands and aliases by adding a command 'set default-args GDB_COMMAND_OR_PREDEFINED_ALIAS [DEFAULT-ARGS...]'. * 'alias' command now has a completer that helps to complete: - ALIAS (if the user defines an alias after a prefix), - the aliased COMMAND - the possible options for the aliased COMMAND. * Help and apropos commands show the definitions of the aliases that have default arguments, e.g. (gdb) help backtrace backtrace, btf, where, bt alias btf = backtrace -full -past-entry -past-main Print backtrace of all stack frames, or innermost COUNT frames. Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT] Options: -entry-values no|only|preferred|if-needed|both|compact|default Set printing of function arguments at function entry. ... gdb/ChangeLog 2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (lookup_cmd_for_default_args) (alias_command_completer) (make_alias_options_def_group): New functions. (alias_opts, alias_option_defs): New struct and array. (alias_usage_error): Update usage. (alias_command): Handles optional DEFAULT-ARGS... arguments. Use option framework. (_initialize_cli_cmds): Update alias command help. Update aliases command help. (show_user): Add NULL for new default_args lookup_cmd argument. (valid_command_p): Rename to validate_aliased_command. Add NULL for new default_args lookup_cmd argument. Verify that the aliased_command has no default args. * cli/cli-decode.c (help_cmd): Show aliases definitions. (lookup_cmd_1, lookup_cmd): New argument default_args. (add_alias_cmd): Add NULL for new default_args lookup_cmd argument. (print_help_for_command): Show default args under the layout alias some_alias = some_aliased_cmd some_alias_default_arg. * cli/cli-decode.h (struct cmd_list_element): New member default_args. xfree default_args in destructor. * cli/cli-script.c (process_next_line, do_define_command): Add NULL for new default_args lookup_cmd argument. * command.h: Declare new default_args argument in lookup_cmd and lookup_cmd_1. * completer.c (complete_line_internal_1): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. * guile/scm-param.c (add_setshow_generic, pascm_parameter_defined_p): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * python/py-auto-load.c (gdbpy_initialize_auto_load): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. * python/py-param.c (add_setshow_generic): Likewise. * remote.c (_initialize_remote): Likewise. * top.c (execute_command): Prepend default_args if command has some. (set_verbose): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument. * tracepoint.c (validate_actionline, encode_actions_1): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
2019-06-19 12:49:55 +02:00
std::string *,
2000-05-28 03:12:42 +02:00
int, int);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *lookup_cmd_1 (const char **,
2000-05-28 03:12:42 +02:00
struct cmd_list_element *,
struct cmd_list_element **,
default-args: allow to define default arguments for aliases Currently, a user can define an alias, but cannot have default arguments for this alias. This patch modifies the 'alias' command so that default args can be provided. (gdb) h alias Define a new command that is an alias of an existing command. Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...] ALIAS is the name of the alias command to create. COMMAND is the command being aliased to. Options: -a Specify that ALIAS is an abbreviation of COMMAND. Abbreviations are not used in command completion.. GDB will automatically prepend the provided DEFAULT-ARGS to the list of arguments explicitly provided when using ALIAS. Use "help aliases" to list all user defined aliases and their default args. Examples: Make "spe" an alias of "set print elements": alias spe set print elements Make "elms" an alias of "elements" in the "set print" command: alias -a set print elms set print elements Make "btf" an alias of "backtrace -full -past-entry -past-main" : alias btf = backtrace -full -past-entry -past-main Make "wLapPeu" an alias of 2 nested "with": alias wLapPeu = with language pascal -- with print elements unlimited -- (gdb) The way 'default-args' is implemented makes it trivial to set default args also for GDB commands (such as "backtrace") and for GDB pre-defined aliases (such as "bt"). It was however deemed better to not allow to define default arguments for pre-defined commands and aliases, to avoid users believing that e.g. default args for "backtrace" would apply to "bt". If needed, default-args could be allowed for GDB predefined commands and aliases by adding a command 'set default-args GDB_COMMAND_OR_PREDEFINED_ALIAS [DEFAULT-ARGS...]'. * 'alias' command now has a completer that helps to complete: - ALIAS (if the user defines an alias after a prefix), - the aliased COMMAND - the possible options for the aliased COMMAND. * Help and apropos commands show the definitions of the aliases that have default arguments, e.g. (gdb) help backtrace backtrace, btf, where, bt alias btf = backtrace -full -past-entry -past-main Print backtrace of all stack frames, or innermost COUNT frames. Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT] Options: -entry-values no|only|preferred|if-needed|both|compact|default Set printing of function arguments at function entry. ... gdb/ChangeLog 2020-06-22 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (lookup_cmd_for_default_args) (alias_command_completer) (make_alias_options_def_group): New functions. (alias_opts, alias_option_defs): New struct and array. (alias_usage_error): Update usage. (alias_command): Handles optional DEFAULT-ARGS... arguments. Use option framework. (_initialize_cli_cmds): Update alias command help. Update aliases command help. (show_user): Add NULL for new default_args lookup_cmd argument. (valid_command_p): Rename to validate_aliased_command. Add NULL for new default_args lookup_cmd argument. Verify that the aliased_command has no default args. * cli/cli-decode.c (help_cmd): Show aliases definitions. (lookup_cmd_1, lookup_cmd): New argument default_args. (add_alias_cmd): Add NULL for new default_args lookup_cmd argument. (print_help_for_command): Show default args under the layout alias some_alias = some_aliased_cmd some_alias_default_arg. * cli/cli-decode.h (struct cmd_list_element): New member default_args. xfree default_args in destructor. * cli/cli-script.c (process_next_line, do_define_command): Add NULL for new default_args lookup_cmd argument. * command.h: Declare new default_args argument in lookup_cmd and lookup_cmd_1. * completer.c (complete_line_internal_1): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. * guile/scm-param.c (add_setshow_generic, pascm_parameter_defined_p): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * python/py-auto-load.c (gdbpy_initialize_auto_load): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. * python/py-param.c (add_setshow_generic): Likewise. * remote.c (_initialize_remote): Likewise. * top.c (execute_command): Prepend default_args if command has some. (set_verbose): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument. * tracepoint.c (validate_actionline, encode_actions_1): Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
2019-06-19 12:49:55 +02:00
std::string *,
2000-05-28 03:12:42 +02:00
int);
extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
const char * );
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void deprecated_cmd_warning (const char *);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern int lookup_cmd_composition (const char *text,
struct cmd_list_element **alias,
struct cmd_list_element **prefix_cmd,
struct cmd_list_element **cmd);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_com (const char *, enum command_class,
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.
2017-10-11 23:43:01 +02:00
cmd_const_cfunc_ftype *fun,
const char *);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_com_alias (const char *, const char *,
2000-05-28 03:12:42 +02:00
enum command_class, int);
Emit inferior, thread and frame selection events to all UIs With this patch, when an inferior, thread or frame is explicitly selected by the user, notifications will appear on all CLI and MI UIs. When a GDB console is integrated in a front-end, this allows the front-end to follow a selection made by the user ont he CLI, and it informs the user about selection changes made behind the scenes by the front-end. This patch addresses PR gdb/20487. In order to communicate frame changes to the front-end, this patch adds a new field to the =thread-selected event for the selected frame. The idea is that since inferior/thread/frame can be seen as a composition, it makes sense to send them together in the same event. The vision would be to eventually send the inferior information as well, if we find that it's needed, although the "=thread-selected" event would be ill-named for that job. Front-ends need to handle this new field if they want to follow the frame selection changes that originate from the console. The format of the frame attribute is the same as what is found in the *stopped events. Here's a detailed example for each command and the events they generate: thread ------ 1. CLI command: thread 1.3 MI event: =thread-selected,id="3",frame={...} 2. MI command: -thread-select 3 CLI event: [Switching to thread 1.3 ...] 3. MI command (CLI-in-MI): thread 1.3 MI event/reply: &"thread 1.3\n" ~"#0 child_sub_function () ... =thread-selected,id="3",frame={level="0",...} ^done frame ----- 1. CLI command: frame 1 MI event: =thread-selected,id="3",frame={level="1",...} 2. MI command: -stack-select-frame 1 CLI event: #1 0x00000000004007f0 in child_function... 3. MI command (CLI-in-MI): frame 1 MI event/reply: &"frame 1\n" ~"#1 0x00000000004007f9 in ..." =thread-selected,id="3",frame={level="1"...} ^done inferior -------- Inferior selection events only go from the console to MI, since there's no way to select the inferior in pure MI. 1. CLI command: inferior 2 MI event: =thread-selected,id="3" Note that if the user selects an inferior that is not started or exited, the MI doesn't receive a notification. Since there is no threads to select, the =thread-selected event does not apply... 2. MI command (CLI-in-MI): inferior 2 MI event/reply: &"inferior 2\n" ~"[Switching to inferior 2 ...]" =thread-selected,id="4",frame={level="0"...} ^done Internal implementation detail: this patch makes it possible to suppress notifications caused by a CLI command, like what is done in mi-interp.c. This means that it's now possible to use the add_com_suppress_notification function to register a command with some event suppressed. It is used to implement the select-frame command in this patch. The function command_notifies_uscc_observer was added to extract the rather complicated logical expression from the if statement. It is also now clearer what that logic does: if the command used by the user already notifies the user_selected_context_changed observer, there is not need to notify it again. It therefore protects again emitting the event twice. No regressions, tested on ubuntu 14.04 x86 with target boards unix and native-extended-gdbserver. gdb/ChangeLog: YYYY-MM-DD Antoine Tremblay <antoine.tremblay@ericsson.com> YYYY-MM-DD Simon Marchi <simon.marchi@ericsson.com> PR gdb/20487 * NEWS: Mention new frame field of =thread-selected event. * cli/cli-decode.c (add_cmd): Initialize c->suppress_notification. (add_com_suppress_notification): New function definition. (cmd_func): Set and restore the suppress_notification flag. * cli/cli-deicode.h (struct cmd_list_element) <suppress_notification>: New field. * cli/cli-interp.c (cli_suppress_notification): New global variable. (cli_on_user_selected_context_changed): New function. (_initialize_cli_interp): Attach to user_selected_context_changed observer. * command.h (struct cli_suppress_notification): New structure. (cli_suppress_notification): New global variable declaration. (add_com_suppress_notification): New function declaration. * defs.h (enum user_selected_what_flag): New enum. (user_selected_what): New enum flag type. * frame.h (print_stack_frame_to_uiout): New function declaration. * gdbthread.h (print_selected_thread_frame): New function declaration. * inferior.c (print_selected_inferior): New function definition. (inferior_command): Remove printing of inferior/thread/frame switch notifications, notify user_selected_context_changed observer. * inferior.h (print_selected_inferior): New function declaration. * mi/mi-cmds.c (struct mi_cmd): Add user_selected_context suppression to stack-select-frame and thread-select commands. * mi/mi-interp.c (struct mi_suppress_notification) <user_selected_context>: Initialize. (mi_user_selected_context_changed): New function definition. (_initialize_mi_interp): Attach to user_selected_context_changed. * mi/mi-main.c (mi_cmd_thread_select): Print thread selection reply. (mi_execute_command): Handle notification suppression. Notify user_selected_context_changed observer on thread change instead of printing event directly. Don't send it if command already sends the notification. (command_notifies_uscc_observer): New function. (mi_cmd_execute): Don't handle notification suppression. * mi/mi-main.h (struct mi_suppress_notification) <user_selected_context>: New field. * stack.c (print_stack_frame_to_uiout): New function definition. (select_frame_command): Notify user_selected_context_changed observer. (frame_command): Call print_selected_thread_frame if there's no frame change or notify user_selected_context_changed observer if there is. (up_command): Notify user_selected_context_changed observer. (down_command): Likewise. (_initialize_stack): Suppress user_selected_context notification for command select-frame. * thread.c (thread_command): Notify user_selected_context_changed if the thread has changed, print thread info directly if it hasn't. (do_captured_thread_select): Do not print thread switch event. (print_selected_thread_frame): New function definition. * tui/tui-interp.c (tui_on_user_selected_context_changed): New function definition. (_initialize_tui_interp): Attach to user_selected_context_changed observer. gdb/doc/ChangeLog: PR gdb/20487 * gdb.texinfo (Context management): Update mention of frame change notifications. (gdb/mi Async Records): Document frame field in =thread-select event. * observer.texi (GDB Observers): New user_selected_context_changed observer. gdb/testsuite/ChangeLog: PR gdb/20487 * gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Adapt =thread-select-event check.
2016-10-03 22:52:44 +02:00
extern struct cmd_list_element *add_com_suppress_notification
(const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun, const char *doc,
Emit inferior, thread and frame selection events to all UIs With this patch, when an inferior, thread or frame is explicitly selected by the user, notifications will appear on all CLI and MI UIs. When a GDB console is integrated in a front-end, this allows the front-end to follow a selection made by the user ont he CLI, and it informs the user about selection changes made behind the scenes by the front-end. This patch addresses PR gdb/20487. In order to communicate frame changes to the front-end, this patch adds a new field to the =thread-selected event for the selected frame. The idea is that since inferior/thread/frame can be seen as a composition, it makes sense to send them together in the same event. The vision would be to eventually send the inferior information as well, if we find that it's needed, although the "=thread-selected" event would be ill-named for that job. Front-ends need to handle this new field if they want to follow the frame selection changes that originate from the console. The format of the frame attribute is the same as what is found in the *stopped events. Here's a detailed example for each command and the events they generate: thread ------ 1. CLI command: thread 1.3 MI event: =thread-selected,id="3",frame={...} 2. MI command: -thread-select 3 CLI event: [Switching to thread 1.3 ...] 3. MI command (CLI-in-MI): thread 1.3 MI event/reply: &"thread 1.3\n" ~"#0 child_sub_function () ... =thread-selected,id="3",frame={level="0",...} ^done frame ----- 1. CLI command: frame 1 MI event: =thread-selected,id="3",frame={level="1",...} 2. MI command: -stack-select-frame 1 CLI event: #1 0x00000000004007f0 in child_function... 3. MI command (CLI-in-MI): frame 1 MI event/reply: &"frame 1\n" ~"#1 0x00000000004007f9 in ..." =thread-selected,id="3",frame={level="1"...} ^done inferior -------- Inferior selection events only go from the console to MI, since there's no way to select the inferior in pure MI. 1. CLI command: inferior 2 MI event: =thread-selected,id="3" Note that if the user selects an inferior that is not started or exited, the MI doesn't receive a notification. Since there is no threads to select, the =thread-selected event does not apply... 2. MI command (CLI-in-MI): inferior 2 MI event/reply: &"inferior 2\n" ~"[Switching to inferior 2 ...]" =thread-selected,id="4",frame={level="0"...} ^done Internal implementation detail: this patch makes it possible to suppress notifications caused by a CLI command, like what is done in mi-interp.c. This means that it's now possible to use the add_com_suppress_notification function to register a command with some event suppressed. It is used to implement the select-frame command in this patch. The function command_notifies_uscc_observer was added to extract the rather complicated logical expression from the if statement. It is also now clearer what that logic does: if the command used by the user already notifies the user_selected_context_changed observer, there is not need to notify it again. It therefore protects again emitting the event twice. No regressions, tested on ubuntu 14.04 x86 with target boards unix and native-extended-gdbserver. gdb/ChangeLog: YYYY-MM-DD Antoine Tremblay <antoine.tremblay@ericsson.com> YYYY-MM-DD Simon Marchi <simon.marchi@ericsson.com> PR gdb/20487 * NEWS: Mention new frame field of =thread-selected event. * cli/cli-decode.c (add_cmd): Initialize c->suppress_notification. (add_com_suppress_notification): New function definition. (cmd_func): Set and restore the suppress_notification flag. * cli/cli-deicode.h (struct cmd_list_element) <suppress_notification>: New field. * cli/cli-interp.c (cli_suppress_notification): New global variable. (cli_on_user_selected_context_changed): New function. (_initialize_cli_interp): Attach to user_selected_context_changed observer. * command.h (struct cli_suppress_notification): New structure. (cli_suppress_notification): New global variable declaration. (add_com_suppress_notification): New function declaration. * defs.h (enum user_selected_what_flag): New enum. (user_selected_what): New enum flag type. * frame.h (print_stack_frame_to_uiout): New function declaration. * gdbthread.h (print_selected_thread_frame): New function declaration. * inferior.c (print_selected_inferior): New function definition. (inferior_command): Remove printing of inferior/thread/frame switch notifications, notify user_selected_context_changed observer. * inferior.h (print_selected_inferior): New function declaration. * mi/mi-cmds.c (struct mi_cmd): Add user_selected_context suppression to stack-select-frame and thread-select commands. * mi/mi-interp.c (struct mi_suppress_notification) <user_selected_context>: Initialize. (mi_user_selected_context_changed): New function definition. (_initialize_mi_interp): Attach to user_selected_context_changed. * mi/mi-main.c (mi_cmd_thread_select): Print thread selection reply. (mi_execute_command): Handle notification suppression. Notify user_selected_context_changed observer on thread change instead of printing event directly. Don't send it if command already sends the notification. (command_notifies_uscc_observer): New function. (mi_cmd_execute): Don't handle notification suppression. * mi/mi-main.h (struct mi_suppress_notification) <user_selected_context>: New field. * stack.c (print_stack_frame_to_uiout): New function definition. (select_frame_command): Notify user_selected_context_changed observer. (frame_command): Call print_selected_thread_frame if there's no frame change or notify user_selected_context_changed observer if there is. (up_command): Notify user_selected_context_changed observer. (down_command): Likewise. (_initialize_stack): Suppress user_selected_context notification for command select-frame. * thread.c (thread_command): Notify user_selected_context_changed if the thread has changed, print thread info directly if it hasn't. (do_captured_thread_select): Do not print thread switch event. (print_selected_thread_frame): New function definition. * tui/tui-interp.c (tui_on_user_selected_context_changed): New function definition. (_initialize_tui_interp): Attach to user_selected_context_changed observer. gdb/doc/ChangeLog: PR gdb/20487 * gdb.texinfo (Context management): Update mention of frame change notifications. (gdb/mi Async Records): Document frame field in =thread-select event. * observer.texi (GDB Observers): New user_selected_context_changed observer. gdb/testsuite/ChangeLog: PR gdb/20487 * gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Adapt =thread-select-event check.
2016-10-03 22:52:44 +02:00
int *supress_notification);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern struct cmd_list_element *add_info (const char *,
Constify add_info This patch constifies add_info and updates all the info commands. The bulk of this patch was written using a script; and then I did a manual pass to fix up the remaining compilation errors. I could not compile every changed file; in particular nto-procfs.c, gnu-nat.c, and darwin-nat-info.c; but I at least tried to check the correctness by inspection. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * frame.h (info_locals_command, info_args_command): Constify. * auto-load.h (auto_load_info_scripts): Constify. * inferior.h (registers_info): Constify. * copying.c: Rebuild. * copying.awk: Constify generated commands. * auto-load.c (auto_load_info_scripts) (info_auto_load_gdb_scripts): Constify. * cli/cli-decode.c (struct cmd_list_element): Take a cmd_const_cfunc_ftype. * command.h (add_info): Take a cmd_const_cfunc_ftype. * tui/tui-win.c (tui_all_windows_info): Constify. * python/py-auto-load.c (info_auto_load_python_scripts): Constify. * cli/cli-cmds.c (show_command): Remove non-const overload. * tracepoint.c (info_tvariables_command, info_scope_command): Constify. (info_static_tracepoint_markers_command): Constify. * thread.c (info_threads_command): Constify. (print_thread_info_1): Constify. * target.c (info_target_command): Constify. * symtab.c (info_sources_command, info_functions_command) (info_types_command): Constify. (info_variables_command): Remove non-const overload. * symfile.c (info_ext_lang_command): Constify. * stack.c (info_frame_command, info_locals_command) (info_args_command): Constify. (backtrace_command): Remove non-const overload. * source.c (info_source_command, info_line_command): Constify. * solib.c (info_sharedlibrary_command): Constify. * skip.c (info_skip_command): Constify. * ser-go32.c (info_serial_command): Constify. * reverse.c (info_bookmarks_command): Constify. * printcmd.c (info_symbol_command, info_address_command) (info_display_command): Constify. * osdata.c (info_osdata_command): Constify. * objc-lang.c (info_selectors_command, info_classes_command): Constify. * nto-procfs.c (procfs_pidlist, procfs_meminfo): Constify. * memattr.c (info_mem_command): Constify. * macrocmd.c (info_macro_command, info_macros_command): Constify. * linux-fork.c (info_checkpoints_command): Constify. * infrun.c (info_signals_command): Constify. * inflow.c (info_terminal_command): Constify. * inferior.c (info_inferiors_command): Constify. (print_inferior): Constify. * infcmd.c (info_program_command, info_all_registers_command) (info_registers_command, info_vector_command) (info_float_command): Constify. (registers_info): Constify. * gnu-nat.c (info_send_rights_cmd, info_recv_rights_cmd) (info_port_sets_cmd, info_dead_names_cmd, info_port_rights_cmd): Constify. * f-valprint.c (info_common_command): Constify. * dcache.c (info_dcache_command): Constify. (dcache_info_1): Constify. * darwin-nat-info.c (info_mach_tasks_command) (info_mach_task_command, info_mach_ports_command) (info_mach_port_command, info_mach_threads_command) (info_mach_thread_command, info_mach_regions_command) (info_mach_regions_recurse_command, info_mach_region_command) (info_mach_exceptions_command): Constify. (get_task_from_args): Constify. * cp-support.c (info_vtbl_command): Constify. * breakpoint.c (info_watchpoints_command) (info_tracepoints_command): Constify. (info_breakpoints_command): Remove non-const overload. * avr-tdep.c (avr_io_reg_read_command): Constify. * auxv.c (info_auxv_command): Constify. * ada-tasks.c (info_tasks_command): Constify. (info_task): Constify. * ada-lang.c (info_exceptions_command): Constify.
2017-10-14 06:07:26 +02:00
cmd_const_cfunc_ftype *fun,
const char *);
extern struct cmd_list_element *add_info_alias (const char *, const char *,
int);
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
extern void complete_on_cmdlist (struct cmd_list_element *,
completion_tracker &tracker,
const char *, const char *, int);
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
extern void complete_on_enum (completion_tracker &tracker,
const char *const *enumlist,
const char *, const char *);
/* Functions that implement commands about CLI commands. */
extern void help_list (struct cmd_list_element *, const char *,
2000-02-02 01:21:19 +01:00
enum command_class, struct ui_file *);
2005-02-16 Andrew Cagney <cagney@gnu.org> Merge setshow print and show parameters. * command.h (show_value_ftype): Define. (deprecated_show_value_hack): Declare. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Change type of show_func to show_value_ftype. * cli/cli-decode.h (struct cmd_list_element): Replace fprint_setshow with show_value_func. * cli/cli-decode.c (add_setshow_cmd_full): Update show_func parameter. Set show_value_func. Do not set cmd_sfunc. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Update. * complaints.c (complaints_show_value): Replace fprint_setshow_complaints. (_initialize_complaints): Update. * mips-tdep.c (show_mask_address): Update. * arm-tdep.c (show_fp_model): Update. * cli/cli-setshow.c (do_setshow_command): Call show_value_func instead of fprint_setshow. Use deprecated_show_value_hack. (deprecated_show_value_hack): New function. * remote.c (add_packet_config_cmd, show_remote_cmd): (show_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_binary_download_cmd) (show_remote_protocol_p_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_vcont_packet_cmd): Update.
2005-02-16 18:20:59 +01:00
/* Method for show a set/show variable's VALUE on FILE. If this
method isn't supplied deprecated_show_value_hack() is called (which
is not good). */
typedef void (show_value_ftype) (struct ui_file *file,
int from_tty,
struct cmd_list_element *cmd,
const char *value);
/* NOTE: i18n: This function is not i18n friendly. Callers should
instead print the value out directly. */
extern show_value_ftype deprecated_show_value_hack;
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_enum_cmd (const char *name,
enum command_class theclass,
gdb/ Code cleanup: Make 1440 bytes of data segment read-only. * arch-utils.c (endian_enum): Make it const char *const []. * arm-tdep.c (fp_model_strings, arm_abi_strings, arm_mode_strings): Likewise. * breakpoint.c (always_inserted_enums): Likewise. * cli/cli-cmds.c (script_ext_enums): Likewise. * cli/cli-decode.c (add_setshow_enum_cmd, complete_on_enum): Make the enumlist parameter const char *const *. * cli/cli-decode.h (struct cmd_list_element): Make the enums field const char *const *. * command.h (complete_on_enum, add_setshow_enum_cmd): Make the enumlist parameter const char *const *. * cris-tdep.c (cris_modes): Make it const char *const []. * filesystem.c (target_file_system_kinds): Likewise. * i386-tdep.c (valid_flavors, valid_conventions): Likewise. * infrun.c (follow_fork_mode_kind_names, follow_exec_mode_names) (can_use_displaced_stepping_enum, scheduler_enums) (exec_direction_names): Likewise. * language.c (_initialize_language): Make the type_or_range_names and case_sensitive_names variables const char *const []. * mips-tdep.c (mips_abi_strings): Make it const char *const []. * python/python.c (python_excp_enums): Likewise. * remote.c (interrupt_sequence_modes): Likewise. * rs6000-tdep.c (powerpc_vector_strings): Likewise. * serial.c (logbase_enums): Likewise. * sh-tdep.c (sh_cc_enum): Likewise. * stack.c (print_frame_arguments_choices, print_entry_values_choices): Likewise. * symtab.c (multiple_symbols_modes): Likewise. * tui/tui-win.c (tui_border_kind_enums, tui_border_mode_enums): Likewise. * utils.c (internal_problem_modes): Likewise.
2012-01-28 19:08:22 +01:00
const char *const *enumlist,
const char **var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
2005-02-16 Andrew Cagney <cagney@gnu.org> Merge setshow print and show parameters. * command.h (show_value_ftype): Define. (deprecated_show_value_hack): Declare. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Change type of show_func to show_value_ftype. * cli/cli-decode.h (struct cmd_list_element): Replace fprint_setshow with show_value_func. * cli/cli-decode.c (add_setshow_cmd_full): Update show_func parameter. Set show_value_func. Do not set cmd_sfunc. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Update. * complaints.c (complaints_show_value): Replace fprint_setshow_complaints. (_initialize_complaints): Update. * mips-tdep.c (show_mask_address): Update. * arm-tdep.c (show_fp_model): Update. * cli/cli-setshow.c (do_setshow_command): Call show_value_func instead of fprint_setshow. Use deprecated_show_value_hack. (deprecated_show_value_hack): New function. * remote.c (add_packet_config_cmd, show_remote_cmd): (show_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_binary_download_cmd) (show_remote_protocol_p_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_vcont_packet_cmd): Update.
2005-02-16 18:20:59 +01:00
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list,
void *context = nullptr);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_auto_boolean_cmd (const char *name,
enum command_class theclass,
enum auto_boolean *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
2005-02-16 Andrew Cagney <cagney@gnu.org> Merge setshow print and show parameters. * command.h (show_value_ftype): Define. (deprecated_show_value_hack): Declare. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Change type of show_func to show_value_ftype. * cli/cli-decode.h (struct cmd_list_element): Replace fprint_setshow with show_value_func. * cli/cli-decode.c (add_setshow_cmd_full): Update show_func parameter. Set show_value_func. Do not set cmd_sfunc. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Update. * complaints.c (complaints_show_value): Replace fprint_setshow_complaints. (_initialize_complaints): Update. * mips-tdep.c (show_mask_address): Update. * arm-tdep.c (show_fp_model): Update. * cli/cli-setshow.c (do_setshow_command): Call show_value_func instead of fprint_setshow. Use deprecated_show_value_hack. (deprecated_show_value_hack): New function. * remote.c (add_packet_config_cmd, show_remote_cmd): (show_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_binary_download_cmd) (show_remote_protocol_p_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_vcont_packet_cmd): Update.
2005-02-16 18:20:59 +01:00
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
"set print raw frame-arguments" -> "set print raw-frame-arguments" A following patch will introduce options for the "backtrace" command, based on some "set print" and "set backtrace" settings. There's one setting in particular that is a bit annoying if we want to describe the backtrace options and the settings commands using the same data structures: "set print raw frame-arguments" The problem is that space between "raw" and "frame-arguments". Calling the option "bt -raw frame-arguments" would be odd. So I'm calling the option "bt -raw-frame-arguments" instead. And for consistency, this patch renames the set/show commands to: "set print raw-frame-arguments" "show print raw-frame-arguments" I.e., dash instead of space. The old commands are left in place, but marked deprecated. We need to adjust a couple testcases, because the relevant tests use gdb_test_no_output and the old commands are no longer silent: (gdb) set print raw frame-arguments on Warning: command 'set print raw frame-arguments' is deprecated. Use 'set print raw-frame-arguments'. gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * NEWS (Changed commands): Mention set/show print raw-frame-arguments, and that "set/show print raw frame-arguments" are now deprecated. * cli/cli-decode.c (add_setshow_boolean_cmd): Now returns the command. * command.h (add_setshow_boolean_cmd): Return cmd_list_element *. * stack.c (_initialize_stack): Install "set/show print raw-frame-arguments", and deprecate "set/show print raw frame-arguments". * valprint.c (_initialize_valprint): Deprecate "set/show print raw". gdb/doc/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.texinfo (Print Settings): Document "set/show print raw-frame-arguments" instead of "set/show print raw frame-arguments". gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.guile/scm-frame-args.exp: Use "set print raw-frame-arguments" instead of "set print raw frame-arguments". * gdb.python/py-frame-args.exp: Likewise.
2019-06-13 01:06:53 +02:00
extern cmd_list_element *
add_setshow_boolean_cmd (const char *name,
enum command_class theclass,
Change boolean options to bool instead of int This is for add_setshow_boolean_cmd as well as the gdb::option interface. gdb/ChangeLog: 2019-09-17 Christian Biesinger <cbiesinger@google.com> * ada-lang.c (ada_ignore_descriptive_types_p): Change to bool. (print_signatures): Likewise. (trust_pad_over_xvs): Likewise. * arch/aarch64-insn.c (aarch64_debug): Likewise. * arch/aarch64-insn.h (aarch64_debug): Likewise. * arm-linux-nat.c (arm_apcs_32): Likewise. * arm-linux-tdep.c (arm_apcs_32): Likewise. * arm-nbsd-nat.c (arm_apcs_32): Likewise. * arm-tdep.c (arm_debug): Likewise. (arm_apcs_32): Likewise. * auto-load.c (debug_auto_load): Likewise. (auto_load_gdb_scripts): Likewise. (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * auto-load.h (global_auto_load): Likewise. (auto_load_local_gdbinit): Likewise. (auto_load_local_gdbinit_loaded): Likewise. * breakpoint.c (disconnected_dprintf): Likewise. (breakpoint_proceeded): Likewise. (automatic_hardware_breakpoints): Likewise. (always_inserted_mode): Likewise. (target_exact_watchpoints): Likewise. (_initialize_breakpoint): Update. * breakpoint.h (target_exact_watchpoints): Change to bool. * btrace.c (maint_btrace_pt_skip_pad): Likewise. * cli/cli-cmds.c (trace_commands): Likewise. * cli/cli-cmds.h (trace_commands): Likewise. * cli/cli-decode.c (add_setshow_boolean_cmd): Change int* argument to bool*. * cli/cli-logging.c (logging_overwrite): Change to bool. (logging_redirect): Likewise. (debug_redirect): Likewise. * cli/cli-option.h (option_def) <boolean>: Change return type to bool*. (struct boolean_option_def) <get_var_address_cb_>: Change return type to bool. <boolean_option_def>: Update. (struct flag_option_def): Change default type of Context to bool from int. <flag_option_def>: Change return type of var_address_cb_ to bool*. * cli/cli-setshow.c (do_set_command): Cast to bool* instead of int*. (get_setshow_command_value_string): Likewise. * cli/cli-style.c (cli_styling): Change to bool. (source_styling): Likewise. * cli/cli-style.h (source_styling): Likewise. (cli_styling): Likewise. * cli/cli-utils.h (struct qcs_flags) <quiet, cont, silent>: Change to bool. * command.h (var_types): Update comment. (add_setshow_boolean_cmd): Change int* var argument to bool*. * compile/compile-cplus-types.c (debug_compile_cplus_types): Change to bool. (debug_compile_cplus_scopes): Likewise. * compile/compile-internal.h (compile_debug): Likewise. * compile/compile.c (compile_debug): Likewise. (struct compile_options) <raw>: Likewise. * cp-support.c (catch_demangler_crashes): Likewise. * cris-tdep.c (usr_cmd_cris_version_valid): Likewise. (usr_cmd_cris_dwarf2_cfi): Likewise. * csky-tdep.c (csky_debug): Likewise. * darwin-nat.c (enable_mach_exceptions): Likewise. * dcache.c (dcache_enabled_p): Likewise. * defs.h (info_verbose): Likewise. * demangle.c (demangle): Likewise. (asm_demangle): Likewise. * dwarf-index-cache.c (debug_index_cache): Likewise. * dwarf2-frame.c (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2-frame.h (dwarf2_frame_unwinders_enabled_p): Likewise. * dwarf2read.c (check_physname): Likewise. (use_deprecated_index_sections): Likewise. (dwarf_always_disassemble): Likewise. * eval.c (overload_resolution): Likewise. * event-top.c (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * event-top.h (set_editing_cmd_var): Likewise. (exec_done_display_p): Likewise. * exec.c (write_files): Likewise. * fbsd-nat.c (debug_fbsd_lwp): Likewise (debug_fbsd_nat): Likewise. * frame.h (struct frame_print_options) <print_raw_frame_arguments>: Likewise. (struct set_backtrace_options) <backtrace_past_main>: Likewise. <backtrace_past_entry> Likewise. * gdb-demangle.h (demangle): Likewise. (asm_demangle): Likewise. * gdb_bfd.c (bfd_sharing): Likewise. * gdbcore.h (write_files): Likewise. * gdbsupport/common-debug.c (show_debug_regs): Likewise. * gdbsupport/common-debug.h (show_debug_regs): Likewise. * gdbthread.h (print_thread_events): Likewise. * gdbtypes.c (opaque_type_resolution): Likewise. (strict_type_checking): Likewise. * gnu-nat.c (gnu_debug_flag): Likewise. * guile/scm-auto-load.c (auto_load_guile_scripts): Likewise. * guile/scm-param.c (pascm_variable): Add boolval. (add_setshow_generic): Update. (pascm_param_value): Update. (pascm_set_param_value_x): Update. * hppa-tdep.c (hppa_debug): Change to bool.. * infcall.c (may_call_functions_p): Likewise. (coerce_float_to_double_p): Likewise. (unwind_on_signal_p): Likewise. (unwind_on_terminating_exception_p): Likewise. * infcmd.c (startup_with_shell): Likewise. * inferior.c (print_inferior_events): Likewise. * inferior.h (startup_with_shell): Likewise. (print_inferior_events): Likewise. * infrun.c (step_stop_if_no_debug): Likewise. (detach_fork): Likewise. (debug_displaced): Likewise. (disable_randomization): Likewise. (non_stop): Likewise. (non_stop_1): Likewise. (observer_mode): Likewise. (observer_mode_1): Likewise. (set_observer_mode): Update. (sched_multi): Change to bool. * infrun.h (debug_displaced): Likewise. (sched_multi): Likewise. (step_stop_if_no_debug): Likewise. (non_stop): Likewise. (disable_randomization): Likewise. * linux-tdep.c (use_coredump_filter): Likewise. (dump_excluded_mappings): Likewise. * linux-thread-db.c (auto_load_thread_db): Likewise. (check_thread_db_on_load): Likewise. * main.c (captured_main_1): Update. * maint-test-options.c (struct test_options_opts) <flag_opt, xx1_opt, xx2_opt, boolean_opt>: Change to bool. * maint-test-settings.c (maintenance_test_settings_boolean): Likewise. * maint.c (maintenance_profile_p): Likewise. (per_command_time): Likewise. (per_command_space): Likewise. (per_command_symtab): Likewise. * memattr.c (inaccessible_by_default): Likewise. * mi/mi-main.c (mi_async): Likewise. (mi_async_1): Likewise. * mips-tdep.c (mips64_transfers_32bit_regs_p): Likewise. * nat/fork-inferior.h (startup_with_shell): Likewise. * nat/linux-namespaces.c (debug_linux_namespaces): Likewise. * nat/linux-namespaces.h (debug_linux_namespaces): Likewise. * nios2-tdep.c (nios2_debug): Likewise. * or1k-tdep.c (or1k_debug): Likewise. * parse.c (parser_debug): Likewise. * parser-defs.h (parser_debug): Likewise. * printcmd.c (print_symbol_filename): Likewise. * proc-api.c (procfs_trace): Likewise. * python/py-auto-load.c (auto_load_python_scripts): Likewise. * python/py-param.c (union parmpy_variable): Add "bool boolval" field. (set_parameter_value): Update. (add_setshow_generic): Update. * python/py-value.c (copy_py_bool_obj): Change argument from int* to bool*. * python/python.c (gdbpy_parameter_value): Cast to bool* instead of int*. * ravenscar-thread.c (ravenscar_task_support): Change to bool. * record-btrace.c (record_btrace_target::store_registers): Update. * record-full.c (record_full_memory_query): Change to bool. (record_full_stop_at_limit): Likewise. * record-full.h (record_full_memory_query): Likewise. * remote-notif.c (notif_debug): Likewise. * remote-notif.h (notif_debug): Likewise. * remote.c (use_range_stepping): Likewise. (interrupt_on_connect): Likewise. (remote_break): Likewise. * ser-tcp.c (tcp_auto_retry): Likewise. * ser-unix.c (serial_hwflow): Likewise. * skip.c (debug_skip): Likewise. * solib-aix.c (solib_aix_debug): Likewise. * spu-tdep.c (spu_stop_on_load_p): Likewise. (spu_auto_flush_cache_p): Likewise. * stack.c (struct backtrace_cmd_options) <full, no_filters, hide>: Likewise. (struct info_print_options) <quiet>: Likewise. * symfile-debug.c (debug_symfile): Likewise. * symfile.c (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symfile.h (auto_solib_add): Likewise. (separate_debug_file_debug): Likewise. * symtab.c (basenames_may_differ): Likewise. (struct filename_partial_match_opts) <dirname, basename>: Likewise. (struct info_print_options) <quiet, exclude_minsyms>: Likewise. (struct info_types_options) <quiet>: Likewise. * symtab.h (demangle): Likewise. (basenames_may_differ): Likewise. * target-dcache.c (stack_cache_enabled_1): Likewise. (code_cache_enabled_1): Likewise. * target.c (trust_readonly): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. (auto_connect_native_target): Likewise. (target_stop_and_wait): Update. (target_async_permitted): Change to bool. (target_async_permitted_1): Likewise. (may_write_registers_1): Likewise. (may_write_memory_1): Likewise. (may_insert_breakpoints_1): Likewise. (may_insert_tracepoints_1): Likewise. (may_insert_fast_tracepoints_1): Likewise. (may_stop_1): Likewise. * target.h (target_async_permitted): Likewise. (may_write_registers): Likewise. (may_write_memory): Likewise. (may_insert_breakpoints): Likewise. (may_insert_tracepoints): Likewise. (may_insert_fast_tracepoints): Likewise. (may_stop): Likewise. * thread.c (struct info_threads_opts) <show_global_ids>: Likewise. (make_thread_apply_all_options_def_group): Change argument from int* to bool*. (thread_apply_all_command): Update. (print_thread_events): Change to bool. * top.c (confirm): Likewise. (command_editing_p): Likewise. (history_expansion_p): Likewise. (write_history_p): Likewise. (info_verbose): Likewise. * top.h (confirm): Likewise. (history_expansion_p): Likewise. * tracepoint.c (disconnected_tracing): Likewise. (circular_trace_buffer): Likewise. * typeprint.c (print_methods): Likewise. (print_typedefs): Likewise. * utils.c (debug_timestamp): Likewise. (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * utils.h (sevenbit_strings): Likewise. (pagination_enabled): Likewise. * valops.c (overload_resolution): Likewise. * valprint.h (struct value_print_options) <prettyformat_arrays, prettyformat_structs, vtblprint, unionprint, addressprint, objectprint, stop_print_at_null, print_array_indexes, deref_ref, static_field_print, pascal_static_field_print, raw, summary, symbol_print, finish_print>: Likewise. * windows-nat.c (new_console): Likewise. (cygwin_exceptions): Likewise. (new_group): Likewise. (debug_exec): Likewise. (debug_events): Likewise. (debug_memory): Likewise. (debug_exceptions): Likewise. (useshell): Likewise. * windows-tdep.c (maint_display_all_tib): Likewise. * xml-support.c (debug_xml): Likewise.
2019-09-14 21:36:58 +02:00
bool *var,
"set print raw frame-arguments" -> "set print raw-frame-arguments" A following patch will introduce options for the "backtrace" command, based on some "set print" and "set backtrace" settings. There's one setting in particular that is a bit annoying if we want to describe the backtrace options and the settings commands using the same data structures: "set print raw frame-arguments" The problem is that space between "raw" and "frame-arguments". Calling the option "bt -raw frame-arguments" would be odd. So I'm calling the option "bt -raw-frame-arguments" instead. And for consistency, this patch renames the set/show commands to: "set print raw-frame-arguments" "show print raw-frame-arguments" I.e., dash instead of space. The old commands are left in place, but marked deprecated. We need to adjust a couple testcases, because the relevant tests use gdb_test_no_output and the old commands are no longer silent: (gdb) set print raw frame-arguments on Warning: command 'set print raw frame-arguments' is deprecated. Use 'set print raw-frame-arguments'. gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * NEWS (Changed commands): Mention set/show print raw-frame-arguments, and that "set/show print raw frame-arguments" are now deprecated. * cli/cli-decode.c (add_setshow_boolean_cmd): Now returns the command. * command.h (add_setshow_boolean_cmd): Return cmd_list_element *. * stack.c (_initialize_stack): Install "set/show print raw-frame-arguments", and deprecate "set/show print raw frame-arguments". * valprint.c (_initialize_valprint): Deprecate "set/show print raw". gdb/doc/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.texinfo (Print Settings): Document "set/show print raw-frame-arguments" instead of "set/show print raw frame-arguments". gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.guile/scm-frame-args.exp: Use "set print raw-frame-arguments" instead of "set print raw frame-arguments". * gdb.python/py-frame-args.exp: Likewise.
2019-06-13 01:06:53 +02:00
const char *set_doc, const char *show_doc,
const char *help_doc,
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_filename_cmd (const char *name,
enum command_class theclass,
char **var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
2005-02-16 Andrew Cagney <cagney@gnu.org> Merge setshow print and show parameters. * command.h (show_value_ftype): Define. (deprecated_show_value_hack): Declare. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Change type of show_func to show_value_ftype. * cli/cli-decode.h (struct cmd_list_element): Replace fprint_setshow with show_value_func. * cli/cli-decode.c (add_setshow_cmd_full): Update show_func parameter. Set show_value_func. Do not set cmd_sfunc. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_uinteger_cmd) (add_setshow_zinteger_cmd): Update. * complaints.c (complaints_show_value): Replace fprint_setshow_complaints. (_initialize_complaints): Update. * mips-tdep.c (show_mask_address): Update. * arm-tdep.c (show_fp_model): Update. * cli/cli-setshow.c (do_setshow_command): Call show_value_func instead of fprint_setshow. Use deprecated_show_value_hack. (deprecated_show_value_hack): New function. * remote.c (add_packet_config_cmd, show_remote_cmd): (show_remote_protocol_P_packet_cmd) (show_remote_protocol_P_packet_cmd) (show_remote_protocol_Z_access_wp_packet_cmd) (show_remote_protocol_Z_hardware_bp_packet_cmd) (show_remote_protocol_Z_packet_cmd) (show_remote_protocol_Z_read_wp_packet_cmd) (show_remote_protocol_Z_software_bp_packet_cmd) (show_remote_protocol_Z_write_wp_packet_cmd) (show_remote_protocol_binary_download_cmd) (show_remote_protocol_p_packet_cmd) (show_remote_protocol_qPart_auxv_packet_cmd) (show_remote_protocol_qSymbol_packet_cmd) (show_remote_protocol_vcont_packet_cmd): Update.
2005-02-16 18:20:59 +01:00
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_string_cmd (const char *name,
enum command_class theclass,
char **var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
extern struct cmd_list_element *add_setshow_string_noescape_cmd
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
(const char *name,
enum command_class theclass,
char **var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_optional_filename_cmd (const char *name,
enum command_class theclass,
char **var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_integer_cmd (const char *name,
enum command_class theclass,
int *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_uinteger_cmd (const char *name,
enum command_class theclass,
unsigned int *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_zinteger_cmd (const char *name,
enum command_class theclass,
int *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
2003-08-09 Andrew Cagney <cagney@redhat.com> Fix GDB PR cli/926. * cli/cli-decode.c (add_setshow_uinteger_cmd): New function. * command.h (add_setshow_uinteger_cmd): Declare. * frame.c (set_backtrace_cmd): New function. (show_backtrace_cmd): New function. * frame.c (_initialize_frame): Replace "set/show backtrace-below-main" with "set/show backtrace past-main". Add command "set/show backtrace limit". (backtrace_past_main): Rename "backtrace_below_main". (backtrace_limit): New variable. (get_prev_frame): Update. Check the backtrace_limit. 2003-08-09 Andrew Cagney <cagney@redhat.com> * gdb.texinfo (Backtrace): Replace "set/show backtrace-below-main" with "set/show backtrace past-main" and "set/show backtrace limit". Index: doc/gdb.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v retrieving revision 1.174 diff -u -r1.174 gdb.texinfo --- doc/gdb.texinfo 8 Aug 2003 01:58:00 -0000 1.174 +++ doc/gdb.texinfo 9 Aug 2003 14:57:10 -0000 @@ -3922,27 +3922,40 @@ value, indicating that your program has stopped at the beginning of the code for line @code{993} of @code{builtin.c}. -@kindex set backtrace-below-main -@kindex show backtrace-below-main +@kindex set backtrace past-main +@kindex show backtrace past-main +@kindex set backtrace limit +@kindex show backtrace limit -Most programs have a standard entry point---a place where system libraries -and startup code transition into user code. For C this is @code{main}. -When @value{GDBN} finds the entry function in a backtrace it will terminate -the backtrace, to avoid tracing into highly system-specific (and generally -uninteresting) code. If you need to examine the startup code, then you can -change this behavior. +Most programs have a standard user entry point---a place where system +libraries and startup code transition into user code. For C this is +@code{main}. When @value{GDBN} finds the entry function in a backtrace +it will terminate the backtrace, to avoid tracing into highly +system-specific (and generally uninteresting) code. + +If you need to examine the startup code, or limit the number of levels +in a backtrace, you can change this behavior: @table @code -@item set backtrace-below-main off +@item set backtrace past-main +@itemx set backtrace past-main on +Backtraces will continue past the user entry point. + +@item set backtrace past-main off Backtraces will stop when they encounter the user entry point. This is the default. -@item set backtrace-below-main -@itemx set backtrace-below-main on -Backtraces will continue past the user entry point to the top of the stack. +@item show backtrace past-main +Display the current user entry point backtrace policy. + +@item set backtrace limit @var{n} +@itemx set backtrace limit 0 +@cindex backtrace limit +Limit the backtrace to @var{n} levels. A value of zero means +unlimited. -@item show backtrace-below-main -Display the current backtrace policy. +@item show backtrace limit +Display the current limit on backtrace levels. @end table @node Selection
2003-08-09 17:10:09 +02:00
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
extern void add_setshow_zuinteger_cmd (const char *name,
enum command_class theclass,
unsigned int *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
extern void
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
add_setshow_zuinteger_unlimited_cmd (const char *name,
enum command_class theclass,
int *var,
const char *set_doc,
const char *show_doc,
const char *help_doc,
Constify add_setshow_* This constifies the add_setshow_* family of functions, and then fixes up the fallout. The bulk of this patch was written by script. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * ada-lang.c (catch_ada_exception_command): Constify. (catch_assert_command): Constify. * break-catch-throw.c (catch_catch_command, catch_throw_command) (catch_rethrow_command): Constify. (catch_exception_command_1): Constify. * breakpoint.h (add_catch_command): Constify. * break-catch-syscall.c (catch_syscall_command_1): Constify. (catch_syscall_split_args): Constify. * break-catch-sig.c (catch_signal_command): Constify. (catch_signal_split_args): Constify. * cli/cli-decode.h (struct cmd_list_element) <function>: Use cmd_const_sfunc_ftype. * cli/cli-decode.c (add_setshow_cmd_full): Constify. (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, struct cmd_list_element) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd): Constify. (set_cmd_sfunc): Constify. (empty_sfunc): Constify. * command.h (add_setshow_enum_cmd, add_setshow_auto_boolean_cmd) (add_setshow_boolean_cmd, add_setshow_filename_cmd) (add_setshow_string_cmd, add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Constify. (set_cmd_sfunc): Constify. (cmd_sfunc_ftype): Remove. * compile/compile.c (set_compile_args): Constify. * infrun.c (set_disable_randomization): Constify. * infcmd.c (set_args_command, set_cwd_command): Constify. * breakpoint.c (set_condition_evaluation_mode): Constify. (add_catch_command): Constify. (catch_fork_command_1, catch_exec_command_1) (catch_load_command_1, catch_unload_command_1): Constify. (catch_load_or_unload): Constify. * guile/scm-param.c (pascm_set_func): Constify. (add_setshow_generic): Constify. * python/py-param.c (get_set_value): Constify. * top.h (set_verbose): Constify. * tui/tui-win.c (tui_set_var_cmd): Constify. * mi/mi-main.c (set_mi_async_command): Constify. * cli/cli-logging.c (set_logging_overwrite) (set_logging_redirect): Constify. * value.c (set_max_value_size): Constify. * valprint.c (set_input_radix, set_output_radix): Constify. * utils.c (set_width_command, set_height_command): Constify. * typeprint.c (set_print_type_methods, set_print_type_typedefs): Constify. * tracepoint.c (set_disconnected_tracing) (set_circular_trace_buffer, set_trace_buffer_size) (set_trace_user, set_trace_notes, set_trace_stop_notes): Constify. * top.c (set_history_size_command, set_verbose, set_editing) (set_gdb_datadir, set_history_filename): Constify. * target.c (set_targetdebug, maint_set_target_async_command) (maint_set_target_non_stop_command, set_target_permissions) (set_write_memory_permission): Constify. (open_target): Constify. * target-descriptions.c (set_tdesc_filename_cmd): Constify. * target-dcache.c (set_stack_cache, set_code_cache): Constify. * symtab.c (set_symbol_cache_size_handler): Constify. * symfile.c (set_ext_lang_command): Constify. * symfile-debug.c (set_debug_symfile): Constify. * source.c (set_directories_command): Constify. * solib.c (reload_shared_libraries, gdb_sysroot_changed): Constify. * serial.c (set_parity): Constify. * rs6000-tdep.c (powerpc_set_soft_float, powerpc_set_vector_abi): Constify. * remote.c (set_remote_exec_file, set_remotebreak) (set_remote_protocol_Z_packet_cmd, set_range_stepping): Constify. * record.c (set_record_insn_history_size) (set_record_call_history_size): Constify. * record-full.c (set_record_full_insn_max_num): Constify. * proc-api.c (set_procfs_trace_cmd, set_procfs_file_cmd): Constify. * osabi.c (set_osabi): Constify. * mips-tdep.c (set_mips64_transfers_32bit_regs) (reinit_frame_cache_sfunc, mips_abi_update): Constify. * maint.c (maintenance_set_profile_cmd): Constify. * linux-thread-db.c (set_libthread_db_search_path): Constify. * language.c (set_language_command, set_range_command) (set_case_command): Constify. * infrun.c (set_non_stop, set_observer_mode) (set_stop_on_solib_events, set_schedlock_func) (set_exec_direction_func): Constify. * infcmd.c (set_inferior_tty_command): Constify. * disasm.c (set_disassembler_options_sfunc): Constify. * demangle.c (set_demangling_command): Constify. * dcache.c (set_dcache_size, set_dcache_line_size): Constify. * cris-tdep.c (set_cris_version, set_cris_mode) (set_cris_dwarf2_cfi): Constify. * corefile.c (set_gnutarget_command): Constify. * charset.c (set_host_charset_sfunc, set_target_charset_sfunc) (set_target_wide_charset_sfunc): Constify. * breakpoint.c (update_dprintf_commands): Constify. * auto-load.c (set_auto_load_dir, set_auto_load_safe_path): Constify. * arm-tdep.c (set_fp_model_sfunc, arm_set_abi) (set_disassembly_style_sfunc): Constify. * arch-utils.c (set_endian, set_architecture): Constify. * alpha-tdep.c (reinit_frame_cache_sfunc): Constify. * agent.c (set_can_use_agent): Constify.
2017-10-14 17:07:00 +02:00
cmd_const_sfunc_ftype *set_func,
show_value_ftype *show_func,
struct cmd_list_element **set_list,
struct cmd_list_element **show_list);
/* Do a "show" command for each thing on a command list. */
Fix inconsistent output of prefix and bugs in 'show' command cmd_show_list function implements the 'show' command. cmd_show_list output is inconsistent: it sometimes shows a prefix and sometimes does not. For example, in the below, you see that there is a prefix before each value, except for 'enabled'. (gdb) show style style address background: The "address" style background color is: none style address foreground: The "address" style foreground color is: blue style address intensity: The "address" style display intensity is: normal enabled: CLI output styling is enabled. style filename background: The "filename" style background color is: none ... There are other inconsistencies or bugs e.g. in the below we see twice insn-number-max, once with a prefix and once without prefix : last line, just before the value of instruction-history-size which is itself without prefix. (gdb) show record record btrace bts buffer-size: The record/replay bts buffer size is 65536. record btrace cpu: btrace cpu is 'auto'. record btrace pt buffer-size: The record/replay pt buffer size is 16384. record btrace replay-memory-access: Replay memory access is read-only. record full insn-number-max: Record/replay buffer limit is 200000. record full memory-query: Whether query if PREC cannot record memory change of next instruction is off. record full stop-at-limit: Whether record/replay stops when record/replay buffer becomes full is on. function-call-history-size: Number of functions to print in "record function-call-history" is 10. insn-number-max: instruction-history-size: Number of instructions to print in "record instruction-history" is 10. (gdb) Also, some values are output several times due to some aliases, so avoid outputting duplicated values by skipping all aliases. Now that the command structure has a correct 'back-pointer' from a command to its prefix command, we can simplify cmd_show_list by removing its prefix argument and at the same time fix the output inconsistencies and bugs. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-setshow.h (cmd_show_list): Remove prefix argument. * cli/cli-decode.c (do_show_prefix_cmd): Likewise. * command.h (cmd_show_list): Likewise. * dwarf2/index-cache.c (show_index_cache_command): Likewise. * cli/cli-setshow.c (cmd_show_list): Use the prefix to produce the output. Skip aliases. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/default.exp: Update output following fixes.
2020-05-10 08:36:29 +02:00
extern void cmd_show_list (struct cmd_list_element *, int);
/* Used everywhere whenever at least one parameter is required and
none is specified. */
extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
Add previous_saved_command_line to allow a command to repeat a previous command. Currently, a previous command can be repeated when the user types an empty line. This is implemented in handle_line_of_input by returning saved_command_line in case an empty line has been input. If we want a command to repeat the previous command, we need to save the previous saved_command_line, as when a command runs, the saved_command_line already contains the current command line of the command being executed. As suggested by Tom, the previous_saved_command_line is made static. At the same time, saved_command_line is also made static. The support functions/variables for the repeat command logic are now all located inside top.c. gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.h (saved_command_line): Remove declaration. * top.c (previous_saved_command_line, previous_repeat_arguments): New variables. (saved_command_line): Make static, define together with other 'repeat variables'. (dont_repeat): Clear repeat_arguments. (repeat_previous, get_saved_command_line, save_command_line): New functions. (gdb_init): Initialize saved_command_line and previous_saved_command_line. * main.c (captured_main_1): Remove saved_command_line initialization. * event-top.c (handle_line_of_input): Update to use the new 'repeat' related functions instead of direct access to saved_command_line. * command.h (repeat_previous, get_saved_command_line, save_command_line): New declarations. (dont_repeat): Add comment.
2019-04-20 14:02:29 +02:00
/* Command line saving and repetition.
Each input line executed is saved to possibly be repeated either
when the user types an empty line, or be repeated by a command
that wants to repeat the previously executed command. The below
functions control command repetition. */
/* Commands call dont_repeat if they do not want to be repeated by null
lines or by repeat_previous (). */
extern void dont_repeat ();
Introduce the "with" command ( See original discussion and prototype here: https://sourceware.org/ml/gdb-patches/2019-05/msg00570.html ) (gdb) help with Temporarily set SETTING to VALUE, run COMMAND, and restore SETTING. Usage: with SETTING [VALUE] [-- COMMAND] Usage: w SETTING [VALUE] [-- COMMAND] With no COMMAND, repeats the last executed command. SETTING is any setting you can change with the "set" subcommands. E.g.: with language pascal -- print obj with print elements unlimited -- print obj As can be seen above, the "with" command is just like "set", but instead of setting the setting permanently, it sets the setting, runs a command and then restores the setting. (gdb) p g_s $1 = {a = 1, b = 2, c = 3} (gdb) with language ada -- print g_s $2 = (a => 1, b => 2, c => 3) Warning: the current language does not match this frame. (gdb) show language The current source language is "auto; currently c". (gdb) with print elements 100 -- with print object on -- print 1 $3 = 1 You can shorten things a bit though, as long as unambiguous. So this: (gdb) with print elements 100 -- with print object off -- print 1 is the same as: (gdb) w p el 100 -- w p o 0 -- p 1 Note that the patch adds a "w" alias for "with", as "w" is not currently taken: (gdb) w Ambiguous command "w": watch, wh, whatis, where, while, while-stepping, winheight, ws. Let me know if you'd prefer to reserve "w" for one of the other commands above. IMHO, this command will end up being used frequently enough that it deserves the "w" shorthand. A nice feature is that this is fully integrated with TAB-completion: (gdb) with p[TAB] pagination print prompt python (gdb) with print [TAB] address max-depth static-members array max-symbolic-offset symbol array-indexes null-stop symbol-filename asm-demangle object symbol-loading demangle pascal_static-members thread-events elements pretty type entry-values raw union frame-arguments repeats vtbl inferior-events sevenbit-strings (gdb) with print [TAB] (gdb) with print elements unlimited -- thread apply all -[TAB] -ascending -c -q -s (gdb) with print elements unlimited -- print -[TAB] -address -max-depth -repeats -vtbl -array -null-stop -static-members -array-indexes -object -symbol -elements -pretty -union The main advantage of this new command compared to command options, like the new "print -OPT", is that this command works with any setting, and, it works nicely when you want to override a setting while running a user-defined command, like: (gdb) with print pretty -- usercmd The disadvantage is that it isn't as compact or easy to type. I think of command options and this command as complementary. I think that even with this new command, it makes sense to continue developing the command options in the direction of exposing most-oft-used settings as command options. Inspired by Philippe's "/" command proposal, if no command is specified, then the last command is re-invoked, under the overridden setting: (gdb) p g_s $1 = {a = 1, b = 2, c = 3} (gdb) with language ada $2 = (a => 1, b => 2, c => 3) Warning: the current language does not match this frame. Note: "with" requires "--" to separate the setting from the command. It might be possible to do without that, but, I haven't tried it yet, and I think that this can go in without it. We can always downgrade to making "--" optional if we manage to make it work. On to the patch itself, the implementation of the command is simpler than one might expect. A few details: - I factored out a bit from pipe_command into repeat_previous directly, because otherwise I'd need to copy&paste the same code and same error message in the with command. - The parse_cli_var_uinteger / parse_cli_var_zuinteger_unlimited / do_set_command changes are necessary since we can now pass an empty string as argument. - do_show_command was split in two, as a FIXME comment suggests, but for a different reason: we need to get a string version of a "set" command's value, and we already had code for that in do_show_command. That code is now factored out to the new get_setshow_command_value_string function. - There's a new "maint with" command added too: (gdb) help maint with Like "with", but works with "maintenance set" variables. Usage: maintenance with SETTING [VALUE] [-- COMMAND] With no COMMAND, repeats the last executed command. SETTING is any setting you can change with the "maintenance set" subcommands. "with" and "maint with" share 99% of the implementation. This might be useful on its own, but it's also useful for testing, since with this, we can use the "maint set/show test-settings" settings for exercising the "with" machinery with all the command type variants (all enum var_types). This is done in the new gdb/base/with.exp testcase. The documentation bits are originally based on Philippe's docs for the "/" command, hence the attribution in the ChangeLog. gdb/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "with" and "maint with". * cli/cli-cmds.c (with_command_1, with_command_completer_1) (with_command, with_command_completer): New. (pipe_command): Adjust to new repeat_previous interface. (_initialize_cli_cmds): Install the "with" command and its "w" alias. * cli/cli-cmds.h (with_command_1, with_command_completer_1): New declarations. * cli/cli-setshow.c (parse_cli_var_uinteger) (parse_cli_var_zuinteger_unlimited, do_set_command): Handle empty argument strings for all var_types. (get_setshow_command_value_string): New, factored out from ... (do_show_command): ... this. * cli/cli-setshow.h: Include <string>. (get_setshow_command_value_string): Declare. * command.h (repeat_previous): Now returns const char *. Adjust comment. * maint.c: Include "cli/cli-cmds.h". (maintenance_with_cmd, maintenance_with_cmd_completer): New. (_initialize_maint_cmds): Register the "maintenance with" command. * top.c (repeat_previous): Move bits from pipe_command here: Return the saved command line, if any; error out if there's no command to relaunch. gdb/doc/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Command Settings): New node documenting the general concept of settings, how to change them, and the new "with" command. (Maintenance Commands): Document "maint with". gdb/testsuite/ChangeLog: 2019-07-03 Pedro Alves <palves@redhat.com> * gdb.base/with.c: New file. * gdb.base/with.exp: New file.
2019-07-03 14:34:20 +02:00
/* Commands call repeat_previous if they want to repeat the previous
command. Such commands that repeat the previous command must
indicate to not repeat themselves, to avoid recursive repeat.
repeat_previous marks the current command as not repeating, and
ensures get_saved_command_line returns the previous command, so
that the currently executing command can repeat it. If there's no
previous command, throws an error. Otherwise, returns the result
of get_saved_command_line, which now points at the command to
repeat. */
extern const char *repeat_previous ();
Add previous_saved_command_line to allow a command to repeat a previous command. Currently, a previous command can be repeated when the user types an empty line. This is implemented in handle_line_of_input by returning saved_command_line in case an empty line has been input. If we want a command to repeat the previous command, we need to save the previous saved_command_line, as when a command runs, the saved_command_line already contains the current command line of the command being executed. As suggested by Tom, the previous_saved_command_line is made static. At the same time, saved_command_line is also made static. The support functions/variables for the repeat command logic are now all located inside top.c. gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.h (saved_command_line): Remove declaration. * top.c (previous_saved_command_line, previous_repeat_arguments): New variables. (saved_command_line): Make static, define together with other 'repeat variables'. (dont_repeat): Clear repeat_arguments. (repeat_previous, get_saved_command_line, save_command_line): New functions. (gdb_init): Initialize saved_command_line and previous_saved_command_line. * main.c (captured_main_1): Remove saved_command_line initialization. * event-top.c (handle_line_of_input): Update to use the new 'repeat' related functions instead of direct access to saved_command_line. * command.h (repeat_previous, get_saved_command_line, save_command_line): New declarations. (dont_repeat): Add comment.
2019-04-20 14:02:29 +02:00
/* Prevent dont_repeat from working, and return a cleanup that
restores the previous state. */
extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
/* Set the arguments that will be passed if the current command is
repeated. Note that the passed-in string must be a constant. */
extern void set_repeat_arguments (const char *args);
Add previous_saved_command_line to allow a command to repeat a previous command. Currently, a previous command can be repeated when the user types an empty line. This is implemented in handle_line_of_input by returning saved_command_line in case an empty line has been input. If we want a command to repeat the previous command, we need to save the previous saved_command_line, as when a command runs, the saved_command_line already contains the current command line of the command being executed. As suggested by Tom, the previous_saved_command_line is made static. At the same time, saved_command_line is also made static. The support functions/variables for the repeat command logic are now all located inside top.c. gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.h (saved_command_line): Remove declaration. * top.c (previous_saved_command_line, previous_repeat_arguments): New variables. (saved_command_line): Make static, define together with other 'repeat variables'. (dont_repeat): Clear repeat_arguments. (repeat_previous, get_saved_command_line, save_command_line): New functions. (gdb_init): Initialize saved_command_line and previous_saved_command_line. * main.c (captured_main_1): Remove saved_command_line initialization. * event-top.c (handle_line_of_input): Update to use the new 'repeat' related functions instead of direct access to saved_command_line. * command.h (repeat_previous, get_saved_command_line, save_command_line): New declarations. (dont_repeat): Add comment.
2019-04-20 14:02:29 +02:00
/* Returns the saved command line to repeat.
When a command is being executed, this is the currently executing
command line, unless the currently executing command has called
repeat_previous (): in this case, get_saved_command_line returns
the previously saved command line. */
extern char *get_saved_command_line ();
/* Takes a copy of CMD, for possible repetition. */
extern void save_command_line (const char *cmd);
/* Used to mark commands that don't do anything. If we just leave the
function field NULL, the command is interpreted as a help topic, or
as a class of commands. */
extern void not_just_help_class_command (const char *, int);
/* Check function pointer. */
extern int cmd_func_p (struct cmd_list_element *cmd);
/* Call the command function. */
extern void cmd_func (struct cmd_list_element *cmd,
Constify execute_command This constifies execute_command and fixes up the callers. gdb/ChangeLog 2017-11-07 Tom Tromey <tom@tromey.com> * event-top.h (command_handler): Constify. * record-full.c (cmd_record_full_start): Update. * thread.c (thread_apply_all_command): Update. * printcmd.c (eval_command): Update. * mi/mi-main.c (mi_execute_cli_command): Update. (mi_execute_async_cli_command): Update. * tui/tui-stack.c (tui_update_command): Update. * cli/cli-interp.c (safe_execute_command): Constify. * record.c (record_start): Update. (record_start, record_stop, cmd_record_start): Update. * record-btrace.c (cmd_record_btrace_bts_start): Update. (cmd_record_btrace_pt_start): Update. (cmd_record_btrace_start): Update. (cmd_record_btrace_start): Update. * reverse.c (exec_reverse_once): Update. * python/python.c (execute_gdb_command): Don't copy the command. * event-top.c (command_line_handler): Update. (command_handler): Constify. * defs.h (deprecated_call_command_hook): Constify. * cli/cli-script.h (execute_user_command): Constify. * cli/cli-script.c (execute_user_command): Constify. (execute_cmd_pre_hook, execute_cmd_post_hook): Constify. (enum command_control_type): Update. * main.c (catch_command_errors): Remove non-const overload. (catch_command_errors_ftype): Remove. * python/py-cmd.c (cmdpy_function): Constify. * guile/scm-cmd.c (cmdscm_function): Constify. * cli/cli-dump.c (call_dump_func): Constify. * cli/cli-decode.c (do_const_cfunc): Constify. (do_sfunc): Constify. (cmd_func): Constify. * gdbcmd.h (execute_command, execute_command_to_string): Constify. * top.h (execute_command): Constify. * top.c (execute_command): Constify. (execute_command_to_string): Constify. (deprecated_call_command_hook): Constify. * command.h (cmd_func): Constify. * cli/cli-decode.h (struct cmd_list_element) <func>: Constify.
2017-10-15 16:36:51 +02:00
const char *args, int from_tty);
#endif /* !defined (COMMAND_H) */