37
37
// - preset column widths for stats are not generic
38
38
// - preset column headers are not generic
39
39
// - "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
44
41
// - "show me the extra allocations since the last snapshot"
45
42
// - "start/stop logging" (eg. quickly skip boring bits)
46
43
// - Add ability to draw multiple graphs, eg. heap-only, stack-only, total.
@@ -1956,8 +1953,11 @@ static void print_monitor_help ( void )
1956
1953
VG_ (gdb_printf ) ("massif monitor commands:\n" );
1957
1954
VG_ (gdb_printf ) (" snapshot [<filename>]\n" );
1958
1955
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" );
1961
1961
VG_ (gdb_printf ) (" default <filename> is massif.vgdb.out\n" );
1962
1962
VG_ (gdb_printf ) ("\n" );
1963
1963
}
@@ -2337,6 +2337,20 @@ static void handle_snapshot_monitor_command (const HChar *filename,
2337
2337
delete_snapshot (& snapshot );
2338
2338
}
2339
2339
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
+
2340
2354
static Bool handle_gdb_monitor_command (ThreadId tid , HChar * req )
2341
2355
{
2342
2356
HChar * wcmd ;
@@ -2346,7 +2360,7 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
2346
2360
VG_ (strcpy ) (s , req );
2347
2361
2348
2362
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 " ,
2350
2364
wcmd , kwd_report_duplicated_matches )) {
2351
2365
case -2 : /* multiple matches */
2352
2366
return True ;
@@ -2367,6 +2381,12 @@ static Bool handle_gdb_monitor_command (ThreadId tid, HChar *req)
2367
2381
handle_snapshot_monitor_command (filename , True /* detailed */ );
2368
2382
return True ;
2369
2383
}
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
+ }
2370
2390
default :
2371
2391
tl_assert (0 );
2372
2392
return False ;
0 commit comments