mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
3847a7bfbf
Currently "maint time" will print the amount of time a command took. Sometimes, though, it's useful to have a timestamp as well -- for example if one is correlating a gdb log with some other log. This patch adds a timestamp to the start and end of each command when this setting is in effect. This also removes a "//" comment and changes scoped_command_stats to use DISABLE_COPY_AND_ASSIGN; two minor things I noticed while working on the patch. Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-06 Tom Tromey <tromey@adacore.com> * maint.h (class scoped_command_stats): Use DISABLE_COPY_AND_ASSIGN. <print_time>: New method. * maint.c (scoped_command_stats, ~scoped_command_stats): Call print_time. (scoped_command_stats::print_time): New method. gdb/testsuite/ChangeLog 2019-06-06 Tom Tromey <tromey@adacore.com> * gdb.base/maint.exp: Expect command started/finished output.
67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
/* Support for GDB maintenance commands.
|
|
Copyright (C) 2013-2019 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef MAINT_H
|
|
#define MAINT_H
|
|
|
|
#include "common/run-time-clock.h"
|
|
#include <chrono>
|
|
|
|
extern void set_per_command_time (int);
|
|
|
|
extern void set_per_command_space (int);
|
|
|
|
/* Records a run time and space usage to be used as a base for
|
|
reporting elapsed time or change in space. */
|
|
|
|
class scoped_command_stats
|
|
{
|
|
public:
|
|
|
|
explicit scoped_command_stats (bool msg_type);
|
|
~scoped_command_stats ();
|
|
|
|
private:
|
|
|
|
DISABLE_COPY_AND_ASSIGN (scoped_command_stats);
|
|
|
|
/* Print the time, along with a string. */
|
|
void print_time (const char *msg);
|
|
|
|
/* Zero if the saved time is from the beginning of GDB execution.
|
|
One if from the beginning of an individual command execution. */
|
|
bool m_msg_type;
|
|
/* Track whether the stat was enabled at the start of the command
|
|
so that we can avoid printing anything if it gets turned on by
|
|
the current command. */
|
|
int m_time_enabled : 1;
|
|
int m_space_enabled : 1;
|
|
int m_symtab_enabled : 1;
|
|
run_time_clock::time_point m_start_cpu_time;
|
|
std::chrono::steady_clock::time_point m_start_wall_time;
|
|
long m_start_space;
|
|
/* Total number of symtabs (over all objfiles). */
|
|
int m_start_nr_symtabs;
|
|
/* A count of the compunits. */
|
|
int m_start_nr_compunit_symtabs;
|
|
/* Total number of blocks. */
|
|
int m_start_nr_blocks;
|
|
};
|
|
|
|
#endif /* MAINT_H */
|