Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Mixed-language Python/C++
debugging
with Python Tools for Visual Studio
Why would you want to debug Python and
C++ at the same time?
• Python code uses extension module written in C (or C++, For...
bitarray library
• https://github.com/ilanschnell/bitarray
• Packed arbitrary-length bit arrays with fast bitwise ops
• Wr...
Demo
Debugging Python and C++ at the same time
is complicated
• Have to attach two debuggers to the same process
• They are not...
Demo
PTVS debugging features
• Step from Python code into C++, or from C++ into Python
• Set breakpoints in both C++ and Python...
Limitations
• Native debugger limits what Python debugger can do
• Can’t run Python code inside the process
• Debugger has...
Additional requirements
• Windows only (sorry!)
• Only supports CPython 2.7 and 3.3+
• Needs symbols for python*.dll
• Ava...
Demo
Try it out today
• Everything you need is FREE!
• Visual Studio Community Edition
http://aka.ms/vs
• Python Tools for Visu...
Upcoming SlideShare
Loading in …5
×

Mixed-language Python/C++ debugging with Python Tools for Visual Studio- Pavel Minaev

1,453 views

Published on

PyData Seattle 2015

Published in: Data & Analytics
  • Be the first to comment

  • Be the first to like this

Mixed-language Python/C++ debugging with Python Tools for Visual Studio- Pavel Minaev

  1. 1. Mixed-language Python/C++ debugging with Python Tools for Visual Studio
  2. 2. Why would you want to debug Python and C++ at the same time? • Python code uses extension module written in C (or C++, Fortran …) • To improve performance • To use some existing library written in that language • Native application hosts Python for scripting
  3. 3. bitarray library • https://github.com/ilanschnell/bitarray • Packed arbitrary-length bit arrays with fast bitwise ops • Written mostly in C • Unit tests in Python • Let’s debug this!
  4. 4. Demo
  5. 5. Debugging Python and C++ at the same time is complicated • Have to attach two debuggers to the same process • They are not aware of each other • So they can only be used one at a time • And can step on each other’s toes if you’re not careful • A better way requires integrated, single-debugger experience
  6. 6. Demo
  7. 7. PTVS debugging features • Step from Python code into C++, or from C++ into Python • Set breakpoints in both C++ and Python at the same time • See and inspect both Python and C++ frames on the stack • In C++ frames, view Python representation of any PyObject • In Python frames, view PyObject struct backing any value • See Python exceptions raised in C right away
  8. 8. Limitations • Native debugger limits what Python debugger can do • Can’t run Python code inside the process • Debugger has to directly parse in-memory object representation • Only types known to debugger have full support • Limited subset of Python available in Locals, Watch etc • No special support for numpy (yet)
  9. 9. Additional requirements • Windows only (sorry!) • Only supports CPython 2.7 and 3.3+ • Needs symbols for python*.dll • Available for stock Python • Download from http://python.org • Installer option in 3.5 • Custom Python distros vary • If they don’t publish symbols, mixed-mode doesn’t work • Bug them about it! 
  10. 10. Demo
  11. 11. Try it out today • Everything you need is FREE! • Visual Studio Community Edition http://aka.ms/vs • Python Tools for Visual Studio http://aka.ms/ptvs • PTVS is open source! https://github.com/Microsoft/ptvs

×