From 9c5fcd16e1ab1d5081b8fff40976e3ced70f5617 Mon Sep 17 00:00:00 2001 From: McKnight22 Date: Sat, 26 Feb 2022 01:13:49 +0800 Subject: [PATCH 1/2] added the first draft of the doc howto-setup-remote-debug-env-with-vscode-for-soong.md --- ...-remote-debug-env-with-vscode-for-soong.md | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md diff --git a/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md b/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md new file mode 100644 index 0000000..e6fcd76 --- /dev/null +++ b/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md @@ -0,0 +1,120 @@ +**如何搭建soong的基于vscode的远程开发调试环境** + +注:提供此文档为方便国内参与小伙伴。 + + + +- [1. vscode的远程开发调试环境](#1-vscode的远程开发调试环境) +- [2. 安装依赖软件](#2-安装依赖软件) +- [3. 运行debug](#3-运行debug) +- [4. 参考文档](#4-参考文档) + + + +# 1. vscode的远程开发调试环境 + +Server端建议为Ubuntu PC,环境如下: +本文所有操作在以下系统环境下验证通过 + +``` +$ lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 18.04.6 LTS +Release: 18.04 +Codename: bionic +``` +Client端运行vscode IDE可以自选PC系统环境,Windows、Linux皆可。 + + +# 2. 安装依赖软件 + +Server端: +``` +$ sudo apt install openssh-server +$ wget https://golang.google.cn/dl/go1.18rc1.linux-amd64.tar.gz && rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18rc1.linux-amd64.tar.gz +``` +至此,Server端配置完成。下面开始配置Client端。 + +Client端: +1)安装vscode 1.64.2 或更高版本; +2)启动vscode并安装vscode extension Remote-SSH在Client端本地,安装成功后左侧边栏新增"REMOTE EXPLORER"; +3)进入"REMOTE EXPLORER"选择"SSH TARGETS"-->"Add New"; +3.1)"Enter SSH Connection Command" --> +       "Select SSH configuration file to update" --> +          "Host added!", +     至此Server端作为Host被添加到Client端的vscode; +3.2)"SSH TARGETS" --> +       "Connect to Host in Current Window" --> +         "Select the platform of the remote host YOURSERVERIP" --> +           "Are you sure want to continue" --> +             "Enter password for YOURUSERNAME@YOURSERVERIP" --> +               打开你想访问的Server端的AOSP目录, +     至此这会将vscode-server程序自动安装到Server端的~/.vscode-server目录下,并且Client端已通过vscode extension Remote-SSH完成登录到Server端; +3.3)在通过vscode extensions Remote-SSH已登录到Server端的状态下,安装vscode extension Go且版本 >0.31,实际是将它安装到了Server端; +3.4)Ctrl+Shift+P,输入"Go: Install/Update Tools",再选择"dlv";如果因网络连接原因该方法失败,可ssh到Server端后先翻墙再手动执行如下: +``` +$ sudo apt install gcc +$ export PATH=$PATH:/usr/local/go/bin +$ go install github.com/go-delve/delve/cmd/dlv@v1.8.1 +``` +至此,Client端配置完成。 +注:此处不翻墙的安装方式还在尝试。 + + +# 3. 运行debug + +如下操作都在Client端进行: +运行vscode通过其插件Remote-SSH远程访问Server端的AOSP代码目录 +打开vscode terminal并先执行如下: +``` +$ source build/envsetup.sh +$ SOONG_UI_DELVE=5006 m nothing //此处5006为自定义值,注意后面port值需跟其保持一致 +``` +选择左侧边栏"Run and Debug" --> +  选择左侧"create a launch.json file" --> +    "Select environment" --> +      "Choose debug configuration" --> +        "Enter hostname" --> +          "Enter port" <5006> --> +            此时launch.json被打开并手动加入`"debugAdapter": "dlv-dap", `, 如下: +``` +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Connect to server", + "type": "go", + "debugAdapter": "dlv-dap", + "request": "attach", + "mode": "remote", + "remotePath": "${workspaceFolder}", + "port": 5006, + "host": "YOURSERVERIP" + } + ] +} +``` +至此再"F5",即可开始远程调试soong。 + +注意: +"SOONG_UI_DELVE=5006 m nothing"后,如遇错误结果如下: +``` +user@Ubuntu1804:~/riscv/aosp/plct/riscv64-android-12.0.0$ SOONG_UI_DELVE=5006 m nothing +API server listening at: [::]:5006 +2022-02-23T22:40:06+08:00 warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted) +2022-02-23T22:40:07+08:00 error layer=debugger can't find build-id note on binary +Go version 1.15.6 is too old for this version of Delve (minimum supported version 1.16, suppress this error with --check-go-version=false) +#### failed to build some targets (1 seconds) #### +``` +其原因是基于当前的riscv64-android-12.0.0代码,prebuilts/go/linux-x86目录下的go版本太过老旧不满足go-delve的版本要求,故临时对prebuilts/go/linux-x86建软链接到系统路径下的高版本go,此问题解决。 +此问题根本解决可等待下一个版本AOSP 13中的这部分升级。 + + +# 4. 参考文档 + +https://android.googlesource.com/platform/build/soong/+/master/README.md +https://github.com/golang/vscode-go/blob/master/docs/debugging.md +https://code.visualstudio.com/docs/remote/ssh +https://code.visualstudio.com/api/advanced-topics/remote-extensions +https://code.visualstudio.com/docs/editor/debugging -- Gitee From a813c6d9de8bcaff5cdd5f1b986e5df9f5ba4a87 Mon Sep 17 00:00:00 2001 From: McKnight22 Date: Sat, 26 Feb 2022 01:39:54 +0800 Subject: [PATCH 2/2] updated the layout of the doc howto-setup-remote-debug-env-with-vscode-for-soong.md --- ...-remote-debug-env-with-vscode-for-soong.md | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md b/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md index e6fcd76..3c0331c 100644 --- a/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md +++ b/docs/zh/howto-setup-remote-debug-env-with-vscode-for-soong.md @@ -13,8 +13,7 @@ # 1. vscode的远程开发调试环境 -Server端建议为Ubuntu PC,环境如下: -本文所有操作在以下系统环境下验证通过 +Server端建议为Ubuntu PC,环境如下:(本文所有操作在以下系统环境下验证通过) ``` $ lsb_release -a @@ -36,48 +35,48 @@ $ wget https://golang.google.cn/dl/go1.18rc1.linux-amd64.tar.gz && rm -rf /usr/l ``` 至此,Server端配置完成。下面开始配置Client端。 -Client端: -1)安装vscode 1.64.2 或更高版本; -2)启动vscode并安装vscode extension Remote-SSH在Client端本地,安装成功后左侧边栏新增"REMOTE EXPLORER"; -3)进入"REMOTE EXPLORER"选择"SSH TARGETS"-->"Add New"; -3.1)"Enter SSH Connection Command" --> -       "Select SSH configuration file to update" --> -          "Host added!", -     至此Server端作为Host被添加到Client端的vscode; -3.2)"SSH TARGETS" --> -       "Connect to Host in Current Window" --> -         "Select the platform of the remote host YOURSERVERIP" --> -           "Are you sure want to continue" --> -             "Enter password for YOURUSERNAME@YOURSERVERIP" --> -               打开你想访问的Server端的AOSP目录, -     至此这会将vscode-server程序自动安装到Server端的~/.vscode-server目录下,并且Client端已通过vscode extension Remote-SSH完成登录到Server端; -3.3)在通过vscode extensions Remote-SSH已登录到Server端的状态下,安装vscode extension Go且版本 >0.31,实际是将它安装到了Server端; -3.4)Ctrl+Shift+P,输入"Go: Install/Update Tools",再选择"dlv";如果因网络连接原因该方法失败,可ssh到Server端后先翻墙再手动执行如下: +Client端: +1)安装vscode 1.64.2 或更高版本; +2)启动vscode并安装vscode extension Remote-SSH在Client端本地,安装成功后左侧边栏新增"REMOTE EXPLORER"; +3)进入"REMOTE EXPLORER"选择"SSH TARGETS"-->"Add New"; +3.1)"Enter SSH Connection Command" --> +       "Select SSH configuration file to update" --> +          "Host added!", +     至此Server端作为Host被添加到Client端的vscode; +3.2)"SSH TARGETS" --> +       "Connect to Host in Current Window" --> +         "Select the platform of the remote host YOURSERVERIP" --> +           "Are you sure want to continue" --> +             "Enter password for YOURUSERNAME@YOURSERVERIP" --> +               打开你想访问的Server端的AOSP目录, +     至此这会将vscode-server程序自动安装到Server端的~/.vscode-server目录下,并且Client端已通过vscode extension Remote-SSH完成登录到Server端; +3.3)在通过vscode extensions Remote-SSH已登录到Server端的状态下,安装vscode extension Go且版本 >0.31,实际是将它安装到了Server端; +3.4)Ctrl+Shift+P,输入"Go: Install/Update Tools",再选择"dlv";如果因网络连接原因该方法失败,可ssh到Server端后先翻墙再手动执行如下: ``` $ sudo apt install gcc $ export PATH=$PATH:/usr/local/go/bin $ go install github.com/go-delve/delve/cmd/dlv@v1.8.1 ``` -至此,Client端配置完成。 -注:此处不翻墙的安装方式还在尝试。 +至此,Client端配置完成。 +注:此处不翻墙的安装方式还在尝试。 # 3. 运行debug -如下操作都在Client端进行: -运行vscode通过其插件Remote-SSH远程访问Server端的AOSP代码目录 -打开vscode terminal并先执行如下: +如下操作都在Client端进行: +运行vscode通过其插件Remote-SSH远程访问Server端的AOSP代码目录 +打开vscode terminal并先执行如下: ``` $ source build/envsetup.sh $ SOONG_UI_DELVE=5006 m nothing //此处5006为自定义值,注意后面port值需跟其保持一致 ``` -选择左侧边栏"Run and Debug" --> -  选择左侧"create a launch.json file" --> -    "Select environment" --> -      "Choose debug configuration" --> -        "Enter hostname" --> -          "Enter port" <5006> --> -            此时launch.json被打开并手动加入`"debugAdapter": "dlv-dap", `, 如下: +选择左侧边栏"Run and Debug" --> +  选择左侧"create a launch.json file" --> +    "Select environment" --> +      "Choose debug configuration" --> +        "Enter hostname" --> +          "Enter port" <5006> --> +            此时launch.json被打开并手动加入`"debugAdapter": "dlv-dap", `, 如下: ``` { "version": "0.2.0", @@ -98,7 +97,7 @@ $ SOONG_UI_DELVE=5006 m nothing //此处5006为自定义值,注意后面por 至此再"F5",即可开始远程调试soong。 注意: -"SOONG_UI_DELVE=5006 m nothing"后,如遇错误结果如下: +"SOONG_UI_DELVE=5006 m nothing"后,如遇错误如下: ``` user@Ubuntu1804:~/riscv/aosp/plct/riscv64-android-12.0.0$ SOONG_UI_DELVE=5006 m nothing API server listening at: [::]:5006 @@ -107,14 +106,14 @@ API server listening at: [::]:5006 Go version 1.15.6 is too old for this version of Delve (minimum supported version 1.16, suppress this error with --check-go-version=false) #### failed to build some targets (1 seconds) #### ``` -其原因是基于当前的riscv64-android-12.0.0代码,prebuilts/go/linux-x86目录下的go版本太过老旧不满足go-delve的版本要求,故临时对prebuilts/go/linux-x86建软链接到系统路径下的高版本go,此问题解决。 +其原因是基于当前的riscv64-android-12.0.0代码,prebuilts/go/linux-x86目录下的go版本太过老旧不满足go-delve的版本要求,故临时对prebuilts/go/linux-x86建软链接到系统路径下的高版本go,此问题解决。 此问题根本解决可等待下一个版本AOSP 13中的这部分升级。 # 4. 参考文档 -https://android.googlesource.com/platform/build/soong/+/master/README.md -https://github.com/golang/vscode-go/blob/master/docs/debugging.md -https://code.visualstudio.com/docs/remote/ssh -https://code.visualstudio.com/api/advanced-topics/remote-extensions -https://code.visualstudio.com/docs/editor/debugging +https://android.googlesource.com/platform/build/soong/+/master/README.md +https://github.com/golang/vscode-go/blob/master/docs/debugging.md +https://code.visualstudio.com/docs/remote/ssh +https://code.visualstudio.com/api/advanced-topics/remote-extensions +https://code.visualstudio.com/docs/editor/debugging -- Gitee