Kratos: [general] Configuring VSCode for hybrid debug Python + C++ in Windows

Created on 20 Oct 2020  路  9Comments  路  Source: KratosMultiphysics/Kratos

Description
I am trying to write a manual on how to set up the needed settings to debug Kratos simultaneously in Python and c++ in Windows.
Anyone who wants to try please help me correcting the steps:

  1. Install the VSCode extensions: Python and C/C++
  2. Click on the Debugger icon (left bar) and follow the recommendation of creating a launch.json file
  3. Once launch.json is created, add two configurations: one for Python and one for (Windows) Attach
  4. Open the main script which starts the Kratos run (open it inside VSCode or drag it onto it)
  5. Put a breakpoint in any line of this main script (click at the left of line numbers)
  6. Start the Python debugger by clicking on the green Play button (the run should start and hit the breakpoint you just set)
  7. Make sure that the version of Kratos that hast just loaded is RelWithDebInfo, Debug or FullDebug. C++ debugging will not work for the Release version.
  8. Now open the drop down menu of debugger choices (where the green Play button) and choose the C++ debugger.
  9. Hit again the green Play button. It asks for a process to attach to. Type python and choose the last one of the matches (that's the one at the bottom!).
  10. Put a breakpoint in any place of your c++ part and check that the run stops there.

Notes:

  • Concerning point 7: to make sure that Kratos is in Debug version you may need to adjust the Environment Variables: LD_LIBRARY_PATH and PYTHONPATH.
  • Concerning point 9: if you want to be 100% sure which process to attach to, add one line to your python script with pid=os.getpid() and watch the value of the variable you just created (pid).

@salvalatorre @AlejandroCornejo please try these steps. For any difficulty, we should find out why it works for me and not for you.

C++ Debug Python Windows

All 9 comments

Thanks, checking!

I am updating the manual according to your comments.

I forgot to say it worked, thanks, good job!

cool @maceligueta! Do you know if sth like this is also possible with Linux?

Also I wanted to say that there is a manual for doing the same with Visual Studio, probably makes sense to add your explanations there too: https://github.com/KratosMultiphysics/Kratos/wiki/How-to-cross-debug-Kratos-under-Windows

Yes, @ipouplana and me used it many times in Linux, but they changed something and our setup got broken. Maybe it's even easier now, I need to try it.

I'll wait for more feedback and once finished, I will put this setup in the wiki as you propose @philbucher

We have pretty much everything standarized for compiling, debugging in python, C++, cross debugging and running the test. I will add out tasks, launch confiruation and our short tutorial so that it can be improved.

Many thanks @jrubiogonzalez !

@AdriaMP this could be of your interest.

Was this page helpful?
0 / 5 - 0 ratings