c++ - Windows环境下的Chromium调试

标签 c++ visual-studio google-chrome debugging chromium

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

This is the code part what I am interested in .

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

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

所以我的问题是:

逐步调试最简单的方法是什么?链接中的方法是什么?

最佳答案

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

安装:

使用“使用 C++ 进行桌面开发”安装 VS2017,来自:https://www.visualstudio.com/downloads/ enter image description here

使用 PATH 从以下位置安装 python 2.x:https://www.python.org/downloads/ enter image description here

从以下位置获取 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\"

为 chromium 源代码创建文件夹:

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:

启用源服务器:

工具->选项->调试->常规->“启用源服务器支持” 带有“打印源服务器诊断消息...” enter image description here

添加符号:

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

重启VS2017

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

开始调试:

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

enter image description here

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

设置断点:

设置断点,右击->条件 并勾选“允许源码与原码不同”

enter image description here

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

关于c++ - Windows环境下的Chromium调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46078967/

相关文章:

c++ - 使用 CPP 插件在 gradle 中编译 C++ 代码

c - main函数返回导致异常

javascript - Sencha Touch 日期代码在 Chrome 中运行良好,但在 Safari 中失败

google-chrome - 打开新标签页/新窗口时自动打开 Chrome 开发者工具

c++ - 交叉编译Qt for ARM时出错

c++ - 您使用 Qt 模型- View 架构的首选模式是什么?

c++ - 从 a_func(A a_in) 转换为 b_func(B b_in) 的函数 (c++)

c# - 部署到 GAC

sql-server - 如何引用 SSRS 报告的嵌入代码中的字段

css - 具有绝对定位元素的 Chrome 和 Safari 之间一个像素的水平偏移