aboutsummaryrefslogtreecommitdiff
path: root/gdb/maint.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-24 21:10:45 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:35 -0600
commit1e3b796d58ac3c4396e1739f44a0a41de6335eef (patch)
tree110d08e5fa5cab3124dc0d6eb2864ad7675d9563 /gdb/maint.h
parent6fc31fc73b577fce960730d87ead9a25df6c2653 (diff)
downloadgdb-1e3b796d58ac3c4396e1739f44a0a41de6335eef.zip
gdb-1e3b796d58ac3c4396e1739f44a0a41de6335eef.tar.gz
gdb-1e3b796d58ac3c4396e1739f44a0a41de6335eef.tar.bz2
Change command stats reporting to use class
This removes make_command_stats_cleanup in favor of an RAII class. The patch is reasonably straightforward, but keeping the same semantics without excessive reindentation required splitting captured_main in two. 2016-10-21 Tom Tromey <tom@tromey.com> * maint.h (scoped_command_stats): New class. (make_command_stats_cleanup): Don't declare. * maint.c (struct cmd_stats): Remove. (~scoped_command_stats): Rename from report_command_stats. Now a destructor. (scoped_command_stats): Rename from make_command_stats_cleanup. Now a constructor. * main.c (captured_main_1): New function. Use scoped_command_stats. (captured_main): Call captured_main_1. * event-top.c (command_handler): Use scoped_command_stats.
Diffstat (limited to 'gdb/maint.h')
-rw-r--r--gdb/maint.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/gdb/maint.h b/gdb/maint.h
index 841e790..8d03800 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -23,9 +23,40 @@ extern void set_per_command_time (int);
extern void set_per_command_space (int);
-/* Note: There's no set_per_command_symtab on purpose.
- Symtab stats aren't yet as useful for --statistics output. */
-
-extern struct cleanup *make_command_stats_cleanup (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:
+
+ // No need for these. They are intentionally not defined anywhere.
+ scoped_command_stats &operator= (const scoped_command_stats &);
+ scoped_command_stats (const scoped_command_stats &);
+
+ /* 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;
+ long m_start_cpu_time;
+ struct timeval 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 */