I have a code in C++ that is called from a Python file. In order to look at the code and debug it, I use VS Code. I follow the instructions in https://nadiah.org/2020/03/01/example-debug-mixed-python-c-in-visual-studio-code/
However, I stuck in Step5 because when I try to attach GDB to Python, the terminal writes:
Python Exception <class 'ImportError'> This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.:
/usr/bin/gdb: warning:
Could not load the Python gdb module from `/usr/share/gdb/python'. Limited Python support is available from the _gdb module. Suggest passing --data-directory=/path/to/gdb/data-directory.
I don't know whether the problem is the launch.jason or not. My launch.json is:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/home/vj/python/anaconda2-2020.02/bin/python", /* My virtual env */
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}