Disambiguate info_print_options

Message ID 20200125050825.53004-1-tamur@google.com
State New, archived
Headers

Commit Message

Terekhov, Mikhail via Gdb-patches Jan. 25, 2020, 5:08 a.m. UTC
  struct info_print_options is defined in both symtab.c and stack.c, which is
an ODR violation. So, I am renaming one of them. (Please suggest a better
name, what I picked is not good).

gdb/ChangeLog:

	* symtab.c (info_print_options): Rename to
	info_print_options_for_symtab.
	(info_print_options_defs): Apply name change.
	(make_info_print_options_def_group): Likewise.
	(info_variables_command): Likewise.
	(info_functions_command): Likewise.
---
 gdb/symtab.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
  

Comments

Tom Tromey Jan. 26, 2020, 4:10 p.m. UTC | #1
>>>>> "Ali" == Ali Tamur via gdb-patches <gdb-patches@sourceware.org> writes:

Ali> struct info_print_options is defined in both symtab.c and stack.c, which is
Ali> an ODR violation. So, I am renaming one of them. (Please suggest a better
Ali> name, what I picked is not good).

Thank you for doing this.

I tend to think the naming of these "throwaway" structures isn't very
important.

That said, the comment just above reads:

/* Structure to hold the values of the options used by the 'info variables'
   and 'info functions' commands.  These correspond to the -q, -t, and -n
   options.  */

So how about "info_vars_funcs_options"?

Maybe make_info_sources_options_def_group should be renamed as well.
And perhaps info_print_command_completer.  My thinking here is that it
is best if the related names are all consistent.

thanks,
Tom
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index f456f4d852..95c15ac6e0 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4976,13 +4976,13 @@  symtab_symbol_info (bool quiet, bool exclude_minsyms,
    and 'info functions' commands.  These correspond to the -q, -t, and -n
    options.  */
 
-struct info_print_options
+struct info_print_options_for_symtab
 {
   bool quiet = false;
   bool exclude_minsyms = false;
   char *type_regexp = nullptr;
 
-  ~info_print_options ()
+  ~info_print_options_for_symtab ()
   {
     xfree (type_regexp);
   }
@@ -4992,23 +4992,23 @@  struct info_print_options
    commands.  */
 
 static const gdb::option::option_def info_print_options_defs[] = {
-  gdb::option::boolean_option_def<info_print_options> {
+  gdb::option::boolean_option_def<info_print_options_for_symtab> {
     "q",
-    [] (info_print_options *opt) { return &opt->quiet; },
+    [] (info_print_options_for_symtab *opt) { return &opt->quiet; },
     nullptr, /* show_cmd_cb */
     nullptr /* set_doc */
   },
 
-  gdb::option::boolean_option_def<info_print_options> {
+  gdb::option::boolean_option_def<info_print_options_for_symtab> {
     "n",
-    [] (info_print_options *opt) { return &opt->exclude_minsyms; },
+    [] (info_print_options_for_symtab *opt) { return &opt->exclude_minsyms; },
     nullptr, /* show_cmd_cb */
     nullptr /* set_doc */
   },
 
-  gdb::option::string_option_def<info_print_options> {
+  gdb::option::string_option_def<info_print_options_for_symtab> {
     "t",
-    [] (info_print_options *opt) { return &opt->type_regexp; },
+    [] (info_print_options_for_symtab *opt) { return &opt->type_regexp; },
     nullptr, /* show_cmd_cb */
     nullptr /* set_doc */
   }
@@ -5018,7 +5018,7 @@  static const gdb::option::option_def info_print_options_defs[] = {
    functions'.  */
 
 static gdb::option::option_def_group
-make_info_print_options_def_group (info_print_options *opts)
+make_info_print_options_def_group (info_print_options_for_symtab *opts)
 {
   return {{info_print_options_defs}, opts};
 }
@@ -5045,7 +5045,7 @@  info_print_command_completer (struct cmd_list_element *ignore,
 static void
 info_variables_command (const char *args, int from_tty)
 {
-  info_print_options opts;
+  info_print_options_for_symtab opts;
   auto grp = make_info_print_options_def_group (&opts);
   gdb::option::process_options
     (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
@@ -5061,7 +5061,7 @@  info_variables_command (const char *args, int from_tty)
 static void
 info_functions_command (const char *args, int from_tty)
 {
-  info_print_options opts;
+  info_print_options_for_symtab opts;
   auto grp = make_info_print_options_def_group (&opts);
   gdb::option::process_options
     (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);