Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / build / .gdbinit
blob870c0a81da7685a65ff59d5c3a6450d5b32b4be4
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 # .gdbinit file for debugging Mozilla
7 # You may need to put an 'add-auto-load-safe-path' command in your
8 # $HOME/.gdbinit file to get GDB to trust this file. If your builds are
9 # generally in $HOME/moz, then you can say:
11 #  add-auto-load-safe-path ~/moz
13 # Don't stop for the SIG32/33/etc signals that Flash produces
14 handle SIG32 noprint nostop pass
15 handle SIG33 noprint nostop pass
16 handle SIGPIPE noprint nostop pass
18 # Don't stop for certain other signals where it's not useful,
19 # such as the SIG64 signals triggered by the Linux
20 # sandboxing code on older kernels.
21 handle SIG38 noprint nostop pass
22 handle SIG64 noprint nostop pass
23 handle SIGSYS noprint nostop pass
25 # Show the concrete types behind nsIFoo
26 set print object on
28 # run when using the auto-solib-add trick
29 define prun
30         tbreak main
31         run
32         set auto-solib-add 0
33         cont
34 end
36 # run -mail, when using the auto-solib-add trick
37 define pmail
38         tbreak main
39         run -mail
40         set auto-solib-add 0
41         cont
42 end
44 # Define a "pu" command to display PRUnichar * strings (100 chars max)
45 # Also allows an optional argument for how many chars to print as long as
46 # it's less than 100.
47 define pu
48   set $uni = $arg0
49   if $argc == 2
50     set $limit = $arg1
51     if $limit > 100
52       set $limit = 100
53     end
54   else
55     set $limit = 100
56   end
57   # scratch array with space for 100 chars plus null terminator.  Make
58   # sure to not use ' ' as the char so this copy/pastes well.
59   set $scratch = "____________________________________________________________________________________________________"
60   set $i = 0
61   set $scratch_idx = 0
62   while (*$uni && $i++ < $limit)
63     if (*$uni < 0x80)
64       set $scratch[$scratch_idx++] = *(char*)$uni++
65     else
66       if ($scratch_idx > 0)
67         set $scratch[$scratch_idx] = '\0'
68         print $scratch
69         set $scratch_idx = 0
70       end
71       print /x *(short*)$uni++
72     end
73   end
74   if ($scratch_idx > 0)
75     set $scratch[$scratch_idx] = '\0'
76     print $scratch
77   end
78 end
80 # Define a "ps" command to display subclasses of nsAC?String.  Note that
81 # this assumes strings as of Gecko 1.9 (well, and probably a few
82 # releases before that as well); going back far enough will get you
83 # to string classes that this function doesn't work for.
84 define ps
85   set $str = $arg0
86   if (sizeof(*$str.mData) == 1 && ($str.mFlags & 1) != 0)
87     print $str.mData
88   else
89     pu $str.mData $str.mLength
90   end
91 end
93 # Define a "pa" command to display the string value for an nsAtom
94 define pa
95   set $atom = $arg0
96   if (sizeof(*((&*$atom)->mString)) == 2)
97     pu (&*$atom)->mString
98   end
99 end
101 # define a "pxul" command to display the type of a XUL element from
102 # an nsXULElement* pointer.
103 define pxul
104   set $p = $arg0
105   print $p->mNodeInfo.mRawPtr->mInner.mName->mStaticAtom->mString
108 # define a "prefcnt" command to display the refcount of an XPCOM obj
109 define prefcnt
110   set $p = $arg0
111   print ((nsPurpleBufferEntry*)$p->mRefCnt.mTagged)->mRefCnt
114 # define a "ptag" command to display the tag name of a content node
115 define ptag
116   set $p = $arg0
117   pa $p->mNodeInfo.mRawPtr->mInner.mName
121 ## nsTArray
123 define ptarray
124         if $argc == 0
125                 help ptarray
126         else
127                 set $size = $arg0.mHdr->mLength
128                 set $capacity = $arg0.mHdr->mCapacity
129                 set $size_max = $size - 1
130                 set $elts = $arg0.Elements()
131         end
132         if $argc == 1
133                 set $i = 0
134                 while $i < $size
135                         printf "elem[%u]: ", $i
136                         p *($elts + $i)
137                         set $i++
138                 end
139         end
140         if $argc == 2
141                 set $idx = $arg1
142                 if $idx < 0 || $idx > $size_max
143                         printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
144                 else
145                         printf "elem[%u]: ", $idx
146                         p *($elts + $idx)
147                 end
148         end
149         if $argc == 3
150           set $start_idx = $arg1
151           set $stop_idx = $arg2
152           if $start_idx > $stop_idx
153             set $tmp_idx = $start_idx
154             set $start_idx = $stop_idx
155             set $stop_idx = $tmp_idx
156           end
157           if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max
158             printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
159           else
160             set $i = $start_idx
161                 while $i <= $stop_idx
162                         printf "elem[%u]: ", $i
163                         p *($elts + $i)
164                         set $i++
165                 end
166           end
167         end
168         if $argc > 0
169                 printf "nsTArray length = %u\n", $size
170                 printf "nsTArray capacity = %u\n", $capacity
171                 printf "Element "
172                 whatis *$elts
173         end
176 document ptarray
177         Prints nsTArray information.
178         Syntax: ptarray
179         Note: idx, idx1 and idx2 must be in acceptable range [0...size()-1].
180         Examples:
181         ptarray a - Prints tarray content, size, capacity and T typedef
182         ptarray a 0 - Prints element[idx] from tarray
183         ptarray a 1 2 - Prints elements in range [idx1..idx2] from tarray
186 define js
187   call DumpJSStack()
190 define ct
191   call $arg0->Dump()
194 define ft
195   call $arg0->DumpFrameTree()
198 define ftp
199   call $arg0->DumpFrameTreeInCSSPixels()
202 define ftl
203   call $arg0->DumpFrameTreeLimited()
206 define ftlp
207   call $arg0->DumpFrameTreeLimitedInCSSPixels()