Paddle2ONNX
Paddle2ONNX copied to clipboard
[OSPP][PIR] modify CMakeLists to enable debug Python & C++
Modify CMakeLists to enable debug with breakpoints in vscode. Please build with cmake which enable debug mode.
git clone https://github.com/PaddlePaddle/Paddle2ONNX.git
cd Paddle2ONNX
git submodule update --init
mkdir build && cd build
cmake .. \
-DPYTHON_INCLUDE_DIR='PATH/TO/PYTHON/include/python3.10' \
-DPYTHON_EXECUTABLE='PATH/TO/PYTHON/bin/python' \
-DBUILD_PADDLE2ONNX_PYTHON=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DONNX_NAMESPACE=onnx \
-DPY_EXT_SUFFIX=.cpython-310-x86_64-linux-gnu.so \
-DPADDLE2ONNX_DEBUG=ON \
-DCMAKE_BUILD_TYPE=Debug
# build
make -j193
# install python package
cd ..
pip install -e .
After this setup, you can debug python script with attach, which can use lldb to step into C++ code with breakpoints.
赞~ 请教一下,vscode 里的 launch.json 文件应该怎么配置?
赞~ 请教一下,vscode 里的 launch.json 文件应该怎么配置?
我写了一篇文档,可以参考一下 ,linux 下我自己测试是可以断点到 C++ 代码里的。 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}/myscripts",
"preLaunchTask": "myShellCmd"
},
{
"type": "lldb",
"request": "attach",
"name": "Attach-Paddle2ONNX",
"pid": "${command:pickMyProcess}"
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "myShellCmd",
"type": "shell",
"command":"echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope"
}
]
}
谢谢,学到啦,不过我的环境是 mac 的,所以还没配置成功。
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.