summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rts/ProfHeap.c2
-rw-r--r--rts/ProfHeap.h5
-rw-r--r--rts/Profiling.c13
-rw-r--r--testsuite/tests/profiling/should_run/Makefile10
-rw-r--r--testsuite/tests/profiling/should_run/T11489.hs1
-rw-r--r--testsuite/tests/profiling/should_run/T11489.stderr1
-rw-r--r--testsuite/tests/profiling/should_run/all.T5
-rw-r--r--testsuite/tests/rts/all.T3
8 files changed, 29 insertions, 11 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c
index 416f5ac4b8..187116fdbc 100644
--- a/rts/ProfHeap.c
+++ b/rts/ProfHeap.c
@@ -161,7 +161,7 @@ doingLDVProfiling( void )
|| RtsFlags.ProfFlags.bioSelector != NULL);
}
-STATIC_INLINE rtsBool
+rtsBool
doingRetainerProfiling( void )
{
return (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER
diff --git a/rts/ProfHeap.h b/rts/ProfHeap.h
index e29a9f6974..279eef2bf9 100644
--- a/rts/ProfHeap.h
+++ b/rts/ProfHeap.h
@@ -16,6 +16,11 @@ nat initHeapProfiling (void);
void endHeapProfiling (void);
rtsBool strMatchesSelector (const char* str, const char* sel);
+#ifdef PROFILING
+// doingRetainerProfiling: `-hr` or `-hr<cc> -h<x>`
+rtsBool doingRetainerProfiling(void);
+#endif
+
#include "EndPrivate.h"
#endif /* PROFHEAP_H */
diff --git a/rts/Profiling.c b/rts/Profiling.c
index 2c2981a02f..c67b0817df 100644
--- a/rts/Profiling.c
+++ b/rts/Profiling.c
@@ -254,9 +254,7 @@ initProfilingLogFile(void)
}
#endif
- if (RtsFlags.CcFlags.doCostCentres == 0 &&
- RtsFlags.ProfFlags.doHeapProfile != HEAP_BY_RETAINER &&
- RtsFlags.ProfFlags.retainerSelector == NULL)
+ if (RtsFlags.CcFlags.doCostCentres == 0 && !doingRetainerProfiling())
{
/* No need for the <prog>.prof file */
prof_filename = NULL;
@@ -272,11 +270,11 @@ initProfilingLogFile(void)
if ((prof_file = fopen(prof_filename, "w")) == NULL) {
debugBelch("Can't open profiling report file %s\n", prof_filename);
RtsFlags.CcFlags.doCostCentres = 0;
- // The following line was added by Sung; retainer/LDV profiling may need
- // two output files, i.e., <program>.prof/hp.
- if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER)
+ // Retainer profiling (`-hr` or `-hr<cc> -h<x>`) writes to
+ // both <program>.hp as <program>.prof.
+ if (doingRetainerProfiling()) {
RtsFlags.ProfFlags.doHeapProfile = 0;
- return;
+ }
}
}
@@ -290,7 +288,6 @@ initProfilingLogFile(void)
debugBelch("Can't open profiling report file %s\n",
hp_filename);
RtsFlags.ProfFlags.doHeapProfile = 0;
- return;
}
}
}
diff --git a/testsuite/tests/profiling/should_run/Makefile b/testsuite/tests/profiling/should_run/Makefile
index 577fc3491f..e46dd973f3 100644
--- a/testsuite/tests/profiling/should_run/Makefile
+++ b/testsuite/tests/profiling/should_run/Makefile
@@ -23,3 +23,13 @@ scc001:
$(call scc001Rule,-O0)
$(call scc001Rule,-O)
+.PHONY: T11489
+T11489:
+ $(RM) T11489
+ touch T11489.prof
+ chmod -w T11489.prof
+ "$(TEST_HC)" -v0 -prof T11489.hs
+ # Should print some message about not being to open the .prof file,
+ # then continue to run and exit normally.
+ # Caused a segmentation fault in GHC <= 7.10.3
+ ./T11489 +RTS -hr{} -hc
diff --git a/testsuite/tests/profiling/should_run/T11489.hs b/testsuite/tests/profiling/should_run/T11489.hs
new file mode 100644
index 0000000000..b3549c2fe3
--- /dev/null
+++ b/testsuite/tests/profiling/should_run/T11489.hs
@@ -0,0 +1 @@
+main = return ()
diff --git a/testsuite/tests/profiling/should_run/T11489.stderr b/testsuite/tests/profiling/should_run/T11489.stderr
new file mode 100644
index 0000000000..4f19dd9094
--- /dev/null
+++ b/testsuite/tests/profiling/should_run/T11489.stderr
@@ -0,0 +1 @@
+Can't open profiling report file T11489.prof
diff --git a/testsuite/tests/profiling/should_run/all.T b/testsuite/tests/profiling/should_run/all.T
index 7804d46670..ca37fe5704 100644
--- a/testsuite/tests/profiling/should_run/all.T
+++ b/testsuite/tests/profiling/should_run/all.T
@@ -134,3 +134,8 @@ test('T5363',
test('profinline001',
[ req_profiling, extra_ways(['prof']), only_ways(prof_ways) ],
compile_and_run, [''])
+
+test('T11489', [
+ req_profiling,
+ extra_clean(['T11489.prof', 'T11489.hp']),
+ ], run_command, ['$MAKE -s --no-print-directory T11489'])
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index c88bd62267..951acbe4b3 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -55,8 +55,7 @@ test('divbyzero',
test('outofmem', when(opsys('darwin'), skip),
run_command, ['$MAKE -s --no-print-directory outofmem'])
-test('outofmem2', extra_run_opts('+RTS -M5m -RTS'),
- run_command, ['$MAKE -s --no-print-directory outofmem2'])
+test('outofmem2', normal, run_command, ['$MAKE -s --no-print-directory outofmem2'])
test('T2047', [ignore_output, extra_run_opts('+RTS -c -RTS')],
compile_and_run, ['-package containers'])