+Tue Nov 22 19:13:39 1994 Stan Shebs (shebs@andros.cygnus.com)
+
+ Maintenance commands to report time and space usage.
+ * main.c (display_time, display_space): New globals.
+ (main): Add argument --statistics to enable reporting, display
+ time and space after startup is done.
+ * maint.c (maintenance_time_display, maintenance_space_display):
+ New commands.
+ * top.c (command_loop): Display time and space after command
+ execution.
+
+ * top.c (pre_init_ui_hook): New global.
+ (gdb_init): If pre_init_ui_hook set, call before all other init.
+
Tue Nov 22 10:25:59 1994 Kung Hsu (kung@mexican.cygnus.com)
* a29k-tdep.c (examine_tag): Fix a bug in stack frame size.
/* Support for GDB maintenance commands.
- Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
Written by Fred Fish at Cygnus Support.
This file is part of GDB.
#include "expression.h" /* For language.h */
#include "language.h"
-static void
-maintenance_command PARAMS ((char *, int));
+static void maintenance_command PARAMS ((char *, int));
-static void
-maintenance_dump_me PARAMS ((char *, int));
+static void maintenance_dump_me PARAMS ((char *, int));
-static void
-maintenance_demangle PARAMS ((char *, int));
+static void maintenance_demangle PARAMS ((char *, int));
+
+static void maintenance_time_display PARAMS ((char *, int));
+
+static void maintenance_space_display PARAMS ((char *, int));
/*
}
}
+static void
+maintenance_time_display (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ extern int display_time;
+
+ if (args == NULL || *args == '\0')
+ printf_unfiltered ("\"maintenance time\" takes a numeric argument.\n");
+ else
+ display_time = strtol (args, NULL, 10);
+}
+
+static void
+maintenance_space_display (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ extern int display_space;
+
+ if (args == NULL || *args == '\0')
+ printf_unfiltered ("\"maintenance space\" takes a numeric argument.\n");
+ else
+ display_space = strtol (args, NULL, 10);
+}
+
/* The "maintenance info" command is defined as a prefix, with allow_unknown 0.
Therefore, its own definition is called only for "maintenance info" with
no args. */
and prints the result.",
&maintenancelist);
+ add_cmd ("time", class_maintenance, maintenance_time_display,
+ "Set the display of time usage.\n\
+If nonzero, will cause the execution time for each command to be\n\
+displayed, following the command's output.",
+ &maintenancelist);
+
+ add_cmd ("space", class_maintenance, maintenance_space_display,
+ "Set the display of space usage.\n\
+If nonzero, will cause the execution space for each command to be\n\
+displayed, following the command's output.",
+ &maintenancelist);
+
add_cmd ("type", class_maintenance, maintenance_print_type,
"Print a type chain for a given symbol.\n\
For each node in a type chain, print the raw data for each member of\n\
\f
extern void init_proc ();
+void (*pre_init_ui_hook) PARAMS ((void));
+
void
gdb_init ()
{
+ if (pre_init_ui_hook)
+ pre_init_ui_hook ();
+
/* Run the init function of each source file */
getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
actually running the program, i.e. there is a stack. */
/* FIXME: This should be cacheing the frame and only running when
the frame changes. */
+
if (target_has_stack)
- {
- flang = get_frame_language ();
- if (!warned
- && flang != language_unknown
- && flang != current_language->la_language)
{
- printf_filtered ("%s\n", lang_frame_mismatch_warn);
- warned = 1;
+ flang = get_frame_language ();
+ if (!warned
+ && flang != language_unknown
+ && flang != current_language->la_language)
+ {
+ printf_filtered ("%s\n", lang_frame_mismatch_warn);
+ warned = 1;
+ }
}
- }
}
/* ARGSUSED */
/* Read commands from `instream' and execute them
until end of file or error reading instream. */
+
void
command_loop ()
{
struct cleanup *old_chain;
char *command;
int stdin_is_tty = ISATTY (stdin);
+ long time_at_cmd_start;
+ extern int display_time;
+ extern int display_space;
while (!feof (instream))
{
instream == stdin, "prompt");
if (command == 0)
return;
+
+ time_at_cmd_start = get_run_time ();
+
execute_command (command, instream == stdin);
/* Do any commands attached to breakpoint we stopped at. */
bpstat_do_actions (&stop_bpstat);
do_cleanups (old_chain);
+
+ if (display_time)
+ {
+ long cmd_time = get_run_time () - time_at_cmd_start;
+
+ printf_unfiltered ("Command execution time: %ld.%06ld\n",
+ cmd_time / 1000000, cmd_time % 1000000);
+ }
+
+ if (display_space)
+ {
+ extern char **environ;
+ char *lim = (char *) sbrk (0);
+
+ printf_unfiltered ("Post-command data size: %ld\n",
+ (long) (lim - (char *) &environ));
+ }
}
}
\f