Created
May 10, 2012 01:15
-
-
Save killerswan/2650257 to your computer and use it in GitHub Desktop.
more Python for GDB debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # (gdb) python execfile ("/home/kcantu/Desktop/gdbScripts/ff.py") | |
| # given address as string | |
| def contentOfStr (addy): | |
| return gdb.parse_and_eval ('({nsIContent} ' + addy + ')') | |
| # given content as gdb.Value | |
| def nameOfContent (content): | |
| name = '' | |
| for ii in range(0,11,1): | |
| achar = content['mNodeInfo']['mRawPtr']['mNodeName']['mData'][ii] | |
| if achar != 0: | |
| name += chr(achar) | |
| else: | |
| break | |
| return name | |
| # given nsIContent as a string | |
| def nameOfStr (addy): | |
| return (nameOfContent (contentOfStr (addy))) | |
| #def childTextOf (nodeAddrStr): | |
| # content = gdb.parse_and_eval ('({nsIContent} ' + nodeAddrStr + ')') | |
| # childText = content['mFirstChild'].GetText() #->m1b | |
| # print "ok" | |
| def documentOfFrame (frameVarName): | |
| #(gdb) print (aFrameList.mFirstChild->mContent->mNodeInfo.mRawPtr->mDocument) | |
| frame = gdb.parse_and_eval (frameVarName) | |
| return frame['mContent']['mNodeInfo']['mRawPtr']['mDocument'] | |
| # list the children of a node | |
| # given its address as a string | |
| def printChildrenOf (indent, node): | |
| if node == 0: | |
| return | |
| else: | |
| # print this node | |
| print "%s%s /%s/" % ((indent * " "), hex(long(node)), nameOfContent(node)) | |
| # get its first child | |
| child = node['mFirstChild'] | |
| printChildrenOf (indent+3,child) # recurse | |
| # get more children | |
| for jj in range(0,1024,1): | |
| if child != 0: | |
| child = child['mNextSibling'] | |
| printChildrenOf (indent+3,child) # recurse | |
| else: | |
| break | |
| return | |
| # print heirarchy of a content tree, given the name of a frame | |
| def printDocumentOfFrame (name): | |
| printChildrenOf (0, documentOfFrame (name)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: http://dmalcolm.fedorapeople.org/presentations/PyCon-US-2011/GdbPythonPresentation/GdbPython.html