binutils-gdb/gdb/cli/cli-setshow.h
Philippe Waroquiers 7aa1b46f43 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-15 22:17:45 +02:00

66 lines
2.7 KiB
C++

/* Header file for GDB CLI set and show commands implementation.
Copyright (C) 2000-2020 Free Software Foundation, Inc.
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
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef CLI_CLI_SETSHOW_H
#define CLI_CLI_SETSHOW_H
#include <string>
struct cmd_list_element;
/* Parse ARG, an option to a boolean variable.
Returns 1 for true, 0 for false, and -1 if invalid. */
extern int parse_cli_boolean_value (const char *arg);
/* Same as above, but work with a pointer to pointer. ARG is advanced
past a successfully parsed value. */
extern int parse_cli_boolean_value (const char **arg);
/* Parse ARG, an option to a var_uinteger or var_zuinteger variable.
Either returns the parsed value on success or throws an error. If
EXPRESSION is true, *ARG is parsed as an expression; otherwise, it
is parsed with get_ulongest. It's not possible to parse the
integer as an expression when there may be valid input after the
integer, such as when parsing command options. E.g., "print
-elements NUMBER -obj --". In such case, parsing as an expression
would parse "-obj --" as part of the expression as well. */
extern unsigned int parse_cli_var_uinteger (var_types var_type,
const char **arg,
bool expression);
/* Like parse_cli_var_uinteger, for var_zuinteger_unlimited. */
extern int parse_cli_var_zuinteger_unlimited (const char **arg,
bool expression);
/* Parse ARG, an option to a var_enum variable. ENUM is a
null-terminated array of possible values. Either returns the parsed
value on success or throws an error. ARG is advanced past the
parsed value. */
const char *parse_cli_var_enum (const char **args,
const char *const *enums);
extern void do_set_command (const char *arg, int from_tty,
struct cmd_list_element *c);
extern void do_show_command (const char *arg, int from_tty,
struct cmd_list_element *c);
/* Get a string version of C's current value. */
extern std::string get_setshow_command_value_string (const cmd_list_element *c);
extern void cmd_show_list (struct cmd_list_element *list, int from_tty);
#endif /* CLI_CLI_SETSHOW_H */