-
Notifications
You must be signed in to change notification settings - Fork 0
/
traverse-arenas.gdb
64 lines (60 loc) · 1.55 KB
/
traverse-arenas.gdb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
define -traverse-bin
set $first_chunk = $arg0
set $cur_chunk = $first_chunk
if ($cur_chunk == 0x0)
return
end
while ($cur_chunk->fd != $first_chunk)
printf "%p.", $cur_chunk
# print *$cur_chunk
set $cur_chunk = $cur_chunk->fd
end
printf "%p.", $cur_chunk
# print *$cur_chunk
end
define -traverse-fast-bin
set $first_chunk = $arg0
set $cur_chunk = $first_chunk
while ($cur_chunk != 0x0)
printf "%p.", $cur_chunk
# print *$cur_chunk
set $cur_chunk = $cur_chunk->fd
end
end
define -traverse-arena
set $arena_ptr = $arg0
# traverse fastbins
set $fast_index = 0
# There are 10 fast bins in total
while($fast_index < 10)
printf "Fastbin %d:", $fast_index
set $fb = $arena_ptr.fastbinsY[$fast_index]
if ($fb != 0x0)
-traverse-fast-bin $fb
end
printf "\n"
set $fast_index = $fast_index + 1
end
# traverse bins
set $bin_index = 0
# There are 126 bins in total
while ($bin_index < 126)
printf "Bin %d:", $bin_index
set $bin = $arena_ptr.bins[$bin_index]
if ($bin != 0x0)
-traverse-bin $bin
end
printf "\n"
set $bin_index = $bin_index + 1
end
end
define -traverse-all-arenas
set $cur_arena = &main_arena
print "Main arena"
-traverse-arena *$cur_arena
while($cur_arena->next != &main_arena)
set $cur_arena = $cur_arena->next
print "Additional Arena"
-traverse-arena *$cur_arena
end
end