Windows 环境中的 Chromium 调试

Chromium debugging on Windows environment

如何在Windows平台上调试chrome本身,我熟悉Visual Studio和c#调试。

This is the code part what I am interested in.

我应该从源代码构建吗?还是可以在不弄乱源代码的情况下记录所有必要的数据?

我在网上四处看看,但我不熟悉健壮的 C++ 项目。 (如符号表等,...)

所以我的问题是:

逐步调试的最简单方法是什么 link?

如果你有完整的源代码,你调试你的应用程序会很容易。

在这里为这个问题点赞:

Visual Studio: Debugging Chrome with Source?

如果你真的想调试 Chrome 浏览器,你真的可以在你的 VS 中 运行 它。你可以得到它的符号文件,然后直接从 PDB 文件中得到一些调试信息。

调试的分步说明 chrome 通过 vs 2017 在我的示例中,我将使用 "c:\Files\Work\chromium\" 文件夹

安装:

使用 "Desktop development with c++" 安装 VS2017 来自:https://www.visualstudio.com/downloads/

步骤安装 python 2.x 路径来自:https://www.python.org/downloads/

从以下位置获取 depot_tools:https://storage.googleapis.com/chrome-infra/depot_tools.zip

将其解压到 "c:\Files\Work\chromium\" 使用右键单击 "Extract All..." 因为隐藏文件

打开 powerhsell

更改文件夹:

cd c:\Files\Work\chromium\

检查 python 安装是否正确:

python --version

Python 2.7.13

设置环境变量:

$env:DEPOT_TOOLS_WIN_TOOLCHAIN=0

$env:GYP_MSVS_VERSION=2017

$env:path = $env:path + ";c:\Files\Work\chromium\depot_tools\"

为铬源代码创建文件夹:

mkdir chromium && cd chromium

下载源代码(20gb 需要一段时间)

fetch chromium

gclient sync

切换到 src 文件夹:

cd src

生成vs2017工程文件:

gn gen --ide=vs2017 --filter//chrome/* --args="is_component_build = true is_debug = true remove_webcore_debug_symbols = true" out\Default

打开 Visual Studio 2017:

启用源服务器:

工具->选项->调试->常规->"Enable source server support" "Print Source server diagnostic messages..."

添加符号:

工具->选项->调试->符号 添加 https://chromium-browser-symsrv.commondatastorage.googleapis.comhttp://msdl.microsoft.com/download/symbols 带缓存

重启VS2017

打开chromium项目(需要一段时间) c:\Files\Work\chromium\chromium\src\out\Default\all.sln 项目

开始调试:

调试 -> 附加到进程 将其设置为附加到本机代码:

当你需要调试 chrome 附加到主进程时 chrome 当你需要调试渲染器附加到选项卡时使用 Chrome 任务管理器找出进程 ID 以打开任务管理器使用:shift+esc

设置断点:

设置断点,右击->条件 并检查 "Allow the source code to be different from the original"

如果 VS 要求检查源,请按确定。