.gdbinit

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.gdbinit	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,181 @@
     1.4 +# .gdbinit file for debugging Mozilla
     1.5 +
     1.6 +# You may need to put an 'add-auto-load-safe-path' command in your
     1.7 +# $HOME/.gdbinit file to get GDB to trust this file. If your builds are
     1.8 +# generally in $HOME/moz, then you can say:
     1.9 +#
    1.10 +#  add-auto-load-safe-path ~/moz
    1.11 +
    1.12 +# Don't stop for the SIG32/33/etc signals that Flash produces
    1.13 +handle SIG32 noprint nostop pass
    1.14 +handle SIG33 noprint nostop pass
    1.15 +handle SIGPIPE noprint nostop pass
    1.16 +
    1.17 +# Show the concrete types behind nsIFoo
    1.18 +set print object on
    1.19 +
    1.20 +# run when using the auto-solib-add trick
    1.21 +def prun
    1.22 +        tbreak main
    1.23 +        run
    1.24 +	set auto-solib-add 0
    1.25 +        cont
    1.26 +end
    1.27 +
    1.28 +# run -mail, when using the auto-solib-add trick
    1.29 +def pmail
    1.30 +        tbreak main
    1.31 +        run -mail
    1.32 +	set auto-solib-add 0
    1.33 +        cont
    1.34 +end
    1.35 +
    1.36 +# Define a "pu" command to display PRUnichar * strings (100 chars max)
    1.37 +# Also allows an optional argument for how many chars to print as long as
    1.38 +# it's less than 100.
    1.39 +def pu
    1.40 +  set $uni = $arg0
    1.41 +  if $argc == 2
    1.42 +    set $limit = $arg1
    1.43 +    if $limit > 100
    1.44 +      set $limit = 100
    1.45 +    end
    1.46 +  else
    1.47 +    set $limit = 100
    1.48 +  end
    1.49 +  # scratch array with space for 100 chars plus null terminator.  Make
    1.50 +  # sure to not use ' ' as the char so this copy/pastes well.
    1.51 +  set $scratch = "____________________________________________________________________________________________________"
    1.52 +  set $i = 0
    1.53 +  set $scratch_idx = 0
    1.54 +  while (*$uni && $i++ < $limit)
    1.55 +    if (*$uni < 0x80)
    1.56 +      set $scratch[$scratch_idx++] = *(char*)$uni++
    1.57 +    else
    1.58 +      if ($scratch_idx > 0)
    1.59 +	set $scratch[$scratch_idx] = '\0'
    1.60 +	print $scratch
    1.61 +	set $scratch_idx = 0
    1.62 +      end
    1.63 +      print /x *(short*)$uni++
    1.64 +    end
    1.65 +  end
    1.66 +  if ($scratch_idx > 0)
    1.67 +    set $scratch[$scratch_idx] = '\0'
    1.68 +    print $scratch
    1.69 +  end
    1.70 +end
    1.71 +
    1.72 +# Define a "ps" command to display subclasses of nsAC?String.  Note that
    1.73 +# this assumes strings as of Gecko 1.9 (well, and probably a few
    1.74 +# releases before that as well); going back far enough will get you
    1.75 +# to string classes that this function doesn't work for.
    1.76 +def ps
    1.77 +  set $str = $arg0
    1.78 +  if (sizeof(*$str.mData) == 1 && ($str.mFlags & 1) != 0)
    1.79 +    print $str.mData
    1.80 +  else
    1.81 +    pu $str.mData $str.mLength
    1.82 +  end
    1.83 +end
    1.84 +
    1.85 +# Define a "pa" command to display the string value for an nsIAtom
    1.86 +def pa
    1.87 +  set $atom = $arg0
    1.88 +  if (sizeof(*((&*$atom)->mString)) == 2)
    1.89 +    pu (&*$atom)->mString
    1.90 +  end
    1.91 +end
    1.92 +
    1.93 +# define a "pxul" command to display the type of a XUL element from
    1.94 +# an nsXULElement* pointer.
    1.95 +def pxul
    1.96 +  set $p = $arg0
    1.97 +  print $p->mNodeInfo.mRawPtr->mInner.mName->mStaticAtom->mString
    1.98 +end
    1.99 +
   1.100 +# define a "prefcnt" command to display the refcount of an XPCOM obj
   1.101 +def prefcnt
   1.102 +  set $p = $arg0
   1.103 +  print ((nsPurpleBufferEntry*)$p->mRefCnt.mTagged)->mRefCnt
   1.104 +end
   1.105 +
   1.106 +# define a "ptag" command to display the tag name of a content node
   1.107 +def ptag
   1.108 +  set $p = $arg0
   1.109 +  pa $p->mNodeInfo.mRawPtr->mInner.mName
   1.110 +end
   1.111 +
   1.112 +##
   1.113 +## nsTArray
   1.114 +##
   1.115 +define ptarray
   1.116 +        if $argc == 0
   1.117 +                help ptarray
   1.118 +        else
   1.119 +                set $size = $arg0.mHdr->mLength
   1.120 +                set $capacity = $arg0.mHdr->mCapacity
   1.121 +                set $size_max = $size - 1
   1.122 +                set $elts = $arg0.Elements()
   1.123 +        end
   1.124 +        if $argc == 1
   1.125 +                set $i = 0
   1.126 +                while $i < $size
   1.127 +                        printf "elem[%u]: ", $i
   1.128 +                        p *($elts + $i)
   1.129 +                        set $i++
   1.130 +                end
   1.131 +        end
   1.132 +        if $argc == 2
   1.133 +                set $idx = $arg1
   1.134 +                if $idx < 0 || $idx > $size_max
   1.135 +                        printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
   1.136 +                else
   1.137 +                        printf "elem[%u]: ", $idx
   1.138 +                        p *($elts + $idx)
   1.139 +                end
   1.140 +        end
   1.141 +        if $argc == 3
   1.142 +          set $start_idx = $arg1
   1.143 +          set $stop_idx = $arg2
   1.144 +          if $start_idx > $stop_idx
   1.145 +            set $tmp_idx = $start_idx
   1.146 +            set $start_idx = $stop_idx
   1.147 +            set $stop_idx = $tmp_idx
   1.148 +          end
   1.149 +          if $start_idx < 0 || $stop_idx < 0 || $start_idx > $size_max || $stop_idx > $size_max
   1.150 +            printf "idx1, idx2 are not in acceptable range: [0..%u].\n", $size_max
   1.151 +          else
   1.152 +            set $i = $start_idx
   1.153 +                while $i <= $stop_idx
   1.154 +                        printf "elem[%u]: ", $i
   1.155 +                        p *($elts + $i)
   1.156 +                        set $i++
   1.157 +                end
   1.158 +          end
   1.159 +        end
   1.160 +        if $argc > 0
   1.161 +                printf "nsTArray length = %u\n", $size
   1.162 +                printf "nsTArray capacity = %u\n", $capacity
   1.163 +                printf "Element "
   1.164 +                whatis *$elts
   1.165 +        end
   1.166 +end
   1.167 +
   1.168 +document ptarray
   1.169 +        Prints nsTArray information.
   1.170 +        Syntax: ptarray   
   1.171 +        Note: idx, idx1 and idx2 must be in acceptable range [0...size()-1].
   1.172 +        Examples:
   1.173 +        ptarray a - Prints tarray content, size, capacity and T typedef
   1.174 +        ptarray a 0 - Prints element[idx] from tarray
   1.175 +        ptarray a 1 2 - Prints elements in range [idx1..idx2] from tarray
   1.176 +end
   1.177 +
   1.178 +def js
   1.179 +  call DumpJSStack()
   1.180 +end
   1.181 +
   1.182 +def ft
   1.183 +  call nsFrame::DumpFrameTree($arg0)
   1.184 +end

mercurial