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