Skip to content

Commit 188e1fa

Browse files
committed
Add usage for commands in printcmd.c
I noticed that the help for "info addr" did not include a "usage" line; and when adding it I went through and fixed a few minor issues in printcmd.c: * Added usage lines to all commands * Updated the help text for some commands * Changed some help to use upper case metasyntactic variables * Removed some dead code Regression tested on x86-64 Fedora 29. gdb/ChangeLog 2019-03-29 Tom Tromey <tromey@adacore.com> * printcmd.c (_initialize_printcmd): Add usage lines. Update some help text. Remove dead code. gdb/testsuite/ChangeLog 2019-03-29 Tom Tromey <tromey@adacore.com> * gdb.base/help.exp: Tighten apropos regexp.
1 parent 2880242 commit 188e1fa

File tree

4 files changed

+47
-24
lines changed

4 files changed

+47
-24
lines changed

gdb/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-03-29 Tom Tromey <tromey@adacore.com>
2+
3+
* printcmd.c (_initialize_printcmd): Add usage lines. Update some
4+
help text. Remove dead code.
5+
16
2019-03-29 Keith Seitz <keiths@redhat.com>
27

38
From Siddhesh Poyarekar:

gdb/printcmd.c

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,10 +2652,12 @@ _initialize_printcmd (void)
26522652
gdb::observers::free_objfile.attach (clear_dangling_display_expressions);
26532653

26542654
add_info ("address", info_address_command,
2655-
_("Describe where symbol SYM is stored."));
2655+
_("Describe where symbol SYM is stored.\n\
2656+
Usage: info address SYM"));
26562657

26572658
add_info ("symbol", info_symbol_command, _("\
26582659
Describe what symbol is at location ADDR.\n\
2660+
Usage: info symbol ADDR\n\
26592661
Only for symbols with fixed locations (global or static scope)."));
26602662

26612663
add_com ("x", class_vars, x_command, _("\
@@ -2673,16 +2675,13 @@ Defaults for format and size letters are those previously used.\n\
26732675
Default count is 1. Default address is following last thing printed\n\
26742676
with this command or \"print\"."));
26752677

2676-
#if 0
2677-
add_com ("whereis", class_vars, whereis_command,
2678-
_("Print line number and file of definition of variable."));
2679-
#endif
2680-
26812678
add_info ("display", info_display_command, _("\
2682-
Expressions to display when program stops, with code numbers."));
2679+
Expressions to display when program stops, with code numbers.\n\
2680+
Usage: info display"));
26832681

26842682
add_cmd ("undisplay", class_vars, undisplay_command, _("\
26852683
Cancel some expressions to be displayed when program stops.\n\
2684+
Usage: undisplay [NUM]...\n\
26862685
Arguments are the code numbers of the expressions to stop displaying.\n\
26872686
No argument means cancel all automatic-display expressions.\n\
26882687
\"delete display\" has the same effect as this command.\n\
@@ -2691,6 +2690,7 @@ Do \"info display\" to see current list of code numbers."),
26912690

26922691
add_com ("display", class_vars, display_command, _("\
26932692
Print value of expression EXP each time the program stops.\n\
2693+
Usage: display[/FMT] EXP\n\
26942694
/FMT may be used before EXP as in the \"print\" command.\n\
26952695
/FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
26962696
as in the \"x\" command, and then EXP is used to get the address to examine\n\
@@ -2700,35 +2700,41 @@ Use \"undisplay\" to cancel display requests previously made."));
27002700

27012701
add_cmd ("display", class_vars, enable_display_command, _("\
27022702
Enable some expressions to be displayed when program stops.\n\
2703+
Usage: enable display [NUM]...\n\
27032704
Arguments are the code numbers of the expressions to resume displaying.\n\
27042705
No argument means enable all automatic-display expressions.\n\
27052706
Do \"info display\" to see current list of code numbers."), &enablelist);
27062707

27072708
add_cmd ("display", class_vars, disable_display_command, _("\
27082709
Disable some expressions to be displayed when program stops.\n\
2710+
Usage: disable display [NUM]...\n\
27092711
Arguments are the code numbers of the expressions to stop displaying.\n\
27102712
No argument means disable all automatic-display expressions.\n\
27112713
Do \"info display\" to see current list of code numbers."), &disablelist);
27122714

27132715
add_cmd ("display", class_vars, undisplay_command, _("\
27142716
Cancel some expressions to be displayed when program stops.\n\
2717+
Usage: delete display [NUM]...\n\
27152718
Arguments are the code numbers of the expressions to stop displaying.\n\
27162719
No argument means cancel all automatic-display expressions.\n\
27172720
Do \"info display\" to see current list of code numbers."), &deletelist);
27182721

27192722
add_com ("printf", class_vars, printf_command, _("\
27202723
Formatted printing, like the C \"printf\" function.\n\
2721-
Usage: printf \"format string\", arg1, arg2, arg3, ..., argn\n\
2724+
Usage: printf \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\
27222725
This supports most C printf format specifications, like %s, %d, etc."));
27232726

27242727
add_com ("output", class_vars, output_command, _("\
27252728
Like \"print\" but don't put in value history and don't print newline.\n\
2729+
Usage: output EXP\n\
27262730
This is useful in user-defined commands."));
27272731

27282732
add_prefix_cmd ("set", class_vars, set_command, _("\
2729-
Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2730-
syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2731-
example). VAR may be a debugger \"convenience\" variable (names starting\n\
2733+
Evaluate expression EXP and assign result to variable VAR\n\
2734+
Usage: set VAR = EXP\n\
2735+
This uses assignment syntax appropriate for the current language\n\
2736+
(VAR = EXP or VAR := EXP for example).\n\
2737+
VAR may be a debugger \"convenience\" variable (names starting\n\
27322738
with $), a register (a few standard names starting with $), or an actual\n\
27332739
variable in the program being debugged. EXP is any valid expression.\n\
27342740
Use \"set variable\" for variables with names identical to set subcommands.\n\
@@ -2738,9 +2744,11 @@ You can see these environment settings with the \"show\" command."),
27382744
&setlist, "set ", 1, &cmdlist);
27392745
if (dbx_commands)
27402746
add_com ("assign", class_vars, set_command, _("\
2741-
Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2742-
syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2743-
example). VAR may be a debugger \"convenience\" variable (names starting\n\
2747+
Evaluate expression EXP and assign result to variable VAR\n\
2748+
Usage: assign VAR = EXP\n\
2749+
This uses assignment syntax appropriate for the current language\n\
2750+
(VAR = EXP or VAR := EXP for example).\n\
2751+
VAR may be a debugger \"convenience\" variable (names starting\n\
27442752
with $), a register (a few standard names starting with $), or an actual\n\
27452753
variable in the program being debugged. EXP is any valid expression.\n\
27462754
Use \"set variable\" for variables with names identical to set subcommands.\n\
@@ -2750,15 +2758,18 @@ You can see these environment settings with the \"show\" command."));
27502758
/* "call" is the same as "set", but handy for dbx users to call fns. */
27512759
c = add_com ("call", class_vars, call_command, _("\
27522760
Call a function in the program.\n\
2761+
Usage: call EXP\n\
27532762
The argument is the function name and arguments, in the notation of the\n\
27542763
current working language. The result is printed and saved in the value\n\
27552764
history, if it is not void."));
27562765
set_cmd_completer (c, expression_completer);
27572766

27582767
add_cmd ("variable", class_vars, set_command, _("\
2759-
Evaluate expression EXP and assign result to variable VAR, using assignment\n\
2760-
syntax appropriate for the current language (VAR = EXP or VAR := EXP for\n\
2761-
example). VAR may be a debugger \"convenience\" variable (names starting\n\
2768+
Evaluate expression EXP and assign result to variable VAR\n\
2769+
Usage: set variable VAR = EXP\n\
2770+
This uses assignment syntax appropriate for the current language\n\
2771+
(VAR = EXP or VAR := EXP for example).\n\
2772+
VAR may be a debugger \"convenience\" variable (names starting\n\
27622773
with $), a register (a few standard names starting with $), or an actual\n\
27632774
variable in the program being debugged. EXP is any valid expression.\n\
27642775
This may usually be abbreviated to simply \"set\"."),
@@ -2767,6 +2778,7 @@ This may usually be abbreviated to simply \"set\"."),
27672778

27682779
c = add_com ("print", class_vars, print_command, _("\
27692780
Print value of expression EXP.\n\
2781+
Usage: print[/FMT] EXP\n\
27702782
Variables accessible are those of the lexical environment of the selected\n\
27712783
stack frame, plus all those whose scope is global or an entire file.\n\
27722784
\n\
@@ -2793,8 +2805,8 @@ but no count or size letter (see \"x\" command)."));
27932805

27942806
add_setshow_uinteger_cmd ("max-symbolic-offset", no_class,
27952807
&max_symbolic_offset, _("\
2796-
Set the largest offset that will be printed in <symbol+1234> form."), _("\
2797-
Show the largest offset that will be printed in <symbol+1234> form."), _("\
2808+
Set the largest offset that will be printed in <SYMBOL+1234> form."), _("\
2809+
Show the largest offset that will be printed in <SYMBOL+1234> form."), _("\
27982810
Tell GDB to only display the symbolic form of an address if the\n\
27992811
offset between the closest earlier symbol and the address is less than\n\
28002812
the specified maximum offset. The default is \"unlimited\", which tells GDB\n\
@@ -2805,13 +2817,15 @@ it. Zero is equivalent to \"unlimited\"."),
28052817
&setprintlist, &showprintlist);
28062818
add_setshow_boolean_cmd ("symbol-filename", no_class,
28072819
&print_symbol_filename, _("\
2808-
Set printing of source filename and line number with <symbol>."), _("\
2809-
Show printing of source filename and line number with <symbol>."), NULL,
2820+
Set printing of source filename and line number with <SYMBOL>."), _("\
2821+
Show printing of source filename and line number with <SYMBOL>."), NULL,
28102822
NULL,
28112823
show_print_symbol_filename,
28122824
&setprintlist, &showprintlist);
28132825

28142826
add_com ("eval", no_class, eval_command, _("\
2815-
Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
2816-
a command line, and call it."));
2827+
Construct a GDB command and then evaluate it.\n\
2828+
Usage: eval \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\
2829+
Convert the arguments to a string as \"printf\" would, but then\n\
2830+
treat this string as a command line, and evaluate it."));
28172831
}

gdb/testsuite/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019-03-29 Tom Tromey <tromey@adacore.com>
2+
3+
* gdb.base/help.exp: Tighten apropos regexp.
4+
15
2019-03-29 Keith Seitz <keiths@redhat.com>
26

37
* gdb.fortran/array-bounds.exp: New file.

gdb/testsuite/gdb.base/help.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ gdb_test "help info bogus-gdb-command" "Undefined info command: \"bogus-gdb-comm
120120
gdb_test "help gotcha" "Undefined command: \"gotcha\"\. Try \"help\"\." "help gotcha"
121121

122122
# test apropos regex
123-
gdb_test "apropos \\\(print\[\^ bsiedf\\\".-\]\\\)" "handle -- Specify how to handle signals"
123+
gdb_test "apropos \\\(print\[\^\[ bsiedf\\\".-\]\\\)" "handle -- Specify how to handle signals"
124124
# test apropos >1 word string
125125
gdb_test "apropos handle signal" "handle -- Specify how to handle signals"
126126
# test apropos apropos

0 commit comments

Comments
 (0)