microsoft / microsoft/vscode-cpptools

Unable to debug C++ from a python script in container

Aperta
#8,222 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

debugger help wanted
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:

  1. 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

  1. 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" ],
    }

  2. Use the code myadd.cpp and myscript.py from: https://nadiah.org/2020/03/01/example-debug-mixed-python-c-in-visual-studio-code/

  3. 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",
    }
    ]
    }
    ]
    }

  4. Set the appropriate breakpoints in myscript.py (line 5) and in myadd.cpp (line 12)

  5. Start Debugging the python script

  6. When stop, attach the C++ debugger

  7. 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. 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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.