summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authoralexbiehl <alex.biehl@gmail.com>2017-01-31 16:06:33 -0500
committerBen Gamari <ben@smart-cactus.org>2017-01-31 18:50:21 -0500
commit4dfc6d1c40b298d4b8f136e46420227eda60a03d (patch)
treefce2d978323653ff0ff989fdb72f3585be5b4de4 /includes
parent44f079f74869d8cb417e2dcc104517ae7f593e5f (diff)
downloadhaskell-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 'includes')
-rw-r--r--includes/RtsAPI.h4
-rw-r--r--includes/rts/EventLogWriter.h40
2 files changed, 44 insertions, 0 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index bf25c011fc..e5326f759b 100644
--- a/includes/RtsAPI.h
+++ b/includes/RtsAPI.h
@@ -18,6 +18,7 @@ extern "C" {
#include "HsFFI.h"
#include "rts/Time.h"
+#include "rts/EventLogWriter.h"
/*
* Running the scheduler
@@ -79,6 +80,9 @@ typedef struct {
// Whether to retain CAFs (default: false)
HsBool keep_cafs;
+ // Writer a for eventlog.
+ const EventLogWriter *eventlog_writer;
+
// Called before processing command-line flags, so that default
// settings for RtsFlags can be provided.
void (* defaultsHook) (void);
diff --git a/includes/rts/EventLogWriter.h b/includes/rts/EventLogWriter.h
new file mode 100644
index 0000000000..f9cb25fe62
--- /dev/null
+++ b/includes/rts/EventLogWriter.h
@@ -0,0 +1,40 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2008-2017
+ *
+ * Support for fast binary event logging.
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef EVENTLOG_WRITER_H
+#define EVENTLOG_WRITER_H
+
+#include <stddef.h>
+#include <stdbool.h>
+
+#include "Rts.h"
+
+/*
+ * Abstraction for writing eventlog data.
+ */
+typedef struct {
+ // Initialize an EventLogWriter (may be NULL)
+ void (* initEventLogWriter) (void);
+
+ // Write a series of events
+ bool (* writeEventLog) (void *eventlog, size_t eventlog_size);
+
+ // Flush possibly existing buffers (may be NULL)
+ void (* flushEventLog) (void);
+
+ // Close an initialized EventLogOutput (may be NULL)
+ void (* stopEventLogWriter) (void);
+} EventLogWriter;
+
+/*
+ * An EventLogWriter which writes eventlogs to
+ * a file `program.eventlog`.
+ */
+extern const EventLogWriter FileEventLogWriter;
+
+#endif /* EVENTLOG_WRITER_H */