diff options
author | Teo Camarasu <teofilcamarasu@gmail.com> | 2022-04-27 21:53:53 +0100 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2022-07-14 14:39:38 +0530 |
commit | 10dbc896d6bed597bc8d84e1b2b30e3e6810f040 (patch) | |
tree | 70af67eccaeceae2fe0305938df8499286edf9ea | |
parent | 494aa15430be8578f8dfd2ccf4b1e40ca0711959 (diff) | |
download | haskell-10dbc896d6bed597bc8d84e1b2b30e3e6810f040.tar.gz |
Respect -po when heap profiling (#21446)
(cherry picked from commit 89a413182c9709b239106b40b1d6c8b20a214a21)
(cherry picked from commit 4b9af020ffa0077983c7952fd27114e47253a6ea)
-rw-r--r-- | rts/ProfHeap.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index b05c34d80f..4f0fd4c7b1 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -419,37 +419,43 @@ initHeapProfiling(void) init_prof_locale(); set_prof_locale(); - char *prog; + char *stem; - prog = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); - strcpy(prog, prog_name); + if (RtsFlags.CcFlags.outputFileNameStem) { + stem = stgMallocBytes(strlen(RtsFlags.CcFlags.outputFileNameStem) + 1, "initHeapProfiling"); + strcpy(stem, RtsFlags.CcFlags.outputFileNameStem); + } else { + + stem = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); + strcpy(stem, 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'; - } - } + // on Windows, drop the .exe suffix if there is one + { + char *suff; + suff = strrchr(stem,'.'); + 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); + hp_filename = stgMallocBytes(strlen(stem) + 6, "hpFileName"); + sprintf(hp_filename, "%s.hp", stem); /* 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); + stgFree(stem); return; } } - stgFree(prog); + stgFree(stem); #if defined(PROFILING) if (doingLDVProfiling() && doingRetainerProfiling()) { |