diff mbox

[1/3] deprecate "skip enable/etc.", doc string cleanup

Message ID 485b3978bc7f02ed740530c3e219@google.com
State New
Headers show

Commit Message

Doug Evans April 18, 2016, 3:19 p.m. UTC
This patch creates some macros for use in enable/disable/delete doc strings
and then uses them in breakpoint.c.

2016-04-17  Doug Evans  <dje@google.com>

	* breakpoint.h (EDDI_USAGE_DOC_STRING, EDD_DOC_STRING): New macros.
	(ENABLE_DOC_STRING, DISABLE_DOC_STRING, DELETE_DOC_STRING): New macros.
	* breakpoint.c (_initialize_breakpoint): Use new macros.


  /* Type of breakpoint.  */

Comments

Eli Zaretskii April 18, 2016, 6:39 p.m. UTC | #1
> Date: Mon, 18 Apr 2016 15:19:12 +0000
> From: Doug Evans <dje@google.com>
> 
> This patch creates some macros for use in enable/disable/delete doc strings
> and then uses them in breakpoint.c.

Is it really a good idea?  It seems to obfuscate the doc strings.
diff mbox

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f99a7ab..62bc3dd 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -16209,87 +16209,99 @@  so it will be deleted when hit.\n\
  BREAK_ARGS_HELP ("thbreak")));
    set_cmd_completer (c, location_completer);

-  add_prefix_cmd ("enable", class_breakpoint, enable_command, _("\
-Enable some breakpoints.\n\
-Give breakpoint numbers (separated by spaces) as arguments.\n\
-With no subcommand, breakpoints are enabled until you command otherwise.\n\
+  add_prefix_cmd ("enable", class_breakpoint, enable_command, _(
+ENABLE_DOC_STRING ("breakpoint", "enable")
+"\n\
  This is used to cancel the effect of the \"disable\" command.\n\
  With a subcommand you can enable temporarily."),
  		  &enablelist, "enable ", 1, &cmdlist);

    add_com_alias ("en", "enable", class_breakpoint, 1);

-  add_prefix_cmd ("breakpoints", class_breakpoint, enable_command, _("\
-Enable some breakpoints.\n\
-Give breakpoint numbers (separated by spaces) as arguments.\n\
+  add_prefix_cmd ("breakpoints", class_breakpoint, enable_command, _(
+ENABLE_DOC_STRING ("breakpoint", "enable breakpoints")
+"\n\
  This is used to cancel the effect of the \"disable\" command.\n\
-May be abbreviated to simply \"enable\".\n"),
+May be abbreviated to simply \"enable\"."),
  		   &enablebreaklist, "enable breakpoints ", 1, &enablelist);

    add_cmd ("once", no_class, enable_once_command, _("\
-Enable breakpoints for one hit.  Give breakpoint numbers.\n\
+Enable breakpoints for one hit.\n"
+EDDI_USAGE_DOC_STRING ("enable breakpoints once")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion, it becomes  
disabled."),
  	   &enablebreaklist);

    add_cmd ("delete", no_class, enable_delete_command, _("\
-Enable breakpoints and delete when hit.  Give breakpoint numbers.\n\
+Enable breakpoints and delete when hit.\n"
+EDDI_USAGE_DOC_STRING ("enable breakpoints delete")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion, it is deleted."),
  	   &enablebreaklist);

    add_cmd ("count", no_class, enable_count_command, _("\
-Enable breakpoints for COUNT hits.  Give count and then breakpoint  
numbers.\n\
+Enable breakpoints for COUNT hits.\n"
+EDDI_USAGE_DOC_STRING ("enable breakpoints count COUNT")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion,\n\
  the count is decremented; when it reaches zero, the breakpoint is  
disabled."),
  	   &enablebreaklist);

    add_cmd ("delete", no_class, enable_delete_command, _("\
-Enable breakpoints and delete when hit.  Give breakpoint numbers.\n\
+Enable breakpoints and delete when hit.\n"
+EDDI_USAGE_DOC_STRING ("enable delete")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion, it is deleted."),
  	   &enablelist);

    add_cmd ("once", no_class, enable_once_command, _("\
-Enable breakpoints for one hit.  Give breakpoint numbers.\n\
+Enable breakpoints for one hit.\n"
+EDDI_USAGE_DOC_STRING ("enable once")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion, it becomes  
disabled."),
  	   &enablelist);

    add_cmd ("count", no_class, enable_count_command, _("\
-Enable breakpoints for COUNT hits.  Give count and then breakpoint  
numbers.\n\
+Enable breakpoints for COUNT hits.\n"
+EDDI_USAGE_DOC_STRING ("enable count COUNT")
+"\n\
+At least one breakpoint must be specified.\n\
  If a breakpoint is hit while enabled in this fashion,\n\
  the count is decremented; when it reaches zero, the breakpoint is  
disabled."),
  	   &enablelist);

-  add_prefix_cmd ("disable", class_breakpoint, disable_command, _("\
-Disable some breakpoints.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To disable all breakpoints, give no argument.\n\
+  add_prefix_cmd ("disable", class_breakpoint, disable_command, _(
+DISABLE_DOC_STRING ("breakpoint", "disable")
+"\n\
  A disabled breakpoint is not forgotten, but has no effect until  
re-enabled."),
  		  &disablelist, "disable ", 1, &cmdlist);
    add_com_alias ("dis", "disable", class_breakpoint, 1);
    add_com_alias ("disa", "disable", class_breakpoint, 1);

-  add_cmd ("breakpoints", class_alias, disable_command, _("\
-Disable some breakpoints.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To disable all breakpoints, give no argument.\n\
+  add_cmd ("breakpoints", class_alias, disable_command, _(
+DISABLE_DOC_STRING ("breakpoint", "disable breakpoints")
+"\n\
  A disabled breakpoint is not forgotten, but has no effect until  
re-enabled.\n\
  This command may be abbreviated \"disable\"."),
  	   &disablelist);

-  add_prefix_cmd ("delete", class_breakpoint, delete_command, _("\
-Delete some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
-\n\
+  add_prefix_cmd ("delete", class_breakpoint, delete_command, _(
+DELETE_DOC_STRING ("breakpoint", "delete")
+"\n\
  Also a prefix command for deletion of other GDB objects.\n\
  The \"unset\" command is also an alias for \"delete\"."),
  		  &deletelist, "delete ", 1, &cmdlist);
    add_com_alias ("d", "delete", class_breakpoint, 1);
    add_com_alias ("del", "delete", class_breakpoint, 1);

-  add_cmd ("breakpoints", class_alias, delete_command, _("\
-Delete some breakpoints or auto-display expressions.\n\
-Arguments are breakpoint numbers with spaces in between.\n\
-To delete all breakpoints, give no argument.\n\
+  add_cmd ("breakpoints", class_alias, delete_command, _(
+DELETE_DOC_STRING ("breakpoint", "delete breakpoints")
+"\n\
  This command may be abbreviated \"delete\"."),
  	   &deletelist);

diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 054eab4..84ba475 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -45,6 +45,34 @@  struct event_location;
     architecture.  */

  #define	BREAKPOINT_MAX	16
+
+/* The usage part of doc strings for enable/disable/delete/info commands.   
*/
+
+#define EDDI_USAGE_DOC_STRING(command_with_prefix) \
+  "Usage: " command_with_prefix " [NUMBERS AND/OR RANGES]\n" \
+  "You can specify numbers (e.g. \"" command_with_prefix " 1 3\"),\n" \
+  "ranges (e.g. \"" command_with_prefix " 4-8\"),\n" \
+  "or both (e.g. \"" command_with_prefix " 1 3 4-8\")."
+
+#define EDDI_USAGE_DOC_STRING_WITH_ALL(kind, command_with_prefix,  
actioned) \
+  EDDI_USAGE_DOC_STRING (command_with_prefix) \
+  "\nIf you don't specify any numbers or ranges,\n" \
+  "all " kind " entries are " actioned "."
+
+/* Part of the doc string for enable/disable/delete commands.  */
+
+#define EDD_DOC_STRING(kind, command_with_prefix, Action, actioned) \
+  Action " " kind " entries.\n" \
+  EDDI_USAGE_DOC_STRING_WITH_ALL (kind, command_with_prefix, actioned)
+
+#define ENABLE_DOC_STRING(kind, command_with_prefix) \
+  EDD_DOC_STRING (kind, command_with_prefix, "Enable", "enabled")
+
+#define DISABLE_DOC_STRING(kind, command_with_prefix) \
+  EDD_DOC_STRING (kind, command_with_prefix, "Disable", "disabled")
+
+#define DELETE_DOC_STRING(kind, command_with_prefix) \
+  EDD_DOC_STRING (kind, command_with_prefix, "Delete", "deleted")