Building & Debugging chromium on CLion for Linux.

使用CLion替换VSCode,开发 chromium kernel(for Linux)

VSCode 不适合开发像chromium 这样的巨型c++工程,Microsoft的cpptools和mono(.net移植,被VScode用作来写code intellisense)存在的严重的memory leak 问题,不一会内存就爆满,然后触发OOM。有想过继续用vim,emacs,但是这些工具在海量文件跳转和符号检索方面效率非常低下,所以还是得使用IDE。最后选择了用CLion,用了一阵子,CLion内存使用率还是非常稳定的。CLion的code intellisense用的clangd(LLVM),性能非常不错,比较节省内存。

 

Checking out and building chromium kernel on Linux:

https://chromium.googlesource.com/chromium/src/+/master/docs/linux/build_instructions.md

 

gdb config & py script:

https://chromium.googlesource.com/chromium/src/+/refs/heads/master/tools/gdb/

https://chromium.googlesource.com/chromium/src/+/refs/heads/master/third_party/blink/tools/gdb/

 

0x00: 下载安装CLion (license破解脚本https://github.com/pxps/jetbrains-agent)

添加Custom VM options: Help -> Edit Custom VM Options
# custom CLion VM options,JVM虚拟机自定义参数
   -Xss2m
   -Xms2g
   -Xmx5g
   -javaagent:/path/to/jetbrains-agent.jar #破解jar包绝对路径

 

0x01: 导入chromium project到 CLion

需要导入chromium目录:

chromium/
├── .cipd
├── .gclient
├── .gclient_entries
└── src

然后在chromium目录中添加一个新的CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(chromium)
set(CMAKE_CXX_STANDARD 17)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(chromium src/base/bind_unittest.cc)

 

此时目录结构:

 

chromium/
├── .cipd
├── cmake-build-debug
├── CMakeLists.txt
├── .gclient
├── .gclient_entries
├── .idea
└── src

 

 

0x02: 添加Build Target,Building, Debugging target

 

添加Build Target

打开 File -> Settings -> Build, Execution, Deployment -> Custom Build Targets :

Name: 随意就好
Toolchina: Default就好
Build:
Progame: 构建工具绝对路径 /path/to/ninja
Arguments: 构建命令 -C src/out/Debug weblayer_shell -j12 (具体查看ninja help)
Clean: 默认就好


Building & Debugging chromium on CLion  for Linux.

 

Building & Debugging chromium on CLion  for Linux. 

 


添加Custom Build Application

Target: 上一个步骤创建的Target

Executable: 用gn, ninja编译出来的想调试的二进制文件路径

Building & Debugging chromium on CLion  for Linux.

 

开始快乐调试Chromium !

 

Building & Debugging chromium on CLion  for Linux. 

 

Building & Debugging chromium on CLion  for Linux.

 

Building & Debugging chromium on CLion for Linux.

上一篇:MAC Docker Error response from daemon: Mounts denied


下一篇:eclipse导入工程报错-项目或者文件有红叉的解决方案