glusterfs
82 строки · 2.2 Кб
1
2#
3# gdb_macros is a gdb script file which can assist
4# developer in debugging. This script provides
5# following functions for debugging gluster processes
6# effectively:
7#
8# pdict : This function will iterate through all the
9# dictionary (dict_t) members and print the
10# key-value pair.
11#
12# plist : This function will print address of each member
13# of gluster list (list_head).
14#
15# gdb script should be loaded in gdb before using these
16# functions. gdb script can be loaded on-demand or on gdb
17# start-up. Use the following command on gdb prompt for
18# loading it on-demand.
19# source <script filename>
20# e.g.
21# (gdb) source /mnt/gdb_macros
22#
23# To automatically load gdb script on startup use .gdbinit
24# file. This file is automatically loaded by gdb on start.
25# Edit (or create) ~/.gdbinit file and add the following
26# entry:
27# source /mnt/gdb_macros
28#
29
30
31
32# This is an internal helper function
33define _print_dict_data
34set $data = ($arg0)
35set $len = $data->len - 1
36set $i = 0
37set $ishex = 0
38while ($i < $len)
39set $ch = $data->data [$i]
40
41# Print only alpha-numeric values as char
42# and remaining as hex value. This is done
43# in this way because using %s screws up
44# the display if the string has non-displayable
45# characters
46if ($ishex == 0) && ($ch > 31) && ($ch < 127)
47printf "%c", $ch
48else
49printf "%x", ($ch & 0xFF)
50set $ishex = 1
51end
52set $i = $i + 1
53end
54end
55
56
57define pdict
58set $cnt = 1
59set $temp = *($arg0->members)
60while ($temp)
61printf "[%d](%s::",$cnt, $temp->key
62_print_dict_data ($temp)->value
63printf ")\n"
64set $temp = $temp->next
65set $cnt = $cnt + 1
66end
67printf "Done\n"
68end
69
70
71define plist
72set $node = &($arg0)
73set $head = $node
74
75printf "[0x%lx]", $node
76set $node = $node->next
77
78while ($node != $head)
79printf "--> [0x%lx]", $node
80set $node = $node->next
81end
82printf "\n"
83end
84
85