summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeo Camarasu <teofilcamarasu@gmail.com>2022-04-27 21:53:53 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-05-09 16:24:37 -0400
commit374554bb6b68fd8916cf2e95cb200b3a1390eb03 (patch)
tree83a695272c4383c0273a0e7867c205f84220fa32
parent67072c31d8b6ce4f0de79fa52bc3e5cdd5a495c6 (diff)
downloadhaskell-374554bb6b68fd8916cf2e95cb200b3a1390eb03.tar.gz
Respect -po when heap profiling (#21446)
-rw-r--r--rts/ProfHeap.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index 7921041a5a..ab65feab2b 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -430,37 +430,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()) {