How to Debug c++ code called from a Basilisk script?

Registered users can post general questions here
Forum rules
-Must be questions and discussion related to BSK software
Post Reply
Posts: 3
Joined: Tue Jun 19, 2018 8:22 pm

How to Debug c++ code called from a Basilisk script?

Post by sjkcarnahan » Mon Jan 28, 2019 6:09 pm

Generally, you can set up Xcode, Clion, or whatever IDE you use to call an executable that triggers your code to debug.

For instance, in CLion in the top right where you select the run configuration, choose Edit Configurations from the drop down. Then click "+" on the left in the new window and select "Application". Leave Target as "All Targets". Find the python you use with BSK as the "Executable" (i.e. /usr/bin/python). Then, put the path to your BSK script (i.e. in the "Program arguments" box. If you use the full path, you won't need to set the working directory. I generally don't build in CLion so I remove the build command from the run sequence at the bottom.

In Xcode, there is a similar process where you set python as the executable and your .py as the argument.

On linux and windows machines that you own and have control of, the above should work fine. There are two common things that get in the way:
1) On a Mac, System Integrity Protection stops your IDE from taking control of the python process. You'll probably get a message about not being able to attach to a process. You can A) turn off system integrity protection (sounds like a bad thing) or B) use a non-Mac-Frameworks python. i.e. brew installed python, which we have instructions for. I recommend switching to a brew installed python.

2) Big brother may have your computer on lock down or loaded with anti-virus software. In this case, the best solution I have found on a Mac is to use Xcode, but work around the problem a bit. From the Debug menu select Debug->Attach to Process by PID or Name... and then enter "Python" in the box. Next, open a terminal and run your script. Xcode will grab onto the process and hit your breakpoints. It seems to work better than the normal debug configuration process on a heavily locked-down Mac.

Good luck!

Post Reply