• Lv0
    粉丝0

积分42 / 贡献0

提问5答案被采纳0文章0

可以单步调试方舟运行时吗

深开鸿_王皓

沙发 发表于 2023-11-15 11:17:17

本帖最后由 深开鸿_王皓 于 2023-11-15 11:46 编辑

官方文档中指导了如何在ubuntu上运行方舟运行时,文档路径如下:

arkcompiler/ets_runtime/docs/development-example.md

总结就是运行下面这条命令来编译可调试的ubuntu版本:

./build.sh --product-name rk3568 \
--build-target ets_frontend_build ark_js_host_linux_tools_packages \
--gn-args is_debug=true

编译成功后,使用如下命令运行:

LD_LIBRARY_PATH=\
out/rk3568/clang_x64/arkcompiler/ets_runtime:\
out/rk3568/clang_x64/thirdparty/icu:\
prebuilts/clang/ohos/linux-x86_64/llvm/lib:\
out/rk3568/clang_x64/thirdparty/zlib \
out/rk3568/clang_x64/arkcompiler/ets_runtime/ark_js_vm a.abc

运行起来之后,需要在vscode中进行一些配置来单步调试:

1,在vscode插件中心搜索安装:CodeLLDB

2,在工程目录下创建.vscode目录,如果已有就不需要创建了

3,在.vscode目录下创建launch.json,内容如下:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {            
            "type": "lldb",
            "request": "launch",
            "name": "ark_js_vm",
            "program": "${workspaceFolder}/out/rk3568/clang_x64/exe.unstripped/clang_x64/arkcompiler/ets_runtime/ark_js_vm",
            "args": [
                "a.abc"
            ],
            "cwd": "${workspaceFolder}",
            "env": {
                "LD_LIBRARY_PATH": "${workspaceFolder}/out/rk3568/clang_x64/lib.unstripped/clang_x64/arkcompiler/ets_runtime:${workspaceFolder}/out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/icu:${workspaceFolder}/prebuilts/clang/ohos/linux-x86_64/llvm/lib:${workspaceFolder}/out/rk3568/clang_x64/lib.unstripped/clang_x64/thirdparty/zlib"
            }
        }
    ]
}

4,在arkcompiler/ets_runtime/ecmascript/js_vm/main.cpp文件中的main函数下断点

5,f5开始调试运行,会停在main的断点位置,然后就可以单步调试了

Copyright   ©2023  OpenHarmony开发者论坛  京ICP备2020036654号-3 |技术支持 Discuz!

返回顶部