Alright, I've made a minimal example.
File runthis.py contains:
from main import main as cymain
def main():
print("Now presenting")
cymain()
if __name__ == "__main__":
main()
File main.pyx contains:
cpdef main():
print("Hello, world!")
print("Goodbye, world!")
File setup.py contains:
from setuptools import Extension, setup
from Cython.Build import cythonize
extensions = [Extension("main", ["main.pyx"])]
setup(name="Minimal cygdb test", ext_modules=cythonize(extensions, gdb_debug=True))
How to reproduce:
First, make sure you've got a version of Python configured --with-pydebug. Then make a venv, activate it, and install dependencies in it:
$ virtualenv -p /usr/local/bin/python3.14 venv
$ source venv/bin/activate
(venv) python -m pip install Cython setuptools
Build the Cython extension:
(venv) python setup.py build_ext --inplace
Start cygdb:
cygdb --build-dir . -- --args /usr/local/bin/python3.14 runthis.py
GNU gdb (Ubuntu 15.1-1ubuntu1~24.04.1) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/bin/python3.14...
gdb command file: Activating virtualenv: /home/sanotehu/src/cythontest/venv; path_to_activate_this_py: /home/sanotehu/src/cythontest/venv/bin/activate_this.py
warning: .cygdbinit: No such file or directory (gdb)
Set a breakpoint in the Python code:
(gdb) cy break -p main
Breakpoint 1 at 0x2831e9: file Python/ceval.c, line 1000.
Now run the program. It runs correctly, but gdb doesn't stop in the Python main() function like we just told it to:
(gdb) cy run
Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled on'.
Now presenting
Hello, world!
Goodbye, world!
[Inferior 1 (process 854665) exited normally]
(gdb)