Build & Debug Envoy

Catalogue
  1. 1. Debug Compiler
  2. 2. 生成 dSYM
  3. 3. Debug
    1. 3.1. Debug By LLDB
    2. 3.2. Debug By Vscode
    3. 3.3. Debug in Clion
      1. 3.3.1. Gen CMakeList
  4. 4. 参考

Debug Compiler

首先构建一个可debug的版本

1
bazel build -c dbg --spawn_strategy=standalone //source/exe:envoy-static

生成 dSYM

进入到 envoy-static 同级目录,执行:

1
dsymutil envoy-static -o envoy-static.dSYM

Debug

Debug By LLDB

1
2
3
4
5
$ lldb envoy-static
(lldb) process launch --stop-at-entry -- -c $PATH_TO_CONFIG
(lldb) add-dsym envoy-static.dSYM
(lldb) breakpoint set --file server.cc --line 147
(lldb) continue

Debug By Vscode

open launch.json file and change program to “${workspaceFolder}/bazel-bin/envoy” (lauch.json will open when to start debugging)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bazel-bin/source/exe/envoy-static",
"args": ["-c", "envoy.yaml"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}

Debug in Clion

Gen CMakeList

下载 bazel-cmakelists,在envoy目录下运行,生成 CMakeLists.txt

1
./bazel-cmakelists --targets //source/exe:envoy-static --skip_build

参考