summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2021-08-31 16:07:16 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-15 18:16:14 -0400
commit88e913d443203376454b5242efa5fff0928992a8 (patch)
tree0da963e6cbfdb078147cacc3461dd5810c5a27c9 /rts
parent1cda768c86e533c917a495c8de0468960cbe7a52 (diff)
downloadhaskell-88e913d443203376454b5242efa5fff0928992a8.tar.gz
Null eventlog writer
Diffstat (limited to 'rts')
-rw-r--r--rts/RtsFlags.c6
-rw-r--r--rts/Trace.c4
-rw-r--r--rts/eventlog/EventLogWriter.c21
-rw-r--r--rts/include/rts/EventLogWriter.h5
-rw-r--r--rts/include/rts/Flags.h1
5 files changed, 37 insertions, 0 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index a775e2986a..0d41108822 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -239,6 +239,7 @@ void initRtsFlagsDefaults(void)
RtsFlags.TraceFlags.ticky = false;
RtsFlags.TraceFlags.trace_output = NULL;
RtsFlags.TraceFlags.eventlogFlushTime = 0;
+ RtsFlags.TraceFlags.nullWriter = false;
#endif
#if defined(PROFILING)
@@ -959,6 +960,11 @@ error = true;
OPTION_UNSAFE;
RtsFlags.MiscFlags.generate_dump_file = true;
}
+ else if (strequal("null-eventlog-writer",
+ &rts_argv[arg][2])) {
+ OPTION_UNSAFE;
+ RtsFlags.TraceFlags.nullWriter = true;
+ }
else if (strequal("machine-readable",
&rts_argv[arg][2])) {
OPTION_UNSAFE;
diff --git a/rts/Trace.c b/rts/Trace.c
index dace0970e6..9edac3565e 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -107,6 +107,10 @@ void initTracing (void)
initEventLogging();
if (RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG
+ && RtsFlags.TraceFlags.nullWriter) {
+ startEventLogging(&NullEventLogWriter);
+ }
+ else if (RtsFlags.TraceFlags.tracing == TRACE_EVENTLOG
&& rtsConfig.eventlog_writer != NULL) {
startEventLogging(rtsConfig.eventlog_writer);
}
diff --git a/rts/eventlog/EventLogWriter.c b/rts/eventlog/EventLogWriter.c
index 06aad2841e..daa6dc3c9d 100644
--- a/rts/eventlog/EventLogWriter.c
+++ b/rts/eventlog/EventLogWriter.c
@@ -147,9 +147,30 @@ stopEventLogFileWriter(void)
#endif
}
+static void
+initEventLogFileWriterNoop(void) {}
+
+static bool
+writeEventLogFileNoop(void *eventlog STG_UNUSED, size_t eventlog_size STG_UNUSED) {
+ return true; // writes succeed always
+}
+
+static void
+flushEventLogFileNoop(void) {}
+
+static void
+stopEventLogFileWriterNoop(void) {}
+
const EventLogWriter FileEventLogWriter = {
.initEventLogWriter = initEventLogFileWriter,
.writeEventLog = writeEventLogFile,
.flushEventLog = flushEventLogFile,
.stopEventLogWriter = stopEventLogFileWriter
};
+
+const EventLogWriter NullEventLogWriter = {
+ .initEventLogWriter = initEventLogFileWriterNoop,
+ .writeEventLog = writeEventLogFileNoop,
+ .flushEventLog = flushEventLogFileNoop,
+ .stopEventLogWriter = stopEventLogFileWriterNoop
+};
diff --git a/rts/include/rts/EventLogWriter.h b/rts/include/rts/EventLogWriter.h
index 73a2aec64c..1f53d2f58a 100644
--- a/rts/include/rts/EventLogWriter.h
+++ b/rts/include/rts/EventLogWriter.h
@@ -43,6 +43,11 @@ typedef struct {
*/
extern const EventLogWriter FileEventLogWriter;
+/*
+ * An EventLogWriter which does nothing.
+ */
+extern const EventLogWriter NullEventLogWriter;
+
enum EventLogStatus {
/* The runtime system wasn't compiled with eventlog support. */
EVENTLOG_NOT_SUPPORTED,
diff --git a/rts/include/rts/Flags.h b/rts/include/rts/Flags.h
index e8298023de..9291f492cf 100644
--- a/rts/include/rts/Flags.h
+++ b/rts/include/rts/Flags.h
@@ -181,6 +181,7 @@ typedef struct _TRACE_FLAGS {
Time eventlogFlushTime; /* Time between force eventlog flushes (or 0 if disabled) */
int eventlogFlushTicks;
char *trace_output; /* output filename for eventlog */
+ bool nullWriter; /* use null writer instead of file writer */
} TRACE_FLAGS;
/* See Note [Synchronization of flags and base APIs] */