diff options
author | Pedro Alves <palves@redhat.com> | 2013-04-10 15:11:12 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2013-04-10 15:11:12 +0000 |
commit | f81d112039fa5c836e446d8f79331fdaa35d76ab (patch) | |
tree | 7f629e7ff028ac4c5eadfd3ba5777203615d0d1f /gdb/cli | |
parent | 2f9d54cfcef6c6085ff4bfcbf42c963527606d89 (diff) | |
download | gdb-f81d112039fa5c836e446d8f79331fdaa35d76ab.zip gdb-f81d112039fa5c836e446d8f79331fdaa35d76ab.tar.gz gdb-f81d112039fa5c836e446d8f79331fdaa35d76ab.tar.bz2 |
Accept "set foo unlimited" in integer/uinteger/zuinteger_unlimited commands.
Currently, several commands take "0" or "-1" to mean "unlimited".
"show" knows when to print "unlimited":
(gdb) show height
Number of lines gdb thinks are in a page is 45.
(gdb) set height 0
(gdb) show height
Number of lines gdb thinks are in a page is unlimited.
However, the user can't herself specify "unlimited" directly:
(gdb) set height unlimited
No symbol table is loaded. Use the "file" command.
(gdb)
This patch addresses that, by adjusting the set handler for all
integer/uinteger/zuinteger_unlimited commands to accept literal
"unlimited". It also installs a completer. Presently, we complete on
symbols by default, and at
<http://sourceware.org/ml/gdb-patches/2013-03/msg00864.html> I've
shown a WIP prototype that tried to keep that half working in these
commands. In the end, it turned out to be more complicated than
justifiable, IMO. It's super rare to want to pass the value of a
variable/symbol in the program to a GDB set/show knob. That'll still
work, it's just that we won't assist with completion anymore. This
patch just sticks with the simple, and completes on "unlimited", and
nothing else. This simplification means that
"set he<tab><tab>"
is all it takes to get to:
"set height unlimited"
The patch then goes through all integer/uinteger/zuinteger_unlimited
commands in the tree, and updates both the online help and the manual
to mention that "unlimited" is accepted in addition to 0/-1. In the
cases where the command had no online help text at all, this adds it.
I've tried to make the texts read in a way that "unlimited" is
suggested before "0" or "-1" is.
Tested on x86_64 Fedora 17.
gdb/
2013-04-10 Pedro Alves <palves@redhat.com>
* cli/cli-decode.c (integer_unlimited_completer): New function.
(add_setshow_integer_cmd, add_setshow_uinteger_cmd)
(add_setshow_zuinteger_unlimited_cmd): Install the "unlimited"
completer.
* cli/cli-setshow.c: Include "cli/cli-utils.h".
(is_unlimited_literal): New function.
(do_set_command): Handle literal "unlimited" arguments.
* frame.c (_initialize_frame) <set backtrace limit>: Document
"unlimited".
* printcmd.c (_initialize_printcmd) <set print
max-symbolic-offset>: Add help text.
* record-full.c (_initialize_record_full) <set record full
insn-number-max>: Likewise.
* record.c (_initialize_record) <set record
instruction-history-size, set record function-call-history-size>:
Add help text.
* ser-tcp.c (_initialize_ser_tcp) <set tcp connect-timeout>: Add
help text.
* tracepoint.c (_initialize_tracepoint) <set trace-buffer-size>:
Likewise.
* source.c (_initialize_source) <set listsize>: Add help text.
* utils.c (initialize_utils) <set height, set width>: Likewise.
<set pagination>: Mention "set height unlimited".
* valprint.c (_initialize_valprint) <set print elements, set print
repeats>: Document "unlimited".
gdb/doc/
2013-04-10 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Process Record and Replay): Document that "set
record full insn-number-max", "set record
instruction-history-size" and "set record
function-call-history-size" accept "unlimited".
(Backtrace): Document that "set backtrace limit" accepts
"unlimited".
(List): Document that "set listsize" accepts "unlimited".
(Print Settings)" Document that "set print max-symbolic-offset",
"set print elements" and "set print repeats" accept "unlimited".
(Starting and Stopping Trace Experiments): Document that "set
trace-buffer-size" accepts "unlimited".
(Remote Configuration): Document that "set tcp connect-timeout"
accepts "unlimited".
(Command History): Document that "set history size" accepts
"unlimited".
(Screen Size): Document that "set height" and "set width" accepts
"unlimited". Adjust "set pagination"'s description to suggest
"set height unlimited" instead of "set height 0".
gdb/testsuite/
2013-04-10 Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp: Test "set height", "set listsize" and
"set trace-buffer-size" completion.
* gdb.base/setshow.exp: Test "set height unlimited".
* gdb.trace/trace-buffer-size.exp: Test "set trace-buffer-size
unlimited".
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-decode.c | 34 | ||||
-rw-r--r-- | gdb/cli/cli-setshow.c | 49 |
2 files changed, 74 insertions, 9 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 61a7b5a..9bc14b5 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -638,6 +638,22 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class class, } +/* Completes on literal "unlimited". Used by integer commands that + support a special "unlimited" value. */ + +static VEC (char_ptr) * +integer_unlimited_completer (struct cmd_list_element *ignore, + const char *text, const char *word) +{ + static const char * const keywords[] = + { + "unlimited", + NULL, + }; + + return complete_on_enum (keywords, text, word); +} + /* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). CLASS is as in add_cmd. VAR is address of the variable which will contain the @@ -653,11 +669,15 @@ add_setshow_integer_cmd (const char *name, enum command_class class, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { + struct cmd_list_element *set; + add_setshow_cmd_full (name, class, var_integer, var, set_doc, show_doc, help_doc, set_func, show_func, set_list, show_list, - NULL, NULL); + &set, NULL); + + set_cmd_completer (set, integer_unlimited_completer); } /* Add element named NAME to both the set and show command LISTs (the @@ -674,11 +694,15 @@ add_setshow_uinteger_cmd (const char *name, enum command_class class, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { + struct cmd_list_element *set; + add_setshow_cmd_full (name, class, var_uinteger, var, set_doc, show_doc, help_doc, set_func, show_func, set_list, show_list, - NULL, NULL); + &set, NULL); + + set_cmd_completer (set, integer_unlimited_completer); } /* Add element named NAME to both the set and show command LISTs (the @@ -714,11 +738,15 @@ add_setshow_zuinteger_unlimited_cmd (const char *name, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { + struct cmd_list_element *set; + add_setshow_cmd_full (name, class, var_zuinteger_unlimited, var, set_doc, show_doc, help_doc, set_func, show_func, set_list, show_list, - NULL, NULL); + &set, NULL); + + set_cmd_completer (set, integer_unlimited_completer); } /* Add element named NAME to both the set and show command LISTs (the diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index f612369..3e41fd4 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -28,6 +28,7 @@ #include "cli/cli-decode.h" #include "cli/cli-cmds.h" #include "cli/cli-setshow.h" +#include "cli/cli-utils.h" /* Return true if the change of command parameter should be notified. */ @@ -127,6 +128,20 @@ deprecated_show_value_hack (struct ui_file *ignore_file, } } +/* Returns true if ARG is "unlimited". */ + +static int +is_unlimited_literal (const char *arg) +{ + size_t len = sizeof ("unlimited") - 1; + + arg = skip_spaces_const (arg); + + return (strncmp (arg, "unlimited", len) == 0 + && (isspace (arg[len]) || arg[len] == '\0')); +} + + /* Do a "set" command. ARG is NULL if no argument, or the text of the argument, and FROM_TTY is nonzero if this command is being entered directly by the user (i.e. these are just like any @@ -273,8 +288,17 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) LONGEST val; if (arg == NULL) - error_no_arg (_("integer to set it to.")); - val = parse_and_eval_long (arg); + { + if (c->var_type == var_uinteger) + error_no_arg (_("integer to set it to, or \"unlimited\".")); + else + error_no_arg (_("integer to set it to.")); + } + + if (c->var_type == var_uinteger && is_unlimited_literal (arg)) + val = 0; + else + val = parse_and_eval_long (arg); if (c->var_type == var_uinteger && val == 0) val = UINT_MAX; @@ -300,8 +324,17 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) LONGEST val; if (arg == NULL) - error_no_arg (_("integer to set it to.")); - val = parse_and_eval_long (arg); + { + if (c->var_type == var_integer) + error_no_arg (_("integer to set it to, or \"unlimited\".")); + else + error_no_arg (_("integer to set it to.")); + } + + if (c->var_type == var_integer && is_unlimited_literal (arg)) + val = 0; + else + val = parse_and_eval_long (arg); if (val == 0 && c->var_type == var_integer) val = INT_MAX; @@ -396,8 +429,12 @@ do_set_command (char *arg, int from_tty, struct cmd_list_element *c) LONGEST val; if (arg == NULL) - error_no_arg (_("integer to set it to.")); - val = parse_and_eval_long (arg); + error_no_arg (_("integer to set it to, or \"unlimited\".")); + + if (is_unlimited_literal (arg)) + val = -1; + else + val = parse_and_eval_long (arg); if (val > INT_MAX) error (_("integer %s out of range"), plongest (val)); |