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.
This commit is contained in:
Stan Shebs 1994-11-23 03:27:40 +00:00
parent aa30c7ee22
commit 43ab4ba582
3 changed files with 98 additions and 15 deletions

View File

@ -1,3 +1,17 @@
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.

View File

@ -1,5 +1,5 @@
/* 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.
@ -33,14 +33,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#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));
/*
@ -113,6 +114,32 @@ maintenance_demangle (args, from_tty)
}
}
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. */
@ -260,6 +287,18 @@ Call internal GDB demangler routine to demangle a C++ link name\n\
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\

View File

@ -557,9 +557,14 @@ read_command_file (stream)
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));
@ -890,17 +895,18 @@ execute_command (p, from_tty)
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 */
@ -912,12 +918,16 @@ command_loop_marker (foo)
/* 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))
{
@ -932,10 +942,30 @@ command_loop ()
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));
}
}
}