Author: njn
Date: 2007-09-21 06:50:30 +0100 (Fri, 21 Sep 2007)
New Revision: 6888

Log:
Fix a bug in time printing that was screwing up times that didn't fit in 32
bits.  Add a test case.

Added:
   branches/MASSIF2/massif/tests/long-time.c
   branches/MASSIF2/massif/tests/long-time.post.exp
   branches/MASSIF2/massif/tests/long-time.stderr.exp
   branches/MASSIF2/massif/tests/long-time.vgtest
Modified:
   branches/MASSIF2/massif/ms_main.c
   branches/MASSIF2/massif/tests/Makefile.am


Modified: branches/MASSIF2/massif/ms_main.c
===================================================================
--- branches/MASSIF2/massif/ms_main.c   2007-09-21 05:12:34 UTC (rev 6887)
+++ branches/MASSIF2/massif/ms_main.c   2007-09-21 05:50:30 UTC (rev 6888)
@@ -317,9 +317,7 @@
 static UInt n_zero_allocs       = 0;
 static UInt n_frees             = 0;
 static UInt n_xpt_expansions    = 0;
-
 static UInt n_getXCon_redo      = 0;
-
 static UInt n_cullings          = 0;
 static UInt n_real_snapshots    = 0;
 static UInt n_skipped_snapshots = 0;
@@ -1541,7 +1539,7 @@
       ip_desc = VG_(describe_IP)(xpt->ip-1, ip_desc, BUF_LEN);
    }
    perc = make_perc(xpt->curr_szB, curr_total_szB);
-   FP("%sn%d: %ld %s\n", depth_str, n_child_entries, xpt->curr_szB, ip_desc);
+   FP("%sn%d: %lu %s\n", depth_str, n_child_entries, xpt->curr_szB, ip_desc);
 
    // Indent.
    tl_assert(depth+1 < depth_str_len-1);    // -1 for end NUL char
@@ -1561,7 +1559,7 @@
       Char* s        = ( n_insig_children == 1 ? "," : "s, all" );
       SizeT total_insig_children_szB = xpt->curr_szB - printed_children_szB;
       perc = make_perc(total_insig_children_szB, curr_total_szB);
-      FP("%sn0: %ld in %d place%s below massif's threshold (%s)\n",
+      FP("%sn0: %lu in %d place%s below massif's threshold (%s)\n",
          depth_str, total_insig_children_szB, n_insig_children, s,
          make_perc(clo_threshold, 10000));
    }
@@ -1578,7 +1576,7 @@
    FP("#-----------\n");
    FP("snapshot=%d\n", snapshot_n);
    FP("#-----------\n");
-   FP("time=%lu\n",             snapshot->time);
+   FP("time=%lld\n",            snapshot->time);
    FP("mem_total_B=%lu\n",      snapshot->total_szB);
    FP("mem_heap_B=%lu\n",       snapshot->heap_szB);
    FP("mem_heap_admin_B=%lu\n", snapshot->heap_admin_szB);

Modified: branches/MASSIF2/massif/tests/Makefile.am
===================================================================
--- branches/MASSIF2/massif/tests/Makefile.am   2007-09-21 05:12:34 UTC (rev 
6887)
+++ branches/MASSIF2/massif/tests/Makefile.am   2007-09-21 05:50:30 UTC (rev 
6888)
@@ -11,6 +11,7 @@
         basic_malloc.stderr.exp basic_malloc.vgtest \
         culling1.stderr.exp culling1.vgtest \
         culling2.stderr.exp culling2.vgtest \
+       long-time.post.exp long-time.stderr.exp long-time.vgtest \
        thresholds_0_0.post.exp   thresholds_0_0.stderr.exp   
thresholds_0_0.vgtest \
        thresholds_0_10.post.exp  thresholds_0_10.stderr.exp  
thresholds_0_10.vgtest \
        thresholds_10_0.post.exp  thresholds_10_0.stderr.exp  
thresholds_10_0.vgtest \
@@ -28,6 +29,7 @@
        basic \
        basic_malloc \
        culling1 culling2 \
+       long-time \
        thresholds \
        zero
 

Added: branches/MASSIF2/massif/tests/long-time.c
===================================================================
--- branches/MASSIF2/massif/tests/long-time.c                           (rev 0)
+++ branches/MASSIF2/massif/tests/long-time.c   2007-09-21 05:50:30 UTC (rev 
6888)
@@ -0,0 +1,22 @@
+// This test does enough allocation and deallocation that the time-unit,
+// when measured in bytes -- 6,000,000,000 -- exceeds 32-bits.  It also does
+// it in a slightly uneven fashion so we get a range of different totals
+// for the snapshots, including a zero-sized detailed snapshot.
+
+#include <stdlib.h>
+
+int main(void)
+{
+   int i;
+   for (i = 0; i < 1500; i++) {
+      int* x1 = malloc( 800 * 1000);
+      int* x2 = malloc(1100 * 1000);
+      free(x1);
+      int* x3 = malloc(1200 * 1000);
+      free(x2);
+      free(x3);
+      int* x4 = malloc( 900 * 1000);
+      free(x4);
+   }
+   return 0;
+}

Added: branches/MASSIF2/massif/tests/long-time.post.exp
===================================================================
--- branches/MASSIF2/massif/tests/long-time.post.exp                            
(rev 0)
+++ branches/MASSIF2/massif/tests/long-time.post.exp    2007-09-21 05:50:30 UTC 
(rev 6888)
@@ -0,0 +1,206 @@
+--------------------------------------------------------------------------------
+Command:   ./long-time
+Data file: massif.out
+Options:   XXX
+--------------------------------------------------------------------------------
+
+
+2.3M|                          :               @   :  @  :  @  :  @  :  @  : 
+    |                          :               @   :  @  :  @  :  @  :  @  : 
+    |                          :               @   :  @  :  @  :  @  :  @  : 
+    |                  ........:   . .  .  . . @.  .  @  .  @  :. @. :. @. :.
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |                  :::::::::   : @  :  : : @:  :  @  :  @  :: @: :: @: ::
+    |..       ::::::::.:::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::       ::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::.......::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+    |::@::::::::::::::::::::::::   : @  :  : : @: :: :@ :: :@ ::::@:::: @: ::
+  0 [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@----
+
+
+Number of snapshots: 97
+ Detailed snapshots: [3, 40, 46, 49, 59, 69, 79, 89]
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  0              0                0                0             0            0
+  1    122,700,000        1,100,008        1,100,000             8            0
+  2    250,700,000        1,100,008        1,100,000             8            0
+  3    399,100,000          900,008          900,000             8            0
+100.00% (900000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->100.00% (900000B) 0x8048447: main (long-time.c:18)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  4    527,100,000          900,008          900,000             8            0
+  5    655,100,000          900,008          900,000             8            0
+  6    783,100,000          900,008          900,000             8            0
+  7    911,100,000          900,008          900,000             8            0
+  8  1,039,100,000          900,008          900,000             8            0
+  9  1,167,100,000          900,008          900,000             8            0
+ 10  1,295,100,000          900,008          900,000             8            0
+ 11  1,423,100,000          900,008          900,000             8            0
+ 12  1,551,100,000          900,008          900,000             8            0
+ 13  1,653,000,000        1,200,008        1,200,000             8            0
+ 14  1,789,000,000        1,200,008        1,200,000             8            0
+ 15  1,925,000,000        1,200,008        1,200,000             8            0
+ 16  2,061,000,000        1,200,008        1,200,000             8            0
+ 17  2,197,000,000        1,200,008        1,200,000             8            0
+ 18  2,333,000,000        1,200,008        1,200,000             8            0
+ 19  2,469,000,000        1,200,008        1,200,000             8            0
+ 20  2,605,000,000        1,200,008        1,200,000             8            0
+ 21  2,741,000,000        1,200,008        1,200,000             8            0
+ 22  2,930,700,000        1,100,008        1,100,000             8            0
+ 23  3,041,900,000        1,900,016        1,900,000            16            0
+ 24  3,153,900,000        1,900,016        1,900,000            16            0
+ 25  3,265,900,000        1,900,016        1,900,000            16            0
+ 26  3,377,900,000        1,900,016        1,900,000            16            0
+ 27  3,489,900,000        1,900,016        1,900,000            16            0
+ 28  3,601,900,000        1,900,016        1,900,000            16            0
+ 29  3,713,900,000        1,900,016        1,900,000            16            0
+ 30  3,825,900,000        1,900,016        1,900,000            16            0
+ 31  3,937,900,000        1,900,016        1,900,000            16            0
+ 32  4,049,900,000        1,900,016        1,900,000            16            0
+ 33  4,161,900,000        1,900,016        1,900,000            16            0
+ 34  4,273,900,000        1,900,016        1,900,000            16            0
+ 35  4,467,900,000        2,300,016        2,300,000            16            0
+ 36  4,688,000,000                0                0             0            0
+ 37  4,798,200,000                0                0             0            0
+ 38  5,017,900,000        1,900,016        1,900,000            16            0
+ 39  5,238,200,000                0                0             0            0
+ 40  5,457,900,000        1,900,016        1,900,000            16            0
+100.00% (1900000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->57.89% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->42.10% (800000B) 0x80483E4: main (long-time.c:12)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 41  5,678,200,000                0                0             0            0
+ 42  5,897,900,000        1,900,016        1,900,000            16            0
+ 43  6,118,200,000                0                0             0            0
+ 44  6,337,900,000        1,900,016        1,900,000            16            0
+ 45  6,448,000,000                0                0             0            0
+ 46  6,558,200,000                0                0             0            0
+00.00% (0B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 47  6,777,900,000        1,900,016        1,900,000            16            0
+ 48  6,888,000,000                0                0             0            0
+ 49  7,107,900,000        2,300,016        2,300,000            16            0
+100.00% (2300000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->52.17% (1200000B) 0x8048418: main (long-time.c:15)
+| 
+->47.83% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 50  7,209,900,000        1,900,016        1,900,000            16            0
+ 51  7,312,000,000                0                0             0            0
+ 52  7,414,200,000                0                0             0            0
+ 53  7,517,000,000        1,200,008        1,200,000             8            0
+ 54  7,619,900,000        2,300,016        2,300,000            16            0
+ 55  7,721,900,000        1,900,016        1,900,000            16            0
+ 56  7,824,000,000                0                0             0            0
+ 57  7,926,200,000                0                0             0            0
+ 58  8,029,000,000        1,200,008        1,200,000             8            0
+ 59  8,131,900,000        2,300,016        2,300,000            16            0
+100.00% (2300000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->52.17% (1200000B) 0x8048418: main (long-time.c:15)
+| 
+->47.83% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 60  8,233,900,000        1,900,016        1,900,000            16            0
+ 61  8,336,000,000                0                0             0            0
+ 62  8,438,200,000                0                0             0            0
+ 63  8,541,000,000        1,200,008        1,200,000             8            0
+ 64  8,643,900,000        2,300,016        2,300,000            16            0
+ 65  8,745,900,000        1,900,016        1,900,000            16            0
+ 66  8,848,000,000                0                0             0            0
+ 67  8,950,200,000                0                0             0            0
+ 68  9,053,000,000        1,200,008        1,200,000             8            0
+ 69  9,155,900,000        2,300,016        2,300,000            16            0
+100.00% (2300000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->52.17% (1200000B) 0x8048418: main (long-time.c:15)
+| 
+->47.83% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 70  9,257,900,000        1,900,016        1,900,000            16            0
+ 71  9,360,000,000                0                0             0            0
+ 72  9,462,200,000                0                0             0            0
+ 73  9,565,000,000        1,200,008        1,200,000             8            0
+ 74  9,667,900,000        2,300,016        2,300,000            16            0
+ 75  9,769,900,000        1,900,016        1,900,000            16            0
+ 76  9,872,000,000                0                0             0            0
+ 77  9,974,200,000                0                0             0            0
+ 78 10,077,000,000        1,200,008        1,200,000             8            0
+ 79 10,179,900,000        2,300,016        2,300,000            16            0
+100.00% (2300000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->52.17% (1200000B) 0x8048418: main (long-time.c:15)
+| 
+->47.83% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 80 10,281,900,000        1,900,016        1,900,000            16            0
+ 81 10,384,000,000                0                0             0            0
+ 82 10,486,200,000                0                0             0            0
+ 83 10,589,000,000        1,200,008        1,200,000             8            0
+ 84 10,691,900,000        2,300,016        2,300,000            16            0
+ 85 10,793,900,000        1,900,016        1,900,000            16            0
+ 86 10,896,000,000                0                0             0            0
+ 87 10,998,200,000                0                0             0            0
+ 88 11,101,000,000        1,200,008        1,200,000             8            0
+ 89 11,203,900,000        2,300,016        2,300,000            16            0
+100.00% (2300000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->52.17% (1200000B) 0x8048418: main (long-time.c:15)
+| 
+->47.83% (1100000B) 0x80483F7: main (long-time.c:13)
+| 
+->00.00% (0B) in 1+ places, all below ms_print's threshold (01.00%)
+
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+ 90 11,305,900,000        1,900,016        1,900,000            16            0
+ 91 11,408,000,000                0                0             0            0
+ 92 11,510,200,000                0                0             0            0
+ 93 11,613,000,000        1,200,008        1,200,000             8            0
+ 94 11,715,900,000        2,300,016        2,300,000            16            0
+ 95 11,817,900,000        1,900,016        1,900,000            16            0
+ 96 11,920,000,000                0                0             0            0

Added: branches/MASSIF2/massif/tests/long-time.stderr.exp
===================================================================
--- branches/MASSIF2/massif/tests/long-time.stderr.exp                          
(rev 0)
+++ branches/MASSIF2/massif/tests/long-time.stderr.exp  2007-09-21 05:50:30 UTC 
(rev 6888)
@@ -0,0 +1,2 @@
+
+

Added: branches/MASSIF2/massif/tests/long-time.vgtest
===================================================================
--- branches/MASSIF2/massif/tests/long-time.vgtest                              
(rev 0)
+++ branches/MASSIF2/massif/tests/long-time.vgtest      2007-09-21 05:50:30 UTC 
(rev 6888)
@@ -0,0 +1,4 @@
+prog: long-time
+vgopts: --stacks=no --time-unit=B
+post: perl ../../massif/ms_print massif.out
+cleanup: rm massif.out


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to