.gdbinit

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:71f32a2d6a07
1 # .gdbinit file for debugging Mozilla
2
3 # You may need to put an 'add-auto-load-safe-path' command in your
4 # $HOME/.gdbinit file to get GDB to trust this file. If your builds are
5 # generally in $HOME/moz, then you can say:
6 #
7 # add-auto-load-safe-path ~/moz
8
9 # Don't stop for the SIG32/33/etc signals that Flash produces
10 handle SIG32 noprint nostop pass
11 handle SIG33 noprint nostop pass
12 handle SIGPIPE noprint nostop pass
13
14 # Show the concrete types behind nsIFoo
15 set print object on
16
17 # run when using the auto-solib-add trick
18 def prun
19 tbreak main
20 run
21 set auto-solib-add 0
22 cont
23 end
24
25 # run -mail, when using the auto-solib-add trick
26 def pmail
27 tbreak main
28 run -mail
29 set auto-solib-add 0
30 cont
31 end
32
33 # Define a "pu" command to display PRUnichar * strings (100 chars max)
34 # Also allows an optional argument for how many chars to print as long as
35 # it's less than 100.
36 def pu
37 set $uni = $arg0
38 if $argc == 2
39 set $limit = $arg1
40 if $limit > 100
41 set $limit = 100
42 end
43 else
44 set $limit = 100
45 end
46 # scratch array with space for 100 chars plus null terminator. Make
47 # sure to not use ' ' as the char so this copy/pastes well.
48 set $scratch = "____________________________________________________________________________________________________"
49 set $i = 0
50 set $scratch_idx = 0
51 while (*$uni && $i++ < $limit)
52 if (*$uni < 0x80)
53 set $scratch[$scratch_idx++] = *(char*)$uni++
54 else
55 if ($scratch_idx > 0)
56 set $scratch[$scratch_idx] = '\0'
57 print $scratch
58 set $scratch_idx = 0
59 end
60 print /x *(short*)$uni++
61 end
62 end
63 if ($scratch_idx > 0)
64 set $scratch[$scratch_idx] = '\0'
65 print $scratch
66 end
67 end
68
69 # Define a "ps" command to display subclasses of nsAC?String. Note that
70 # this assumes strings as of Gecko 1.9 (well, and probably a few
71 # releases before that as well); going back far enough will get you
72 # to string classes that this function doesn't work for.
73 def ps
74 set $str = $arg0
75 if (sizeof(*$str.mData) == 1 && ($str.mFlags & 1) != 0)
76 print $str.mData
77 else
78 pu $str.mData $str.mLength
79 end
80 end
81
82 # Define a "pa" command to display the string value for an nsIAtom
83 def pa
84 set $atom = $arg0
85 if (sizeof(*((&*$atom)->mString)) == 2)
86 pu (&*$atom)->mString
87 end
88 end
89
90 # define a "pxul" command to display the type of a XUL element from
91 # an nsXULElement* pointer.
92 def pxul
93 set $p = $arg0
94 print $p->mNodeInfo.mRawPtr->mInner.mName->mStaticAtom->mString
95 end
96
97 # define a "prefcnt" command to display the refcount of an XPCOM obj
98 def prefcnt
99 set $p = $arg0
100 print ((nsPurpleBufferEntry*)$p->mRefCnt.mTagged)->mRefCnt
101 end
102
103 # define a "ptag" command to display the tag name of a content node
104 def ptag
105 set $p = $arg0
106 pa $p->mNodeInfo.mRawPtr->mInner.mName
107 end
108
109 ##
110 ## nsTArray
111 ##
112 define ptarray
113 if $argc == 0
114 help ptarray
115 else
116 set $size = $arg0.mHdr->mLength
117 set $capacity = $arg0.mHdr->mCapacity
118 set $size_max = $size - 1
119 set $elts = $arg0.Elements()
120 end
121 if $argc == 1
122 set $i = 0
123 while $i < $size
124 printf "elem[%u]: ", $i
125 p *($elts + $i)
126 set $i++
127 end
128 end
129 if $argc == 2
130 set $idx = $arg1
131 if $idx < 0 || $idx > $size_max
132 printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
133 else
134 printf "elem[%u]: ", $idx
135 p *($elts + $idx)
136 end
137 end
138 if $argc == 3
139 set $start_idx = $arg1
140 set $stop_idx = $arg2
141 if $start_idx > $stop_idx
142 set $tmp_idx = $start_idx
143 set $start_idx = $stop_idx
144 set $stop_idx = $tmp_idx
145 end
146 if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max
147 printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
148 else
149 set $i = $start_idx
150 while $i <= $stop_idx
151 printf "elem[%u]: ", $i
152 p *($elts + $i)
153 set $i++
154 end
155 end
156 end
157 if $argc > 0
158 printf "nsTArray length = %u\n", $size
159 printf "nsTArray capacity = %u\n", $capacity
160 printf "Element "
161 whatis *$elts
162 end
163 end
164
165 document ptarray
166 Prints nsTArray information.
167 Syntax: ptarray
168 Note: idx, idx1 and idx2 must be in acceptable range [0...size()-1].
169 Examples:
170 ptarray a - Prints tarray content, size, capacity and T typedef
171 ptarray a 0 - Prints element[idx] from tarray
172 ptarray a 1 2 - Prints elements in range [idx1..idx2] from tarray
173 end
174
175 def js
176 call DumpJSStack()
177 end
178
179 def ft
180 call nsFrame::DumpFrameTree($arg0)
181 end

mercurial