-
Notifications
You must be signed in to change notification settings - Fork 478
uftrace for chromium
1. Download depot_tools
Chromium uses a package of scripts called depot_tools to manage checkouts and code reviews.
The depot_tools package includes gclient
, gcl
, git-cl
, repo
, and others. Chromium uses a package of scripts called depot_tools
to manage checkouts and code reviews.
# download depot_tools
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# environment setup for depot_tools
$ export PATH=`pwd`/depot_tools:$PATH
2. Download chromium
First, create a directory chromium
.
$ mkdir chromium && cd chromium
Then, create .gclient
file as follows:
$ cat .gclient
solutions = [
{
"url": "https://chromium.googlesource.com/chromium/src.git",
"managed": False,
"name": "src",
"custom_deps": {},
},
]
Do (shallow) git clone for chromium source code.
$ git clone --depth=1 https://chromium.googlesource.com/chromium/src.git -b 73.0.3676.0
$ cd src
Then, download third party modules.
$ gclient sync --shallow
3. Add -pg option with a build flag
The following use_uftrace.diff
file contains the changes to apply -pg
build for uftrace.
diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni
index 18a7f08..ca00a68 100644
--- a/build/config/compiler/compiler.gni
+++ b/build/config/compiler/compiler.gni
@@ -74,6 +74,9 @@ declare_args() {
# It's currently not possible to collect AFDO profiles on anything but
# x86{,_64}.
using_mismatched_sample_profile = current_cpu != "x64" && current_cpu != "x86"
+
+ # Enables -g -pg -fno-omit-frame-pointer for uftrace
+ use_uftrace = false
}
assert(!is_cfi || use_thin_lto, "CFI requires ThinLTO")
diff --git a/third_party/ffmpeg/BUILD.gn b/third_party/ffmpeg/BUILD.gn
index fd79bc4..4a3eaae 100755
--- a/third_party/ffmpeg/BUILD.gn
+++ b/third_party/ffmpeg/BUILD.gn
@@ -7,6 +7,7 @@ import("ffmpeg_generated.gni")
import("//build/buildflag_header.gni")
import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/compiler/compiler.gni")
# Path to platform configuration files.
platform_config_root =
@@ -265,6 +266,10 @@ target(link_target_type, "ffmpeg_internal") {
"-Wno-deprecated-declarations",
]
+ if (use_uftrace) {
+ cflags -= [ "-fomit-frame-pointer" ]
+ }
+
if (!is_clang) {
# gcc doesn't have flags for specific warnings, so disable them
# all.
diff --git a/third_party/swiftshader/BUILD.gn b/third_party/swiftshader/BUILD.gn
index 56c78ce..54933c0 100644
--- a/third_party/swiftshader/BUILD.gn
+++ b/third_party/swiftshader/BUILD.gn
@@ -76,6 +76,10 @@ config("swiftshader_config") {
"-Os",
]
+ if (use_uftrace) {
+ cflags -= [ "-fomit-frame-pointer" ]
+ }
+
defines += [
"ANGLE_DISABLE_TRACE",
"NDEBUG",
Since those changes have to be made across multiple different repositories, it has to be applied as follows:
$ patch -p1 < use_uftrace.diff
patching file build/config/compiler/compiler.gni
patching file third_party/ffmpeg/BUILD.gn
patching file third_party/swiftshader/BUILD.gn
4. Build for chrome
$ gn gen out/Release.pg.g "--args=enable_nacl=false is_component_build=false is_debug=false use_jumbo_build=true symbol_level=2 use_uftrace=true"
$ ninja -C out/Release.pg.g chrome
$ cd out/Release.pg.g
5. Tracing chrome with uftrace The following command records a simple chrome execution in headless mode.
$ uftrace record -t 5ms ./chrome --no-sandbox --headless https://www.google.com
6. Visualized trace output of chrome
- chrome: https://uftrace.github.io/dump/chrome.html
- flame-graph: https://uftrace.github.io/dump/chrome.svg
- Home
- Tutorial
- Development
- Practical Use Cases
- GCC
- Clang/LLVM
- Node.js
- Chromium
- MySQL/InnoDB
- FFmpeg
- CPython
- POCO
- Telegram
- yara
- RustPython
- cURL
- bpftrace
- SpiderMonkey
- Apache HTTP Server
- GStreamer
- Squid
- TCPDUMP
- OpenCV
- Libav
- Wireshark
- LXC
- Git
- Radare2
- uftrace on Android
- deno
- parallel sort algorithm
- LevelDB/RocksDB (YCSB)
- Redis
- libjpeg‐turbo (JPEG)
- JM (H.264/AVC)
- HM (HEVC)
- VTM (VVC)
- CUDA
- Erlang/OTP BEAM
- uftrace on Yocto
- TTCN3