.gdbinit 5.1 KB

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