From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailsec102.isp.belgacom.be (mailsec102.isp.belgacom.be [195.238.20.98]) by server2.sourceware.org (Postfix) with ESMTPS id C7015385E82C for ; Sat, 7 Mar 2020 13:14:40 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1583586881; x=1615122881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sjUWcc8QJn0uX4AGNfUCqZa3SQt775nYHXc1D0sbpAA=; b=awanfKFk4FiAJ+4l/jIYbxCYeVWzFcuTSlFeeAH7hSBaR0m1LKpGxRlj QWEzP9WYb+lVrPWzSuSltRx3xtnQJw==; IronPort-SDR: WKo0x+3G0kS8e+cvH+mwonV7XDGcUJdKQKz5RR6iahnURFXMTM/nBNFjy/E+hITMrl/XRf19NP TG6gGW3l5w3d5CEMBqas7PxGZs2qEYgGfZ/DD/cVZYOXQCXLDt767+4Cdiv1sQbCWjYQmFOcze Ana5XM78/FGXAQV9myByYgPkOsY5dq9FhUez9sjCAezXNXSz+SrPMDb1Ehdzb565+BwmVKt9IA rFmS8LnBpm6zwTaeUC2n38FPxRzLNjGXnrhgwc0cIwxQtl29gYpmW7L7azhXqHz+dljj5vVvad sVM= IronPort-PHdr: =?us-ascii?q?9a23=3AmeOgshS2KQcQGpGNc2tI/oy++9psv+yvbD5Q0Y?= =?us-ascii?q?Iujvd0So/mwa6yYhGN2/xhgRfzUJnB7Loc0qyK6vymADVcqsvZ+Fk5M7VyFD?= =?us-ascii?q?Y9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQk?= =?us-ascii?q?a3OgV6PPn6FZDPhMqrye+y54fTYwJVjzahfL9+Nhq7oRjeu8UMnIduN6k8xh?= =?us-ascii?q?TJr3dUZu9b2X5mKVWPkhnz4cu94IRt+DlKtfI78M5AX6T6f6AmQrFdET8rLW?= =?us-ascii?q?M76tD1uBfaVQeA6WcSXWsQkhpTHgjK9wr6UYvrsiv7reVyxi+XNtDrQL8uWD?= =?us-ascii?q?Si66BrSAL0iCoCKjU0/n3bhtB2galGph+quh5xzJPOYIyNNPRwYL7Tc90ZS2?= =?us-ascii?q?RGXMlRWSNODIynYocTDOcMJ/pUopPhq1cSqxa1GAmiBPnoyj9NnnL4x6060+?= =?us-ascii?q?UlEQHHxAwgB8wBu2nUo9rvLqcSVvm1zLTJzTrddfNWwir25Y/QchAhoPGMWb?= =?us-ascii?q?NwcdLJyUYxDQ/EgE+fqZbiPzOMy+QNsnaU7/B7Ve+0kG4nqAFwoj6xyccwkI?= =?us-ascii?q?XGnZwax0nC+C5kw4g1PcW1RFBmbdOmCpdcqi+XOopsTs4hXm1koig3x7MAtJ?= =?us-ascii?q?WmZiYF0o4nyATaa/GfdoiI5Q/sW/iJLDdjgXJlZKq/hxGv8Ui80uH8Vte70F?= =?us-ascii?q?JNriddl9nDq2oB1xzU6siCVPRx5kah2TCR2ADP8uxIP104mKjBJ5I8zLM9l4?= =?us-ascii?q?AfvEfeEiPslkj7greadkA+9eip7+TnbK/mppiZN4JskgH+MqUumsi+AeQgKg?= =?us-ascii?q?gBQXKX+Oqm2735+k35WahKjvwonanDq5DXPt8bpq25Ag9TzIkj9wyzACy439?= =?us-ascii?q?gAh3kIMEpFeA6bj4juI1zOL+33Auymj1S0ijhr2+zJPr3/DZXWNXXDi7Dhfa?= =?us-ascii?q?tn60FA1gUyw8pQ54hKBb0bJ/LzQEDxvsTCDhAlKwy03/rnCNJl24MGWWKPA6?= =?us-ascii?q?uZMKLKsV+Q+O0jOeeNa5UPuDb6Mvgl+v/ugmEjmV8GZqSpxpgXaXC+Hvt4P0?= =?us-ascii?q?WVe2HjjclSWVsN6wUyRqnygUGJUTNIT221Qrg36y4yEo/gCp3MFa63h7nU5C?= =?us-ascii?q?e6GpxOfm0ONVmWFm71doieQL9YcCKTJs55ijFCSrG7TJY81By0ryfhyKthI/?= =?us-ascii?q?aS8CBO5sGr78R8++CGzUJ6zjdzFcnIi2w=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2CHCAB1nWNe/yFRiNljHAEBAQEBBwE?= =?us-ascii?q?BEQEEBAEBgXsCgieBQCESKo0YhgGdTgkBAQEBAQEBAQEILAECBAEBhEMCggs?= =?us-ascii?q?nOBMCAwEBAQMCBQEBBgEBAQEBAQQEAWwEAQEHCgIBhE4hAQMBAQUKAUNCFgG?= =?us-ascii?q?BYiKDBwYyASMjED8SVxkagwyDAKk+hUqDOIE+gTgBh0lrhAaBTD+BEAGHZBC?= =?us-ascii?q?FdiIEjV2JHZg0dgeCP3gEjCOJOwwcmzUhqk6BaSKBWG1TgmxQGA2OVY4RQzC?= =?us-ascii?q?BBAEiAYplgiIsghcBAQ?= X-IPAS-Result: =?us-ascii?q?A2CHCAB1nWNe/yFRiNljHAEBAQEBBwEBEQEEBAEBgXsCg?= =?us-ascii?q?ieBQCESKo0YhgGdTgkBAQEBAQEBAQEILAECBAEBhEMCggsnOBMCAwEBAQMCB?= =?us-ascii?q?QEBBgEBAQEBAQQEAWwEAQEHCgIBhE4hAQMBAQUKAUNCFgGBYiKDBwYyASMjE?= =?us-ascii?q?D8SVxkagwyDAKk+hUqDOIE+gTgBh0lrhAaBTD+BEAGHZBCFdiIEjV2JHZg0d?= =?us-ascii?q?geCP3gEjCOJOwwcmzUhqk6BaSKBWG1TgmxQGA2OVY4RQzCBBAEiAYplgiIsg?= =?us-ascii?q?hcBAQ?= Received: from 33.81-136-217.adsl-dyn.isp.belgacom.be (HELO md.home) ([217.136.81.33]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 07 Mar 2020 14:14:36 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Subject: [RFAv5 3/3] NEWS and documentation for default-args related concept and commands. Date: Sat, 7 Mar 2020 14:14:28 +0100 Message-Id: <20200307131428.11942-4-philippe.waroquiers@skynet.be> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200307131428.11942-1-philippe.waroquiers@skynet.be> References: <20200307131428.11942-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Sat, 07 Mar 2020 13:14:42 -0000 gdb/ChangeLog YYYY-MM-DD Philippe Waroquiers * NEWS: Mention new default-args commands. Mention change to the alias command. gdb/doc/ChangeLog YYYY-MM-DD Philippe Waroquiers * gdb.texinfo (Command default args): New node documenting 'set|show default-args' and 'set|show enable-default-args'. (Aliases): Document the new 'DEFAULT-ARGS...' option. --- gdb/NEWS | 29 +++++++++ gdb/doc/gdb.texinfo | 139 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 167 insertions(+), 1 deletion(-) diff --git a/gdb/NEWS b/gdb/NEWS index 6657f6fadc..62dea7e983 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -55,10 +55,39 @@ show exec-file-mismatch -- Show exec-file-mismatch handling (ask|warn|off). whether to load the process executable file; if 'warn', just display a warning; if 'off', don't attempt to detect a mismatch. +set default-args COMMAND [DEFAULT-ARGS...] +show default-args [COMMAND] +set enable-default-args [on|off] +show enable-default-args + GDB can now automatically prepend default arguments to the argument list + provided explicitely by the user. + This allows to set default arguments or options for the GDB commands + or define easily more specialised aliases. + For example, 'set default-args backtrace -full -frame-arguments all' + ensures that backtrace will automatically use the options -full + -frame-arguments all, without having to retype them for each backtrace + command. + tui new-layout NAME WINDOW WEIGHT [WINDOW WEIGHT]... Define a new TUI layout, specifying its name and the windows that will be displayed. +* Changed commands + +alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...] + The alias command can now directly define default-args + to prepend to the argument list provided explicitely by the user. + For example, to have a backtrace with full details, you can define + an alias 'bt_ALL' as + 'alias bt_ALL = backtrace -entry-values both -frame-arg all + -past-main -past-entry -full'. + Alias default arguments can also use a set of nested 'with' commands, + e.g. 'alias pp10 = with print pretty -- with print elem 10 -- print' + defines the alias pp10 that will pretty print a maximum of 10 elements + of the given expression (if the expression is an array). + See 'set default-args COMMAND [DEFAULT-ARGS...]' for more + information about default args concept. + * New targets GNU/Linux/RISC-V (gdbserver) riscv*-*-linux* diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 385c832f22..c0fdb25ce2 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1577,6 +1577,7 @@ show you the alternatives available, if there is more than one possibility). * Command Settings:: How to change default behavior of commands * Completion:: Command completion * Command Options:: Command options +* Command default args:: Automatically prepend default arguments to commands and aliases * Help:: How to ask @value{GDBN} for help @end menu @@ -1997,6 +1998,129 @@ uppercase. (For more on using the @code{print} command, see @ref{Data, ,Examining Data}.) +@node Command default args +@section Automatically prepend default arguments to commands and aliases + +You can tell @value{GDBN} to always prependd some default arguments to +the list of arguments provided explicitely by the user. + +@cindex command options, automatically prepend +@cindex command, default arguments + +@table @code +@kindex set default-args +@item set default-args @var{command} [@var{default-args@dots{}}] + +If you repeatedly use the same arguments or options for a command, +you can tell @value{GDBN} to automatically prepend these arguments +or options to the list of arguments you type explicitely. + +For example, if you always want to have the command @code{thread apply all} +working on the threads in ascending order and to continue in case it +encounters an error, you can tell @value{GDBN} to automatically preprend +the @code{-ascending} and @code{-c} options by using: + +@smallexample +(@value{GDBP}) set default-args thread apply all -ascending -c +@end smallexample + +Once you have set these default args, any time you type +the @code{thread apply all} followed by @code{some arguments}, +@value{GDBN} will execute @code{thread apply all -ascending -c some arguments}. + +As usual, unambiguous abbreviations can be used for @var{command} +and @var{default-args}. + +Commands and their aliases do not share their default args. +So, for example, you can configure the commands @code{bt}, @code{where}, +@code{backtrace} and @code{info stack} to output different levels +of information and define a new alias @code{bt_ALL} showing all possible +information using: +@smallexample +(@value{GDBP}) set default-args bt -entry-values no -frame-arguments none +(@value{GDBP}) set default-args where -entry-values no -frame-argu scalars +(@value{GDBP}) set default-args backtrace -entry-values no -frame-argu all +(@value{GDBP}) set default-args info stack -entry-val both -fr all +(@value{GDBP}) alias bt_ALL = backtrace +(@value{GDBP}) set default-args bt_ALL -entry-values both -frame-arg all \ + -past-main -past-entry -full +@end smallexample + +You can define an alias and specify its default args in one command using +the shorter to type: +@smallexample +(@value{GDBP}) alias bt_ALL = backtrace -entry-values both -frame-arg all \ + -past-main -past-entry -full +@end smallexample +(For more on using the @code{alias} command, see @ref{Aliases}.) + +Default args are not limited to the arguments and options of @var{command}, +but can specify nested commands if @var{command} accepts such a nested command +as argument. +For example, the below defines @code{faalocalsoftype} that can be used to list +the frames having locals of a certain type, together with the matching local +vars: +@smallexample +(@value{GDBP}) alias faalocalsoftype = frame apply all info locals -q -t +(@value{GDBP}) faalocalsoftype int +#1 0x55554f5e in sleeper_or_burner (v=0xdf50) at sleepers.c:86 +i = 0 +ret = 21845 +@end smallexample + +This is also very useful to define an alias for a set of nested @code{with} +commands to have a particular combination of temporary settings. For example, +the below defines the alias @code{pp10} that pretty prints an expression +argument, with a maximum of 10 elements if the expression is a string or +an array: +@smallexample +(@value{GDBP}) alias pp10 = with print pretty -- with print elements 10 -- print +@end smallexample +This defines the alias @code{pp10} as being a sequence of 3 commands. +The first part @code{with print pretty --} temporarily activates the setting +@code{set print pretty}, then launches the command that follows the separator +@code{--}. +The command following the first part is also a @code{with} command that +temporarily changes the setting @code{set print elements} to 10, then +launches the command that follows the second separator @code{--}. +The third part @code{print} is the command the @code{pp10} alias will launch, +using the temporary values of the settings and the arguments explicitely given +by the user. +For more information about the @code{with} command usage, +see @ref{Command Settings}. + +Use @code{set default-args @var{command}} (without giving @var{default-args}) +to clear the default args of @var{command}. + +@item show default-args [@var{command}] + +Use @code{show default-args @var{command}} to show the current values of +the default args for @var{command}. For example: +@smallexample +(@value{GDBP}) show default-args backtrace +default-args backtrace = -entry-values no -frame-arguments all +(@value{GDBP}) show default-args break +default-args break = +@end smallexample + +To show all the commands and aliases that have some default args configured, +use the command +@code{show default-args} without giving a @var{command} argument. + +@item set enable-default-args @r{[}on|off@r{]} +@itemx show enable-default-args +By default, @value{GDBN} will use the configured default args. This +can be disabled using @code{set enable-default-args off}. The default +args of all commands are not cleared by @code{set enable-default-args +off}, but will not be used till you do @code{set enable-default-args +on}. This can be useful in user defined commands to ensure only the +specified set of options are used by a command launched by the +user-defined command. You can also use this setting in the +@code{with} command, to temporarily run a command without its possibly +configured default args. + +@end table + @node Help @section Getting Help @cindex online documentation @@ -27500,7 +27624,7 @@ You can define a new alias with the @samp{alias} command. @table @code @kindex alias -@item alias [-a] [--] @var{ALIAS} = @var{COMMAND} +@item alias [-a] [--] @var{ALIAS} = @var{COMMAND} [DEFAULT-ARGS...] @end table @@ -27518,6 +27642,19 @@ lists displayed by the @samp{help} command. The @samp{--} option specifies the end of options, and is useful when @var{ALIAS} begins with a dash. +You can specify @var{default-args} for your alias. +These @var{default-args} will be automatically added before the alias +arguments typed explicitely on the command line. + +For example, the below defines an alias @code{btfullall} that shows all local +variables and all frame arguments: +@smallexample +(@value{GDBP}) alias btfullall = backtrace -full -frame-arguments all +@end smallexample + +For more information about @var{default-args}, see @ref{Command default args, +,Automatically prepend default arguments to commands and aliases} + Here is a simple example showing how to make an abbreviation of a command so that there is less to type. Suppose you were tired of typing @samp{disas}, the current -- 2.20.1