Closed swift-kim closed 2 years ago
Level 1 (g1
) provides no local variable information:
Level 2 (g2
) should be the best fit for general purpose debugging, although the file size is quite large (156 MB → 331 MB).
Modify build/config/compiler/BUILD.gn
as follows.
@@ -907,6 +903,6 @@ config("minimal_symbols") {
config("no_symbols") {
if (!is_win) {
- cflags = [ "-g0" ]
+ cflags = [ "-g2" ]
}
}
Note: Alternatively you can give the --unoptimized
option to gn
, but it will result in additional libdart
dependency of the embedder:
--- a/shell/platform/tizen/BUILD.gn
+++ b/shell/platform/tizen/BUILD.gn
@@ -215,6 +215,7 @@ template("embedder") {
public_deps = [ ":flutter_engine" ]
deps = [
+ "//flutter/runtime:libdart",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/common:common_cpp_library_headers",
Build your app with stripped versions of the engine and embedder and install to your device.
Launch the app under gdbserver. (How: https://github.com/flutter-tizen/plugins/issues/295 - will be detailed later)
Connect to the gdbserver and find the base addresses of the engine and embedder objects using info share
.
(gdb) info share
0xb53ee540 0xb5fe6719 Yes (*) target:/opt/usr/globalapps/com.example.native_plugin_example/bin/../lib/libflutter_engine.so
0xb74d7030 0xb7537b79 Yes (*) target:/opt/usr/globalapps/com.example.native_plugin_example/bin/../lib/libflutter_tizen_mobile.so
Register symbol files (.debug
) using add-symbol-file
.
(gdb) add-symbol-file ~/Git/engine/src/out/linux_debug_x86/so.unstripped/libflutter_engine.so 0xb53ee540
(gdb) add-symbol-file ~/Git/engine/src/out/linux_debug_x86/so.unstripped/libflutter_tizen_mobile.so 0xb74d7030
Follow steps 1-5 in the above comment.
Run info share
through the VS Code debug console.
-exec info share
0xb7548030 0xb75a8b79 Yes target:/opt/usr/globalapps/com.example.native_plugin_example/bin/../lib/libflutter_tizen_mobile.so
0xb545f540 0xb6057719 Yes target:/opt/usr/globalapps/com.example.native_plugin_example/bin/../lib/libflutter_engine.so
Run add-symbol-file
through the debug console.
-exec add-symbol-file ~/Git/engine/src/out/linux_debug_x86/so.unstripped/libflutter_engine.so 0xb545f540
-exec add-symbol-file ~/Git/engine/src/out/linux_debug_x86/so.unstripped/libflutter_tizen_mobile.so 0xb7548030
There's no need to extract debug files from artifacts. See https://github.com/flutter-tizen/flutter-tizen/wiki/Debugging-the-engine-and-embedder for how to load symbol info in GDB.
Currently it's not possible to do source line-level debugging of the engine and embedder binaries (even with
so.unstripped
binaries) because the compiler strips out all debugging information (-g0
) by default:Extracting debug info files from unstripped binaries (and publishing them along with engine releases) will make it convenient to debug the engine and embedder via gdb and gdbserver.
(before)
(after)