博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
《Debugging Chromium on Windows》学习
阅读量:2123 次
发布时间:2019-04-30

本文共 3510 字,大约阅读时间需要 11 分钟。

学习资料:

学习进度跟踪

  • 下午真的好困 :) 除了喝咖啡,有什么好办法么?
  • 2021.6.24 下午,完成翻译和理解,留存几个疑问。今天比昨天好,没那么困,应该再早点睡

Getting started

可以使用VS内置的built-in debugger,或者是WinGBD,不需要使用IDE去build。ninja是用来构建chromium并且大多数开发人员使用cmd来执行ninja build

可以在Solution Explorer并设置启动项Startup Project

symbol_level = 2 默认参数,会有更多的debug info,symbol_level = 1会少一些debug info,so PDBs is smaller。在args.gn里设置

  • symbol_level=2 is the default on Windows and gives full debugging information with types, locals, globals, function names, and source/line information. symbol_level=1 creates smaller PDBs with just function names, and source/line information - source-level debugging is still supported (new from June 2019).在args.gn或者cmd里都可以吗
    • 在cmd里输入 gn args out/Default --args=''就会弹出Edit文本进行编辑

Browsing source code

使用VSChromium插件,可以实现代码的索引

参考文档:

翻译以及总结:

Profiles(配置文件)

不同chrome代码可能会有一些版本冲突的情况,因为配置不一样

Chrome Debug Log

--enable-logging --v=1

  • release可以加在app property末尾
  • debug可以在启动chrome.exe的时候跟着命令行一起进去
    • 测试
      • ​​​​​​​通过命令行启动,记得no sandbox
      • 通过VS启动

Symbol Server(调试符号文件)

用于存储一个debug information on remote server,developed by Microsoft。结论:有一个舒服的debug environment

Source Index

会自动更新一些Source Code


Multi-process issues

因为chromium的multi-process architecture,导致很难调试。当在IDE Run&Debugger的时候,只有main browser process will be debugged.

ProcessExplorer tool 绘制进程树,可以查看进程间的关系

Automatically attach to child processes

Two extensions can attach all Chrome processes to debugger

  • There are two Visual Studio extensions that enable the debugger to automatically attach to all Chrome processes, so you can debug all of Chrome at once. Microsoft's  is a standalone extension for this, and  is another option that bundles many other additional features. In addition to installing one of these extensions, you must run Visual Studio as Administrator, or it will silently fail to attach to some of Chrome's child processes. 一次性调试所有的chrome是什么意思?
    • ​​​​​​​通过安装插件,在no sandbox的condition下,可以调试所有的processes

Single-process mode

可以使用single-process mode进行完整的调试,但问题在于单进程模式有很多BUG并且一些功能无法正常使用

通过添加命令行 --single-process

  • 在哪里添加这个命令行?用ninja build的时候吗?
    • ​​​​​​​在运行时,所以是启动的时候。用的很少,一般就是跟某个进程的代码才会用

Manually attaching to a child process

VS Attach to process 要选择 native code,否则会attach fail,and get an error message "An operation is not legal in the current state"

 有时deubgging something的时机在startup,我们可以使用命令

--renderer-startup-dialog --no-sandbox

必须关闭sandbox,否则dialog box会被禁止显示。当dialog弹出,在VS Tool | Attach to Process,然后就开始debug in render process了,类似的,把render参数改成gpu,ppapi,utility,plugin等等,换成其他 Process  Name调试对应的进程

Problem:在哪个地方设置这些参数呢?

  • 显然是运行时

Semi-automatically attaching the debugger to child processes

可以通过--wait-for-debugger-children[=filter] 让子进程等60s让debugger attach to process

--render-process-limit = 1可以限制Render Process的Spawn numbger

Image File Execution Option

This feature is unuseful

Time travel debugging

可以往前或者往后,更强大的debug tool

JsDbg -- data structure visualization

JsDbg 是一个 SV插件,可视化DOM Tree,Layout Tree这样的复杂数据结构


Visual Studio hints

Debug visualizers

chrome's custom debug visualizers 被加入到 dpb files 并且 自动被VS pick up

定义在src\tools\win\DebugVisualizers中

设置不需要单步进入的函数

default.natstepfilter可以配置不进入正则表达式


V8 and Chromium

V8支持一些命令行参数for debugging


Graphics debugging

GPU 加速渲染可以被Debug


Deubgging on another machine

Sometimes it is useful to debug on another machine


Finding all memory allocations

Heap Snapshots 可以获取所有未完成分配的 call stacks

  • It is possible to use Heap Snapshots (requires recent versions of Windows 10?) to get call stacks on all outstanding allocations 获取的作用是什么?Debuf for what?
    • ​​​​​​​用的少

Find memory leaks

Windows heap manager has useful debug flag,可以跟踪每一次内存的分配

转载地址:http://fkcrf.baihongyu.com/

你可能感兴趣的文章
剑指offer 37.数组中重复的数字
查看>>
剑指offer 38.丑数
查看>>
剑指offer 39.构建乘积数组
查看>>
剑指offer 57. 删除链表中重复的结点
查看>>
剑指offer 58. 链表中环的入口结点
查看>>
剑指offer 59. 把字符串转换成整数
查看>>
剑指offer 60. 不用加减乘除做加法
查看>>
leetcode 热题 Hot 100-3. 合并两个有序链表
查看>>
leetcode 热题 Hot 100-4. 对称二叉树
查看>>
Leetcode C++《热题 Hot 100-12》226.翻转二叉树
查看>>
Leetcode C++《热题 Hot 100-13》234.回文链表
查看>>
Leetcode C++《热题 Hot 100-14》283.移动零
查看>>
Leetcode C++《热题 Hot 100-15》437.路径总和III
查看>>
Leetcode C++《热题 Hot 100-17》461.汉明距离
查看>>
Leetcode C++《热题 Hot 100-18》538.把二叉搜索树转换为累加树
查看>>
Leetcode C++《热题 Hot 100-19》543.二叉树的直径
查看>>
Leetcode C++《热题 Hot 100-21》581.最短无序连续子数组
查看>>
Leetcode C++《热题 Hot 100-22》2.两数相加
查看>>
Leetcode C++《热题 Hot 100-23》3.无重复字符的最长子串
查看>>
Leetcode C++《热题 Hot 100-24》5.最长回文子串
查看>>