This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: `maint


I first sent this patch in around November 1.

This adds --enable-profile to gdb's configure, and, when gdb is
configured with profiling enabled, adds a `maint profile-gdb' command
to let profiling be enabled or disabled by the user at runtime.  This
makes it easy to profile only the commands which you're interested in.

As I recall, Stan liked this idea, and others indicated that they had
previously implemented this functionality for themselves as well.
However, I never got an official "ok" to let me check this in.

If this shouldn't go in, that's fine too -- but could somebody tell me
so I don't keep this patch sitting around another 3 months?

The patch includes updates to the documentation, the test suite, and
NEWS.

Tom

2000-01-16  Tom Tromey  <tromey@cygnus.com>

	* maint.c (maint_profile_gdb): New function.
	(_initialize_maint_cmds): Add `profile-gdb' command if profiling
	enabled.
	* main.c (captured_main): Call moncontrol if profiling enabled.
	* config.in, configure: Rebuilt.
	* configure.in: Added --enable-profiling.  Define PROFILE_CFLAGS
	and ENABLE_PROFILE as appropriate.
	* acconfig.h (ENABLE_PROFILE): Added.
	* Makefile.in (PROFILE_CFLAGS): Define as @PROFILE_CFLAGS@.

2000-01-16  Tom Tromey  <tromey@cygnus.com>

	* gdbint.texinfo (Profiling GDB): New node.

2000-01-16  Tom Tromey  <tromey@cygnus.com>

	* gdb.base/selftest.exp (do_steps_and_nexts): Account for
	possible `moncontrol' call at startup.

Index: Makefile.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/Makefile.in,v
retrieving revision 1.738
diff -u -r1.738 Makefile.in
--- Makefile.in	2000/01/13 16:41:26	1.738
+++ Makefile.in	2000/01/17 17:58:04
@@ -228,7 +228,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: NEWS
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/NEWS,v
retrieving revision 2.73
diff -u -r2.73 NEWS
--- NEWS	1999/12/16 02:03:23	2.73
+++ NEWS	2000/01/17 17:58:30
@@ -215,6 +215,12 @@
 The i960 configuration now includes an initial implementation of a
 builtin simulator, contributed by Jim Wilson.
 
+* 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.17:
 
Index: acconfig.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/acconfig.h,v
retrieving revision 2.23
diff -u -r2.23 acconfig.h
--- acconfig.h	1999/12/23 00:56:47	2.23
+++ acconfig.h	2000/01/17 17:58:30
@@ -85,3 +85,6 @@
 
 /* Define if <sys/ptrace.h> defines the PTRACE_GETXFPREGS request.  */
 #undef HAVE_PTRACE_GETXFPREGS
+
+/* 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.46
diff -u -r2.46 config.in
--- config.in	1999/12/23 00:56:47	2.46
+++ config.in	2000/01/17 17:58:32
@@ -59,13 +59,13 @@
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
-/* Define if ioctl argument PIOCSET is available. */
-#undef HAVE_PROCFS_PIOCSET
-
 /* Define if you want to use new multi-fd /proc interface
    (replaces HAVE_MULTIPLE_PROC_FDS as well as other macros). */
 #undef NEW_PROC_API
 
+/* Define if ioctl argument PIOCSET is available. */
+#undef HAVE_PROCFS_PIOCSET
+
 /* Define if the `long long' type works.  */
 #undef CC_HAS_LONG_LONG
 
@@ -120,6 +120,9 @@
 /* Define if <sys/ptrace.h> defines the PTRACE_GETXFPREGS request.  */
 #undef HAVE_PTRACE_GETXFPREGS
 
+/* Define if profiling support should be enabled.  */
+#undef ENABLE_PROFILE
+
 /* Define if you have the __argz_count function.  */
 #undef HAVE___ARGZ_COUNT
 
@@ -225,6 +228,9 @@
 /* Define if you have the <objlist.h> header file.  */
 #undef HAVE_OBJLIST_H
 
+/* Define if you have the <proc_service.h> header file.  */
+#undef HAVE_PROC_SERVICE_H
+
 /* Define if you have the <ptrace.h> header file.  */
 #undef HAVE_PTRACE_H
 
@@ -234,6 +240,9 @@
 /* Define if you have the <stddef.h> header file.  */
 #undef HAVE_STDDEF_H
 
+/* Define if you have the <stdint.h> header file.  */
+#undef HAVE_STDINT_H
+
 /* Define if you have the <stdlib.h> header file.  */
 #undef HAVE_STDLIB_H
 
@@ -273,6 +282,9 @@
 /* Define if you have the <termios.h> header file.  */
 #undef HAVE_TERMIOS_H
 
+/* Define if you have the <thread_db.h> header file.  */
+#undef HAVE_THREAD_DB_H
+
 /* Define if you have the <time.h> header file.  */
 #undef HAVE_TIME_H
 
@@ -284,15 +296,6 @@
 
 /* Define if you have the <wait.h> header file.  */
 #undef HAVE_WAIT_H
-
-/* Define if you have the <thread_db.h> header file.  */
-#undef HAVE_THREAD_DB_H
-
-/* Define if you have the <proc_service.h> header file.  */
-#undef HAVE_PROC_SERVICE_H
-
-/* Define if you have the <stdint.h> header file.  */
-#undef HAVE_STDINT_H
 
 /* Define if you have the <wchar.h> header file.  */
 #undef HAVE_WCHAR_H
Index: configure.in
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/configure.in,v
retrieving revision 1.406
diff -u -r1.406 configure.in
--- configure.in	2000/01/11 19:24:10	1.406
+++ configure.in	2000/01/17 17:58:45
@@ -358,7 +358,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],
 [
@@ -945,6 +954,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.197
diff -u -r1.197 main.c
--- main.c	1999/12/13 16:07:40	1.197
+++ main.c	2000/01/17 17:59:00
@@ -164,6 +164,10 @@
 
   long time_at_startup = get_run_time ();
 
+#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.34
diff -u -r2.34 maint.c
--- maint.c	1999/08/31 03:54:24	2.34
+++ maint.c	2000/01/17 17:59:04
@@ -57,6 +57,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
@@ -358,6 +363,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 ()
 {
@@ -455,6 +480,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.140
diff -u -r1.140 gdbint.texinfo
--- gdbint.texinfo	1999/12/08 09:12:46	1.140
+++ gdbint.texinfo	2000/01/17 18:00:38
@@ -2772,6 +2772,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
@@ -2973,6 +2974,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: testsuite/gdb.base/selftest.exp
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/testsuite/gdb.base/selftest.exp,v
retrieving revision 1.3
diff -u -r1.3 selftest.exp
--- selftest.exp	2000/01/10 18:35:50	1.3
+++ selftest.exp	2000/01/17 18:00:51
@@ -1,4 +1,4 @@
-#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 2000 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -96,6 +96,10 @@
 	    }
 	    -re ".*time_at_startup = get_run_time.*$gdb_prompt $" {
 		set description "next over get_run_time and everything it calls"
+		set command "next"
+	    }
+	    -re ".*moncontrol.*$gdb_prompt $" {
+		set description "next over moncontrol"
 		set command "next"
 	    }
 	    -re ".*START_PROGRESS.*$gdb_prompt $" {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]