Skip to content

Commit 4dbb7a3

Browse files
author
philippe
committed
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent 076a270 commit 4dbb7a3

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Release 3.11.0 is under development, not yet released.
1111

1212
* Memcheck:
1313

14+
* Massif:
15+
New monitor command 'all_snapshots <filename>' that dumps all snapshots
16+
taken so far.
17+
1418
* Helgrind:
1519

1620
* Callgrind:
@@ -84,6 +88,7 @@ where XXXXXX is the bug number as listed below.
8488
342038 Unhandled syscalls on aarch64 (mbind/get/set_mempolicy)
8589
342063 wrong format specifier for test mcblocklistsearch in gdbserver_tests
8690
342221 socket connect false positive uninit memory for unknown af family
91+
342353 Allow dumping full massif output while valgrind is still running
8792
342603 Add I2C_SMBUS ioctl support
8893
342635 OS X 10.10 (Yosemite) - missing system calls and fcntl code
8994
342795 Internal glibc __GI_mempcpy call should be intercepted

gdbserver_tests/mssnapshot.stderrB.exp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ general valgrind monitor commands:
1717
massif monitor commands:
1818
snapshot [<filename>]
1919
detailed_snapshot [<filename>]
20-
takes a snapshot (or a detailed snapshot)
21-
and saves it in <filename>
20+
takes a snapshot (or a detailed snapshot)
21+
and saves it in <filename>
22+
default <filename> is massif.vgdb.out
23+
all_snapshots [<filename>]
24+
saves all snapshot(s) taken so far in <filename>
2225
default <filename> is massif.vgdb.out
2326
monitor command request to kill this process
2427
Remote connection closed

gdbserver_tests/mssnapshot.stdinB.gdb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ monitor help
1616
# test non detailed and detailed snapshot
1717
monitor snapshot
1818
monitor detailed_snapshot
19+
monitor all_snapshots
1920
#
2021
#
2122
monitor v.kill

massif/docs/ms-manual.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,12 @@ gdbserver (see <xref linkend="manual-core-adv.gdbserver-commandhandling"/>).
877877
&lt;filename&gt; (default massif.vgdb.out).
878878
</para>
879879
</listitem>
880+
<listitem>
881+
<para><varname>all_snapshots [&lt;filename&gt;]</varname>
882+
requests to take all captured snapshots so far and save them in the given
883+
&lt;filename&gt; (default massif.vgdb.out).
884+
</para>
885+
</listitem>
880886
</itemizedlist>
881887
</sect1>
882888

massif/ms_main.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@
3737
// - preset column widths for stats are not generic
3838
// - preset column headers are not generic
3939
// - "Massif arguments:" line is not generic
40-
// - do snapshots on client requests
41-
// - (Michael Meeks): have an interactive way to request a dump
42-
// (callgrind_control-style)
43-
// - "profile now"
40+
// - do snapshots on some specific client requests
4441
// - "show me the extra allocations since the last snapshot"
4542
// - "start/stop logging" (eg. quickly skip boring bits)
4643
// - Add ability to draw multiple graphs, eg. heap-only, stack-only, total.
@@ -1956,8 +1953,11 @@ static void print_monitor_help ( void )
19561953
VG_(gdb_printf) ("massif monitor commands:\n");
19571954
VG_(gdb_printf) (" snapshot [<filename>]\n");
19581955
VG_(gdb_printf) (" detailed_snapshot [<filename>]\n");
1959-
VG_(gdb_printf) (" takes a snapshot (or a detailed snapshot)\n");
1960-
VG_(gdb_printf) (" and saves it in <filename>\n");
1956+
VG_(gdb_printf) (" takes a snapshot (or a detailed snapshot)\n");
1957+
VG_(gdb_printf) (" and saves it in <filename>\n");
1958+
VG_(gdb_printf) (" default <filename> is massif.vgdb.out\n");
1959+
VG_(gdb_printf) (" all_snapshots [<filename>]\n");
1960+
VG_(gdb_printf) (" saves all snapshot(s) taken so far in <filename>\n");
19611961
VG_(gdb_printf) (" default <filename> is massif.vgdb.out\n");
19621962
VG_(gdb_printf) ("\n");
19631963
}
@@ -2337,6 +2337,20 @@ static void handle_snapshot_monitor_command (const HChar *filename,
23372337
delete_snapshot(&snapshot);
23382338
}
23392339

2340+
static void handle_all_snapshots_monitor_command (const HChar *filename)
2341+
{
2342+
if (!clo_pages_as_heap && !have_started_executing_code) {
2343+
// See comments of variable have_started_executing_code.
2344+
VG_(gdb_printf)
2345+
("error: cannot take snapshot before execution has started\n");
2346+
return;
2347+
}
2348+
2349+
write_snapshots_to_file ((filename == NULL) ?
2350+
"massif.vgdb.out" : filename,
2351+
snapshots, next_snapshot_i);
2352+
}
2353+
23402354
static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
23412355
{
23422356
HChar* wcmd;
@@ -2346,7 +2360,7 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
23462360
VG_(strcpy) (s, req);
23472361

23482362
wcmd = VG_(strtok_r) (s, " ", &ssaveptr);
2349-
switch (VG_(keyword_id) ("help snapshot detailed_snapshot",
2363+
switch (VG_(keyword_id) ("help snapshot detailed_snapshot all_snapshots",
23502364
wcmd, kwd_report_duplicated_matches)) {
23512365
case -2: /* multiple matches */
23522366
return True;
@@ -2367,6 +2381,12 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
23672381
handle_snapshot_monitor_command (filename, True /* detailed */);
23682382
return True;
23692383
}
2384+
case 3: { /* all_snapshots */
2385+
HChar* filename;
2386+
filename = VG_(strtok_r) (NULL, " ", &ssaveptr);
2387+
handle_all_snapshots_monitor_command (filename);
2388+
return True;
2389+
}
23702390
default:
23712391
tl_assert(0);
23722392
return False;

0 commit comments

Comments
 (0)