.gdbinit

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial