[C++-sig] tell my the way to debug on vs2017
Mohan Varma
mohan.varma at gmail.com
Sat Nov 9 00:10:27 EST 2019
Hi,
I have been using Visual Studio for debugging C++ part of the code only and
PDB for debugging Python code. It works pretty well.
You can't debug C++ code in Visual Studio by attaching it to python.exe
process. You need to attach it to python_d.exe process. You need to link
the release variant of you module with release versions of Python
executable and libraries and debug variant with debug versions.
If I remember correctly (no longer using Boost.Python, I switched to
Pybind11 a while ago), here are the steps that are involved in creating
successful debug builds of Boost.Python modules.
- *Install Python with debug binary and symbols: *During the python
installation, choose "Custom installation" and in the advanced options,
enable "Download debugging symbols" and "Download debug binaries" options
and install Python. It installs python_d.[exe,lib,dll] along with
python.[exe,lib,dll]. Once they are installed, link the debug variant of
your module with debug version of python (python_d.[exe,lib,dll]) and
release variant with release version of python (python.[exe,lib,dll]).
- *Build Boost.Python debug variant libraries using python_d.exe*:
Create a user-config.jam and provide the paths to desired python
installation. Here is a sample user-config.jam file to create debug variant
of the libraries.
using python : 3.7 : F:\\Software\\Python\\3.7.5\\python_d.exe :
F:\\Software\\Python\\3.7.5\\include : F:\\Software\\Python\\3.7.5\\libs ;
Once you create the user-config.jam, you can build the debug variants of
the Boost.Python libraries with a command such as the following:
b2 toolset=msvc-14.1 address-model=64 variant=debug link=shared,static
--build-type=minimal --with-python python-debugging=on
--user-config=user-config_d.jam stage
Use different user-config.jam files to build the release variants of the
libraries using python.exe and debug variants using python_d.exe.
- *Set appropriate configuration properties for building debug variant*:
You need to add a "_d" (example hello_d.pyd) suffix to your module name in
the debug configuration settings (Configuration Properties -> General ->
Target Name). python_d.exe identifies the debug versions of modules with
the suffix "_d". You also need to define BOOST_DEBUG_PYTHON in the
post-processor definitions for debug variants.
- *Use python_d.exe for using debug variant of the module and python.exe
for using release variant*: Once the module is built for both debug and
release variants, you can use debug variant of the module with python_d.exe
for debugging your C++ code.
On Fri, 8 Nov 2019 at 23:28, chengfang.ai at yunify.com <
chengfang.ai at yunify.com> wrote:
> hi boost.python.org:
> I want to debug python.pyd,but I didn't find the way to debug on
> visual studio 2017 C++ code.
> The docment only write "On *Windows*, my favorite debugging solution
> is the debugger that comes with Microsoft Visual C++ 7. This debugger seems
> to work with code generated by all versions of Microsoft and Metrowerks
> toolsets; it's rock solid and "just works" without requiring any special
> tricks from the user." but I can't find the detail.
> I attached process but the breakpoint didn't not hit in C++ code.
> Can you tell me a way to debug?
>
>
> ------------------------------
> chengfang.ai at yunify.com
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> https://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20191109/48be8977/attachment.html>
More information about the Cplusplus-sig
mailing list