michael@0: # .gdbinit file for debugging Mozilla michael@0: michael@0: # You may need to put an 'add-auto-load-safe-path' command in your michael@0: # $HOME/.gdbinit file to get GDB to trust this file. If your builds are michael@0: # generally in $HOME/moz, then you can say: michael@0: # michael@0: # add-auto-load-safe-path ~/moz michael@0: michael@0: # Don't stop for the SIG32/33/etc signals that Flash produces michael@0: handle SIG32 noprint nostop pass michael@0: handle SIG33 noprint nostop pass michael@0: handle SIGPIPE noprint nostop pass michael@0: michael@0: # Show the concrete types behind nsIFoo michael@0: set print object on michael@0: michael@0: # run when using the auto-solib-add trick michael@0: def prun michael@0: tbreak main michael@0: run michael@0: set auto-solib-add 0 michael@0: cont michael@0: end michael@0: michael@0: # run -mail, when using the auto-solib-add trick michael@0: def pmail michael@0: tbreak main michael@0: run -mail michael@0: set auto-solib-add 0 michael@0: cont michael@0: end michael@0: michael@0: # Define a "pu" command to display PRUnichar * strings (100 chars max) michael@0: # Also allows an optional argument for how many chars to print as long as michael@0: # it's less than 100. michael@0: def pu michael@0: set $uni = $arg0 michael@0: if $argc == 2 michael@0: set $limit = $arg1 michael@0: if $limit > 100 michael@0: set $limit = 100 michael@0: end michael@0: else michael@0: set $limit = 100 michael@0: end michael@0: # scratch array with space for 100 chars plus null terminator. Make michael@0: # sure to not use ' ' as the char so this copy/pastes well. michael@0: set $scratch = "____________________________________________________________________________________________________" michael@0: set $i = 0 michael@0: set $scratch_idx = 0 michael@0: while (*$uni && $i++ < $limit) michael@0: if (*$uni < 0x80) michael@0: set $scratch[$scratch_idx++] = *(char*)$uni++ michael@0: else michael@0: if ($scratch_idx > 0) michael@0: set $scratch[$scratch_idx] = '\0' michael@0: print $scratch michael@0: set $scratch_idx = 0 michael@0: end michael@0: print /x *(short*)$uni++ michael@0: end michael@0: end michael@0: if ($scratch_idx > 0) michael@0: set $scratch[$scratch_idx] = '\0' michael@0: print $scratch michael@0: end michael@0: end michael@0: michael@0: # Define a "ps" command to display subclasses of nsAC?String. Note that michael@0: # this assumes strings as of Gecko 1.9 (well, and probably a few michael@0: # releases before that as well); going back far enough will get you michael@0: # to string classes that this function doesn't work for. michael@0: def ps michael@0: set $str = $arg0 michael@0: if (sizeof(*$str.mData) == 1 && ($str.mFlags & 1) != 0) michael@0: print $str.mData michael@0: else michael@0: pu $str.mData $str.mLength michael@0: end michael@0: end michael@0: michael@0: # Define a "pa" command to display the string value for an nsIAtom michael@0: def pa michael@0: set $atom = $arg0 michael@0: if (sizeof(*((&*$atom)->mString)) == 2) michael@0: pu (&*$atom)->mString michael@0: end michael@0: end michael@0: michael@0: # define a "pxul" command to display the type of a XUL element from michael@0: # an nsXULElement* pointer. michael@0: def pxul michael@0: set $p = $arg0 michael@0: print $p->mNodeInfo.mRawPtr->mInner.mName->mStaticAtom->mString michael@0: end michael@0: michael@0: # define a "prefcnt" command to display the refcount of an XPCOM obj michael@0: def prefcnt michael@0: set $p = $arg0 michael@0: print ((nsPurpleBufferEntry*)$p->mRefCnt.mTagged)->mRefCnt michael@0: end michael@0: michael@0: # define a "ptag" command to display the tag name of a content node michael@0: def ptag michael@0: set $p = $arg0 michael@0: pa $p->mNodeInfo.mRawPtr->mInner.mName michael@0: end michael@0: michael@0: ## michael@0: ## nsTArray michael@0: ## michael@0: define ptarray michael@0: if $argc == 0 michael@0: help ptarray michael@0: else michael@0: set $size = $arg0.mHdr->mLength michael@0: set $capacity = $arg0.mHdr->mCapacity michael@0: set $size_max = $size - 1 michael@0: set $elts = $arg0.Elements() michael@0: end michael@0: if $argc == 1 michael@0: set $i = 0 michael@0: while $i < $size michael@0: printf "elem[%u]: ", $i michael@0: p *($elts + $i) michael@0: set $i++ michael@0: end michael@0: end michael@0: if $argc == 2 michael@0: set $idx = $arg1 michael@0: if $idx < 0 || $idx > $size_max michael@0: printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max michael@0: else michael@0: printf "elem[%u]: ", $idx michael@0: p *($elts + $idx) michael@0: end michael@0: end michael@0: if $argc == 3 michael@0: set $start_idx = $arg1 michael@0: set $stop_idx = $arg2 michael@0: if $start_idx > $stop_idx michael@0: set $tmp_idx = $start_idx michael@0: set $start_idx = $stop_idx michael@0: set $stop_idx = $tmp_idx michael@0: end michael@0: if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max michael@0: printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max michael@0: else michael@0: set $i = $start_idx michael@0: while $i <= $stop_idx michael@0: printf "elem[%u]: ", $i michael@0: p *($elts + $i) michael@0: set $i++ michael@0: end michael@0: end michael@0: end michael@0: if $argc > 0 michael@0: printf "nsTArray length = %u\n", $size michael@0: printf "nsTArray capacity = %u\n", $capacity michael@0: printf "Element " michael@0: whatis *$elts michael@0: end michael@0: end michael@0: michael@0: document ptarray michael@0: Prints nsTArray information. michael@0: Syntax: ptarray michael@0: Note: idx, idx1 and idx2 must be in acceptable range [0...size()-1]. michael@0: Examples: michael@0: ptarray a - Prints tarray content, size, capacity and T typedef michael@0: ptarray a 0 - Prints element[idx] from tarray michael@0: ptarray a 1 2 - Prints elements in range [idx1..idx2] from tarray michael@0: end michael@0: michael@0: def js michael@0: call DumpJSStack() michael@0: end michael@0: michael@0: def ft michael@0: call nsFrame::DumpFrameTree($arg0) michael@0: end