1 # connect gdb to Valgrind gdbserver: 2 target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-mcleak 3 echo vgdb launched process attached\n 4 monitor v.set vgdb-error 999999 5 # 6 # 7 # insert break: 8 break breakme 9 # 10 # continue till each break and execute via gdb the leak search as done in the C code. 11 continue 12 # 13 # 14 # fprintf(stderr, "expecting details 10 bytes reachable\n"); fflush(stderr); breakme(); 15 up 16 monitor leak_check full reachable any 17 continue 18 # VALGRIND_DO_LEAK_CHECK; 19 # 20 # fprintf(stderr, "expecting to have NO details\n"); fflush(stderr); 21 up 22 monitor leak_check full reachable increased 23 continue 24 # VALGRIND_DO_ADDED_LEAK_CHECK; 25 # 26 # b10--; // lose b10 27 # b21 = malloc (21); 28 # fprintf(stderr, "expecting details +10 bytes lost, +21 bytes reachable\n"); fflush(stderr); breakme(); 29 up 30 monitor leak_check full reachable increased 31 continue 32 # VALGRIND_DO_ADDED_LEAK_CHECK; 33 # 34 # for (i = 0; i < 2; i ++) 35 # b32_33[i] = malloc (32+i); 36 # fprintf(stderr, "expecting details +65 bytes reachable\n"); fflush(stderr); breakme(); 37 up 38 monitor leak_check full reachable increased 39 continue 40 # VALGRIND_DO_ADDED_LEAK_CHECK; 41 # 42 # fprintf(stderr, "expecting to have NO details\n"); fflush(stderr); breakme(); 43 up 44 monitor leak_check full reachable increased 45 continue 46 # VALGRIND_DO_ADDED_LEAK_CHECK; 47 # 48 # b10++; 49 # fprintf(stderr, "expecting details +10 bytes reachable\n"); fflush(stderr); breakme(); 50 up 51 monitor leak_check full reachable increased 52 continue 53 # VALGRIND_DO_ADDED_LEAK_CHECK; 54 # 55 # b10--; 56 # fprintf(stderr, "expecting details -10 bytes reachable, +10 bytes lost\n"); fflush(stderr); breakme(); 57 up 58 monitor leak_check full reachable changed 59 continue 60 # VALGRIND_DO_CHANGED_LEAK_CHECK; 61 # 62 # b10++; 63 # fprintf(stderr, "expecting details -10 bytes lost, +10 bytes reachable\n"); fflush(stderr); breakme(); 64 up 65 monitor leak_check full reachable changed 66 continue 67 # VALGRIND_DO_CHANGED_LEAK_CHECK; 68 # 69 # b32_33[0]--; 70 # fprintf(stderr, "expecting details 32 (+32) bytes lost, 33 (-32) bytes reachable\n"); fflush(stderr); breakme(); 71 up 72 monitor leak_check full reachable changed 73 # output all leak records: 74 monitor leak_check full reachable any unlimited 75 # output the 2 biggest leak records: 76 monitor leak_check full reachable any limited 2 77 #output the biggest leak record: 78 monitor leak_check full reachable any limited 1 79 # output the biggest definitely leaked record: 80 monitor leak_check full definiteleak any limited 1 81 continue 82 # VALGRIND_DO_CHANGED_LEAK_CHECK; 83 # 84 quit 85