aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-cache.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-11-04 15:31:28 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-11-04 15:48:59 -0400
commit7bc5c369fae6dda3657467aee14e352a66b4270f (patch)
tree892fdb9b3bb2fc0f6d1cab26f7fd64373ca691cd /gdb/dwarf2/index-cache.c
parentfcef6471ed3c07d6eac2d9e0010552994f0891aa (diff)
downloadbinutils-7bc5c369fae6dda3657467aee14e352a66b4270f.zip
binutils-7bc5c369fae6dda3657467aee14e352a66b4270f.tar.gz
binutils-7bc5c369fae6dda3657467aee14e352a66b4270f.tar.bz2
gdb: introduce "set index-cache enabled", deprecate "set index-cache on/off"
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
Diffstat (limited to 'gdb/dwarf2/index-cache.c')
-rw-r--r--gdb/dwarf2/index-cache.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c
index f439b37..06c27db 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"
@@ -267,20 +268,32 @@ show_index_cache_command (const char *arg, int from_tty)
global_index_cache.enabled () ? _("enabled") : _("disabled"));
}
-/* "set index-cache on" handler. */
+/* "set/show index-cache enabled" set callback. */
static void
-set_index_cache_on_command (const char *arg, int from_tty)
+set_index_cache_enabled_command (bool value)
{
- global_index_cache.enable ();
+ if (value)
+ global_index_cache.enable ();
+ else
+ global_index_cache.disable ();
+}
+
+/* "set/show index-cache enabled" get callback. */
+
+static bool
+get_index_cache_enabled_command ()
+{
+ 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. */
@@ -342,13 +355,31 @@ _initialize_index_cache ()
_("Show index-cache options."), &show_index_cache_prefix_list,
false, &showlist);
+ /* set/show index-cache enabled */
+ 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,