gdb: Fix build failure with GCC 7
[deliverable/binutils-gdb.git] / gdb / maint.c
index 25a495caea18c498419bed4ba617c9bc1e406a60..a0d43ec7c0edd02e2741676a3320437379f99ec5 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for GDB maintenance commands.
 
-   Copyright (C) 1992-2016 Free Software Foundation, Inc.
+   Copyright (C) 1992-2017 Free Software Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.
 
@@ -24,8 +24,6 @@
 #include "arch-utils.h"
 #include <ctype.h>
 #include <signal.h>
-#include "gdb_sys_time.h"
-#include <time.h>
 #include "command.h"
 #include "gdbcmd.h"
 #include "symtab.h"
@@ -39,7 +37,6 @@
 #include "objfiles.h"
 #include "value.h"
 #include "top.h"
-#include "timeval-utils.h"
 #include "maint.h"
 #include "selftest.h"
 
@@ -181,6 +178,19 @@ maintenance_info_command (char *arg, int from_tty)
             gdb_stdout);
 }
 
+/* The "maintenance check" command is defined as a prefix, with
+   allow_unknown 0.  Therefore, its own definition is called only for
+   "maintenance check" with no args.  */
+
+static void
+maintenance_check_command (char *arg, int from_tty)
+{
+  printf_unfiltered (_("\"maintenance check\" must be followed "
+                      "by the name of a check command.\n"));
+  help_list (maintenancechecklist, "maintenance check ", all_commands,
+            gdb_stdout);
+}
+
 /* Mini tokenizing lexer for 'maint info sections' command.  */
 
 static int
@@ -406,14 +416,11 @@ maintenance_print_architecture (char *args, int from_tty)
     gdbarch_dump (gdbarch, gdb_stdout);
   else
     {
-      struct cleanup *cleanups;
-      struct ui_file *file = gdb_fopen (args, "w");
+      stdio_file file;
 
-      if (file == NULL)
+      if (!file.open (args, "w"))
        perror_with_name (_("maintenance print architecture"));
-      cleanups = make_cleanup_ui_file_delete (file);
-      gdbarch_dump (gdbarch, file);
-      do_cleanups (cleanups);
+      gdbarch_dump (gdbarch, &file);
     }
 }
 
@@ -822,23 +829,21 @@ scoped_command_stats::~scoped_command_stats ()
 
   if (m_time_enabled && per_command_time)
     {
-      long cmd_time = get_run_time () - m_start_cpu_time;
-      struct timeval now_wall_time, delta_wall_time, wait_time;
+      using namespace std::chrono;
 
-      gettimeofday (&now_wall_time, NULL);
-      timeval_sub (&delta_wall_time,
-                  &now_wall_time, &m_start_wall_time);
+      run_time_clock::duration cmd_time
+       = run_time_clock::now () - m_start_cpu_time;
 
+      steady_clock::duration wall_time
+       = steady_clock::now () - m_start_wall_time;
       /* Subtract time spend in prompt_for_continue from walltime.  */
-      wait_time = get_prompt_for_continue_wait_time ();
-      timeval_sub (&delta_wall_time, &delta_wall_time, &wait_time);
+      wall_time -= get_prompt_for_continue_wait_time ();
 
       printf_unfiltered (!m_msg_type
-                        ? _("Startup time: %ld.%06ld (cpu), %ld.%06ld (wall)\n")
-                        : _("Command execution time: %ld.%06ld (cpu), %ld.%06ld (wall)\n"),
-                        cmd_time / 1000000, cmd_time % 1000000,
-                        (long) delta_wall_time.tv_sec,
-                        (long) delta_wall_time.tv_usec);
+                        ? _("Startup time: %.6f (cpu), %.6f (wall)\n")
+                        : _("Command execution time: %.6f (cpu), %.6f (wall)\n"),
+                        duration<double> (cmd_time).count (),
+                        duration<double> (wall_time).count ());
     }
 
   if (m_space_enabled && per_command_space)
@@ -892,8 +897,10 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
 
   if (msg_type == 0 || per_command_time)
     {
-      m_start_cpu_time = get_run_time ();
-      gettimeofday (&m_start_wall_time, NULL);
+      using namespace std::chrono;
+
+      m_start_cpu_time = run_time_clock::now ();
+      m_start_wall_time = steady_clock::now ();
       m_time_enabled = 1;
     }
   else
@@ -912,7 +919,7 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
   else
     m_symtab_enabled = 0;
 
-  /* Initalize timer to keep track of how long we waited for the user.  */
+  /* Initialize timer to keep track of how long we waited for the user.  */
   reset_prompt_for_continue_wait_time ();
 }
 
@@ -1110,6 +1117,11 @@ Print the internal architecture configuration.\n\
 Takes an optional file parameter."),
           &maintenanceprintlist);
 
+  add_prefix_cmd ("check", class_maintenance, maintenance_check_command, _("\
+Commands for checking internal gdb state."),
+                 &maintenancechecklist, "maintenance check ", 0,
+                 &maintenancelist);
+
   add_cmd ("translate-address", class_maintenance,
           maintenance_translate_address,
           _("Translate a section name and address to a symbol."),
This page took 0.027475 seconds and 4 git commands to generate.