Gecko:Debugging Tools: Difference between revisions

→‎Frame Tree Dump: add link to a page with documentation on layout debugger
No edit summary
(→‎Frame Tree Dump: add link to a page with documentation on layout debugger)
 
(3 intermediate revisions by one other user not shown)
Line 68: Line 68:
== Frame Tree Dump ==
== Frame Tree Dump ==


<bz> for a frame dump, you can use the layout debugger, or... if you're in a debugger and want to examine the tree, you can do
<bz> for a frame dump, you can use the [https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/Layout_Debugger layout debugger], or... if you're in a debugger and want to examine the tree, you can do


  def frametree
  def frametree
Line 79: Line 79:
== Printing nsIAtoms ==
== Printing nsIAtoms ==


<bz> To print an nsIAtom, you see what concrete type it is using "set print object on", then cast it to that type, etc
def pa
  set $atom = $arg0
  if (sizeof(*((&*$atom)->mString)) == 2)
    pu (&*$atom)->mString
  end
end


<bz> if it's an nsStaticAtom:
== Reflow Logs ==


  def satom
See [[http://www.mozilla.org/newlayout/doc/frame_reflow_debug.html Debugging Frame Reflow]]
    p *((class nsStaticAtomWrapper*)$arg0)->mStaticAtom
  end


<bz> to be used as: ''satom content->Tag()'' or ''satom frame->GetType()''
== Printing strings ==


<bz> for nsGkAtoms it'll work great
# Define a "ps" command to display subclasses of nsAC?String.  Note that
# this assumes strings as of Gecko 1.9 (well, and probably a few
# releases before that as well); going back far enough will get you
# to string classes that this function doesn't work for.
def ps
  set $str = $arg0
  if (sizeof(*$str.mData) == 1 && ($str.mFlags & 1) != 0)
    print $str.mData
  else
    pu $str.mData $str.mLength
  end
end


== Reflow Logs ==
# Define a "pu" command to display PRUnichar * strings (100 chars max)
# Also allows an optional argument for how many chars to print as long as
# it's less than 100.
def pu
  set $uni = $arg0
  if $argc == 2
    set $limit = $arg1
    if $limit > 100
      set $limit = 100
    end
  else
    set $limit = 100
  end
  # scratch array with space for 100 chars plus null terminator.  Make
  # sure to not use ' ' as the char so this copy/pastes well.
  set $scratch = "____________________________________________________________________________________________________"
  set $i = 0
  set $scratch_idx = 0
  while (*$uni && $i++ < $limit)
    if (*$uni < 0x80)
      set $scratch[$scratch_idx++] = *(char*)$uni++
    else
      if ($scratch_idx > 0)
set $scratch[$scratch_idx] = '\0'
print $scratch
set $scratch_idx = 0
      end
      print /x *(short*)$uni++
    end
  end
  if ($scratch_idx > 0)
    set $scratch[$scratch_idx] = '\0'
    print $scratch
  end
end
 
== Dumping the JS Stack ==


See [[http://www.mozilla.org/newlayout/doc/frame_reflow_debug.html Debugging Frame Reflow]]
def js
  call DumpJSStack()
end
Confirmed users
489

edits