Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSPP][PIR] modify CMakeLists to enable debug Python & C++ #1353

Closed
wants to merge 0 commits into from

Conversation

qzylalala
Copy link

@qzylalala qzylalala commented Aug 20, 2024

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.

@jzhang533
Copy link
Collaborator

赞~
请教一下,vscode 里的 launch.json 文件应该怎么配置?

@qzylalala
Copy link
Author

qzylalala commented Aug 22, 2024

赞~ 请教一下,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"
        }
    ]
}

@jzhang533
Copy link
Collaborator

谢谢,学到啦,不过我的环境是 mac 的,所以还没配置成功。

@CLAassistant
Copy link

CLA assistant check
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants