Ticket #1955 (closed merge: fixed)

Opened 5 years ago

Last modified 4 years ago

Heap profiling on Windows doesn't work

Reported by: NeilMitchell Owned by: igloo
Priority: normal Milestone: 6.8.3
Component: Runtime System Version: 6.8.1
Keywords: Cc:
Operating System: Windows Architecture: Unknown/Multiple
Type of failure: Difficulty: Easy (less than 1 hour)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

C:\Temp>type Main.hs
main = print "neil"

C:\Temp>ghc --make -prof -auto-all Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking Main.exe ...

C:\Temp>main +RTS -hc
"neil"

C:\Temp>hp2ps main
hp2ps: cannot open main.exe.hp

This can be fixed by either renaming the generated main.hp to main.exe.hp, or running "main.exe +RTS -hc" in the first place. I guess you are using argv [0]as the basis of where to put the heap profiling information, and using the executable name as the basis of where to find it.

My suggestion would be that heap profiling information should always go at basename.hp (so main.hp), ignoring any extension. This would require fixing up both the RTS and the hp2ps utility.

Change History

Changed 5 years ago by igloo

  • milestone set to 6.8.3

Thanks for the report; should be easy to fix, so let's do it for 6.8.3.

Changed 5 years ago by simonmar

  • difficulty changed from Unknown to Easy (1 hr)

Changed 5 years ago by igloo

  • owner set to simonmar

OK, part of the problem is that with the gcc 3.4.2 supplied with GHC the argv[0] value is changed to be the path to the executable if we are in a cygwin shell, but not if we are in a cmd shell; the 3.4.4 I have installed works as I'd expect in either case. With a cygwin shell:

$ cat argv0.c 

#include <stdio.h>

int main(int argc, char **argv) {
    printf("%s\n", argv[0]);
}

$ gcc -dumpversion
3.4.4

$ gcc argv0.c -o 344

$ c:/ghc/ghc-6.8.2/gcc -dumpversion
3.4.2

$ c:/ghc/ghc-6.8.2/gcc argv0.c -o 342

$ ./344
./344

$ ./342
C:\cygwin\home\ian\q\342.exe

In cmd:

C:\cygwin\home\ian\q>344
344

C:\cygwin\home\ian\q>342
342

Simon, I am assigning this bug to you as it'll need to be you who upgrades the version of gcc that comes with the nightly Windows build.

After that, I think that the best thing is to drop this code from utils/hp2ps/Main.c:

#if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
        DropSuffix(pathName, ".exe");
        pathName = copystring2(pathName,".exe");
#endif

That way, if people use foo.exe to run the program then hp2ps foo.exe will work, and likewise, if they use foo then hp2ps foo will work.

Changed 5 years ago by NeilMitchell

In general, a Windows user would expect foo.exe then h2ps foo to work, and vice versa. Is there any reason for not always dropping the .exe when figuring out the heap profiling location, including within hp2ps?

Changed 5 years ago by igloo

That's probably better, good point.

Changed 5 years ago by simonmar

  • owner changed from simonmar to igloo
  • type changed from bug to merge

To merge:

Mon May 19 05:51:01 PDT 2008  Simon Marlow <simonmar@microsoft.com>
  * FIX #1955: confusion between .exe.hp and .hp suffixes for heap profiles

Changed 5 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Merged

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 4 years ago by simonmar

  • difficulty changed from Easy (1 hr) to Easy (less than 1 hour)
Note: See TracTickets for help on using tickets.