]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
342353 - Allow dumping full massif output while valgrind is still running
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 7 Mar 2015 19:20:12 +0000 (19:20 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 7 Mar 2015 19:20:12 +0000 (19:20 +0000)
Patch from Andre Goddard Rosa

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14992

NEWS
gdbserver_tests/mssnapshot.stderrB.exp
gdbserver_tests/mssnapshot.stdinB.gdb
massif/docs/ms-manual.xml
massif/ms_main.c

diff --git a/NEWS b/NEWS
index efb85eac1a5acbed21185ad878a19f68a9d04548..66689ff72512cfb67d4fd9144c5f35a0ccdf446a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,10 @@ Release 3.11.0 is under development, not yet released.
 
 * Memcheck:
 
+* Massif:
+  New monitor command 'all_snapshots <filename>' that dumps all snapshots
+  taken so far.
+
 * Helgrind:
 
 * Callgrind:
@@ -84,6 +88,7 @@ where XXXXXX is the bug number as listed below.
 342038  Unhandled syscalls on aarch64 (mbind/get/set_mempolicy)
 342063  wrong format specifier for test mcblocklistsearch in gdbserver_tests
 342221  socket connect false positive uninit memory for unknown af family
+342353  Allow dumping full massif output while valgrind is still running
 342603  Add I2C_SMBUS ioctl support
 342635  OS X 10.10 (Yosemite) - missing system calls and fcntl code
 342795  Internal glibc __GI_mempcpy call should be intercepted
index 62c47b045c2e107643394b461ecb32ab1125d912..93ba9c9ce79af5efeba14458f63c2d04047e933d 100644 (file)
@@ -17,8 +17,11 @@ general valgrind monitor commands:
 massif monitor commands:
   snapshot [<filename>]
   detailed_snapshot [<filename>]
-       takes a snapshot (or a detailed snapshot)
-       and saves it in <filename>
+      takes a snapshot (or a detailed snapshot)
+      and saves it in <filename>
+             default <filename> is massif.vgdb.out
+  all_snapshots [<filename>]
+      saves all snapshot(s) taken so far in <filename>
              default <filename> is massif.vgdb.out
 monitor command request to kill this process
 Remote connection closed
index 5f4257a31c7402e3c02d6d95d334ebd8121f633c..69b10e15714d33ea26d285e4bcb957f40e0b3d10 100644 (file)
@@ -16,6 +16,7 @@ monitor help
 # test non detailed and detailed snapshot
 monitor snapshot
 monitor detailed_snapshot
+monitor all_snapshots
 #
 #
 monitor v.kill
index 484d3eaa76d804df066af3a9f2b5b862bec1a842..4c555a97025fa4c64edd5b50716d5e3816a57e95 100644 (file)
@@ -877,6 +877,12 @@ gdbserver (see <xref linkend="manual-core-adv.gdbserver-commandhandling"/>).
     &lt;filename&gt; (default massif.vgdb.out).
     </para>
   </listitem>
+  <listitem>
+    <para><varname>all_snapshots [&lt;filename&gt;]</varname>
+    requests to take all captured snapshots so far and save them in the given
+    &lt;filename&gt; (default massif.vgdb.out).
+    </para>
+  </listitem>
 </itemizedlist>
 </sect1>
 
index 24fb18f646e6ae6ed69635455bd1b60e3450a3bf..5053c4f0ae7739895f2b7c9637564259c1e33f61 100644 (file)
 //   - preset column widths for stats are not generic
 //   - preset column headers are not generic
 //   - "Massif arguments:" line is not generic
-// - do snapshots on client requests
-//   - (Michael Meeks): have an interactive way to request a dump
-//     (callgrind_control-style)
-//     - "profile now"
+// - do snapshots on some specific client requests
 //     - "show me the extra allocations since the last snapshot"
 //     - "start/stop logging" (eg. quickly skip boring bits)
 // - Add ability to draw multiple graphs, eg. heap-only, stack-only, total.
@@ -1956,8 +1953,11 @@ static void print_monitor_help ( void )
    VG_(gdb_printf) ("massif monitor commands:\n");
    VG_(gdb_printf) ("  snapshot [<filename>]\n");
    VG_(gdb_printf) ("  detailed_snapshot [<filename>]\n");
-   VG_(gdb_printf) ("       takes a snapshot (or a detailed snapshot)\n");
-   VG_(gdb_printf) ("       and saves it in <filename>\n");
+   VG_(gdb_printf) ("      takes a snapshot (or a detailed snapshot)\n");
+   VG_(gdb_printf) ("      and saves it in <filename>\n");
+   VG_(gdb_printf) ("             default <filename> is massif.vgdb.out\n");
+   VG_(gdb_printf) ("  all_snapshots [<filename>]\n");
+   VG_(gdb_printf) ("      saves all snapshot(s) taken so far in <filename>\n");
    VG_(gdb_printf) ("             default <filename> is massif.vgdb.out\n");
    VG_(gdb_printf) ("\n");
 }
@@ -2337,6 +2337,20 @@ static void handle_snapshot_monitor_command (const HChar *filename,
    delete_snapshot(&snapshot);
 }
 
+static void handle_all_snapshots_monitor_command (const HChar *filename)
+{
+   if (!clo_pages_as_heap && !have_started_executing_code) {
+      // See comments of variable have_started_executing_code.
+      VG_(gdb_printf) 
+         ("error: cannot take snapshot before execution has started\n");
+      return;
+   }
+
+   write_snapshots_to_file ((filename == NULL) ? 
+                            "massif.vgdb.out" : filename,
+                            snapshots, next_snapshot_i);
+}
+
 static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
 {
    HChar* wcmd;
@@ -2346,7 +2360,7 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
    VG_(strcpy) (s, req);
 
    wcmd = VG_(strtok_r) (s, " ", &ssaveptr);
-   switch (VG_(keyword_id) ("help snapshot detailed_snapshot", 
+   switch (VG_(keyword_id) ("help snapshot detailed_snapshot all_snapshots", 
                             wcmd, kwd_report_duplicated_matches)) {
    case -2: /* multiple matches */
       return True;
@@ -2367,6 +2381,12 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
       handle_snapshot_monitor_command (filename, True /* detailed */);
       return True;
    }
+   case  3: { /* all_snapshots */
+      HChar* filename;
+      filename = VG_(strtok_r) (NULL, " ", &ssaveptr);
+      handle_all_snapshots_monitor_command (filename);
+      return True;
+   }
    default: 
       tl_assert(0);
       return False;