Skip to content

Vscode configuration for debugging CPython in a Linux container

Notifications You must be signed in to change notification settings

d4tech/Vscode-CPython-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Vscode-CPython-debug

Vscode configuration for debugging CPython.

Prerequisites:

  1. Install Docker
  2. Install vscode with remote-development plugin

Setup:

  1. Clone Cpython.

  2. Clone/Download this repo in another location apart from where you cloned Cpython.

  3. Copy and Paste the .devcontainer and .vscode directories into the directory where you cloned CPython.

  4. Open Cpython in vscode.

  5. Click on the green Remote action button " >< " at the lower leftmost corner in vscode(as shown in the image) and select Remote-Containers: Open Folder in Container... from the commands popup that appears, vscode will now start building the container and then build Cpython with relevant flags.

Debug Configurations:

Inside the .vscode/launch.json resides the debug configurations, there are three types of debugging configured:

  1. Cpython test

    Debug a CPython test case.

    The best way to read the code of any open source project is to debug using the test cases. CPython's test cases are inside Lib/tests. Open any of the test case, for eg Lib/tests/test_list.py, these are the test cases for good ol python list, each object in Python has its respective implementations inside the directory Objects and you can find the list implementation in Objects/listobject.c, open the same and set a debug point in PyList_GetItem at line 199. Now go back to the test_list.py and start the debugger, Voila, the debugger breaks exactly at PyList_GetItem.

  2. python -c

    Debug the python process by executing using the python -c option.

    Change the statement that you want the Python interpreter to run in the args option; currently it is "args": ["-c", "print(\"hello\")"]; i.e python -c "print('hello')".

  3. python

    Launches a Python interpreter and from there you can provide a statement for the interpreter to execute and you can follow along.

Further reading

Head to Exploring Cpython, the Additional References section has all the exhaustive resources for you to get started with CPython walkthrough! Happy Hacking.

About

Vscode configuration for debugging CPython in a Linux container

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published