maint.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Support for GDB maintenance commands.
  2. Copyright (C) 2013-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef MAINT_H
  15. #define MAINT_H
  16. #include "gdbsupport/run-time-clock.h"
  17. #include <chrono>
  18. extern void set_per_command_time (int);
  19. extern void set_per_command_space (int);
  20. /* Records a run time and space usage to be used as a base for
  21. reporting elapsed time or change in space. */
  22. class scoped_command_stats
  23. {
  24. public:
  25. explicit scoped_command_stats (bool msg_type);
  26. ~scoped_command_stats ();
  27. private:
  28. DISABLE_COPY_AND_ASSIGN (scoped_command_stats);
  29. /* Print the time, along with a string. */
  30. void print_time (const char *msg);
  31. /* Zero if the saved time is from the beginning of GDB execution.
  32. One if from the beginning of an individual command execution. */
  33. bool m_msg_type;
  34. /* Track whether the stat was enabled at the start of the command
  35. so that we can avoid printing anything if it gets turned on by
  36. the current command. */
  37. int m_time_enabled : 1;
  38. int m_space_enabled : 1;
  39. int m_symtab_enabled : 1;
  40. run_time_clock::time_point m_start_cpu_time;
  41. std::chrono::steady_clock::time_point m_start_wall_time;
  42. long m_start_space;
  43. /* Total number of symtabs (over all objfiles). */
  44. int m_start_nr_symtabs;
  45. /* A count of the compunits. */
  46. int m_start_nr_compunit_symtabs;
  47. /* Total number of blocks. */
  48. int m_start_nr_blocks;
  49. };
  50. extern obj_section *maint_obj_section_from_bfd_section (bfd *abfd,
  51. asection *asection,
  52. objfile *ofile);
  53. #endif /* MAINT_H */