diff options
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); } |