From b48805b98417ca9d20d36ebb0d7464bb6356cda9 Mon Sep 17 00:00:00 2001
From: Duncan Coutts <duncan@well-typed.com>
Date: Mon, 9 Jan 2023 00:01:21 +0000
Subject: [PATCH] Add a new trace class for the iomanager

It makes sense now for it to be separate from the scheduler class of
tracers.

Enabled with +RTS -Do. Document the -Do debug flag in the user guide.
---
 docs/users_guide/runtime_control.rst | 1 +
 rts/RtsFlags.c                       | 4 ++++
 rts/Trace.h                          | 1 +
 rts/include/rts/Flags.h              | 1 +
 4 files changed, 7 insertions(+)

diff --git a/docs/users_guide/runtime_control.rst b/docs/users_guide/runtime_control.rst
index 370593d207e1..1377db771d0a 100644
--- a/docs/users_guide/runtime_control.rst
+++ b/docs/users_guide/runtime_control.rst
@@ -1443,6 +1443,7 @@ recommended for everyday use!
 .. rts-flag::  -Dr  DEBUG: sparks
 .. rts-flag::  -DC  DEBUG: compact
 .. rts-flag::  -Dk  DEBUG: continuation
+.. rts-flag::  -Do  DEBUG: iomanager
 
     Debug messages will be sent to the binary event log file instead of
     stdout if the :rts-flag:`-l ⟨flags⟩` option is added. This might be useful
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index e74499954bad..b0c6b13beb1b 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -486,6 +486,7 @@ usage_text[] = {
 "  -Dr  DEBUG: sparks",
 "  -DC  DEBUG: compact",
 "  -Dk  DEBUG: continuation",
+"  -Do  DEBUG: iomanager",
 "",
 "     NOTE: DEBUG events are sent to stderr by default; add -l to create a",
 "     binary event log file instead.",
@@ -2259,6 +2260,9 @@ static void read_debug_flags(const char* arg)
         case 'k':
             RtsFlags.DebugFlags.continuation = true;
             break;
+        case 'o':
+            RtsFlags.DebugFlags.iomanager = true;
+            break;
         default:
             bad_option( arg );
         }
diff --git a/rts/Trace.h b/rts/Trace.h
index a8a51ebe9dd8..baca2d5a964b 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -68,6 +68,7 @@ enum CapsetType { CapsetTypeCustom = CAPSET_TYPE_CUSTOM,
 #define DEBUG_sparks      RtsFlags.DebugFlags.sparks
 #define DEBUG_compact     RtsFlags.DebugFlags.compact
 #define DEBUG_continuation RtsFlags.DebugFlags.continuation
+#define DEBUG_iomanager   RtsFlags.DebugFlags.iomanager
 
 // Event-enabled flags
 // These semantically booleans but we use a dense packing to minimize their
diff --git a/rts/include/rts/Flags.h b/rts/include/rts/Flags.h
index ca9520ef8a88..63ffccd2f541 100644
--- a/rts/include/rts/Flags.h
+++ b/rts/include/rts/Flags.h
@@ -117,6 +117,7 @@ typedef struct _DEBUG_FLAGS {
     bool numa;           /* '--debug-numa' */
     bool compact;        /* 'C' */
     bool continuation;   /* 'k' */
+    bool iomanager;      /* 'o' */
 } DEBUG_FLAGS;
 
 /* See Note [Synchronization of flags and base APIs] */
-- 
GitLab