I’m working with VLLM (open-source) which includes C++ extension code compiled for Python. I installed it using
CXXFLAGS="-Og -g" pip install -e .
I want to debug the C++ code from Python by attaching a debugger to the running Python process.
I can step into functions, but when I try to inspect local variables, I see messages like d = value has been optimized out
Additionally, compilation is quite slow, and I want to know how to speed up rebuilds after making changes to C++ files.
My questions:
How can I correctly debug the C++ code (via gdb) from Python and see all local variables?
Are there flags or approaches to reduce compile time during development, without losing debugging capabilities?
Environment:
- Python 3.11
- Linux Ubuntu 24.04
- VLLM from source
- pip installation from source (pip install -e .)
- Compiler: GCC 12.3.0 (used to build VLLM C++ extensions)
Any guidance on best practices for debugging Python extensions written in C++ and improving the development workflow would be appreciated.
value has been optimized out, then you have to use-O0instead of-Og. See here.