From f0a352756958c7c841da25143f7fdea610ab9a21 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 19 May 2008 12:51:01 +0000 Subject: [PATCH] FIX #1955: confusion between .exe.hp and .hp suffixes for heap profiles Now we use .hp and .prof consistently. --- rts/Profiling.c | 25 ++++++++++++++++++++----- utils/hp2ps/Main.c | 1 - 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/rts/Profiling.c b/rts/Profiling.c index 77fab52..d729c8a 100644 --- a/rts/Profiling.c +++ b/rts/Profiling.c @@ -268,6 +268,21 @@ ccsSetSelected( CostCentreStack *ccs ) static void initProfilingLogFile(void) { + char *prog; + + prog = arenaAlloc(prof_arena, strlen(prog_name) + 1); + strcpy(prog, prog_name); +#ifdef 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.CcFlags.doCostCentres == 0 && RtsFlags.ProfFlags.doHeapProfile != HEAP_BY_RETAINER) { @@ -278,8 +293,8 @@ initProfilingLogFile(void) else { /* Initialise the log file name */ - prof_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6); - sprintf(prof_filename, "%s.prof", prog_name); + prof_filename = arenaAlloc(prof_arena, strlen(prog) + 6); + sprintf(prof_filename, "%s.prof", prog); /* open the log file */ if ((prof_file = fopen(prof_filename, "w")) == NULL) { @@ -310,9 +325,9 @@ initProfilingLogFile(void) if (RtsFlags.ProfFlags.doHeapProfile) { /* Initialise the log file name */ - hp_filename = arenaAlloc(prof_arena, strlen(prog_name) + 6); - sprintf(hp_filename, "%s.hp", prog_name); - + hp_filename = arenaAlloc(prof_arena, strlen(prog) + 6); + sprintf(hp_filename, "%s.hp", prog); + /* open the log file */ if ((hp_file = fopen(hp_filename, "w")) == NULL) { debugBelch("Can't open profiling report file %s\n", diff --git a/utils/hp2ps/Main.c b/utils/hp2ps/Main.c index 53f010b..947ff46 100644 --- a/utils/hp2ps/Main.c +++ b/utils/hp2ps/Main.c @@ -147,7 +147,6 @@ nextarg: ; DropSuffix(pathName, ".hp"); #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32) DropSuffix(pathName, ".exe"); - pathName = copystring2(pathName,".exe"); #endif baseName = copystring(Basename(pathName)); -- 1.7.10.4