summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-08-19 15:21:26 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-11 23:45:10 -0400
commit866c736ef29a07c6f3aa68063ef98ee0ecea12f3 (patch)
tree2e213cf10bc8d25a31020f5128969de25b09a140
parentf6e8feb475cf421c408102c2abd531e380b67b00 (diff)
downloadhaskell-866c736ef29a07c6f3aa68063ef98ee0ecea12f3.tar.gz
rts: Refactor IPE tracing support
-rw-r--r--rts/IPE.c30
-rw-r--r--rts/IPE.h5
-rw-r--r--rts/Trace.c13
-rw-r--r--rts/Trace.h10
-rw-r--r--rts/eventlog/EventLog.c34
-rw-r--r--rts/eventlog/EventLog.h8
6 files changed, 34 insertions, 66 deletions
diff --git a/rts/IPE.c b/rts/IPE.c
index 5ab8a861fd..10ddee435b 100644
--- a/rts/IPE.c
+++ b/rts/IPE.c
@@ -62,20 +62,23 @@ void initIpeMapLock(void) { initMutex(&ipeMapLock); }
void closeIpeMapLock(void) { closeMutex(&ipeMapLock); }
-void dumpIPEToEventLog(void) {
#if defined(TRACING)
+static void traceIPEFromHashTable(void *data STG_UNUSED,
+ StgWord key STG_UNUSED,
+ const void *value) {
+ InfoProvEnt *ipe = (InfoProvEnt *)value;
+ traceIPE(ipe);
+}
+
+void dumpIPEToEventLog(void) {
ACQUIRE_LOCK(&ipeMapLock);
IpeBufferListNode *cursor = ipeBufferList;
while (cursor != NULL) {
for (int i = 0; i < cursor->count; i++) {
- for (InfoProvEnt **ipeList = cursor->buffer[i]; *ipeList != NULL;
- ipeList++) {
+ for (InfoProvEnt **ipeList = cursor->buffer[i]; *ipeList != NULL; ipeList++) {
InfoProvEnt *ipe = *ipeList;
-
- traceIPE(ipe->info, ipe->prov.table_name,
- ipe->prov.closure_desc, ipe->prov.ty_desc,
- ipe->prov.label, ipe->prov.module, ipe->prov.srcloc);
+ traceIPE(ipe);
}
}
@@ -87,19 +90,12 @@ void dumpIPEToEventLog(void) {
}
RELEASE_LOCK(&ipeMapLock);
-#endif
- return;
}
-#if defined(TRACING)
-void traceIPEFromHashTable(void *data STG_UNUSED, StgWord key STG_UNUSED,
- const void *value) {
- InfoProvEnt *ipe = (InfoProvEnt *)value;
+#else
+
+void dumpIPEToEventLog(void) { }
- traceIPE(ipe->info, ipe->prov.table_name, ipe->prov.closure_desc,
- ipe->prov.ty_desc, ipe->prov.label, ipe->prov.module,
- ipe->prov.srcloc);
-}
#endif
/* Registering IPEs
diff --git a/rts/IPE.h b/rts/IPE.h
index 064ff9d7ad..267e386f00 100644
--- a/rts/IPE.h
+++ b/rts/IPE.h
@@ -26,9 +26,4 @@ void updateIpeMap(void);
void initIpeMapLock(void);
void closeIpeMapLock(void);
-#if defined(TRACING)
-void traceIPEFromHashTable(void *data STG_UNUSED, StgWord key STG_UNUSED,
- const void *value);
-#endif
-
#include "EndPrivate.h"
diff --git a/rts/Trace.c b/rts/Trace.c
index ab9effd522..323ffb6ce7 100644
--- a/rts/Trace.c
+++ b/rts/Trace.c
@@ -675,13 +675,7 @@ void traceHeapProfSampleString(StgWord8 profile_id,
}
}
-void traceIPE(StgInfoTable * info,
- const char *table_name,
- const char *closure_desc,
- const char *ty_desc,
- const char *label,
- const char *module,
- const char *srcloc )
+void traceIPE(const InfoProvEnt *ipe)
{
#if defined(DEBUG)
if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
@@ -689,13 +683,14 @@ void traceIPE(StgInfoTable * info,
tracePreface();
debugBelch("IPE: table_name %s, closure_desc %s, ty_desc %s, label %s, module %s, srcloc %s\n",
- table_name, closure_desc, ty_desc, label, module, srcloc);
+ ipe->prov.table_name, ipe->prov.closure_desc, ipe->prov.ty_desc,
+ ipe->prov.label, ipe->prov.module, ipe->prov.srcloc);
RELEASE_LOCK(&trace_utx);
} else
#endif
if (eventlog_enabled) {
- postIPE((W_) INFO_PTR_TO_STRUCT(info), table_name, closure_desc, ty_desc, label, module, srcloc);
+ postIPE(ipe);
}
}
diff --git a/rts/Trace.h b/rts/Trace.h
index 8c65972954..6e08d0d2fd 100644
--- a/rts/Trace.h
+++ b/rts/Trace.h
@@ -330,13 +330,7 @@ void traceConcUpdRemSetFlush(Capability *cap);
void traceNonmovingHeapCensus(uint32_t log_blk_size,
const struct NonmovingAllocCensus *census);
-void traceIPE(StgInfoTable *info,
- const char *table_name,
- const char *closure_desc,
- const char *ty_desc,
- const char *label,
- const char *module,
- const char *srcloc );
+void traceIPE(const InfoProvEnt *ipe);
void flushTrace(void);
#else /* !TRACING */
@@ -373,7 +367,7 @@ void flushTrace(void);
#define traceTaskDelete_(taskID) /* nothing */
#define traceHeapProfBegin(profile_id) /* nothing */
#define traceHeapProfCostCentre(ccID, label, module, srcloc, is_caf) /* nothing */
-#define traceIPE(info, table_name, closure_desc, ty_desc, label, module, srcloc) /* nothing */
+#define traceIPE(ipe) /* nothing */
#define traceHeapProfSampleBegin(era) /* nothing */
#define traceHeapBioProfSampleBegin(era, time) /* nothing */
#define traceHeapProfSampleEnd(era) /* nothing */
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index e576a77a28..4ed48c4412 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -1411,34 +1411,28 @@ void postTickyCounterSamples(StgEntCounter *counters)
RELEASE_LOCK(&eventBufMutex);
}
#endif /* TICKY_TICKY */
-void postIPE(StgWord64 info,
- const char *table_name,
- const char *closure_desc,
- const char *ty_desc,
- const char *label,
- const char *module,
- const char *srcloc)
+void postIPE(const InfoProvEnt *ipe)
{
ACQUIRE_LOCK(&eventBufMutex);
- StgWord table_name_len = strlen(table_name);
- StgWord closure_desc_len = strlen(closure_desc);
- StgWord ty_desc_len = strlen(ty_desc);
- StgWord label_len = strlen(label);
- StgWord module_len = strlen(module);
- StgWord srcloc_len = strlen(srcloc);
+ StgWord table_name_len = strlen(ipe->prov.table_name);
+ StgWord closure_desc_len = strlen(ipe->prov.closure_desc);
+ StgWord ty_desc_len = strlen(ipe->prov.ty_desc);
+ StgWord label_len = strlen(ipe->prov.label);
+ StgWord module_len = strlen(ipe->prov.module);
+ StgWord srcloc_len = strlen(ipe->prov.srcloc);
// 8 for the info word
// 6 for the number of strings in the payload as postString adds 1 to the length
StgWord len = 8+table_name_len+closure_desc_len+ty_desc_len+label_len+module_len+srcloc_len+6;
ensureRoomForVariableEvent(&eventBuf, len);
postEventHeader(&eventBuf, EVENT_IPE);
postPayloadSize(&eventBuf, len);
- postWord64(&eventBuf, info);
- postString(&eventBuf, table_name);
- postString(&eventBuf, closure_desc);
- postString(&eventBuf, ty_desc);
- postString(&eventBuf, label);
- postString(&eventBuf, module);
- postString(&eventBuf, srcloc);
+ postWord64(&eventBuf, (StgWord) ipe->info);
+ postString(&eventBuf, ipe->prov.table_name);
+ postString(&eventBuf, ipe->prov.closure_desc);
+ postString(&eventBuf, ipe->prov.ty_desc);
+ postString(&eventBuf, ipe->prov.label);
+ postString(&eventBuf, ipe->prov.module);
+ postString(&eventBuf, ipe->prov.srcloc);
RELEASE_LOCK(&eventBufMutex);
}
diff --git a/rts/eventlog/EventLog.h b/rts/eventlog/EventLog.h
index 39be13674e..2dc4ab4c1d 100644
--- a/rts/eventlog/EventLog.h
+++ b/rts/eventlog/EventLog.h
@@ -190,13 +190,7 @@ void postProfSampleCostCentre(Capability *cap,
void postProfBegin(void);
#endif /* PROFILING */
-void postIPE(StgWord64 info,
- const char *table_name,
- const char *closure_desc,
- const char *ty_desc,
- const char *label,
- const char *module,
- const char *srcloc);
+void postIPE(const InfoProvEnt *ipe);
void postConcUpdRemSetFlush(Capability *cap);
void postConcMarkEnd(StgWord32 marked_obj_count);