《Debugging Chromium on Windows》学习

学习资料:《Debugging Chromium on Windows》

学习进度跟踪

  • 下午真的好困 :) 除了喝咖啡,有什么好办法么?
  • 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插件,可以实现代码的索引

参考文档:https://chromium.github.io/vs-chromium/#code-search

翻译以及总结:链接

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 Child Process Debugging Power Tool is a standalone extension for this, and VsChromium 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,可以跟踪每一次内存的分配

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值