Debugging Chromium on Windows
转自:https://www.chromium.org/developers/how-tos/debugging-on-windows
Debugging Chromium on Windows
|
This page has detailed information to help you debug Chromium on Windows.
Note: If you've never built or debugged Chromium on Windows, first read the Windows build instructions.
Before you startRequirementsYou can use Visual Studio's built-in debugger or WinDBG to debug Chromium. Note that if you are using goma to build, much of this will not work; see "Unable to set breakpoints in VS when building with goma on Windows".
OptionalSo that you can continue to run release versions of the browser — and avoid incompatible profile changes — while you debug, you should use a different profile for your debug Chromium instance from the release build that you use. You can set the profile by modifying the command line used to launch Chromium from the debugger. To do this, go to the Debugging tab of the properties of the chrome project, and set the Command Arguments field to --user-data-dir=c:\tmp\my_debug_profile. (Replace c:\tmp\my_debug_profile with a directory of your choosing.) Another possibility, if you have lots of different checkouts, is to change the path of the shortcut you use for the release build so that it sets the profile.
Tools such as ProcessExplorer, Spy++/Winspector Spy, Inspect32, and FileMon may be of use when debugging different parts of Chromium.
Multi-process issuesChromium can be challenging to debug because of its multi-process architecture. When you select Run in the debugger, only the main Browser process will be debugged. The code that actually renders web pages (the Renderer) and the plugins will be in separate processes that's not (yet!) being debugged. There are a number of approaches to solving this problem. Single-process modeThe easiest way to debug issues is to run Chromium in single-process mode. This will allow you to see the entire state of the program without extra work (although it will still have many threads). To use single-process mode, add the command-line flag Tip: By default, when you load the project, Visual Studio may select Browser/browser.exe as the "startup project," and you will notice that chrome.exe is not bolded in the list of projects. If this is the case, then just clicking Debug > Start Debugging will start a different project, and ignore the command line flag you just provided. To change this, right-click the chrome.exe project and choose Set As Startup Project. Using Image File Execution OptionsUsing Image File Execution Options (IFEO) will not work, because CreateProcess() returns the handle to the debugger process instead of the intended child process. There are issues too with the sandbox.
Chrome Debug LogEnable Chrome debug logging to a file by passing --enable-logging --v=1 command-line flags at startup. Debug builds place the chrome_debug.log file in the out\Debug directory. Release builds place the file in the top level of the user data Chromium app directory, which is OS-version-dependent. For more information, see logging and user data directory details.
Debugging with Visual StudioAttaching to the rendererYou can also attach to the running child processes with the debugger. Select Tools > Attach to Process and click the chrome.exe process you want to attach to. You can now debug the two processes as if they were one.Use this macro or the vs-chromium plug-in to attach to the right processes.
When you are debugging multiple processes, open the Debug > Windows > Processes window to switch between them.
Sometimes you are debugging something that only happens on startup, and want to see the child process as soon as it starts. In this case, you can use the --renderer-startup-dialog command line flag to the browser.Important note: If you use this flag you also have to pass the --no-sandbox flag, since the sandbox will otherwise prevent the renderer from showing a startup dialog. The browser will pass this along to each renderer it starts, which will display a message box as soon as it starts. When the dialog appears, visit Tools > Attach to Process and attach to the process showing the Renderer startup dialog. Now you're debugging in the renderer.
Semi-automatically attaching the debugger to child processesThe following flags cause the processes to wait for 60 seconds in a busy loop for a debugger to attach to the process. Once either condition is true, it continues on; no exception is thrown. This is the only reliable way to debug an issue occurring on process startup with Visual Studio.
Usage
It should be used with the .NET macro to help catch the processes. Alt-P does the job, too. Symbol serverSave yourself some time and debug an official build! Setup your symbols:
Important note: release build debugging is much easier with WinDBG. Don't step into trivial functionsRight click and select "Step Into Specific" when the current statement is on a line with multiple function calls.
![]() The debugger can be configured to automatically not step into functions based on regular expression:
Debugging with WinDBGWinDBG is a great, free tool. It is more powerful than Visual Studio's built-in debugger, but is harder to use (kind of like gdb on Linux). You can retrieve the latest version from Microsoft's web site. You should end up with two versions of the tool: the 32-bit debugger and the 64-bit debugger. Most of the time the one that you should use for Chromium is the 32-bit version. Initial setupOnce you're started, you may wish to fix a few things:
Common commands
One of the major benefits of WinDBG for debugging Chromium is its ability to automatically debug child processes. This allows you to skip all the complicated instructions above. The easiest way to enable this is to check "Debug child processes also" in the "Open Executable" dialog box when you start debugging or start "windbg.exe -o". NOTE that on 64-bit Windows you may need to use the 64-bit WinDbg for this to work. You can switch dynamically the setting on and off at will with the .childdbg 1|0 command, to follow a particular renderer creation. You can also attach to a running process (F6) and even detach without crashing the process (.detach) Common commands when working with a crash
For more info, see this example of working with a crash dump, consult the program help (really, it's exhaustive!), see Common windbg commands or use your favorite search engine.
V8 and ChromiumV8 supports many command-line flags that are useful for debugging. V8 command-line flags can be set via the Chromium command-line flag --js-flags; for instance:
chrome.exe --js-flags="--trace_exception --heap_stats" Note that some V8 command-line flags exist only in the debug build of V8. For a list of all V8 flags try: chrome.exe --js-flags="--help" Graphical DebuggingGPU Acceleration of rendering can be more easily debugged with tools. See:
Debugging on another machineSometimes it's useful to debug installation and execution on a machine other than your primary build box. To run the installer on said other machine, first build the mini_installer target on your main build machine (e.g., ninja -C out\Debug mini_installer). Next, on the debug machine:
Consider reading the documentation at the top of copy-installer.bat to see how you can run it. It tries to be smart and copy the right things, but you may need to be explicit (e.g., "copy-installer.bat out Debug"). It is safe to re-run the script to copy only modified files (after a rebuild, for example).
Miscellaneous
|
Debugging Chromium on Windows的更多相关文章
- 在windows上编译chrome浏览器Building Chromium for Windows
web端用webRTC实现的一对一视频,互动直播和会议.https://github.com/starrtc/android-demo Chromium requires Visual Studio ...
- Build Instructions (Windows) – The Chromium Projects
转自:http://121.199.54.6/wordpress/?p=1156 原始地址:http://www.chromium.org/developers/how-tos/build-instr ...
- 记录windows下编译chromium,备忘
编译windows下chromium,时间:20170619, 官方地址:https://chromium.googlesource.com/chromium/src/+/master/docs/wi ...
- Chromium Windows Build
https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/windows_build_instructions.md ...
- cef chromium 编译
前言 目前客户端引用了cef sharp库来嵌入web页面 cef sharp是对cef (chromium embed framework)的c#封装 cef是对chromium内核的c++封装 什 ...
- Setup QT 5.5.1 + OpenCV 3.0 + Visual Studio 2013 on windows 10
1. Install Visual studio 2013 community version which is free to use for personal usage. 2. Setup th ...
- 在64位windows 7上安装汇编调试工具debug.exe的方法
最近我在研究汇编,书中介绍的调试工具还是基于WinXP 32bit时代中自带debug.exe进行调试,但是64bit的Windows XP.Vista.Win7.Win8都已经不自带这个工具了,网上 ...
- .NET对象与Windows句柄(三):句柄泄露实例分析
在上篇文章.NET对象与Windows句柄(二):句柄分类和.NET句柄泄露的例子中,我们有一个句柄泄露的例子.例子中多次创建和Dispose了DataReceiver和DataAnalyzer对象, ...
- debugging books
https://blogs.msdn.microsoft.com/debuggingtoolbox/2007/06/08/recommended-books-how-to-acquire-or-imp ...
随机推荐
- asp.net环境变量
// 获取程序的基目录. System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径. System.Diagnostics.Process.G ...
- linux kernel thread(Daemons)
内核线程是直接由内核本身启动的进程.内核线程实际上是将内核函数委托给独立的进程,与系统中其他进程“并行”执行(实际上,也并行于内核自身的执行),内核线程经常被称为内核“守护进程”.它们主要用于执行下列 ...
- struts2使用注解--ACTION中的应用
1.在类中指定包:@ParentPackage("system").其中system是在struts.xml中定义的包名.2.配置文件--->注解2.1配置文件方式(返回js ...
- Ueditor配置及在项目中的使用
引言 上篇中简单介绍了Ueditor的两种定制方式,想了解的请戳这里:Ueditor的两种定制方式.在项目中,Ueditor该怎么使用更方便呢?很容易让人想到将ueditor放入用户控件页,可以拖到需 ...
- 微信公众平台开发(十) 消息回复总结——用其xml模板
一.简介 微信公众平台提供了三种消息回复的格式,即文本回复.音乐回复和图文回复,在这一篇文章中,我们将对这三种消息回复的格式做一下简单讲解,然后封装成函数,以供读者使用. 二.思路分析 对于每一个PO ...
- Windbg对过滤驱动DriverEntry函数下断点技巧
方法1: 1> 先用DeviceTree.exe查看指定的过滤驱动的Load Address(加载地址) 2> 再用LordPE.EXE查看指定过滤驱动文件的入口点地址 3> 计算过 ...
- Docker大行其道—初识
导读 随着分布式.云计算.大数据的火热爆发,大量的云计算集群出现,光凭计算机硬件配置的已经无法再次一较高下,虚拟化成为其中最核心的技术.虚拟化既可以通过硬件模拟,也可以通过操作系统层面去实现,近年来热 ...
- MFC获取系统当前时间的几种方法
1.使用CTime类 CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime(); str=tm.Format("现在时间是%Y年% ...
- sort如何按指定的列排序
<1>[root@localhost company]# cat test 06d7 145 4192542506e1 ...
- SCOPE_IDENTITY的作用
SCOPE_IDENTITY返回插入到同一作用域中的 IDENTITY 列内的最后一个 IDENTITY 值.一个作用域就是一个模块——存储过程.触发器.函数或批处理.因此,如果两个语句处于同一个存储 ...
