summaryrefslogtreecommitdiff
path: root/gmon
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-08-08 00:24:13 +0000
committerUlrich Drepper <drepper@redhat.com>1997-08-08 00:24:13 +0000
commit14a418c633882eff8b82aef18244093404716300 (patch)
tree78b411dd415d9187f219dbaceed5bece530dac1c /gmon
parent26c9179ab997f8b2a40de4df452f72b930d30141 (diff)
(write_gmon): New function; guts from _mcleanup.
(_mcleanup): Use write_gmon. (write_profiling): This function can be safely called at any time to write a current histogram without interfering with ongoing profiling.
Diffstat (limited to 'gmon')
-rw-r--r--gmon/gmon.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 5eb08b2fb5..d4198ebe0b 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -63,6 +63,7 @@ void moncontrol __P ((int mode));
static void write_hist __P ((int fd));
static void write_call_graph __P ((int fd));
static void write_bb_counts __P ((int fd));
+static void write_gmon __P ((void));
/*
* Control profiling
@@ -289,13 +290,12 @@ write_bb_counts (fd)
}
-void
-_mcleanup ()
+static void
+write_gmon ()
{
struct gmon_hdr ghdr __attribute__ ((aligned (__alignof__ (int))));
int fd;
- moncontrol (0);
fd = __open ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0)
{
@@ -319,6 +319,25 @@ _mcleanup ()
write_bb_counts (fd);
__close (fd);
+}
+
+void
+__write_profiling ()
+{
+ int save = _gmonparam.state;
+ _gmonparam.state = GMON_PROF_OFF;
+ if (save == GMON_PROF_ON)
+ write_gmon ();
+ _gmonparam.state = save;
+}
+weak_alias (__write_profiling, write_profiling)
+
+void
+_mcleanup ()
+{
+ moncontrol (0);
+
+ write_gmon ();
/* free the memory. */
free (_gmonparam.tos);