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]

profiling gdb


Lately I've had occasion to profile parts of gdb.  I wrote the
appended patch, which adds a command to let me enable and disable
profiling.  That way I can profile parts of gdb without getting
misleading data about things I don't care about.

This patch isn't really complete.  At the very least it needs a
configure option to define ENABLE_PROFILE.  I'm posting it to get
feedback.  If this isn't worthwhile, I'll just keep it as my own
private hack.

1999-10-27  Tom Tromey  <tromey@cygnus.com>

	* maint.c: Include <sys/gmon.h> if profiling support enabled.
	(maint_moncontrol): New function.
	(_initialize_maint_cmds): Add `moncontrol' command if profiling
	support is enabled.
	* main.c: Include <sys/gmon.h> if profiling support enabled.
	(main): Turn off profiling if profiling support is enabled.

Tom

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/27 19:02:50
@@ -35,6 +35,10 @@
 
 #include "gdb_string.h"
 
+#ifdef ENABLE_PROFILE
+#include <sys/gmon.h>
+#endif
+
 /* Temporary variable for SET_TOP_LEVEL.  */
 
 static int top_level_val;
@@ -127,6 +131,10 @@
   long time_at_startup = get_run_time ();
 
   int gdb_file_size;
+
+#ifdef ENABLE_PROFILE
+  moncontrol (GMON_PROF_OFF);
+#endif
 
   START_PROGRESS (argv[0], 0);
 
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/27 19:02:53
@@ -38,6 +38,10 @@
 #include <unistd.h>
 #endif
 
+#ifdef ENABLE_PROFILE
+#include <sys/gmon.h>
+#endif
+
 static void maintenance_command PARAMS ((char *, int));
 
 static void maintenance_dump_me PARAMS ((char *, int));
@@ -339,6 +343,24 @@
   return;
 }
 
+#ifdef ENABLE_PROFILE
+/* "maintenance moncontrol <on|off>"  */
+static void
+maint_moncontrol (char *arg, int from_tty)
+{
+  int val;
+  if (arg == NULL || ! *arg)
+    error ("requires argument");
+  if (! strcmp (arg, "on"))
+    val = GMON_PROF_ON;
+  else if (! strcmp (arg, "off"))
+    val = GMON_PROF_OFF;
+  else
+    error ("unrecognized argument");
+  moncontrol (val);
+}
+#endif
+
 void
 _initialize_maint_cmds ()
 {
@@ -431,6 +453,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 ("moncontrol", class_maintenance, maint_moncontrol,
+	   "Enable or disable profiling.",
+	   &maintenancelist);
+#endif
 
   add_show_from_set (
     add_set_cmd ("watchdog", class_maintenance, var_zinteger, (char *)&watchdog,

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