Skip to content
Snippets Groups Projects
Commit 9c51473b authored by Duncan Coutts's avatar Duncan Coutts Committed by Marge Bot
Browse files

Add tracing for the main I/O manager actions


Using the new tracer class.

Note: The unconditional definition of showIOManager should be
compatible with the debugTrace change in 7c7d1f66.

Co-authored-by: default avatarPi Delport <pi@well-typed.com>
parent 877a2a80
No related branches found
No related tags found
No related merge requests found
......@@ -248,6 +248,35 @@ void selectIOManager(void)
}
char * showIOManager(void)
{
switch (iomgr_type) {
#if defined(IOMGR_ENABLED_SELECT)
case IO_MANAGER_SELECT:
return "select";
#endif
#if defined(IOMGR_ENABLED_MIO_POSIX)
case IO_MANAGER_MIO_POSIX:
return "mio";
#endif
#if defined(IOMGR_ENABLED_MIO_WIN32)
case IO_MANAGER_MIO_WIN32:
return "mio";
#endif
#if defined(IOMGR_ENABLED_WINIO)
case IO_MANAGER_WINIO:
return "winio";
#endif
#if defined(IOMGR_ENABLED_WIN32_LEGACY)
case IO_MANAGER_WIN32_LEGACY:
return "win32-legacy";
#endif
default:
barf("showIOManager: %d", iomgr_type);
}
}
/* Allocate and initialise the per-capability CapIOManager that lives in each
* Capability. Called from initCapability(), which is done in the RTS startup
* in initCapabilities(), and later at runtime via setNumCapabilities().
......@@ -257,6 +286,9 @@ void selectIOManager(void)
*/
void initCapabilityIOManager(Capability *cap)
{
debugTrace(DEBUG_iomanager, "initialising I/O manager %s for cap %d",
showIOManager(), cap->no);
CapIOManager *iomgr =
(CapIOManager *) stgMallocBytes(sizeof(CapIOManager),
"initCapabilityIOManager");
......@@ -294,6 +326,7 @@ void initCapabilityIOManager(Capability *cap)
*/
void initIOManager(void)
{
debugTrace(DEBUG_iomanager, "initialising %s I/O manager", showIOManager());
switch (iomgr_type) {
......@@ -677,6 +710,9 @@ void syncIOWaitReady(Capability *cap,
IOReadOrWrite rw,
HsInt fd)
{
debugTrace(DEBUG_iomanager,
"thread %ld waiting for %s I/O readiness on fd %d",
(long) tso->id, rw == IORead ? "read" : "write", (int) fd);
ASSERT(tso->why_blocked == NotBlocked);
switch (iomgr_type) {
#if defined(IOMGR_ENABLED_SELECT)
......@@ -707,6 +743,7 @@ void syncIOWaitReady(Capability *cap,
void syncIOCancel(Capability *cap, StgTSO *tso)
{
debugTrace(DEBUG_iomanager, "cancelling I/O for thread %ld", (long) tso->id);
switch (iomgr_type) {
#if defined(IOMGR_ENABLED_SELECT)
case IO_MANAGER_SELECT:
......@@ -734,6 +771,7 @@ static void insertIntoSleepingQueue(Capability *cap, StgTSO *tso, LowResTime tar
void syncDelay(Capability *cap, StgTSO *tso, HsInt us_delay)
{
debugTrace(DEBUG_iomanager, "thread %ld waiting for %lld us", tso->id, us_delay);
ASSERT(tso->why_blocked == NotBlocked);
switch (iomgr_type) {
#if defined(IOMGR_ENABLED_SELECT)
......
......@@ -185,6 +185,12 @@ enum IOManagerAvailability {
enum IOManagerAvailability
parseIOManagerFlag(const char *iomgrstr, IO_MANAGER_FLAG *flag);
/* The string name of the current I/O manager. Initialised by selectIOManager().
*/
char * showIOManager(void);
/* Temporary compat helper function used in the Win32 I/O managers.
* TODO: replace by consulting the iomgr_type global instead.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment