From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailsec114.isp.belgacom.be (mailsec114.isp.belgacom.be [195.238.20.110]) by sourceware.org (Postfix) with ESMTPS id 275023973068 for ; Thu, 14 May 2020 21:19:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 275023973068 IronPort-SDR: RecFqtzZtlw4D93BOCE0pyla7BV127QRNqOKsR/QUZAb5Ed4mBx1PO9wlaWDpvG9Tjh2nYa01t xrq8yC+VFt1jky42zQXCWghsGI6zqb/ljKE1YHuAujcn51wcRhxpKNbM2SLPdZXmTohfeX04LE skoczfde4SVgq8BJKi6yTtYOLIDBh/6JnQfZaz/ihk+uWqttd1lAcjHI5iC/F5sZwiuAtXcRLR EcVOYWm0p1wosdYpLT1g2l955M2qsQ3vsnRIBQYh8KxTITXOeBmj+UE8G0+5exqtmacQuNZUYp dDs= IronPort-PHdr: =?us-ascii?q?9a23=3ATzCrWR+JeYx5xv9uRHKM819IXTAuvvDOBiVQ1K?= =?us-ascii?q?B22+gcTK2v8tzYMVDF4r011RmVBNiduqwP0raK+4nbGkU4qa6bt34DdJEeHz?= =?us-ascii?q?Qksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPER?= =?us-ascii?q?vjKwV1Ov71GonPhMiryuy+4ZLebxhIiTanZb5/LRq6oRjeu8QZnIBvNrs/xh?= =?us-ascii?q?zVr3VSZu9Y33loJVWdnxb94se/4ptu+DlOtvwi6sBNT7z0c7w3QrJEAjsmNX?= =?us-ascii?q?s15NDwuhnYUQSP/HocXX4InRdOHgPI8Qv1Xpb1siv9q+p9xCyXNtD4QLwoRT?= =?us-ascii?q?iv6bpgRRn1gykFKjE56nnahMxugqxGrhyvpBtxzIzaYI6aO/RzZb/RcNAASG?= =?us-ascii?q?ZdRMtdSzBND4WhZIUPFeoBOuNYopHnqVsOrBu+AQisBPv3yjBWm3T53bc10/?= =?us-ascii?q?4mEQHfwQwgHswBsG7PrN7oM6oSSeC1zKjMzTXCd/NWwSny5JLGcx87u/GMWq?= =?us-ascii?q?twcdfQyUYxDQPFlU6dqZfmPzKV0OQCrXSb4/B7Wu2xkmMqrRx6rTezyMk2kI?= =?us-ascii?q?bJmp4VxU7e9SV/2Is7Kt21RVB0bNOqH5VduT2XO5ZqT80tR2xltig3x7wYtZ?= =?us-ascii?q?C1ciUG1ZAqyhHQZvGJc4aG7A7uWfqPLDp5mn9oeLayihCv+kaj0u3xTte43E?= =?us-ascii?q?tIoyZfj9XBuHEA2wbQ58SaUPdw8Ems1DCS3A7J8O5EO1o7la/DJp4kxb4/i4?= =?us-ascii?q?QcvFzYHi/zhEX2lKiWdlg4+uSw6+TofLHmppiEOo9xlw7yKKMumtSkAegiLg?= =?us-ascii?q?cOUW2b+fmm2LL94E35WrJKgeExkqnfrJDaP8MbpqqjDwBOzIkv8xe/DzG439?= =?us-ascii?q?QEhXQLMk9JdRCdg4T0NVzDIer0APSij1i2njpmyejKPrj7DZXMKnjDnq3hfb?= =?us-ascii?q?F460NE0AozzdFf55ZVCrEZOPL8RFX9tdLCAR8jNAy02vvnCNRj2YMEQmKCGb?= =?us-ascii?q?SZMKDSsF+O+O0vP/OAa5QLtzrlMfgq++bujWMlmV8aZaSp0oYYZ2uhEvR+OU?= =?us-ascii?q?qZfWbjgtcfHmcRpQc+V+vqiECYUTFPeXmzUbgz5islB468CofDXI+tiqSb3C?= =?us-ascii?q?inBp1WenxGCleUHHfwd4WEWvMMaCOKIs95jDMIT7agRJU71RGprQ/61rtnIf?= =?us-ascii?q?TO+i0Drp/jz9t15u3VlR4s6Tx4Fd+S3H/eB11zy2wETXou1bx0oUFm4kyEzL?= =?us-ascii?q?JzjuNRD9EV4OlGASkgMpuJ9+x7D9HqQg+JQd6TT0+7Q9i8GnllVtIwx94We0?= =?us-ascii?q?s7BNy4iQne3iewGJcOlK2NCYBy+K+KjCu5HNp013uTjPpptFIhWMYabWA=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2ArDQCOtL1e/yFRiNlcCoJSgip0TyE?= =?us-ascii?q?SLI0miQqOQoo2gWcLAQEBAQEBAQEBCC8EAQGERAKCEic4EwIDAQEBAwIFAQE?= =?us-ascii?q?GAQEBAQEBBAQBbAQBAQcKAgGETiEBAwEBBQoBQ0IWAYFiIoMVBjIBIyMQUVc?= =?us-ascii?q?ZgyaDAbRMhVGEBYFAgTgBh1qEdoFMP4EQAYJbhQgME4YOBJgcmWV9B4JQfwS?= =?us-ascii?q?XJQwdnUktrV+BaSKBVm1TgmlQGA2fCkIwNwIGCAEBAwmKaoIVgkUBAQ?= X-IPAS-Result: =?us-ascii?q?A2ArDQCOtL1e/yFRiNlcCoJSgip0TyESLI0miQqOQoo2g?= =?us-ascii?q?WcLAQEBAQEBAQEBCC8EAQGERAKCEic4EwIDAQEBAwIFAQEGAQEBAQEBBAQBb?= =?us-ascii?q?AQBAQcKAgGETiEBAwEBBQoBQ0IWAYFiIoMVBjIBIyMQUVcZgyaDAbRMhVGEB?= =?us-ascii?q?YFAgTgBh1qEdoFMP4EQAYJbhQgME4YOBJgcmWV9B4JQfwSXJQwdnUktrV+Ba?= =?us-ascii?q?SKBVm1TgmlQGA2fCkIwNwIGCAEBAwmKaoIVgkUBAQ?= Received: from 33.81-136-217.adsl-dyn.isp.belgacom.be (HELO md.ops.cfmu.eurocontrol.be) ([217.136.81.33]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 14 May 2020 23:18:25 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Subject: [RFAv2 09/10] Ensure class_alias is only used for user-defined aliases. Date: Thu, 14 May 2020 23:18:14 +0200 Message-Id: <20200514211815.988-10-philippe.waroquiers@skynet.be> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200514211815.988-1-philippe.waroquiers@skynet.be> References: <20200514211815.988-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2020 21:19:12 -0000 This commit finally does the (small) change that started this patch series. It ensures that the class_alias is only used for user-defined aliases. So, the few GDB pre-defined aliases that were using the 'class_alias' class are now using a real help class, typically the class of the aliased command. gdb/ChangeLog YYYY-MM-DD Philippe Waroquiers * command.h (enum command_class): Improve comments, document that class_alias is for user-defined aliases, give the class name for each class, remove unused class_xdb. * cli/cli-decode.c (add_com_alias): Document THECLASS intended usage. * breakpoint.c (_initialize_breakpoint): Replace class_alias by a precise class. * infcmd.c (_initialize_infcmd): Likewise. * reverse.c (_initialize_reverse): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. gdb/testsuite/ChangeLog YYYY-MM-DD Philippe Waroquiers * gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases. --- gdb/breakpoint.c | 12 ++++---- gdb/cli/cli-decode.c | 5 +++- gdb/command.h | 47 ++++++++++++++++++++++++-------- gdb/infcmd.c | 6 ++-- gdb/reverse.c | 10 +++---- gdb/stack.c | 2 +- gdb/symfile.c | 4 +-- gdb/testsuite/gdb.base/alias.exp | 3 ++ gdb/tracepoint.c | 4 +-- 9 files changed, 62 insertions(+), 31 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 480f095876..15d76d4a9c 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15478,7 +15478,7 @@ A disabled breakpoint is not forgotten, but has no effect until re-enabled."), add_com_alias ("dis", "disable", class_breakpoint, 1); add_com_alias ("disa", "disable", class_breakpoint, 1); - add_cmd ("breakpoints", class_alias, disable_command, _("\ + add_cmd ("breakpoints", class_breakpoint, disable_command, _("\ Disable all or some breakpoints.\n\ Usage: disable breakpoints [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ @@ -15498,7 +15498,7 @@ Also a prefix command for deletion of other GDB objects."), add_com_alias ("d", "delete", class_breakpoint, 1); add_com_alias ("del", "delete", class_breakpoint, 1); - add_cmd ("breakpoints", class_alias, delete_command, _("\ + add_cmd ("breakpoints", class_breakpoint, delete_command, _("\ Delete all or some breakpoints or auto-display expressions.\n\ Usage: delete breakpoints [BREAKPOINTNUM]...\n\ Arguments are breakpoint numbers with spaces in between.\n\ @@ -15686,10 +15686,10 @@ BREAK_ARGS_HELP ("trace") "\n\ Do \"help tracepoints\" for info on other tracepoint commands.")); set_cmd_completer (c, location_completer); - add_com_alias ("tp", "trace", class_alias, 0); - add_com_alias ("tr", "trace", class_alias, 1); - add_com_alias ("tra", "trace", class_alias, 1); - add_com_alias ("trac", "trace", class_alias, 1); + add_com_alias ("tp", "trace", class_breakpoint, 0); + add_com_alias ("tr", "trace", class_breakpoint, 1); + add_com_alias ("tra", "trace", class_breakpoint, 1); + add_com_alias ("trac", "trace", class_breakpoint, 1); c = add_com ("ftrace", class_breakpoint, ftrace_command, _("\ Set a fast tracepoint at specified location.\n\ diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 2b24e57d46..a4ef93c62b 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1006,7 +1006,10 @@ add_com (const char *name, enum command_class theclass, return add_cmd (name, theclass, fun, doc, &cmdlist); } -/* Add an alias or abbreviation command to the list of commands. */ +/* Add an alias or abbreviation command to the list of commands. + For aliases predefined by GDB (such as bt), THECLASS must be + different of class_alias, as class_alias is used to identify + user defined aliases. */ struct cmd_list_element * add_com_alias (const char *name, const char *oldname, enum command_class theclass, diff --git a/gdb/command.h b/gdb/command.h index 0a1706c545..04a380cba4 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -29,21 +29,46 @@ struct completion_tracker; /* Command classes are top-level categories into which commands are broken down for "help" purposes. - Notes on classes: class_alias is for alias commands which are not - abbreviations of the original command. class-pseudo is for - commands which are not really commands nor help topics ("stop"). */ + The class_alias is used for the user-defined aliases, defined + using the "alias" command. + + Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command) + are not using the class_alias. + Different pre-defined aliases of the same command do not necessarily + have the same classes. For example, class_stack is used for the + "backtrace" and its "bt" alias", while "info stack" (also an alias + of "backtrace" uses class_info. */ enum command_class { - /* Special args to help_list */ - class_deprecated = -3, all_classes = -2, all_commands = -1, + /* Classes of commands followed by a comment giving the name + to use in "help ". + Note that help accepts unambiguous abbreviated class names. */ + + /* Special classes to help_list */ + class_deprecated = -3, + all_classes = -2, /* help without */ + all_commands = -1, /* all */ + /* Classes of commands */ - no_class = -1, class_run = 0, class_vars, class_stack, class_files, - class_support, class_info, class_breakpoint, class_trace, - class_alias, class_bookmark, class_obscure, class_maintenance, - class_tui, class_user, class_xdb, - no_set_class /* Used for "show" commands that have no corresponding - "set" command. */ + no_class = -1, + class_run = 0, /* running */ + class_vars, /* data */ + class_stack, /* stack */ + class_files, /* files */ + class_support, /* support */ + class_info, /* status */ + class_breakpoint, /* breakpoints */ + class_trace, /* tracepoints */ + class_alias, /* aliases */ + class_bookmark, + class_obscure, /* obscure */ + class_maintenance, /* internals */ + class_tui, + class_user, /* user-defined */ + + /* Used for "show" commands that have no corresponding "set" command. */ + no_set_class }; /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 8b01f45828..32905a7b59 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -3180,7 +3180,7 @@ is restored."), cmd_name = "inferior-tty"; c = lookup_cmd (&cmd_name, setlist, "", -1, 1); gdb_assert (c != NULL); - add_alias_cmd ("tty", c, class_alias, 0, &cmdlist); + add_alias_cmd ("tty", c, class_run, 0, &cmdlist); cmd_name = "args"; add_setshow_string_noescape_cmd (cmd_name, class_run, @@ -3318,14 +3318,14 @@ Step one instruction exactly.\n\ Usage: stepi [N]\n\ Argument N means step N times (or till program stops for another \ reason).")); - add_com_alias ("si", "stepi", class_alias, 0); + add_com_alias ("si", "stepi", class_run, 0); add_com ("nexti", class_run, nexti_command, _("\ Step one instruction, but proceed through subroutine calls.\n\ Usage: nexti [N]\n\ Argument N means step N times (or till program stops for another \ reason).")); - add_com_alias ("ni", "nexti", class_alias, 0); + add_com_alias ("ni", "nexti", class_run, 0); add_com ("finish", class_run, finish_command, _("\ Execute until selected stack frame returns.\n\ diff --git a/gdb/reverse.c b/gdb/reverse.c index 1ccb9d2797..583e0d02da 100644 --- a/gdb/reverse.c +++ b/gdb/reverse.c @@ -330,7 +330,7 @@ _initialize_reverse () Step program backward until it reaches the beginning of another source line.\n\ Argument N means do this N times (or till program stops for another reason).") ); - add_com_alias ("rs", "reverse-step", class_alias, 1); + add_com_alias ("rs", "reverse-step", class_run, 1); add_com ("reverse-next", class_run, reverse_next, _("\ Step program backward, proceeding through subroutine calls.\n\ @@ -338,26 +338,26 @@ Like the \"reverse-step\" command as long as subroutine calls do not happen;\n\ when they do, the call is treated as one instruction.\n\ Argument N means do this N times (or till program stops for another reason).") ); - add_com_alias ("rn", "reverse-next", class_alias, 1); + add_com_alias ("rn", "reverse-next", class_run, 1); add_com ("reverse-stepi", class_run, reverse_stepi, _("\ Step backward exactly one instruction.\n\ Argument N means do this N times (or till program stops for another reason).") ); - add_com_alias ("rsi", "reverse-stepi", class_alias, 0); + add_com_alias ("rsi", "reverse-stepi", class_run, 0); add_com ("reverse-nexti", class_run, reverse_nexti, _("\ Step backward one instruction, but proceed through called subroutines.\n\ Argument N means do this N times (or till program stops for another reason).") ); - add_com_alias ("rni", "reverse-nexti", class_alias, 0); + add_com_alias ("rni", "reverse-nexti", class_run, 0); add_com ("reverse-continue", class_run, reverse_continue, _("\ Continue program being debugged but run it in reverse.\n\ If proceeding from breakpoint, a number N may be used as an argument,\n\ which means to set the ignore count of that breakpoint to N - 1 (so that\n\ the breakpoint won't break until the Nth time it is reached).")); - add_com_alias ("rc", "reverse-continue", class_alias, 0); + add_com_alias ("rc", "reverse-continue", class_run, 0); add_com ("reverse-finish", class_run, reverse_finish, _("\ Execute backward until just before selected stack frame is called.")); diff --git a/gdb/stack.c b/gdb/stack.c index f67a151aee..d7e2120541 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3485,7 +3485,7 @@ With a negative COUNT, print outermost -COUNT frames."), add_com_alias ("bt", "backtrace", class_stack, 0); - add_com_alias ("where", "backtrace", class_alias, 0); + add_com_alias ("where", "backtrace", class_stack, 0); add_info ("stack", backtrace_command, _("Backtrace of the stack, or innermost COUNT frames.")); add_info_alias ("s", "stack", 1); diff --git a/gdb/symfile.c b/gdb/symfile.c index 7c862d5513..946443f07a 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3906,8 +3906,8 @@ on its own."), &cmdlist); _("Commands for debugging overlays."), &overlaylist, "overlay ", 0, &cmdlist); - add_com_alias ("ovly", "overlay", class_alias, 1); - add_com_alias ("ov", "overlay", class_alias, 1); + add_com_alias ("ovly", "overlay", class_support, 1); + add_com_alias ("ov", "overlay", class_support, 1); add_cmd ("map-overlay", class_support, map_overlay_command, _("Assert that an overlay section is mapped."), &overlaylist); diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp index 69cfde67c1..6993d42648 100644 --- a/gdb/testsuite/gdb.base/alias.exp +++ b/gdb/testsuite/gdb.base/alias.exp @@ -122,3 +122,6 @@ gdb_test_no_output "alias abcd = backtrace" gdb_test_no_output "alias abcde = backtrace" gdb_test_no_output "alias fghij = backtrace" gdb_test_no_output "alias fghi = backtrace" + +# Verify help aliases shows the user defined aliases +gdb_test "help aliases" ".*abcd --.*.*abcde --.*" diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2e0f0df9ff..f4a208f616 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -4098,8 +4098,8 @@ one or more \"collect\" commands, to specify what to collect\n\ while single-stepping.\n\n\ Note: this command can only be used in a tracepoint \"actions\" list.")); - add_com_alias ("ws", "while-stepping", class_alias, 0); - add_com_alias ("stepping", "while-stepping", class_alias, 0); + add_com_alias ("ws", "while-stepping", class_trace, 0); + add_com_alias ("stepping", "while-stepping", class_trace, 0); add_com ("collect", class_trace, collect_pseudocommand, _("\ Specify one or more data items to be collected at a tracepoint.\n\ -- 2.20.1