From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 8B6483858001 for ; Mon, 1 Nov 2021 15:50:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B6483858001 X-ASG-Debug-ID: 1635781811-0c856e03888b8fa0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 3cGeqhrU1Kd5jco8 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 01 Nov 2021 11:50:11 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 40317441D68; Mon, 1 Nov 2021 11:50:11 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Subject: [PATCH 5/5] gdb: introduce "set index-cache enabled", deprecate "set index-cache on/off" Date: Mon, 1 Nov 2021 11:50:09 -0400 X-ASG-Orig-Subj: [PATCH 5/5] gdb: introduce "set index-cache enabled", deprecate "set index-cache on/off" Message-Id: <20211101155009.457224-6-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211101155009.457224-1-simon.marchi@efficios.com> References: <20211101155009.457224-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1635781811 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 10997 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.93667 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Mon, 01 Nov 2021 15:50:22 -0000 From: Simon Marchi The "set index-cache" command is used at the same time as a prefix command (prefix for "set index-cache directory", for example), and a boolean setting for turning the index-cache on and off. Even though I did introduce that, I now don't think it's a good idea to do something non-standard like this. First, there's no dedicated CLI command to show whether the index-cache is enabled, so it has to be custom output in the "show index-cache handler". Also, it means there's no good way a MI frontend can find out if the index-cache is enabled. "-gdb-show index-cache" doesn't show it in the MI output record: (gdb) interpreter-exec mi "-gdb-show index-cache" ~"\n" ~"The index cache is currently disabled.\n" ^done,showlist={option={name="directory",value="/home/simark/.cache/gdb"}} Fix this by introducing "set/show index-cache enabled on/off", regular boolean setting commands. Keep commands "set index-cache on" and "set index-cache off" as deprecated aliases of "set index-cache enabled", with respectively the default arguments "on" and "off". Update tests using "set index-cache on/off" to use the new command. Update the regexps in gdb.base/maint.exp to figure out whether the index-cache is enabled or not. Update the doc to mention the new commands. Change-Id: I7d5aaaf7fd22bf47bd03e0023ef4fbb4023b37b3 --- gdb/doc/gdb.texinfo | 8 +-- gdb/dwarf2/index-cache.c | 73 ++++++++++++-------- gdb/testsuite/gdb.base/index-cache.exp | 27 ++++++-- gdb/testsuite/gdb.base/maint.exp | 6 +- gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp | 6 +- 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index c435bc655b0d..ed9018b3c0c4 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -21795,14 +21795,14 @@ Indices only work when using DWARF debugging information, not stabs. @cindex automatic symbol index cache It is possible for @value{GDBN} to automatically save a copy of this index in a cache on disk and retrieve it from there when loading the same binary in the -future. This feature can be turned on with @kbd{set index-cache on}. The -following commands can be used to tweak the behavior of the index cache. +future. This feature can be turned on with @kbd{set index-cache enabled on}. +The following commands can be used to tweak the behavior of the index cache. @table @code @kindex set index-cache -@item set index-cache on -@itemx set index-cache off +@item set index-cache enabled on +@itemx set index-cache enabled off Enable or disable the use of the symbol index cache. @item set index-cache directory @var{directory} diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index 4a83213a6250..a56d1485dcb3 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -22,6 +22,7 @@ #include "build-id.h" #include "cli/cli-cmds.h" +#include "cli/cli-decode.h" #include "command.h" #include "gdbsupport/scoped_mmap.h" #include "gdbsupport/pathstuff.h" @@ -249,34 +250,32 @@ index_cache::make_index_filename (const bfd_build_id *build_id, return m_dir + SLASH_STRING + build_id_str + suffix; } -/* "show index-cache" handler. */ +/* "set/show index-cache enabled" set callback. */ static void -show_index_cache_command (const char *arg, int from_tty) +set_index_cache_enabled_command (bool value) { - /* Call all "show index-cache" subcommands. */ - cmd_show_list (show_index_cache_prefix_list, from_tty); - - printf_unfiltered ("\n"); - printf_unfiltered - (_("The index cache is currently %s.\n"), - global_index_cache.enabled () ? _("enabled") : _("disabled")); + if (value) + global_index_cache.enable (); + else + global_index_cache.disable (); } -/* "set index-cache on" handler. */ +/* "set/show index-cache enabled" get callback. */ -static void -set_index_cache_on_command (const char *arg, int from_tty) +static bool +get_index_cache_enabled_command () { - global_index_cache.enable (); + return global_index_cache.enabled (); } -/* "set index-cache off" handler. */ +/* "set/show index-cache enabled" show callback. */ static void -set_index_cache_off_command (const char *arg, int from_tty) +show_index_cache_enabled_command (ui_file *stream, int from_tty, + cmd_list_element *cmd, const char *value) { - global_index_cache.disable (); + fprintf_filtered (stream, _("The index cache is %s.\n"), value); } /* "set index-cache directory" handler. */ @@ -317,24 +316,38 @@ _initialize_index_cache () else warning (_("Couldn't determine a path for the index cache directory.")); - /* set index-cache */ - add_basic_prefix_cmd ("index-cache", class_files, - _("Set index-cache options."), - &set_index_cache_prefix_list, - false, &setlist); - - /* show index-cache */ - add_prefix_cmd ("index-cache", class_files, show_index_cache_command, - _("Show index-cache options."), &show_index_cache_prefix_list, - false, &showlist); + /* set/show index-cache */ + add_setshow_prefix_cmd ("index-cache", class_files, + _("Set index-cache options."), + _("Show index-cache options."), + &set_index_cache_prefix_list, + &show_index_cache_prefix_list, + &setlist, &showlist); + + set_show_commands setshow_index_cache_enabled_cmds + = add_setshow_boolean_cmd ("enabled", class_files, + _("Enable the index cache."), + _("Show whether the index cache is enabled."), + _("help doc"), + set_index_cache_enabled_command, + get_index_cache_enabled_command, + show_index_cache_enabled_command, + &set_index_cache_prefix_list, + &show_index_cache_prefix_list); /* set index-cache on */ - add_cmd ("on", class_files, set_index_cache_on_command, - _("Enable the index cache."), &set_index_cache_prefix_list); + cmd_list_element *set_index_cache_on_cmd + = add_alias_cmd ("on", setshow_index_cache_enabled_cmds.set, class_files, + false, &set_index_cache_prefix_list); + deprecate_cmd (set_index_cache_on_cmd, "set index-cache enabled on"); + set_index_cache_on_cmd->default_args = "on"; /* set index-cache off */ - add_cmd ("off", class_files, set_index_cache_off_command, - _("Disable the index cache."), &set_index_cache_prefix_list); + cmd_list_element *set_index_cache_off_cmd + = add_alias_cmd ("off", setshow_index_cache_enabled_cmds.set, class_files, + false, &set_index_cache_prefix_list); + deprecate_cmd (set_index_cache_off_cmd, "set index-cache enabled off"); + set_index_cache_off_cmd->default_args = "off"; /* set index-cache directory */ add_setshow_filename_cmd ("directory", class_files, &index_cache_directory, diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp index b6e2c3ec0223..626f88bd5a0a 100644 --- a/gdb/testsuite/gdb.base/index-cache.exp +++ b/gdb/testsuite/gdb.base/index-cache.exp @@ -81,7 +81,7 @@ proc run_test_with_flags { cache_dir cache_enabled code } { save_vars { GDBFLAGS } { set GDBFLAGS "$GDBFLAGS -iex \"set index-cache directory $cache_dir\"" - set GDBFLAGS "$GDBFLAGS -iex \"set index-cache $cache_enabled\"" + set GDBFLAGS "$GDBFLAGS -iex \"set index-cache enabled $cache_enabled\"" clean_restart ${testfile} @@ -98,17 +98,30 @@ proc_with_prefix test_basic_stuff { } { # Check that the index cache is disabled by default. gdb_test \ - "show index-cache" \ - " is currently disabled." \ + "show index-cache enabled" \ + "The index cache is off." \ "index-cache is disabled by default" - # Test that we can enable it and "show index-cache" reflects that. - gdb_test_no_output "set index-cache on" "enable index cache" + # Test that we can enable it and "show index-cache enabled" reflects that. + gdb_test_no_output "set index-cache enabled on" "enable index cache" gdb_test \ - "show index-cache" \ - " is currently enabled." \ + "show index-cache enabled" \ + "The index cache is on." \ "index-cache is now enabled" + with_test_prefix "deprecated commands" { + gdb_test "set index-cache off" ".*is deprecated.*" "disable index cache" + gdb_test \ + "show index-cache enabled" \ + "The index cache is off." \ + "index-cache is now disabled" + gdb_test "set index-cache on" ".*is deprecated.*" "enable index cache" + gdb_test \ + "show index-cache enabled" \ + "The index cache is on." \ + "index-cache is now enabled" + } + # Test the "set/show index-cache directory" commands. gdb_test "set index-cache directory" "Argument required.*" "set index-cache directory without arg" gdb_test_no_output "set index-cache directory /tmp" "change the index cache directory" diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 7d1f462f9739..34fc9e1090ed 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -131,11 +131,11 @@ gdb_test_multiple "info index-cache stats" "check index cache stats" { } set using_index_cache 0 -gdb_test_multiple "show index-cache" "check index cache status" { - -re ".*is currently disabled.\r\n$gdb_prompt $" { +gdb_test_multiple "show index-cache enabled" "check index cache status" { + -re ".*is off.\r\n$gdb_prompt $" { set using_index_cache 0 } - -re ".*is currently enabled.\r\n$gdb_prompt $" { + -re ".*is on.\r\n$gdb_prompt $" { set using_index_cache 1 } } diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp index 6891cd774465..47c92d9a26f2 100644 --- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp +++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp @@ -45,7 +45,7 @@ with_test_prefix "populate index cache" { gdb_test_no_output "set index-cache directory $cache_dir" \ "set index-cache directory" - gdb_test_no_output "set index-cache on" + gdb_test_no_output "set index-cache enabled on" gdb_test "file $binfile" "Reading symbols from .*" "file" } @@ -56,9 +56,9 @@ proc load_binary { method } { if { $method == "standard" } { gdb_test "file $binfile" "Reading symbols from .*" "file" } elseif { $method == "index" } { - gdb_test_no_output "set index-cache on" + gdb_test_no_output "set index-cache enabled on" gdb_test "file $binfile" "Reading symbols from .*" "file index" - gdb_test_no_output "set index-cache off" + gdb_test_no_output "set index-cache enabled off" } elseif { $method == "readnow" } { gdb_test "file -readnow $binfile" \ "Reading symbols from .*Expanding full symbols from .*" \ -- 2.26.2