Remove initialize_utils

Message ID 20190925153709.8282-1-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 25, 2019, 3:37 p.m. UTC
  initialize_utils only registers some commands, so it isn't necessary
to run it at any particular time during startup.  This patch removes
it and merges its contents into _initialize_utils.

Tested by the buildbot.

gdb/ChangeLog
2019-09-25  Tom Tromey  <tom@tromey.com>

	* utils.h (initialize_utils): Don't declare.
	* top.c (gdb_init): Don't call initialize_utils.
	* utils.c (initialize_utils): Remove.  Move contents...
	(_initialize_utils): ... here.
---
 gdb/ChangeLog |  7 ++++
 gdb/top.c     |  1 -
 gdb/utils.c   | 98 ++++++++++++++++++++++++---------------------------
 gdb/utils.h   |  2 --
 4 files changed, 54 insertions(+), 54 deletions(-)
  

Comments

Simon Marchi Sept. 26, 2019, 2:16 a.m. UTC | #1
On 2019-09-25 11:37 a.m., Tom Tromey wrote:
> initialize_utils only registers some commands, so it isn't necessary
> to run it at any particular time during startup.  This patch removes
> it and merges its contents into _initialize_utils.
> 
> Tested by the buildbot.

The comment made me wonder, maybe it's purposefully done earlier so that
calls to warning or error in other _initialize functions work.  But as
you said, all it does is register commands, so I don't really see how this
could go wrong.

Simon
  
Tom Tromey Sept. 26, 2019, 1:37 p.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> On 2019-09-25 11:37 a.m., Tom Tromey wrote:
>> initialize_utils only registers some commands, so it isn't necessary
>> to run it at any particular time during startup.  This patch removes
>> it and merges its contents into _initialize_utils.
>> 
>> Tested by the buildbot.

Simon> The comment made me wonder, maybe it's purposefully done earlier so that
Simon> calls to warning or error in other _initialize functions work.  But as
Simon> you said, all it does is register commands, so I don't really see how this
Simon> could go wrong.

Thanks, I'm checking it in now.

Perhaps this function did more work in the past?  I didn't look but it
would make sense given the comment.

Tom
  

Patch

diff --git a/gdb/top.c b/gdb/top.c
index 49e6daae949..a1a08e0b99e 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2234,7 +2234,6 @@  gdb_init (char *argv0)
 
   init_cmd_lists ();	    /* This needs to be done first.  */
   initialize_targets ();    /* Setup target_terminal macros for utils.c.  */
-  initialize_utils ();	    /* Make errors and warnings possible.  */
 
   init_page_info ();
 
diff --git a/gdb/utils.c b/gdb/utils.c
index b2535ebefd3..b6a1ed58b20 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -2789,57 +2789,6 @@  show_debug_timestamp (struct ui_file *file, int from_tty,
 }
 
 
-void
-initialize_utils (void)
-{
-  add_setshow_uinteger_cmd ("width", class_support, &chars_per_line, _("\
-Set number of characters where GDB should wrap lines of its output."), _("\
-Show number of characters where GDB should wrap lines of its output."), _("\
-This affects where GDB wraps its output to fit the screen width.\n\
-Setting this to \"unlimited\" or zero prevents GDB from wrapping its output."),
-			    set_width_command,
-			    show_chars_per_line,
-			    &setlist, &showlist);
-
-  add_setshow_uinteger_cmd ("height", class_support, &lines_per_page, _("\
-Set number of lines in a page for GDB output pagination."), _("\
-Show number of lines in a page for GDB output pagination."), _("\
-This affects the number of lines after which GDB will pause\n\
-its output and ask you whether to continue.\n\
-Setting this to \"unlimited\" or zero causes GDB never pause during output."),
-			    set_height_command,
-			    show_lines_per_page,
-			    &setlist, &showlist);
-
-  add_setshow_boolean_cmd ("pagination", class_support,
-			   &pagination_enabled, _("\
-Set state of GDB output pagination."), _("\
-Show state of GDB output pagination."), _("\
-When pagination is ON, GDB pauses at end of each screenful of\n\
-its output and asks you whether to continue.\n\
-Turning pagination off is an alternative to \"set height unlimited\"."),
-			   NULL,
-			   show_pagination_enabled,
-			   &setlist, &showlist);
-
-  add_setshow_boolean_cmd ("sevenbit-strings", class_support,
-			   &sevenbit_strings, _("\
-Set printing of 8-bit characters in strings as \\nnn."), _("\
-Show printing of 8-bit characters in strings as \\nnn."), NULL,
-			   NULL,
-			   show_sevenbit_strings,
-			   &setprintlist, &showprintlist);
-
-  add_setshow_boolean_cmd ("timestamp", class_maintenance,
-			    &debug_timestamp, _("\
-Set timestamping of debugging messages."), _("\
-Show timestamping of debugging messages."), _("\
-When set, debugging messages will be marked with seconds and microseconds."),
-			   NULL,
-			   show_debug_timestamp,
-			   &setdebuglist, &showdebuglist);
-}
-
 /* See utils.h.  */
 
 CORE_ADDR
@@ -3448,6 +3397,53 @@  copy_bitwise (gdb_byte *dest, ULONGEST dest_offset,
 void
 _initialize_utils (void)
 {
+  add_setshow_uinteger_cmd ("width", class_support, &chars_per_line, _("\
+Set number of characters where GDB should wrap lines of its output."), _("\
+Show number of characters where GDB should wrap lines of its output."), _("\
+This affects where GDB wraps its output to fit the screen width.\n\
+Setting this to \"unlimited\" or zero prevents GDB from wrapping its output."),
+			    set_width_command,
+			    show_chars_per_line,
+			    &setlist, &showlist);
+
+  add_setshow_uinteger_cmd ("height", class_support, &lines_per_page, _("\
+Set number of lines in a page for GDB output pagination."), _("\
+Show number of lines in a page for GDB output pagination."), _("\
+This affects the number of lines after which GDB will pause\n\
+its output and ask you whether to continue.\n\
+Setting this to \"unlimited\" or zero causes GDB never pause during output."),
+			    set_height_command,
+			    show_lines_per_page,
+			    &setlist, &showlist);
+
+  add_setshow_boolean_cmd ("pagination", class_support,
+			   &pagination_enabled, _("\
+Set state of GDB output pagination."), _("\
+Show state of GDB output pagination."), _("\
+When pagination is ON, GDB pauses at end of each screenful of\n\
+its output and asks you whether to continue.\n\
+Turning pagination off is an alternative to \"set height unlimited\"."),
+			   NULL,
+			   show_pagination_enabled,
+			   &setlist, &showlist);
+
+  add_setshow_boolean_cmd ("sevenbit-strings", class_support,
+			   &sevenbit_strings, _("\
+Set printing of 8-bit characters in strings as \\nnn."), _("\
+Show printing of 8-bit characters in strings as \\nnn."), NULL,
+			   NULL,
+			   show_sevenbit_strings,
+			   &setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("timestamp", class_maintenance,
+			    &debug_timestamp, _("\
+Set timestamping of debugging messages."), _("\
+Show timestamping of debugging messages."), _("\
+When set, debugging messages will be marked with seconds and microseconds."),
+			   NULL,
+			   show_debug_timestamp,
+			   &setdebuglist, &showdebuglist);
+
   add_internal_problem_command (&internal_error_problem);
   add_internal_problem_command (&internal_warning_problem);
   add_internal_problem_command (&demangler_warning_problem);
diff --git a/gdb/utils.h b/gdb/utils.h
index 7cdc73ef54f..348585cc922 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -28,8 +28,6 @@ 
 struct completion_match_for_lcd;
 class compiled_regex;
 
-extern void initialize_utils (void);
-
 /* String utilities.  */
 
 extern bool sevenbit_strings;