]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Update more calls to add_prefix_cmd
authorTom Tromey <tom@tromey.com>
Sun, 3 May 2020 17:31:19 +0000 (11:31 -0600)
committerTom Tromey <tom@tromey.com>
Sun, 3 May 2020 17:31:20 +0000 (11:31 -0600)
I looked at all the calls to add_prefix_cmd, and replaced them with
calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate.
This makes gdb's command language a bit more regular.  I don't think
there's a significant downside.

Note that this patch removes a couple of tests.  The removed ones are
completely redundant.

gdb/ChangeLog
2020-05-03  Tom Tromey  <tom@tromey.com>

* breakpoint.c (catch_command, tcatch_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(set_breakpoint_cmd, show_breakpoint_cmd): Remove
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Remove.
(add_internal_problem_command): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (set_mipsfpu_command): Remove.
(_initialize_mips_tdep): Use add_basic_prefix_cmd.
* dwarf2/index-cache.c (set_index_cache_command): Remove.
(_initialize_index_cache): Use add_basic_prefix_cmd.
* memattr.c (dummy_cmd): Remove.
(_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
* tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
(_initialize_tui_win): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-logging.c (set_logging_command): Remove.
(_initialize_cli_logging): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_logging_command): Remove.
* target.c (target_command): Remove.
(add_target): Use add_basic_prefix_cmd.

gdb/testsuite/ChangeLog
2020-05-03  Tom Tromey  <tom@tromey.com>

* gdb.base/sepdebug.exp: Remove "catch" test.
* gdb.base/break.exp: Remove "catch" test.
* gdb.base/default.exp: Update expected output.

13 files changed:
gdb/ChangeLog
gdb/breakpoint.c
gdb/cli/cli-logging.c
gdb/dwarf2/index-cache.c
gdb/memattr.c
gdb/mips-tdep.c
gdb/target.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/break.exp
gdb/testsuite/gdb.base/default.exp
gdb/testsuite/gdb.base/sepdebug.exp
gdb/tui/tui-win.c
gdb/utils.c

index b5f664c2bc5824984009edb58187e469812a1472..9a611ae939d93cf2dc7eb6edb2eaf0d751c4e5f5 100644 (file)
@@ -1,3 +1,29 @@
+2020-05-03  Tom Tromey  <tom@tromey.com>
+
+       * breakpoint.c (catch_command, tcatch_command): Remove.
+       (_initialize_breakpoint): Use add_basic_prefix_cmd,
+       add_show_prefix_cmd.
+       (set_breakpoint_cmd, show_breakpoint_cmd): Remove
+       * utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
+       Remove.
+       (add_internal_problem_command): Use add_basic_prefix_cmd,
+       add_show_prefix_cmd.
+       * mips-tdep.c (set_mipsfpu_command): Remove.
+       (_initialize_mips_tdep): Use add_basic_prefix_cmd.
+       * dwarf2/index-cache.c (set_index_cache_command): Remove.
+       (_initialize_index_cache): Use add_basic_prefix_cmd.
+       * memattr.c (dummy_cmd): Remove.
+       (_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
+       * tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
+       (_initialize_tui_win): Use add_basic_prefix_cmd,
+       add_show_prefix_cmd.
+       * cli/cli-logging.c (set_logging_command): Remove.
+       (_initialize_cli_logging): Use add_basic_prefix_cmd,
+       add_show_prefix_cmd.
+       (show_logging_command): Remove.
+       * target.c (target_command): Remove.
+       (add_target): Use add_basic_prefix_cmd.
+
 2020-05-02  Hannes Domani  <ssbssa@yahoo.de>
 
        * gdbtypes.h (enum dynamic_prop_node_kind): Fix typo.
index 858f4c756918724072706d0aa6f9e19757646f3d..4cba77400974f4d44914fc11689f4bed62607c25 100644 (file)
@@ -11214,19 +11214,8 @@ init_ada_exception_breakpoint (struct breakpoint *b,
   b->language = language_ada;
 }
 
-static void
-catch_command (const char *arg, int from_tty)
-{
-  error (_("Catch requires an event name."));
-}
 \f
 
-static void
-tcatch_command (const char *arg, int from_tty)
-{
-  error (_("Catch requires an event name."));
-}
-
 /* Compare two breakpoints and return a strcmp-like result.  */
 
 static int
@@ -14335,16 +14324,6 @@ enable_delete_command (const char *args, int from_tty)
      });
 }
 \f
-static void
-set_breakpoint_cmd (const char *args, int from_tty)
-{
-}
-
-static void
-show_breakpoint_cmd (const char *args, int from_tty)
-{
-}
-
 /* Invalidate last known value of any hardware watchpoint if
    the memory which that value represents has been written to by
    GDB itself.  */
@@ -15614,15 +15593,15 @@ Convenience variable \"$bpnum\" contains the number of the last\n\
 breakpoint set."),
           &maintenanceinfolist);
 
-  add_prefix_cmd ("catch", class_breakpoint, catch_command, _("\
+  add_basic_prefix_cmd ("catch", class_breakpoint, _("\
 Set catchpoints to catch events."),
-                 &catch_cmdlist, "catch ",
-                 0/*allow-unknown*/, &cmdlist);
+                       &catch_cmdlist, "catch ",
+                       0/*allow-unknown*/, &cmdlist);
 
-  add_prefix_cmd ("tcatch", class_breakpoint, tcatch_command, _("\
+  add_basic_prefix_cmd ("tcatch", class_breakpoint, _("\
 Set temporary catchpoints to catch events."),
-                 &tcatch_cmdlist, "tcatch ",
-                 0/*allow-unknown*/, &cmdlist);
+                       &tcatch_cmdlist, "tcatch ",
+                       0/*allow-unknown*/, &cmdlist);
 
   add_catch_command ("fork", _("Catch calls to fork."),
                     catch_fork_command_1,
@@ -15799,18 +15778,18 @@ Use the 'source' command in another debug session to restore them."),
   c = add_com_alias ("save-tracepoints", "save tracepoints", class_trace, 0);
   deprecate_cmd (c, "save tracepoints");
 
-  add_prefix_cmd ("breakpoint", class_maintenance, set_breakpoint_cmd, _("\
+  add_basic_prefix_cmd ("breakpoint", class_maintenance, _("\
 Breakpoint specific settings.\n\
 Configure various breakpoint-specific variables such as\n\
 pending breakpoint behavior."),
-                 &breakpoint_set_cmdlist, "set breakpoint ",
-                 0/*allow-unknown*/, &setlist);
-  add_prefix_cmd ("breakpoint", class_maintenance, show_breakpoint_cmd, _("\
+                       &breakpoint_set_cmdlist, "set breakpoint ",
+                       0/*allow-unknown*/, &setlist);
+  add_show_prefix_cmd ("breakpoint", class_maintenance, _("\
 Breakpoint specific settings.\n\
 Configure various breakpoint-specific variables such as\n\
 pending breakpoint behavior."),
-                 &breakpoint_show_cmdlist, "show breakpoint ",
-                 0/*allow-unknown*/, &showlist);
+                      &breakpoint_show_cmdlist, "show breakpoint ",
+                      0/*allow-unknown*/, &showlist);
 
   add_setshow_auto_boolean_cmd ("pending", no_class,
                                &pending_break_support, _("\
index d7c1b779bfe465a42761238d45ead9dcc8b59406..a58cdcec8766a831ef1d138492e9715903488e56 100644 (file)
@@ -165,55 +165,18 @@ set_logging_off (const char *args, int from_tty)
   saved_filename = NULL;
 }
 
-static void
-set_logging_command (const char *args, int from_tty)
-{
-  printf_unfiltered (_("\"set logging\" lets you log output to a file.\n"
-                      "Usage: set logging on [FILENAME]\n"
-                      "       set logging off\n"
-                      "       set logging file FILENAME\n"
-                      "       set logging overwrite [on|off]\n"
-                      "       set logging redirect [on|off]\n"));
-}
-
-static void
-show_logging_command (const char *args, int from_tty)
-{
-  if (saved_filename)
-    printf_unfiltered (_("Currently logging to \"%s\".\n"), saved_filename);
-  if (saved_filename == NULL
-      || strcmp (logging_filename, saved_filename) != 0)
-    printf_unfiltered (_("Future logs will be written to %s.\n"),
-                      logging_filename);
-
-  if (logging_overwrite)
-    printf_unfiltered (_("Logs will overwrite the log file.\n"));
-  else
-    printf_unfiltered (_("Logs will be appended to the log file.\n"));
-
-  if (logging_redirect)
-    printf_unfiltered (_("Output will be sent only to the log file.\n"));
-  else
-    printf_unfiltered (_("Output will be logged and displayed.\n"));
-
-  if (debug_redirect)
-    printf_unfiltered (_("Debug output will be sent only to the log file.\n"));
-  else
-    printf_unfiltered (_("Debug output will be logged and displayed.\n"));
-}
-
 void _initialize_cli_logging ();
 void
 _initialize_cli_logging ()
 {
   static struct cmd_list_element *set_logging_cmdlist, *show_logging_cmdlist;
 
-  add_prefix_cmd ("logging", class_support, set_logging_command,
-                 _("Set logging options."), &set_logging_cmdlist,
-                 "set logging ", 0, &setlist);
-  add_prefix_cmd ("logging", class_support, show_logging_command,
-                 _("Show logging options."), &show_logging_cmdlist,
-                 "show logging ", 0, &showlist);
+  add_basic_prefix_cmd ("logging", class_support,
+                       _("Set logging options."), &set_logging_cmdlist,
+                       "set logging ", 0, &setlist);
+  add_show_prefix_cmd ("logging", class_support,
+                      _("Show logging options."), &show_logging_cmdlist,
+                      "show logging ", 0, &showlist);
   add_setshow_boolean_cmd ("overwrite", class_support, &logging_overwrite, _("\
 Set whether logging overwrites or appends to the log file."), _("\
 Show whether logging overwrites or appends to the log file."), _("\
index 62fbe2a0b4dbafed511e8f49d65e3d7b06d3af0d..23e938b010256dfe39557e98d33a5d91b4a16bf9 100644 (file)
@@ -246,15 +246,6 @@ index_cache::make_index_filename (const bfd_build_id *build_id,
   return m_dir + SLASH_STRING + build_id_str + suffix;
 }
 
-/* "set index-cache" handler.  */
-
-static void
-set_index_cache_command (const char *arg, int from_tty)
-{
-  printf_unfiltered (_("\
-Missing arguments.  See \"help set index-cache\" for help.\n"));
-}
-
 /* True when we are executing "show index-cache".  This is used to improve the
    printout a little bit.  */
 static bool in_show_index_cache_command = false;
@@ -341,9 +332,10 @@ _initialize_index_cache ()
     warning (_("Couldn't determine a path for the index cache directory."));
 
   /* set index-cache */
-  add_prefix_cmd ("index-cache", class_files, set_index_cache_command,
-                 _("Set index-cache options."), &set_index_cache_prefix_list,
-                 "set index-cache ", false, &setlist);
+  add_basic_prefix_cmd ("index-cache", class_files,
+                       _("Set index-cache options."),
+                       &set_index_cache_prefix_list,
+                       "set index-cache ", false, &setlist);
 
   /* show index-cache */
   add_prefix_cmd ("index-cache", class_files, show_index_cache_command,
index da60df071c5b10be9c61cce9bc90d8d04f0dd8fc..e38bc5c33ab6720e450fe34b6ba6dac42fc86b23 100644 (file)
@@ -586,11 +586,6 @@ delete_mem_command (const char *args, int from_tty)
   dont_repeat ();
 }
 
-static void
-dummy_cmd (const char *args, int from_tty)
-{
-}
-
 static struct cmd_list_element *mem_set_cmdlist;
 static struct cmd_list_element *mem_show_cmdlist;
 
@@ -628,14 +623,14 @@ Do \"info mem\" to see current list of IDs."), &deletelist);
   add_info ("mem", info_mem_command,
            _("Memory region attributes."));
 
-  add_prefix_cmd ("mem", class_vars, dummy_cmd, _("\
+  add_basic_prefix_cmd ("mem", class_vars, _("\
 Memory regions settings."),
-                 &mem_set_cmdlist, "set mem ",
-                 0/* allow-unknown */, &setlist);
-  add_prefix_cmd ("mem", class_vars, dummy_cmd, _("\
+                       &mem_set_cmdlist, "set mem ",
+                       0/* allow-unknown */, &setlist);
+  add_show_prefix_cmd ("mem", class_vars, _("\
 Memory regions settings."),
-                 &mem_show_cmdlist, "show mem  ",
-                 0/* allow-unknown */, &showlist);
+                      &mem_show_cmdlist, "show mem  ",
+                      0/* allow-unknown */, &showlist);
 
   add_setshow_boolean_cmd ("inaccessible-by-default", no_class,
                                  &inaccessible_by_default, _("\
index 2e93f9e5fd3c096d76c131a26e9f570ec03e5839..e3d8581c9c9a5130d93a5d035ae499d2cf490b54 100644 (file)
@@ -6916,14 +6916,6 @@ show_mipsfpu_command (const char *args, int from_tty)
 }
 
 
-static void
-set_mipsfpu_command (const char *args, int from_tty)
-{
-  printf_unfiltered ("\"set mipsfpu\" must be followed by \"double\", "
-                    "\"single\",\"none\" or \"auto\".\n");
-  show_mipsfpu_command (args, from_tty);
-}
-
 static void
 set_mipsfpu_single_command (const char *args, int from_tty)
 {
@@ -9018,9 +9010,9 @@ and is updated automatically from ELF file flags if available."),
   /* Let the user turn off floating point and set the fence post for
      heuristic_proc_start.  */
 
-  add_prefix_cmd ("mipsfpu", class_support, set_mipsfpu_command,
-                 _("Set use of MIPS floating-point coprocessor."),
-                 &mipsfpulist, "set mipsfpu ", 0, &setlist);
+  add_basic_prefix_cmd ("mipsfpu", class_support,
+                       _("Set use of MIPS floating-point coprocessor."),
+                       &mipsfpulist, "set mipsfpu ", 0, &setlist);
   add_cmd ("single", class_support, set_mipsfpu_single_command,
           _("Select single-precision MIPS floating-point coprocessor."),
           &mipsfpulist);
index 2dc356d935f90bc56cb0c4af8415fbf7fb8b977a..6982a806e3eb427ab33b2e375d86e18876ba7009 100644 (file)
@@ -168,15 +168,6 @@ show_targetdebug (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Target debugging is %s.\n"), value);
 }
 
-/* The user just typed 'target' without the name of a target.  */
-
-static void
-target_command (const char *arg, int from_tty)
-{
-  fputs_filtered ("Argument required (target name).  Try `help target'\n",
-                 gdb_stdout);
-}
-
 int
 target_has_all_memory_1 (void)
 {
@@ -269,13 +260,13 @@ add_target (const target_info &t, target_open_ftype *func,
   func_slot = func;
 
   if (targetlist == NULL)
-    add_prefix_cmd ("target", class_run, target_command, _("\
+    add_basic_prefix_cmd ("target", class_run, _("\
 Connect to a target machine or process.\n\
 The first argument is the type or protocol of the target machine.\n\
 Remaining arguments are interpreted by the target protocol.  For more\n\
 information on the arguments for a particular protocol, type\n\
 `help target ' followed by the protocol name."),
-                   &targetlist, "target ", 0, &cmdlist);
+                         &targetlist, "target ", 0, &cmdlist);
   c = add_cmd (t.shortname, no_class, t.doc, &targetlist);
   set_cmd_context (c, (void *) &t);
   set_cmd_sfunc (c, open_target);
index 986e3be34bcf3cf40493ec9c48b52de37a5e56ec..2984996641f2fa84bb094e549f8e0a536ba8e08b 100644 (file)
@@ -1,3 +1,9 @@
+2020-05-03  Tom Tromey  <tom@tromey.com>
+
+       * gdb.base/sepdebug.exp: Remove "catch" test.
+       * gdb.base/break.exp: Remove "catch" test.
+       * gdb.base/default.exp: Update expected output.
+
 2020-05-02  Tom de Vries  <tdevries@suse.de>
 
        * lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc.
index d2121c3d635ec326ae2593b4f181ba73ba51b32b..8c7ce42d805869f040795d2ed95a8c549851a2fe 100644 (file)
@@ -469,10 +469,6 @@ gdb_test "info break" "Num     Type.*Disp Enb Address.*What.*\[\r\n\]
 #
 if ![runto_main] then { fail "break tests suppressed" }
 
-gdb_test "catch" \
-    "Catch requires an event name." \
-    "catch requires an event name"
-
 gdb_test "catch fork" "Catchpoint \[0-9\]+ \\(fork\\)" \
     "set catch fork, never expected to trigger"
 
index 846c91af6bc5cc56436349b055f2a9fe427a5d5f..95b92c4871696332ac5a81c3f8e6b6faed648a4c 100644 (file)
@@ -78,7 +78,7 @@ gdb_test "call" "The history is empty..*"
 
 
 #test catch
-gdb_test "catch" "Catch requires an event name..*"
+gdb_test "catch" "List of catch subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help catch\" followed by catch subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
 
 #test cd
 gdb_test "cd" "Working directory \[^\r\n\]*\(\r\n \\(canonically \[^\r\n\]*\\)\)?\\."
@@ -794,7 +794,7 @@ gdb_expect {
 }
 
 #test target
-gdb_test "target" "Argument required .target name.*"
+gdb_test "target" "List of target subcommands:(\[^\r\n\]*\[\r\n\])+Type \"help target\" followed by target subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous."
 #test tbreak
 gdb_test "tbreak" "No default breakpoint address now."
 #test thread
index 70f29d5b35f4e98e9d26ef1ba1a278137d22a097..bdbfa2c98eeced0effc4057e5acc67cf6787f837 100644 (file)
@@ -280,9 +280,6 @@ gdb_test "info break" "Num     Type.*Disp Enb Address.*What.*\[\r\n\]
 #
 if ![runto_main] then { fail "sepdebug tests suppressed" }
 
-gdb_test "catch" "Catch requires an event name.*" \
-    "catch requires an event name"
-
 gdb_test "catch fork" "Catchpoint \[0-9\]+ \\(fork\\)" \
     "set catch fork, never expected to trigger"
 
index 6546793d6bd87ab0585df2f1d23946163f459902..a78837fe6896d5a6508bc6dc646cc16c4fc35f4a 100644 (file)
@@ -298,16 +298,6 @@ tui_update_variables ()
   return need_redraw;
 }
 
-static void
-set_tui_cmd (const char *args, int from_tty)
-{
-}
-
-static void
-show_tui_cmd (const char *args, int from_tty)
-{
-}
-
 static struct cmd_list_element *tuilist;
 
 struct cmd_list_element **
@@ -1004,14 +994,14 @@ _initialize_tui_win ()
 
   /* Define the classes of commands.
      They will appear in the help list in the reverse of this order.  */
-  add_prefix_cmd ("tui", class_tui, set_tui_cmd,
-                  _("TUI configuration variables."),
-                 &tui_setlist, "set tui ",
-                 0 /* allow-unknown */, &setlist);
-  add_prefix_cmd ("tui", class_tui, show_tui_cmd,
-                  _("TUI configuration variables."),
-                 &tui_showlist, "show tui ",
-                 0 /* allow-unknown */, &showlist);
+  add_basic_prefix_cmd ("tui", class_tui,
+                       _("TUI configuration variables."),
+                       &tui_setlist, "set tui ",
+                       0 /* allow-unknown */, &setlist);
+  add_show_prefix_cmd ("tui", class_tui,
+                      _("TUI configuration variables."),
+                      &tui_showlist, "show tui ",
+                      0 /* allow-unknown */, &showlist);
 
   add_com ("refresh", class_tui, tui_refresh_all_command,
            _("Refresh the terminal display."));
index 2f2cd845c4b14218c5f906e44c4542c270902b21..989b13d0e0f3882eab9e872c149116368e05c1d6 100644 (file)
@@ -469,18 +469,6 @@ demangler_warning (const char *file, int line, const char *string, ...)
   va_end (ap);
 }
 
-/* Dummy functions to keep add_prefix_cmd happy.  */
-
-static void
-set_internal_problem_cmd (const char *args, int from_tty)
-{
-}
-
-static void
-show_internal_problem_cmd (const char *args, int from_tty)
-{
-}
-
 /* When GDB reports an internal problem (error or warning) it gives
    the user the opportunity to quit GDB and/or create a core file of
    the current debug session.  This function registers a few commands
@@ -515,19 +503,17 @@ add_internal_problem_command (struct internal_problem *problem)
   show_doc = xstrprintf (_("Show what GDB does when %s is detected."),
                         problem->name);
 
-  add_prefix_cmd (problem->name,
-                 class_maintenance, set_internal_problem_cmd, set_doc,
-                 set_cmd_list,
-                 concat ("maintenance set ", problem->name, " ",
-                         (char *) NULL),
-                 0/*allow-unknown*/, &maintenance_set_cmdlist);
-
-  add_prefix_cmd (problem->name,
-                 class_maintenance, show_internal_problem_cmd, show_doc,
-                 show_cmd_list,
-                 concat ("maintenance show ", problem->name, " ",
-                         (char *) NULL),
-                 0/*allow-unknown*/, &maintenance_show_cmdlist);
+  add_basic_prefix_cmd (problem->name, class_maintenance, set_doc,
+                       set_cmd_list,
+                       concat ("maintenance set ", problem->name, " ",
+                               (char *) NULL),
+                       0/*allow-unknown*/, &maintenance_set_cmdlist);
+
+  add_show_prefix_cmd (problem->name, class_maintenance, show_doc,
+                      show_cmd_list,
+                      concat ("maintenance show ", problem->name, " ",
+                              (char *) NULL),
+                      0/*allow-unknown*/, &maintenance_show_cmdlist);
 
   if (problem->user_settable_should_quit)
     {