Patch: Updated --enable-profiling
Tom Tromey
tromey@cygnus.com
Sun Oct 31 11:59:00 GMT 1999
Here is an updated version of my --enable-profiling patch.
This one includes changes suggested by Stan and Michael.
1999-10-29 Tom Tromey <tromey@cygnus.com>
* config.in: Rebuilt.
* acconfig.h (ENABLE_PROFILE): New #undef.
* Makefile.in (PROFILE_CFLAGS): New macro.
* configure: Rebuilt.
* configure.in: Added --enable-profiling. Define ENABLE_PROFILE
if provided. Set and subst PROFILE_CFLAGS.
* maint.c (maint_profile_gdb): New function.
(_initialize_maint_cmds): Add `profile-gdb' command if profiling
support is enabled.
* main.c (main): Turn off profiling if profiling support is
enabled.
1999-10-31 Tom Tromey <tromey@cygnus.com>
* gdbint.texinfo (Profiling GDB): New node.
More comments / requests? Or is this ok to commit?
Tom
Index: Makefile.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/Makefile.in,v
retrieving revision 1.662.2.4
diff -u -r1.662.2.4 Makefile.in
--- Makefile.in 1999/06/15 17:57:51 1.662.2.4
+++ Makefile.in 1999/10/31 19:51:21
@@ -206,7 +206,7 @@
# M{H,T}_CFLAGS, if defined, have host- and target-dependent CFLAGS
# from the config directory.
GLOBAL_CFLAGS = $(MT_CFLAGS) $(MH_CFLAGS)
-#PROFILE_CFLAGS = -pg
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
# CFLAGS is specifically reserved for setting from the command line
# when running make. I.E. "make CFLAGS=-Wmissing-prototypes".
Index: acconfig.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/acconfig.h,v
retrieving revision 2.19
diff -u -r2.19 acconfig.h
--- acconfig.h 1999/03/24 00:57:12 2.19
+++ acconfig.h 1999/10/31 19:51:23
@@ -96,3 +96,6 @@
/* Set to true if the save_state_t structure has the ss_wide member */
#define HAVE_STRUCT_MEMBER_SS_WIDE 0
+
+/* Define if profiling support should be enabled. */
+#undef ENABLE_PROFILE
Index: config.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/config.in,v
retrieving revision 2.34
diff -u -r2.34 config.in
--- config.in 1999/03/24 00:57:12 2.34
+++ config.in 1999/10/31 19:51:25
@@ -129,6 +129,9 @@
/* Set to true if the save_state_t structure has the ss_wide member */
#define HAVE_STRUCT_MEMBER_SS_WIDE 0
+/* Define if profiling support should be enabled. */
+#undef ENABLE_PROFILE
+
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT
Index: configure.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/configure.in,v
retrieving revision 1.385.2.1
diff -u -r1.385.2.1 configure.in
--- configure.in 1999/04/15 22:53:46 1.385.2.1
+++ configure.in 1999/10/31 19:51:34
@@ -330,7 +330,16 @@
dnl Handle optional features that can be enabled.
ENABLE_CFLAGS=
+PROFILE_CFLAGS=
+AC_ARG_ENABLE(profiling,
+[ --enable-profiling Turn on profiling of gdb])
+
+if test "$enable_profiling" = yes; then
+ AC_DEFINE(ENABLE_PROFILE)
+ PROFILE_CFLAGS=-pg
+fi
+
AC_ARG_ENABLE(tui,
[ --enable-tui Enable full-screen terminal user interface],
[
@@ -681,6 +690,7 @@
AC_SUBST(IGNORE_SIM_OBS)
AC_SUBST(ENABLE_CFLAGS)
+AC_SUBST(PROFILE_CFLAGS)
AC_SUBST(CONFIG_OBS)
AC_SUBST(CONFIG_DEPS)
Index: main.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/main.c,v
retrieving revision 1.164.2.1
diff -u -r1.164.2.1 main.c
--- main.c 1999/04/15 22:53:48 1.164.2.1
+++ main.c 1999/10/31 19:51:41
@@ -128,6 +128,10 @@
int gdb_file_size;
+#ifdef ENABLE_PROFILE
+ moncontrol (0);
+#endif
+
START_PROGRESS (argv[0], 0);
#ifdef MPW
Index: maint.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/maint.c,v
retrieving revision 2.27
diff -u -r2.27 maint.c
--- maint.c 1999/04/02 23:11:57 2.27
+++ maint.c 1999/10/31 19:51:46
@@ -56,6 +56,11 @@
static void maintenance_print_command PARAMS ((char *, int));
+#ifdef ENABLE_PROFILE
+static void maint_profile_gdb PARAMS ((char *, int));
+#endif
+
+
/* Set this to the maximum number of seconds to wait instead of waiting forever
in target_wait(). If this timer times out, then it generates an error and
the command is aborted. This replaces most of the need for timeouts in the
@@ -339,6 +344,26 @@
return;
}
+/* "maintenance profile-gdb <on|off>" */
+static void
+maint_profile_gdb (char *arg, int from_tty)
+{
+#ifdef ENABLE_PROFILE
+ int val;
+ if (arg == NULL || ! *arg)
+ error ("requires argument (\"on\" or \"off\"");
+ if (! strcmp (arg, "on"))
+ val = 1;
+ else if (! strcmp (arg, "off"))
+ val = 0;
+ else
+ error ("unrecognized argument; must be \"on\" or \"off\"");
+ moncontrol (val);
+#else
+ error ("gdb was not configured with --enable-profiling");
+#endif
+}
+
void
_initialize_maint_cmds ()
{
@@ -431,6 +456,12 @@
add_cmd ("translate-address", class_maintenance, maintenance_translate_address,
"Translate a section name and address to a symbol.",
&maintenancelist);
+
+#ifdef ENABLE_PROFILE
+ add_cmd ("profile-gdb", class_maintenance, maint_profile_gdb,
+ "Enable or disable profiling.",
+ &maintenancelist);
+#endif
add_show_from_set (
add_set_cmd ("watchdog", class_maintenance, var_zinteger, (char *)&watchdog,
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/doc/gdbint.texinfo,v
retrieving revision 1.110
diff -u -r1.110 gdbint.texinfo
--- gdbint.texinfo 1999/04/12 12:32:53 1.110
+++ gdbint.texinfo 1999/10/31 19:52:27
@@ -2522,6 +2522,7 @@
@menu
* Getting Started:: Getting started working on GDB
* Debugging GDB:: Debugging GDB with itself
+* Profiling GDB:: Profiling GDB
@end menu
@node Getting Started,,, Hints
@@ -2728,6 +2729,28 @@
@end table
+@node Profiling GDB,,, Hints
+
+@section Profiling GDB
+
+GDB contains some support for profiling itself. Currently this support
+is rudimentary.
+
+You can configure GDB with @samp{--enable-profiling}. This does two
+things. First, it arranges for GDB to be compiled and linked with
+@samp{-pg}. (This might not work on all platforms; feel free to submit
+patches to fix this for your platform.) Second, this configure flag
+arranges for the @code{maint profile-gdb} command to be enabled.
+
+@code{maint profile-gdb} takes a single argument, which must be
+@samp{on} or @samp{off}. This command enables or disables profiling of
+gdb, and can be used to limit profiling to a chosen set of user
+commands.
+
+Note that when configured this way, GDB disables profiling in
+@code{main}. If you want to profile GDB's initialization code, you will
+have to arrange to build GDB with @code{-pg} but without
+@samp{ENABLE_PROFILE} defined.
@contents
@bye
Index: NEWS
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/NEWS,v
retrieving revision 2.58
diff -u -r2.58 NEWS
--- NEWS 1999/04/13 00:17:35 2.58
+++ NEWS 1999/10/31 19:56:39
@@ -7,6 +7,12 @@
TI TMS320C80 tic80-*-*
+* Profiling for gdb
+
+If gdb is configured with `--enable-profiling', then gdb is built with
+`-pg' and a new `maintenance profile-gdb' command is created. This
+command can be used to enable or disable profiling, making it possible
+to profile a single command or set of commands.
*** Changes in GDB-4.18:
More information about the Gdb-patches
mailing list