Chromium Browser Development Series fourth: How to debug the latest chromium source code

Source: Internet
Author: User

A succession of things, time is more tense, but still did not put this series of articles lost, because this is also a summary of their own knowledge of it. Advocating that we write more, and then look at the time will have a strange little excitement.

Last week I wrote about the chromium directory structure, as if we were not interested in it, and it seems to me that this part is very important. There is a link at the beginning of the address, we would like to see.

From the source code download to the compilation, to the directory structure, today finally to the important link, debugging.

On Windows, debugging tools use Microsoft's own products: Visual studio or WinDbg (Windebug). Chromium is also advancing with the times and is now primarily used by visual Studio2013. Today I mainly talk about using vs2013 Debug source.

I used to compile the code that chapter (http://my.oschina.net/ghost045/blog/395973) When I said the source of the project to generate the east, as follows:

Set gyp_msvs_version=2013

Set Gyp_generators=msvs-ninja,ninja

Set Gyp_defines=component=shared_library

Set path=c:\depot_tools\python276_bin\; C:\depot_tools\;

Python.exe Src/build/gyp_chromiumsrc/chrome/chrome.gyp >>log.txt 2>&1

After running successfully, open the Src\chrome folder, found that there are many more files----are engineering files.

If you have installed the vs2013, then double-tap open Chrome.sln . After you open the Solution Explorer, you can see all the solution information.

Click the Chrome folder in the expand, select Chrome Solution , right-click Set to start Project, and then direct F5 (Debug and start Debugging) to start the program debugging.

If you want to start the project with a different solution, you can directly right-click on the line. However, you need to add the following settings: Right-click to open the properties of the startup item you want to set

Click on the Debug option on the left and set "command" to set the file address directly to the absolute path address of chrome.exe.

This allows you to directly choose to start debugging from a different solution.

Chromium is a multi-process architecture, we can only debug the main process after launch, the other renderer process and plug-in extension process is separate, can not be directly debugged. Here are a few ways to debug other processes:

1. Single process mode

The simplest approach is to run chromium in single-process mode. This way you will see the state of the whole program without extra work (though it will still have a lot of threads). With single-process mode, you need to add--single-process to the command-line arguments in the Chrome Project Properties Debug page. This method is not perfect, because some problems do not appear in this pattern.

By default, Visual Studio chooses Browser/browser.exe as the startup project and requires the user to manually select the Chrome solution right-click Set as the Startup Project.

2. Start Chrome's debug log

Add--enable-logging--v=1 in the command line arguments, the log will be saved in the file, the debug version is placed in Chrome_debug.log under Out\debug, the release version is placed in the C:\Users\ account name \appdata\local\chromium\user the Data directory.

3. Debugging with the "Attach to process" option that comes with vs2013

When debugging directly in vs2013, you can use the function attached to the process, immediately after debugging, click Tools > Attach to Process, attach the process you need to debug.

If the contents of the renderer process you want to debug occur when the process starts, you can add --renderer-startup-dialog and--no-sandboxto the command-line arguments, Both must be used at the same time to pop-up windows when the renderer process is started so you can attach to the process in a timely manner.

There are also a lot of useful parameters can be set, using these parameters can let you do what you want to debug content, the chromium team has been trying to make debugging easier and more practical. Other commands can view the file: content_switches.cc, which identifies various parameters and meanings.

Debugging a lot of things, today to talk about so much, more and more difficult to digest, and then I will give you more detailed explanations, including Windebug debugging.

If you have any questions or questions that you would like to discuss with me, I hope you will pay attention to the public platform: Programmer Interaction Alliance (coder_online)

Here's what you want.

Chromium Browser Development Series fourth: How to debug the latest chromium source code

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.