Closed Ward-zzZ closed 2 years ago
After much searching,I am finally able to debug.Telling GDB what paths to search for .so files. is the key.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python C++ Debugger",
"type": "pythoncpp",
"request": "launch",
"pythonLaunchName": "Python: Current File",
"cppAttachName": "(gdb) Attach"
},
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/usr/bin/python3.6",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"additionalSOLibSearchPath": "${workspaceFolder}",// adder_plus.so in current folder
"targetArchitecture": "x86_64",
"logging": { "engineLogging": true, "traceResponse": true
},//show gdb log
"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"
}
]
}
BTW,runecho 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
in linux terminal,after that you can run without entering a password
I write a small test,but c++ debugger was not stopping at the breakpoints.
adder_plus.cpp
CompileCommand:
g++ adder_plus.cpp -fPIC -g -shared -o adder_plus.so
test.py
launch.json
It works well when running directly. But I can not step into the cpp file when using debugger. What I do wrong? Help is very much appreciated.