Whamcloud - gitweb
import libsysio for b_newsysio
[fs/lustre-release.git] / libsysio / misc / gdb-libsysio
1 #    This Cplant(TM) source code is the property of Sandia National
2 #    Laboratories.
3 #
4 #    This Cplant(TM) source code is copyrighted by Sandia National
5 #    Laboratories.
6 #
7 #    The redistribution of this Cplant(TM) source code is subject to the
8 #    terms of the GNU Lesser General Public License
9 #    (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html)
10 #
11 #    Cplant(TM) Copyright 1998-2003 Sandia Corporation. 
12 #    Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
13 #    license for use of this work by or on behalf of the US Government.
14 #    Export of this program may require a license from the United States
15 #    Government.
16
17 # This library is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU Lesser General Public
19 # License as published by the Free Software Foundation; either
20 # version 2.1 of the License, or (at your option) any later version.
21
22 # This library is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 # Lesser General Public License for more details.
26
27 # You should have received a copy of the GNU Lesser General Public
28 # License along with this library; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #
31 # Questions or comments about this library should be sent to:
32 #
33 # Lee Ward
34 # Sandia National Laboratories, New Mexico
35 # P.O. Box 5800
36 # Albuquerque, NM 87185-1110
37 #
38 # lee@sandia.gov
39
40 #
41 # Useful commands for debugging libsysio in gdb
42 #
43
44 define x_dump_pbnode
45         printf "%p: ", $arg0
46         if $arg0->pb_name.name
47                 printf " \"%s\"", \
48                   $arg0->pb_name.name
49         else
50                 printf " <NULL>"
51         end
52         printf " aliases:["
53         set $x_p = $arg0->pb_aliases.lh_first
54         while $x_p
55                 printf "<%p r:%d mnt:%p>", \
56                   $x_p, \
57                   $x_p->p_ref, \
58                   $x_p->p_mount
59                 set $x_p = $x_p->p_links.le_next
60         end
61         printf "]\n"
62 end
63 document x_dump_pbnode
64 Dump path-base node and it's aliases
65
66 Usage: x_dump_pbnode <pbnode>
67 end
68
69 define __x_dump_pnode
70         printf "%spnode %p, mount %p, base: ", $arg0, $arg1, $arg1->p_mount
71         x_dump_pbnode $arg1->p_base
72 end
73
74 define x_dump_pnode
75         __x_dump_pnode "" $arg0
76 end
77 document x_dump_pnode
78 Dump path node information
79
80 Usage: x_dump_pnode <pnode>
81 end
82
83 define x_dump_mount
84         printf "MOUNT %p: root pnode %p, covers %p\n", \
85             $arg0, $arg0->mnt_root, $arg0->mnt_covers
86         set $_x_dump_mount_var_pno = _sysio_pnodes->tqh_first
87         while $_x_dump_mount_var_pno != 0
88 printf "%p, %p\n", $_x_dump_mount_var_pno, $arg0
89                 if $_x_dump_mount_var_pno->p_mount == $arg0
90                         __x_dump_pnode " " $_x_dump_mount_var_pno
91                 end
92                 set $_x_dump_mount_var_pno = \
93                     $_x_dump_mount_var_pno->p_nodes.tqe_next
94         end
95 end
96 document x_dump_mount
97 Dump single mount record information
98
99 Usage: x_dump_mount <mnt>
100 end
101
102 define x_dump_mounts
103         set $__x_dump_mounts_var_mnt = mounts.lh_first
104         while $__x_dump_mounts_var_mnt
105                 x_dump_mount $__x_dump_mounts_var_mnt
106                 set $__x_dump_mounts_var_mnt = \
107                     $__x_dump_mounts_var_mnt->mnt_link.le_next
108         end
109 end
110 document x_dump_mounts
111 Dump the contents of the libsysio mount table
112
113 Usage: x_dump_mounts
114 end
115
116 define x_dump_pnodes
117         set $_x_dump_pnodes_var_pno = _sysio_pnodes.tqh_first
118         while $_x_dump_pnodes_var_pno
119                 x_dump_pnode $_x_dump_pnodes_var_pno
120                 set $_x_dump_pnodes_var_pno = \
121                     $_x_dump_pnodes_var_pno->p_nodes.tqe_next
122         end
123 end
124
125 br _sysio_unmount_all
126 run -r /tmp/lee foo bar
127 x_dump_pnodes