From: Philippe Waroquiers Date: Sat, 7 Mar 2015 19:20:12 +0000 (+0000) Subject: 342353 - Allow dumping full massif output while valgrind is still running X-Git-Tag: svn/VALGRIND_3_11_0~600 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f85702628aedcb98891aabca8a02c42e2c052100;p=thirdparty%2Fvalgrind.git 342353 - Allow dumping full massif output while valgrind is still running Patch from Andre Goddard Rosa git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14992 --- diff --git a/NEWS b/NEWS index efb85eac1a..66689ff725 100644 --- 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 ' 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 diff --git a/gdbserver_tests/mssnapshot.stderrB.exp b/gdbserver_tests/mssnapshot.stderrB.exp index 62c47b045c..93ba9c9ce7 100644 --- a/gdbserver_tests/mssnapshot.stderrB.exp +++ b/gdbserver_tests/mssnapshot.stderrB.exp @@ -17,8 +17,11 @@ general valgrind monitor commands: massif monitor commands: snapshot [] detailed_snapshot [] - takes a snapshot (or a detailed snapshot) - and saves it in + takes a snapshot (or a detailed snapshot) + and saves it in + default is massif.vgdb.out + all_snapshots [] + saves all snapshot(s) taken so far in default is massif.vgdb.out monitor command request to kill this process Remote connection closed diff --git a/gdbserver_tests/mssnapshot.stdinB.gdb b/gdbserver_tests/mssnapshot.stdinB.gdb index 5f4257a31c..69b10e1571 100644 --- a/gdbserver_tests/mssnapshot.stdinB.gdb +++ b/gdbserver_tests/mssnapshot.stdinB.gdb @@ -16,6 +16,7 @@ monitor help # test non detailed and detailed snapshot monitor snapshot monitor detailed_snapshot +monitor all_snapshots # # monitor v.kill diff --git a/massif/docs/ms-manual.xml b/massif/docs/ms-manual.xml index 484d3eaa76..4c555a9702 100644 --- a/massif/docs/ms-manual.xml +++ b/massif/docs/ms-manual.xml @@ -877,6 +877,12 @@ gdbserver (see ). <filename> (default massif.vgdb.out). + + all_snapshots [<filename>] + requests to take all captured snapshots so far and save them in the given + <filename> (default massif.vgdb.out). + + diff --git a/massif/ms_main.c b/massif/ms_main.c index 24fb18f646..5053c4f0ae 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -37,10 +37,7 @@ // - 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 []\n"); VG_(gdb_printf) (" detailed_snapshot []\n"); - VG_(gdb_printf) (" takes a snapshot (or a detailed snapshot)\n"); - VG_(gdb_printf) (" and saves it in \n"); + VG_(gdb_printf) (" takes a snapshot (or a detailed snapshot)\n"); + VG_(gdb_printf) (" and saves it in \n"); + VG_(gdb_printf) (" default is massif.vgdb.out\n"); + VG_(gdb_printf) (" all_snapshots []\n"); + VG_(gdb_printf) (" saves all snapshot(s) taken so far in \n"); VG_(gdb_printf) (" default 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;