diff options
author | Daniel Jacobowitz <drow@false.org> | 2003-01-22 23:50:35 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2003-01-22 23:50:35 +0000 |
commit | d28f9cdffd64eccc907a788a61c75968eeb0e954 (patch) | |
tree | 26505ccef16583054609ba765abc9d5dbfe0b4af /gdb/maint.c | |
parent | e7ba9c658425d264adc54dfcf0b654cfc3df8f14 (diff) | |
download | gdb-d28f9cdffd64eccc907a788a61c75968eeb0e954.zip gdb-d28f9cdffd64eccc907a788a61c75968eeb0e954.tar.gz gdb-d28f9cdffd64eccc907a788a61c75968eeb0e954.tar.bz2 |
Original patch by Tom Tromey <tromey@cygnus.com> and
Jason Molenda <jmolenda@apple.com>.
* Makefile.in (PROFILE_CFLAGS): Substitute from configure.
(INTERNAL_LDFLAGS): Don't include PROFILE_CFLAGS.
* NEWS: Mention profiling.
* configure.in (--enable-gdbtk): Fix typo.
(--enable-profiling): New. Set PROFILE_CFLAGS.
* maint.c (maintenance_set_profile_cmd): Remove NOTYET.
Fill in function.
(profiling_state): New variable.
(mcleanup_wrapper): New function.
(_initialize_maint): Remove NOTYET, fix call to
add_setshow_boolean_cmd for "maint set profile".
* configure: Regenerated.
Diffstat (limited to 'gdb/maint.c')
-rw-r--r-- | gdb/maint.c | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/gdb/maint.c b/gdb/maint.c index db7d42d..045510c 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1,5 +1,5 @@ /* Support for GDB maintenance commands. - Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002 + Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Written by Fred Fish at Cygnus Support. @@ -639,18 +639,52 @@ maintenance_show_cmd (char *args, int from_tty) cmd_show_list (maintenance_show_cmdlist, from_tty, ""); } -#ifdef NOTYET /* Profiling support. */ static int maintenance_profile_p; +static int profiling_state; + +static void +mcleanup_wrapper (void) +{ + extern void _mcleanup (void); + + if (profiling_state) + _mcleanup (); +} static void maintenance_set_profile_cmd (char *args, int from_tty, struct cmd_list_element *c) { - maintenance_profile_p = 0; - warning ("\"maintenance set profile\" command not supported.\n"); + if (maintenance_profile_p == profiling_state) + return; + + profiling_state = maintenance_profile_p; + + if (maintenance_profile_p) + { + static int profiling_initialized; + + extern void monstartup (unsigned long, unsigned long); + extern char _etext; + extern int main(); + + if (!profiling_initialized) + { + atexit (mcleanup_wrapper); + profiling_initialized = 1; + } + + /* "main" is now always the first function in the text segment, so use + its address for monstartup. */ + monstartup ((unsigned long) &main, (unsigned long) &_etext); + } + else + { + extern void _mcleanup (void); + _mcleanup (); + } } -#endif void _initialize_maint_cmds (void) @@ -807,16 +841,12 @@ passes without a response from the target, an error occurs.", &setlist), &showlist); -#ifdef NOTYET - /* FIXME: cagney/2002-06-15: A patch implementing profiling is - pending, this just sets up the framework. */ - tmpcmd = add_setshow_boolean_cmd ("profile", class_maintenance, - var_boolean, &maintenance_profile_p, "\ -Set internal profiling.\n\ -When enabled GDB is profiled.", "\ -Show internal profiling.\n", - maintenance_set_profile_cmd, NULL, - &maintenance_set_cmdlist, - &maintenance_show_cmdlist); -#endif + add_setshow_boolean_cmd ("profile", class_maintenance, + &maintenance_profile_p, + "Set internal profiling.\n" + "When enabled GDB is profiled.", + "Show internal profiling.\n", + maintenance_set_profile_cmd, NULL, + &maintenance_set_cmdlist, + &maintenance_show_cmdlist); } |