diff options
author | alexbiehl <alex.biehl@gmail.com> | 2017-01-31 16:06:33 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-01-31 18:50:21 -0500 |
commit | 4dfc6d1c40b298d4b8f136e46420227eda60a03d (patch) | |
tree | fce2d978323653ff0ff989fdb72f3585be5b4de4 /rts/Trace.c | |
parent | 44f079f74869d8cb417e2dcc104517ae7f593e5f (diff) | |
download | haskell-4dfc6d1c40b298d4b8f136e46420227eda60a03d.tar.gz |
Abstract over the way eventlogs are flushed
Currently eventlog data is always written to a file `progname.eventlog`.
This patch introduces the `flushEventLog` field in `RtsConfig` which
allows to customize the writing of eventlog data.
One possible scenario is the ongoing live-profile-monitor effort by
@NCrashed which slurps all eventlog data through `fluchEventLog`.
`flushEventLog` takes a buffer with eventlog data and its size and
returns `false` (0) in case eventlog data could not be procesed.
Reviewers: simonmar, austin, erikd, bgamari
Reviewed By: simonmar, bgamari
Subscribers: qnikst, thomie, NCrashed
Differential Revision: https://phabricator.haskell.org/D2934
Diffstat (limited to 'rts/Trace.c')
-rw-r--r-- | rts/Trace.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/rts/Trace.c b/rts/Trace.c index 91680b7b8a..07717f3ac3 100644 --- a/rts/Trace.c +++ b/rts/Trace.c @@ -18,8 +18,10 @@ #include "GetEnv.h" #include "Stats.h" #include "eventlog/EventLog.h" +#include "rts/EventLogWriter.h" #include "Threads.h" #include "Printer.h" +#include "RtsFlags.h" #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -43,8 +45,15 @@ static bool eventlog_enabled; Starting up / shuttting down the tracing facilities --------------------------------------------------------------------------- */ +static const EventLogWriter *getEventLogWriter(void) +{ + return rtsConfig.eventlog_writer; +} + void initTracing (void) { + const EventLogWriter *eventlog_writer = getEventLogWriter(); + #ifdef THREADED_RTS initMutex(&trace_utx); #endif @@ -82,14 +91,15 @@ void initTracing (void) TRACE_spark_full || TRACE_user; - eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG; + eventlog_enabled = RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG && + eventlog_writer != NULL; /* Note: we can have any of the TRACE_* flags turned on even when eventlog_enabled is off. In the DEBUG way we may be tracing to stderr. */ if (eventlog_enabled) { - initEventLogging(); + initEventLogging(eventlog_writer); } } @@ -109,9 +119,14 @@ void freeTracing (void) void resetTracing (void) { + const EventLogWriter *eventlog_writer; + eventlog_writer = getEventLogWriter(); + if (eventlog_enabled) { abortEventLogging(); // abort eventlog inherited from parent - initEventLogging(); // child starts its own eventlog + if (eventlog_writer != NULL) { + initEventLogging(eventlog_writer); // child starts its own eventlog + } } } |