Author: njn
Date: 2007-10-18 09:56:48 +0100 (Thu, 18 Oct 2007)
New Revision: 7022

Log:
- Add some C++ tests.
- Add some notes about generic file formats.

Added:
   branches/MASSIF2/massif/tests/new-cpp.cpp
   branches/MASSIF2/massif/tests/new-cpp.post.exp
   branches/MASSIF2/massif/tests/new-cpp.stderr.exp
   branches/MASSIF2/massif/tests/new-cpp.vgtest
   branches/MASSIF2/massif/tests/overloaded-new.post.exp
   branches/MASSIF2/massif/tests/overloaded-new.stderr.exp
   branches/MASSIF2/massif/tests/overloaded-new.vgtest
Modified:
   branches/MASSIF2/massif/ms_main.c
   branches/MASSIF2/massif/tests/Makefile.am
   branches/MASSIF2/massif/tests/overloaded-new.cpp


Modified: branches/MASSIF2/massif/ms_main.c
===================================================================
--- branches/MASSIF2/massif/ms_main.c   2007-10-18 03:30:45 UTC (rev 7021)
+++ branches/MASSIF2/massif/ms_main.c   2007-10-18 08:56:48 UTC (rev 7022)
@@ -109,8 +109,6 @@
 //
 // Todo -- critical for release:
 // - decide on a name!
-// - C++ tests -- for each of the allocators, and overloaded versions of
-//   them (see 'init_alloc_fns').
 // - do a graph-drawing test
 // - write a good basic test that shows how the tool works, suitable for
 //   documentation
@@ -214,6 +212,68 @@
 // Tests:
 // - tests/overloaded_new.cpp is there
 //
+// File format working notes:
+
+#if 0
+desc: --heap-admin=foo
+cmd: date
+time_unit: ms
+#-----------
+snapshot=0
+#-----------
+time=0
+mem_heap_B=0
+mem_heap_admin_B=0
+mem_stacks_B=0
+heap_tree=empty
+#-----------
+snapshot=1
+#-----------
+time=353
+mem_heap_B=5
+mem_heap_admin_B=0
+mem_stacks_B=0
+heap_tree=detailed
+n1: 5 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
+ n1: 5 0x27F6E0: _nl_normalize_codeset (in /lib/libc-2.3.5.so)
+  n1: 5 0x279DE6: _nl_load_locale_from_archive (in /lib/libc-2.3.5.so)
+   n1: 5 0x278E97: _nl_find_locale (in /lib/libc-2.3.5.so)
+    n1: 5 0x278871: setlocale (in /lib/libc-2.3.5.so)
+     n1: 5 0x8049821: (within /bin/date)
+      n0: 5 0x26ED5E: (below main) (in /lib/libc-2.3.5.so)
+
+
+n_events: n  time(ms)  total(B)    useful-heap(B)  admin-heap(B)  stacks(B)
+t_events: B
+n  0 0 0 0 0 
+td 0 0 0 0 0
+n1:
+
+Challenges:
+- how to specify and scale/abbreviate units on axes?
+- how to combine multiple values into the y-axis?
+
+--------------------------------------------------------------------------------Command:
            date
+Massif arguments:   --heap-admin=foo
+ms_print arguments: massif.out
+--------------------------------------------------------------------------------
+    KB
+6.472^                                                       :#
+     |                                                       :#  ::  .    .
+     ...
+     |                                     ::@  :@    :@ :@:::#  ::  :    ::::
+   0 [EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]>ms     0            
                                                         713
+
+Number of snapshots: 50
+ Detailed snapshots: [2, 11, 13, 19, 25, 32 (peak)]
+--------------------------------------------------------------------------------
  n       time(ms)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
  0              0                0                0             0            0
+  1            345                5                5             0            0
+  2            353                5                5             0            0
+100.00% (5B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
+->100.00% (5B) 0x27F6E0: _nl_normalize_codeset (in /lib/libc-2.3.5.so)
+#endif
+
 //---------------------------------------------------------------------------
 
 #include "pub_tool_basics.h"

Modified: branches/MASSIF2/massif/tests/Makefile.am
===================================================================
--- branches/MASSIF2/massif/tests/Makefile.am   2007-10-18 03:30:45 UTC (rev 
7021)
+++ branches/MASSIF2/massif/tests/Makefile.am   2007-10-18 08:56:48 UTC (rev 
7022)
@@ -19,9 +19,11 @@
        custom_alloc.post.exp custom_alloc.stderr.exp custom_alloc.vgtest
        ignoring.post.exp ignoring.stderr.exp ignoring.vgtest \
        long-time.post.exp long-time.stderr.exp long-time.vgtest \
+       new-cpp.post.exp new-cpp.stderr.exp new-cpp.vgtest \
        no-stack-no-heap.post.exp no-stack-no-heap.stderr.exp 
no-stack-no-heap.vgtest \
        null.post.exp null.stderr.exp null.vgtest \
        one.post.exp one.stderr.exp one.vgtest \
+       overloaded-new.post.exp overloaded-new.stderr.exp overloaded-new.vgtest 
\
        params.post.exp params.stderr.exp params.vgtest \
        peak.post.exp peak.stderr.exp peak.vgtest \
        peak2.post.exp peak2.stderr.exp peak2.vgtest \
@@ -52,10 +54,16 @@
        ignoring \
        insig \
        long-time \
+       new-cpp \
        null \
        one \
+       overloaded-new \
        peak \
        realloc \
        thresholds \
        zero
 
+# C++ tests
+new_cpp_SOURCES                = new-cpp.cpp
+overloaded_new_SOURCES = overloaded-new.cpp
+

Added: branches/MASSIF2/massif/tests/new-cpp.cpp
===================================================================
--- branches/MASSIF2/massif/tests/new-cpp.cpp                           (rev 0)
+++ branches/MASSIF2/massif/tests/new-cpp.cpp   2007-10-18 08:56:48 UTC (rev 
7022)
@@ -0,0 +1,30 @@
+// operator new(unsigned)
+// operator new[](unsigned)
+// operator new(unsigned, std::nothrow_t const&)
+// operator new[](unsigned, std::nothrow_t const&)
+
+#include <stdlib.h>
+
+#include <new>
+
+using std::nothrow_t;
+
+// A big structure.  Its details don't matter.
+struct s {
+    int array[1000];
+};
+
+int main(void)
+{
+    struct s* p1 = new                struct s;
+    struct s* p2 = new (std::nothrow) struct s;
+    char*     c1 = new                char[2000];
+    char*     c2 = new (std::nothrow) char[2000];
+    delete p1;
+    delete p2;
+    delete [] c1;
+    delete [] c2;
+    return 0;
+}
+
+

Added: branches/MASSIF2/massif/tests/new-cpp.post.exp
===================================================================
--- branches/MASSIF2/massif/tests/new-cpp.post.exp                              
(rev 0)
+++ branches/MASSIF2/massif/tests/new-cpp.post.exp      2007-10-18 08:56:48 UTC 
(rev 7022)
@@ -0,0 +1,58 @@
+--------------------------------------------------------------------------------
+Command:            ./new-cpp
+Massif arguments:   --stacks=no --time-unit=B
+ms_print arguments: massif.out
+--------------------------------------------------------------------------------
+
+
+    KB
+11.75^                                   #                                    
+     |                                   #                                    
+     |                                   #                                    
+     |                             .     #                                    
+     |                             :     #                                    
+     |                             :     #                                    
+     |                             :     #                                    
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |           .           :     :     #           :           .            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :     :      
+     |           :           :     :     #           :           :     :      
+     |           :           :     :     #           :           :     :      
+   0 
+-----------------------------------#----------------------------------->KB
+     0                                                                   23.50
+
+Number of snapshots: 10
+ Detailed snapshots: [5 (peak)]
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  0              0                0                0             0            0
+  1          4,008            4,008            4,000             8            0
+  2          8,016            8,016            8,000            16            0
+  3         10,024           10,024           10,000            24            0
+  4         12,032           12,032           12,000            32            0
+  5         12,032           12,032           12,000            32            0
+99.73% (12,000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->33.24% (4,000B) 0x........: main (new-cpp.cpp:19)
+| 
+->33.24% (4,000B) 0x........: main (new-cpp.cpp:20)
+| 
+->16.62% (2,000B) 0x........: main (new-cpp.cpp:21)
+| 
+->16.62% (2,000B) 0x........: main (new-cpp.cpp:22)
+  
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  6         16,040            8,024            8,000            24            0
+  7         20,048            4,016            4,000            16            0
+  8         22,056            2,008            2,000             8            0
+  9         24,064                0                0             0            0

Added: branches/MASSIF2/massif/tests/new-cpp.stderr.exp
===================================================================
--- branches/MASSIF2/massif/tests/new-cpp.stderr.exp                            
(rev 0)
+++ branches/MASSIF2/massif/tests/new-cpp.stderr.exp    2007-10-18 08:56:48 UTC 
(rev 7022)
@@ -0,0 +1,2 @@
+
+

Added: branches/MASSIF2/massif/tests/new-cpp.vgtest
===================================================================
--- branches/MASSIF2/massif/tests/new-cpp.vgtest                                
(rev 0)
+++ branches/MASSIF2/massif/tests/new-cpp.vgtest        2007-10-18 08:56:48 UTC 
(rev 7022)
@@ -0,0 +1,4 @@
+prog: new-cpp
+vgopts: --stacks=no --time-unit=B
+post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses
+cleanup: rm massif.out

Modified: branches/MASSIF2/massif/tests/overloaded-new.cpp
===================================================================
--- branches/MASSIF2/massif/tests/overloaded-new.cpp    2007-10-18 03:30:45 UTC 
(rev 7021)
+++ branches/MASSIF2/massif/tests/overloaded-new.cpp    2007-10-18 08:56:48 UTC 
(rev 7022)
@@ -9,7 +9,7 @@
 
 using std::nothrow_t;
 
-// A big structure.  It's details don't matter.
+// A big structure.  Its details don't matter.
 struct s {
     int array[1000];
 };
@@ -34,12 +34,26 @@
     return malloc(n);
 }
 
+void operator delete (void* p)
+{
+    return free(p);
+}
+
+void operator delete[] (void* p)
+{
+    return free(p);
+}
+
 int main(void)
 {
     struct s* p1 = new                struct s;
     struct s* p2 = new (std::nothrow) struct s;
     char*     c1 = new                char[2000];
     char*     c2 = new (std::nothrow) char[2000];
+    delete p1;
+    delete p2;
+    delete [] c1;
+    delete [] c2;
     return 0;
 }
 

Added: branches/MASSIF2/massif/tests/overloaded-new.post.exp
===================================================================
--- branches/MASSIF2/massif/tests/overloaded-new.post.exp                       
        (rev 0)
+++ branches/MASSIF2/massif/tests/overloaded-new.post.exp       2007-10-18 
08:56:48 UTC (rev 7022)
@@ -0,0 +1,58 @@
+--------------------------------------------------------------------------------
+Command:            ./overloaded-new
+Massif arguments:   --stacks=no --time-unit=B
+ms_print arguments: massif.out
+--------------------------------------------------------------------------------
+
+
+    KB
+11.75^                                   #                                    
+     |                                   #                                    
+     |                                   #                                    
+     |                             .     #                                    
+     |                             :     #                                    
+     |                             :     #                                    
+     |                             :     #                                    
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |                       :     :     #           :                        
+     |           .           :     :     #           :           .            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :            
+     |           :           :     :     #           :           :     :      
+     |           :           :     :     #           :           :     :      
+     |           :           :     :     #           :           :     :      
+   0 
+-----------------------------------#----------------------------------->KB
+     0                                                                   23.50
+
+Number of snapshots: 10
+ Detailed snapshots: [5 (peak)]
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  0              0                0                0             0            0
+  1          4,008            4,008            4,000             8            0
+  2          8,016            8,016            8,000            16            0
+  3         10,024           10,024           10,000            24            0
+  4         12,032           12,032           12,000            32            0
+  5         12,032           12,032           12,000            32            0
+99.73% (12,000B) (heap allocation functions) malloc/new/new[], --alloc-fns, 
etc.
+->33.24% (4,000B) 0x........: main (overloaded-new.cpp:49)
+| 
+->33.24% (4,000B) 0x........: main (overloaded-new.cpp:50)
+| 
+->16.62% (2,000B) 0x........: main (overloaded-new.cpp:51)
+| 
+->16.62% (2,000B) 0x........: main (overloaded-new.cpp:52)
+  
+--------------------------------------------------------------------------------
+  n        time(B)         total(B)   useful-heap(B) admin-heap(B)    stacks(B)
+--------------------------------------------------------------------------------
+  6         16,040            8,024            8,000            24            0
+  7         20,048            4,016            4,000            16            0
+  8         22,056            2,008            2,000             8            0
+  9         24,064                0                0             0            0

Added: branches/MASSIF2/massif/tests/overloaded-new.stderr.exp
===================================================================
--- branches/MASSIF2/massif/tests/overloaded-new.stderr.exp                     
        (rev 0)
+++ branches/MASSIF2/massif/tests/overloaded-new.stderr.exp     2007-10-18 
08:56:48 UTC (rev 7022)
@@ -0,0 +1,2 @@
+
+

Added: branches/MASSIF2/massif/tests/overloaded-new.vgtest
===================================================================
--- branches/MASSIF2/massif/tests/overloaded-new.vgtest                         
(rev 0)
+++ branches/MASSIF2/massif/tests/overloaded-new.vgtest 2007-10-18 08:56:48 UTC 
(rev 7022)
@@ -0,0 +1,4 @@
+prog: overloaded-new
+vgopts: --stacks=no --time-unit=B
+post: perl ../../massif/ms_print massif.out | ../../tests/filter_addresses
+cleanup: rm massif.out


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Valgrind-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to