README.txt 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. lldb debugging functionality for Gecko
  2. ======================================
  3. This directory contains a module, lldbutils, which is imported by the
  4. in-tree .lldbinit file. The lldbutil modules define some lldb commands
  5. that are handy for debugging Gecko.
  6. If you want to add a new command or Python-implemented type summary, either add
  7. it to one of the existing broad area Python files (such as lldbutils/layout.py
  8. for layout-related commands) or create a new file if none of the existing files
  9. is appropriate. If you add a new file, make sure you add it to __all__ in
  10. lldbutils/__init__.py.
  11. Supported commands
  12. ------------------
  13. Most commands below that can take a pointer to an object also support being
  14. called with a smart pointer like nsRefPtr or nsCOMPtr.
  15. * frametree EXPR, ft EXPR
  16. frametreelimited EXPR, ftl EXPR
  17. Shows information about a frame tree. EXPR is an expression that
  18. is evaluated, and must be an nsIFrame*. frametree displays the
  19. entire frame tree that contains the given frame. frametreelimited
  20. displays a subtree of the frame tree rooted at the given frame.
  21. (lldb) p this
  22. (nsBlockFrame *) $4 = 0x000000011687fcb8
  23. (lldb) ftl this
  24. Block(div)(-1)@0x11687fcb8 {0,0,7380,690} [state=0002100000d04601] [content=0x11688c0c0] [sc=0x11687f990:-moz-scrolled-content]<
  25. line 0x116899130: count=1 state=inline,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x100] {60,0,0,690} vis-overflow=60,510,0,0 scr-overflow=60,510,0,0 <
  26. Text(0)""@0x1168990c0 {60,510,0,0} [state=0001000020404000] [content=0x11687ca10] [sc=0x11687fd88:-moz-non-element,parent=0x11687eb00] [run=0x115115e80][0,0,T]
  27. >
  28. >
  29. (lldb) ft this
  30. Viewport(-1)@0x116017430 [view=0x115efe190] {0,0,60,60} [state=000b063000002623] [sc=0x1160170f8:-moz-viewport]<
  31. HTMLScroll(html)(-1)@0x1160180d0 {0,0,0,0} [state=000b020000000403] [content=0x115e4d640] [sc=0x116017768:-moz-viewport-scroll]<
  32. ...
  33. Canvas(html)(-1)@0x116017e08 {0,0,60,60} vis-overflow=0,0,8340,2196 scr-overflow=0,0,8220,2196 [state=000b002000000601] [content=0x115e4d640] [sc=0x11687e0f8:-moz-scrolled-canvas]<
  34. Block(html)(-1)@0x11687e578 {0,0,60,2196} vis-overflow=0,0,8340,2196 scr-overflow=0,0,8220,2196 [state=000b100000d00601] [content=0x115e4d640] [sc=0x11687e4b8,parent=0x0]<
  35. line 0x11687ec48: count=1 state=block,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x48] bm=480 {480,480,0,1236} vis-overflow=360,426,7980,1410 scr-overflow=480,480,7740,1236 <
  36. Block(body)(1)@0x11687ebb0 {480,480,0,1236} vis-overflow=-120,-54,7980,1410 scr-overflow=0,0,7740,1236 [state=000b120000100601] [content=0x115ed8980] [sc=0x11687e990]<
  37. line 0x116899170: count=1 state=inline,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x0] {0,0,7740,1236} vis-overflow=-120,-54,7980,1410 scr-overflow=0,0,7740,1236 <
  38. nsTextControlFrame@0x11687f068 {0,66,7740,1170} vis-overflow=-120,-120,7980,1410 scr-overflow=0,0,7740,1170 [state=0002000000004621] [content=0x115ca2c50] [sc=0x11687ea40]<
  39. HTMLScroll(div)(-1)@0x11687f6b0 {180,240,7380,690} [state=0002000000084409] [content=0x11688c0c0] [sc=0x11687eb00]<
  40. Block(div)(-1)@0x11687fcb8 {0,0,7380,690} [state=0002100000d04601] [content=0x11688c0c0] [sc=0x11687f990:-moz-scrolled-content]<
  41. line 0x116899130: count=1 state=inline,clean,prevmarginclean,not impacted,not wrapped,before:nobr,after:nobr[0x100] {60,0,0,690} vis-overflow=60,510,0,0 scr-overflow=60,510,0,0 <
  42. Text(0)""@0x1168990c0 {60,510,0,0} [state=0001000020404000] [content=0x11687ca10] [sc=0x11687fd88:-moz-non-element,parent=0x11687eb00] [run=0x115115e80][0,0,T]
  43. ...
  44. * js
  45. Dumps the current JS stack.
  46. (lldb) js
  47. 0 anonymous(aForce = false) ["chrome://browser/content/browser.js":13414]
  48. this = [object Object]
  49. 1 updateAppearance() ["chrome://browser/content/browser.js":13326]
  50. this = [object Object]
  51. 2 handleEvent(aEvent = [object Event]) ["chrome://browser/content/tabbrowser.xml":3811]
  52. this = [object XULElement]
  53. * prefcnt EXPR
  54. Shows the refcount of a given object. EXPR is an expression that is
  55. evaluated, and can be either a pointer to or an actual refcounted
  56. object. The object can be a standard nsISupports-like refcounted
  57. object, a cycle-collected object or a mozilla::RefCounted<T> object.
  58. (lldb) p this
  59. (nsHTMLDocument *) $1 = 0x0000000116e9d800
  60. (lldb) prefcnt this
  61. 20
  62. (lldb) p mDocumentURI
  63. (nsCOMPtr<nsIURI>) $3 = {
  64. mRawPtr = 0x0000000117163e50
  65. }
  66. (lldb) prefcnt mDocumentURI
  67. 11
  68. * pstate EXPR
  69. Shows the frame state bits (using their symbolic names) of a given frame.
  70. EXPR is an expression that is evaluated, and must be an nsIFrame*.
  71. (lldb) p this
  72. (nsTextFrame *) $1 = 0x000000011f470b10
  73. (lldb) p/x mState
  74. (nsFrameState) $2 = 0x0000004080604000
  75. (lldb) pstate this
  76. TEXT_HAS_NONCOLLAPSED_CHARACTERS | TEXT_END_OF_LINE | TEXT_START_OF_LINE | NS_FRAME_PAINTED_THEBES | NS_FRAME_INDEPENDENT_SELECTION
  77. * ptag EXPR
  78. Shows the DOM tag name of a node. EXPR is an expression that is
  79. evaluated, and can be either an nsINode pointer or a concrete DOM
  80. object.
  81. (lldb) p this
  82. (nsHTMLDocument *) $0 = 0x0000000116e9d800
  83. (lldb) ptag this
  84. (PermanentAtomImpl *) $1 = 0x0000000110133ac0 u"#document"
  85. (lldb) p this->GetRootElement()
  86. (mozilla::dom::HTMLSharedElement *) $2 = 0x0000000118429780
  87. (lldb) ptag $2
  88. (PermanentAtomImpl *) $3 = 0x0000000110123b80 u"html"
  89. Supported type summaries and synthetic children
  90. -----------------------------------------------
  91. In lldb terminology, type summaries are rules for how to display a value
  92. when using the "expression" command (or its familiar-to-gdb-users "p" alias),
  93. and synthetic children are fake member variables or array elements also
  94. added by custom rules.
  95. For objects that do have synthetic children defined for them, like nsTArray,
  96. the "expr -R -- EXPR" command can be used to show its actual member variables.
  97. * nsAString, nsACString,
  98. nsFixedString, nsFixedCString,
  99. nsAutoString, nsAutoCString
  100. Strings have a type summary that shows the actual string.
  101. (lldb) frame info
  102. frame #0: 0x000000010400cfea XUL`nsCSSParser::ParseProperty(this=0x00007fff5fbf5248, aPropID=eCSSProperty_margin_top, aPropValue=0x00007fff5fbf53f8, aSheetURI=0x0000000115ae8c00, aBaseURI=0x0000000115ae8c00, aSheetPrincipal=0x000000010ff9e040, aDeclaration=0x00000001826fd580, aChanged=0x00007fff5fbf5247, aIsImportant=false, aIsSVGMode=false) + 74 at nsCSSParser.cpp:12851
  103. (lldb) p aPropValue
  104. (const nsAString_internal) $16 = u"-25px"
  105. (lldb) p this
  106. (nsHTMLDocument *) $18 = 0x0000000115b56000
  107. (lldb) p mContentType
  108. (nsCString) $19 = {
  109. nsACString_internal = "text/html"
  110. }
  111. * nscolor
  112. nscolors (32-bit RGBA colors) have a type summary that shows the color as
  113. one of the CSS 2.1 color keywords, a six digit hex color, an rgba() color,
  114. or the "transparent" keyword.
  115. (lldb) p this
  116. (nsTextFrame *) $0 = 0x00000001168245e0
  117. (lldb) p *this->StyleColor()
  118. (const nsStyleColor) $1 = {
  119. mColor = lime
  120. }
  121. (lldb) expr -R -- *this->StyleColor()
  122. (const nsStyleColor) $2 = {
  123. mColor = 4278255360
  124. }
  125. * nsIAtom
  126. Atoms have a type summary that shows the string value inside the atom.
  127. (lldb) frame info
  128. frame #0: 0x00000001028b8c49 XUL`mozilla::dom::Element::GetBoolAttr(this=0x0000000115ca1c50, aAttr=0x000000011012a640) const + 25 at Element.h:907
  129. (lldb) p aAttr
  130. (PermanentAtomImpl *) $1 = 0x000000011012a640 u"readonly"
  131. * nsTArray and friends
  132. nsTArrays and their auto and fallible varieties have synthetic children
  133. for their elements. This means when displaying them with "expr" (or "p"),
  134. they will be shown like regular arrays, rather than showing the mHdr and
  135. other fields.
  136. (lldb) frame info
  137. frame #0: 0x00000001043eb8a8 XUL`SVGTextFrame::DoGlyphPositioning(this=0x000000012f3f8778) + 248 at SVGTextFrame.cpp:4940
  138. (lldb) p charPositions
  139. (nsTArray<nsPoint>) $5 = {
  140. [0] = {
  141. mozilla::gfx::BasePoint<int, nsPoint> = {
  142. x = 0
  143. y = 816
  144. }
  145. }
  146. [1] = {
  147. mozilla::gfx::BasePoint<int, nsPoint> = {
  148. x = 426
  149. y = 816
  150. }
  151. }
  152. [2] = {
  153. mozilla::gfx::BasePoint<int, nsPoint> = {
  154. x = 906
  155. y = 816
  156. }
  157. }
  158. }
  159. (lldb) expr -R -- charPositions
  160. (nsTArray<nsPoint>) $4 = {
  161. nsTArray_Impl<nsPoint, nsTArrayInfallibleAllocator> = {
  162. nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyWithMemutils> = {
  163. mHdr = 0x000000012f3f1b80
  164. }
  165. }
  166. }
  167. * nsTextNode, nsTextFragment
  168. Text nodes have a type summary that shows the nsTextFragment in the
  169. nsTextNode, which itself has a type summary that shows the text
  170. content.
  171. (lldb) p this
  172. (nsTextFrame *) $14 = 0x000000011811bb10
  173. (lldb) p mContent
  174. (nsTextNode *) $15 = 0x0000000118130110 "Search or enter address"