aboutsummaryrefslogtreecommitdiff
path: root/gdb/main.c
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/main.c
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/main.c')
-rw-r--r--gdb/main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/gdb/main.c b/gdb/main.c
index 2ea9466..e55c07b 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -441,12 +441,12 @@ typedef struct cmdarg {
/* Define type VEC (cmdarg_s). */
DEF_VEC_O (cmdarg_s);
-static int
-captured_main (void *data)
+static void
+captured_main_1 (struct captured_main_args *context)
{
- struct captured_main_args *context = (struct captured_main_args *) data;
int argc = context->argc;
char **argv = context->argv;
+
static int quiet = 0;
static int set_args = 0;
static int inhibit_home_gdbinit = 0;
@@ -486,14 +486,14 @@ captured_main (void *data)
int save_auto_load;
struct objfile *objfile;
- struct cleanup *pre_stat_chain;
+ struct cleanup *chain;
#ifdef HAVE_SBRK
- /* Set this before calling make_command_stats_cleanup. */
+ /* Set this before constructing scoped_command_stats. */
lim_at_start = (char *) sbrk (0);
#endif
- pre_stat_chain = make_command_stats_cleanup (0);
+ scoped_command_stats stat_reporter (false);
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
@@ -510,7 +510,7 @@ captured_main (void *data)
notice_open_fds ();
save_original_signals_state ();
- make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec);
+ chain = make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec);
dirsize = 1;
dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
ndir = 0;
@@ -1139,8 +1139,15 @@ captured_main (void *data)
quit_force (NULL, 0);
}
- /* Show time and/or space usage. */
- do_cleanups (pre_stat_chain);
+ do_cleanups (chain);
+}
+
+static void
+captured_main (void *data)
+{
+ struct captured_main_args *context = (struct captured_main_args *) data;
+
+ captured_main_1 (context);
/* NOTE: cagney/1999-11-07: There is probably no reason for not
moving this loop and the code found in captured_command_loop()