microsoft / microsoft/vscode-cpptools
Unable to debug C++ from a python script in container
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 6.2k
- Fork
- 1.7k
- Merge medio
- 14h 46m
- PR unite (30g)
- 61
Descrizione
Hello,
I am trying to debug a C++ code from a python script in a dev container, but the breakpoints at my .cpp do not have any effect.
Thank you very much in advance.
Steps to reproduce:
- Use the following as Dockerfile:
FROM python:3.8-slim
RUN apt-get update &&
apt-get install -y binutils cmake
gcc g++ libtool make
vim curl net-tools unzip procps gdb
-
Use the following as devcontainer.json:
{
"name": "Existing Dockerfile",
"context": "..",
"dockerFile": "../Dockerfile",
"extensions": ["ms-python.python", "ms-vscode.cpptools"],
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
} -
Use the code myadd.cpp and myscript.py from: https://nadiah.org/2020/03/01/example-debug-mixed-python-c-in-visual-studio-code/
-
Use the following as launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/usr/local/bin/python",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
}
]
}
]
} -
Set the appropriate breakpoints in myscript.py (line 5) and in myadd.cpp (line 12)
-
Start Debugging the python script
-
When stop, attach the C++ debugger
-
Continue execution of python script
At this point, a cpptools terminal is created but gdb does not stop in the .cpp code, and the program executes until the end.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo la sessione mista Python/C++ usando il Dockerfile, devcontainer.json e launch.json mostrati nell’issue, quindi esamina il comportamento del terminale cpptools e dell’attach di GDB. Confronta la gestione dei breakpoint in myscript.py e myadd.cpp; il lavoro è completato quando il breakpoint C++ viene raggiunto dopo l’attach e la continuazione del processo Python.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, docker, python, vscode
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100