#3904: Bug in shipped gcc makes profiling lose resolution
-----------------------------+----------------------------------------------
    Reporter:  augustss      |        Owner:              
        Type:  bug           |       Status:  new         
    Priority:  normal        |    Milestone:              
   Component:  Build System  |      Version:  6.12.1      
    Keywords:                |   Difficulty:              
          Os:  Windows       |     Testcase:              
Architecture:  x86           |      Failure:  None/Unknown
-----------------------------+----------------------------------------------

Comment(by simonmar):

 Replying to [comment:1 augustss]:
 > Why is the prining so complex anyway, why not just
 >   fprintf(..., "%s %.02f\n", ..., sampleValue);
 > ?

 This is the patch that did it:

 {{{
 Tue May 11 19:36:10 BST 2004  panne
   * [project @ 2004-05-11 18:36:10 by panne]
   Make the printing of samples really locale-independent
     {
     hunk ./ghc/rts/ProfHeap.c 2
     - * $Id: ProfHeap.c,v 1.51 2004/03/19 23:20:20 panne Exp $
     + * $Id: ProfHeap.c,v 1.52 2004/05/11 18:36:10 panne Exp $
     hunk ./ghc/rts/ProfHeap.c 35
     +#include <math.h>
     hunk ./ghc/rts/ProfHeap.c 386
     +static void
     +printSample(rtsBool beginSample, StgDouble sampleValue)
     +{
     +    StgDouble fractionalPart, integralPart;
     +    fractionalPart = modf(sampleValue, &integralPart);
     +    fprintf(hp_file, "%s %d.%02d\n",
     +            (beginSample ? "BEGIN_SAMPLE" : "END_SAMPLE"),
     +            (int)integralPart, (int)(fractionalPart * 100 + 0.5));
     +}
     +
     hunk ./ghc/rts/ProfHeap.c 457
     -    fprintf(hp_file, "BEGIN_SAMPLE 0.00\n");
     -    fprintf(hp_file, "END_SAMPLE 0.00\n");
     +    printSample(rtsTrue, 0);
     +    printSample(rtsFalse, 0);
     hunk ./ghc/rts/ProfHeap.c 500
     -    fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", seconds);
     -    fprintf(hp_file, "END_SAMPLE %0.2f\n", seconds);
     +    printSample(rtsTrue, seconds);
     +    printSample(rtsFalse, seconds);
     hunk ./ghc/rts/ProfHeap.c 597
     +    (void)p;   /* keep gcc -Wall happy */
     hunk ./ghc/rts/ProfHeap.c 744
     -    fprintf(hp_file, "BEGIN_SAMPLE %0.2f\n", census->time);
     +    printSample(rtsTrue, census->time);
     hunk ./ghc/rts/ProfHeap.c 757
     -   fprintf(hp_file, "END_SAMPLE %0.2f\n", census->time);
     +   printSample(rtsFalse, census->time);
     hunk ./ghc/rts/ProfHeap.c 837
     -    fprintf(hp_file, "END_SAMPLE %0.2f\n", census->time);
     +    printSample(rtsFalse, census->time);
     }
 }}}

 I guess the problem is that the decimal point is not necessarily a '.'.

 It looks like a later patch changed the types to StgWord64, which tickled
 the bug in gcc.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3904#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to