forked from OpenImageDebugger/OpenImageDebugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Building on MacOS CLion
Anton Hromov edited this page Jan 3, 2022
·
1 revision
By default, CLion uses built-in ‘Bundled LLDB’ debugger.
This driver has no problems, and it is suitable for python hooking.
You can review selected debugger in Settings -> Build, Execution, Deployment -> Toolchains -> Debugger.
CLion's lldb debugger uses python framework instead of python library.
By default, it is contained in /Applications/CLion.app/Contents/bin/lldb/mac. Let's ensure that.
-
Open CLion
-
Setup basic c++ project
- Open your c++ project (or create a basic one)
- Build it in
Debugmode
-
Discover python framework directory path variable
- Set a breakpoint anywhere and run newly created debugging session
- When paused, open
LLDBdebug console in theDebugtool window. - Execute
script import platform; platform.python_version()to get the exact version of used python binary - For instance, here I got the following results:
'3.9.1'- Execute
script import sys; print(sys.path)to ret a list of search paths for modules - For instance, here I got the following results:
['/Applications/CLion.app/Contents/bin/lldb/mac/LLDB.framework', '/usr/local/bin/OpenImageDebugger', '/Applications/CLion.app/Contents/bin/lldb/mac/LLDB.framework/Resources/Python', '/Applications/CLion.app/Contents/bin/lldb/renderers', '/Applications/CLion.app/Contents/bin/lldb/mac/Python.framework/lib/python39.zip', '/Applications/CLion.app/Contents/bin/lldb/mac/Python.framework/lib/python3.9', '/Applications/CLion.app/Contents/bin/lldb/mac/Python.framework/lib/python3.9/lib-dynload', '.', '/usr/local/bin/OpenImageDebugger'] -
Discover python framework
- You have to find a path, which contains
Python.frameworkin it. In my case it is this path:/Applications/CLion.app/Contents/bin/lldb/mac/Python.framework/lib/python3.9 - Take parent directory of
Python.framework:/Applications/CLion.app/Contents/bin/lldb/mac - Jot path to this directory down, because it will be needed in the following steps
- You have to find a path, which contains
-
Discover python include directory
- Since
CLiondoesn't contain python include files, we have to provide include files from system python. Such directory must contain file named ‘Python.h’ and a bunch of others - It will be perfect to provide exactly the same version of include files, however it's usually enough to provide existent ones even if versions don't match
- Tip. You can use Anaconda to get a specific version of python development package:
conda install python=3.9.1 - In my case, python include directory is located under
/Users/agromov/opt/anaconda3/include/python3.9 - Jot path to this file down, because it will be needed in the following steps
- Since