Chrome Multi-process debugging

Source: Internet
Author: User
Tags switches

The chrome multi-process model poses a big challenge to debug.

If you set a breakpoint on the code, by default, VS will only track those breakpoints in the main process browser code. VS provides a "Attach to process" approach. For example, when the render process is started, you can use the menu "Debug" => "Attach to process" option, select the newly generated process, and then set breakpoints in the code where you need to track. However, this method can only be effective when the subprocess is started, and if we want to track the execution of some code when the child process starts, there is no way.

Second, for this chrome from the source code level provides support. There are two kinds of methods:

1. Use the startup option "--single-process" to start chrome in a single process. Found this method is not good to use has been

2. Use the startup option "--renderer-startup-dialog" and "--no-sandbox". Two options will let the child process eject a modal dialog after it starts. You can then continue to run the code after closing the dialog box. During this time, we can use the above "Attach to process" method to track the execution of child Process code.

The reason for adding "--no-sandbox" is that by default, the creation and startup of the Chrome subprocess is in Sanbox (which means that access to system resources is strictly limited) and the modal dialog UI cannot be displayed.

The main functions of the render process are as follows:

[CPP]   View plain copy print Int renderermain (const mainfunctionparams&  parameters)  {     const commandline& parsed_command_line =  parameters.command_line_;     base::ScopedNSAutoreleasePool* pool =  parameters.autorelease_pool_;        // This function allows  pausing execution using the --renderer-startup-dialog     // flag  allowing us to attach a debugger.     // do not  move this function down since that would mean we can ' t  easily debug     // whatever occurs before it.     handlerenderererrortestparameters (parsed_command_line);  

The Handlerendererrortestparameters function displays this modal dialog box.

This function provides some ways to test crash and assertion handling//behavior of the renderer
.
static void Handlerenderererrortestparameters (const commandline& command_line) {
if (command_line).  Hasswitch (Switches::kwaitfordebugger))
Base::d Ebug::waitfordebugger (true);


if (command_line.  Hasswitch (Switches::krendererstartupdialog))
Childprocess::waitfordebugger ("Renderer");


This is parameter causes an assertion.
if (command_line.  Hasswitch (switches::krendererasserttest)) {
Dcheck (false);
}
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.