how to debug webkit

本文介绍如何通过修改配置去除WebKit库的无调试信息编译,并开启NDEBUG宏来查看DOM树结构,利用GDB进行WebKit中DOM树的跟踪及在代码中直接调用showTree()函数显示DOM树。
1、编译带debug 信息的webkit 库
 删除qt-everywhere-opensource-src-4.7.0/src/3rdparty/webkit/WebCore/WebCore.pro 中的红色两行代码
还有JavaScriptCore/JavaScriptCore.pro

CONFIG(QTDIR_build) {
    # Remove the following 2 lines if you want debug information in WebCore
    #CONFIG -= separate_debug_info
    #CONFIG += no_debug_info
}

2、打开NDEBUG宏,可以跟踪webkit 中dom tree 的结构,在GDB 中用call showTree(node) 可以打印出整个dom tree

   如何打开NDEBUG 宏: 删除以下文件中的NDEBUG定义
   webkit/WebCore/Makefile
   webkit/WebKit.pri 
    webkit/JavaScriptCore/JavaScriptCore.pri
    webkit/JavaScriptCore/Makefile

3、在代码中加入showTree(),查看 dom tree
  如: 在FrameView.cpp 的paintContents() 中加入  showTree(contentRenderer);
       打印结果:
       *#document      0x4e1940
        html    0x4e5a10
        HTML    0x4c03b0
                HEAD    0x4e7d50
                        #text   0x4f8380 "\n            "
                        META    0x4f8aa8
                        #text   0x4f8b08 "\n            "
                        TITLE   0x4e7dc0
                        #text   0x4f81b8 "\n            \n"
                        SCRIPT  0x4effd0
                        #text   0x4cf700 "\n"
                        SCRIPT  0x4bb160
                        #text   0x521728 "\n"
                        SCRIPT  0x51f7b0
                        #text   0x521760 "\n            "
                        STYLE   0x4f0cc0
                                #text   0x513ba0 "\n* {\n       margin: 0;\n    padding: 0;\n}\n\nbody {\n      background-color: transparent;\n        width: 640px;\n height: 530px;\n        overflow: hidden;\n     background: url(images/index.jpg) no-repeat;\n}\n\n div.menu {\n    position: absolute;\n    top: 0px;\n    left: 0px;\n    width: 640px;\n    height: 530px;\n}\n \n\n #background {\n    position: absolute;\n  "
                        #text   0x4bb6d0 "\n \n"
                        SCRIPT  0x4bbe30
                                #text   0x4e7b80 "\nvar backurl=window.location.href;\nvar data="[{'   "
                BODY    0x511c28
                        #text   0x512f48 "\n            "
                        DIV     0x5120b8 CLASS=menu
                                #text   0x511428 "\n                    "
                                DIV     0x4fef68
                                #text   0x54f070 "\n                    "
                                DIV     0x54daa0
                                        DIV     0x4eba58 CLASS=img0 STYLE=top: 35px; left: 405px; width: 95px; height: 190px; display: block; 
                                                IMG     0x4ebd18 STYLE=-webkit-transition-property: -webkit-transform; -webkit-transition-duration: 2s; -webkit-transition-timing-function: initial; -webkit-transition-delay: initial; -webkit-transform: rotate(0deg); 
                                #text   0x54dd88 "\n            "
                        #text   0x54dde0 "\n            "
                        DIV     0x54de70 CLASS=name
                        #text   0x54e4b0 "\n    "
                        #text   0x54a4e8 "\n \n"
                        #text   0x54a540 "\n\n"
# Make the request on the HTTPConnection object > response = self._make_request( conn, method, url, timeout=timeout_obj, body=body, headers=headers, chunked=chunked, retries=retries, response_conn=response_conn, preload_content=preload_content, decode_content=decode_content, **response_kw, ) /opt/venv/lib/python3.10/site-packages/urllib3/connectionpool.py:787: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/venv/lib/python3.10/site-packages/urllib3/connectionpool.py:534: in _make_request response = conn.getresponse() /opt/venv/lib/python3.10/site-packages/urllib3/connection.py:565: in getresponse httplib_response = super().getresponse() /usr/local/lib/python3.10/http/client.py:1375: in getresponse response.begin() /usr/local/lib/python3.10/http/client.py:318: in begin version, status, reason = self._read_status() _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <http.client.HTTPResponse object at 0x7fe43434ffa0> def _read_status(self): line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") if len(line) > _MAXLINE: raise LineTooLong("status line") if self.debuglevel > 0: print("reply:", repr(line)) if not line: # Presumably, the server closed the connection before # sending a valid response. > raise RemoteDisconnected("Remote end closed connection without" " response") E http.client.RemoteDisconnected: Remote end closed connection without response /usr/local/lib/python3.10/http/client.py:287: RemoteDisconnected During handling of the above exception, another exception occurred: self = <requests.adapters.HTTPAdapter object at 0x7fe435f852d0> request = <PreparedRequest [POST]>, stream = False timeout = Timeout(connect=10, read=10, total=None) verify = '/tmp/tmp.Dx7DeYhhmM/scripts/combined-cacert.pem', cert = None proxies = OrderedDict() def send( self, request, stream=False, timeout=None, verify=True, cert=None, proxies=None ): """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) <timeouts>` tuple. :type timeout: float or tuple or urllib3 Timeout object :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. :rtype: requests.Response """ try: conn = self.get_connection_with_tls_context( request, verify, proxies=proxies, cert=cert ) except LocationValueError as e: raise InvalidURL(e, request=request) self.cert_verify(conn, request.url, verify, cert) url = self.request_url(request, proxies) self.add_headers( request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, ) chunked = not (request.body is None or "Content-Length" in request.headers) if isinstance(timeout, tuple): try: connect, read = timeout timeout = TimeoutSauce(connect=connect, read=read) except ValueError: raise ValueError( f"Invalid timeout {timeout}. Pass a (connect, read) timeout tuple, " f"or a single float to set both timeouts to the same value." ) elif isinstance(timeout, TimeoutSauce): pass else: timeout = TimeoutSauce(connect=timeout, read=timeout) try: > resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=False, assert_same_host=False, preload_content=False, decode_content=False, retries=self.max_retries, timeout=timeout, chunked=chunked, ) /opt/venv/lib/python3.10/site-packages/requests/adapters.py:667:
09-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值