summaryrefslogtreecommitdiff
path: root/rts/eventlog/EventLog.c
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2020-11-18 11:36:07 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2021-03-03 19:09:34 +0000
commit4b297979d25740d31241a9000e36068db112545a (patch)
treee2e40fa7922fb4a91125c73fcbae04e7a6a66f73 /rts/eventlog/EventLog.c
parent8402ea951b31e01a925ca691747d1757eaf31fcc (diff)
downloadhaskell-4b297979d25740d31241a9000e36068db112545a.tar.gz
Add -finfo-table-map which maps info tables to source positions
This new flag embeds a lookup table from the address of an info table to information about that info table. The main interface for consulting the map is the `lookupIPE` C function > InfoProvEnt * lookupIPE(StgInfoTable *info) The `InfoProvEnt` has the following structure: > typedef struct InfoProv_{ > char * table_name; > char * closure_desc; > char * ty_desc; > char * label; > char * module; > char * srcloc; > } InfoProv; > > typedef struct InfoProvEnt_ { > StgInfoTable * info; > InfoProv prov; > struct InfoProvEnt_ *link; > } InfoProvEnt; The source positions are approximated in a similar way to the source positions for DWARF debugging information. They are only approximate but in our experience provide a good enough hint about where the problem might be. It is therefore recommended to use this flag in conjunction with `-g<n>` for more accurate locations. The lookup table is also emitted into the eventlog when it is available as it is intended to be used with the `-hi` profiling mode. Using this flag will significantly increase the size of the resulting object file but only by a factor of 2-3x in our experience.
Diffstat (limited to 'rts/eventlog/EventLog.c')
-rw-r--r--rts/eventlog/EventLog.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c
index c1eda283f5..0a1ed09f6f 100644
--- a/rts/eventlog/EventLog.c
+++ b/rts/eventlog/EventLog.c
@@ -165,6 +165,7 @@ char *EventDesc[] = {
[EVENT_HACK_BUG_T9003] = "Empty event for bug #9003",
[EVENT_HEAP_PROF_BEGIN] = "Start of heap profile",
[EVENT_HEAP_PROF_COST_CENTRE] = "Cost center definition",
+ [EVENT_IPE] = "Info Table Source Position",
[EVENT_HEAP_PROF_SAMPLE_BEGIN] = "Start of heap profile sample",
[EVENT_HEAP_BIO_PROF_SAMPLE_BEGIN] = "Start of heap profile (biographical) sample",
[EVENT_HEAP_PROF_SAMPLE_END] = "End of heap profile sample",
@@ -497,6 +498,9 @@ init_event_types(void)
case EVENT_HEAP_PROF_COST_CENTRE:
eventTypes[t].size = EVENT_SIZE_DYNAMIC;
break;
+ case EVENT_IPE:
+ eventTypes[t].size = EVENT_SIZE_DYNAMIC;
+ break;
case EVENT_HEAP_PROF_SAMPLE_BEGIN:
eventTypes[t].size = 8;
@@ -1640,6 +1644,36 @@ 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)
+{
+ 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);
+ // 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);
+ RELEASE_LOCK(&eventBufMutex);
+}
void printAndClearEventBuf (EventsBuf *ebuf)
{