summaryrefslogtreecommitdiff
path: root/rts/ProfHeap.c
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-07-10 17:16:33 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-07-16 02:41:23 -0400
commit373c9cb379bd64c4d295becf3afce122a6e199f4 (patch)
treed1d50715bb8d9fd90865268d54a2937839866d4f /rts/ProfHeap.c
parentdb948daea6c01c073f8d09a79fa5adda279fbf0c (diff)
downloadhaskell-373c9cb379bd64c4d295becf3afce122a6e199f4.tar.gz
rts: Divorce init of Heap profiler from CCS profiler
Currently initProfiling gets defined by Profiling.c only if PROFILING is defined. Otherwise the ProfHeap.c defines it. This is just needlessly complicated so in this commit I make Profiling and ProfHeap into properly seperate modules and call their respective init functions from RtsStartup.c.
Diffstat (limited to 'rts/ProfHeap.c')
-rw-r--r--rts/ProfHeap.c96
1 files changed, 41 insertions, 55 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index b63bc527ef..1023f7ccbe 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -26,6 +26,9 @@
#include <fs_rts.h>
#include <string.h>
+FILE *hp_file;
+static char *hp_filename; /* heap profile (hp2ps style) log file */
+
/* -----------------------------------------------------------------------------
* era stores the current time period. It is the same as the
* number of censuses that have been performed.
@@ -311,57 +314,6 @@ nextEra( void )
* Heap profiling by info table
* ------------------------------------------------------------------------- */
-#if !defined(PROFILING)
-FILE *hp_file;
-static char *hp_filename;
-
-void freeProfiling (void)
-{
-}
-
-void initProfiling (void)
-{
- char *prog;
-
- prog = stgMallocBytes(strlen(prog_name) + 1, "initProfiling2");
- strcpy(prog, prog_name);
-#if defined(mingw32_HOST_OS)
- // on Windows, drop the .exe suffix if there is one
- {
- char *suff;
- suff = strrchr(prog,'.');
- if (suff != NULL && !strcmp(suff,".exe")) {
- *suff = '\0';
- }
- }
-#endif
-
- if (RtsFlags.ProfFlags.doHeapProfile) {
- /* Initialise the log file name */
- hp_filename = stgMallocBytes(strlen(prog) + 6, "hpFileName");
- sprintf(hp_filename, "%s.hp", prog);
-
- /* open the log file */
- if ((hp_file = __rts_fopen(hp_filename, "w")) == NULL) {
- debugBelch("Can't open profiling report file %s\n",
- hp_filename);
- RtsFlags.ProfFlags.doHeapProfile = 0;
- stgFree(prog);
- return;
- }
- }
-
- stgFree(prog);
-
- initHeapProfiling();
-}
-
-void endProfiling( void )
-{
- endHeapProfiling();
-}
-#endif /* !PROFILING */
-
static void
printEscapedString(const char* string)
{
@@ -398,16 +350,52 @@ dumpCostCentresToEventLog(void)
#endif
}
+void freeHeapProfiling (void)
+{
+}
+
/* --------------------------------------------------------------------------
* Initialize the heap profilier
* ----------------------------------------------------------------------- */
-uint32_t
+void
initHeapProfiling(void)
{
if (! RtsFlags.ProfFlags.doHeapProfile) {
- return 0;
+ return;
}
+ char *prog;
+
+ prog = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling");
+ strcpy(prog, prog_name);
+#if defined(mingw32_HOST_OS)
+ // on Windows, drop the .exe suffix if there is one
+ {
+ char *suff;
+ suff = strrchr(prog,'.');
+ if (suff != NULL && !strcmp(suff,".exe")) {
+ *suff = '\0';
+ }
+ }
+#endif
+
+ if (RtsFlags.ProfFlags.doHeapProfile) {
+ /* Initialise the log file name */
+ hp_filename = stgMallocBytes(strlen(prog) + 6, "hpFileName");
+ sprintf(hp_filename, "%s.hp", prog);
+
+ /* open the log file */
+ if ((hp_file = __rts_fopen(hp_filename, "w")) == NULL) {
+ debugBelch("Can't open profiling report file %s\n",
+ hp_filename);
+ RtsFlags.ProfFlags.doHeapProfile = 0;
+ stgFree(prog);
+ return;
+ }
+ }
+
+ stgFree(prog);
+
#if defined(PROFILING)
if (doingLDVProfiling() && doingRetainerProfiling()) {
errorBelch("cannot mix -hb and -hr");
@@ -475,8 +463,6 @@ initHeapProfiling(void)
traceHeapProfBegin(0);
dumpCostCentresToEventLog();
-
- return 0;
}
void